Belle II Software development
UserInfo.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef USERINFO_H_
10#define USERINFO_H_
11
12#include <framework/core/FrameworkExceptions.h>
13#include <mdst/dataobjects/MCParticleGraph.h>
14#include <simulation/dataobjects/MCParticleTrajectory.h>
15
16#include "G4VUserTrackInformation.hh"
17#include "G4VUserPrimaryParticleInformation.hh"
18
19
20namespace Belle2 {
26 namespace Simulation {
27
28 //Define exceptions
30 BELLE2_DEFINE_EXCEPTION(CouldNotFindUserInfo, "No User Information was found !");
31
36 template<class Info, class Payload> class UserInfo: public Info {
37
38 public:
39
44 explicit UserInfo(Payload data) : Info(), m_data(data), m_status(0), m_fraction(1.0), m_trajectory(nullptr) {}
45
50 Payload getData() { return m_data; }
51
59 int getStatus() {return m_status;}
60
68 double getFraction() {return m_fraction;}
69
72
77 void setStatus(int status) { m_status = status;}
78
83 void setFraction(double fraction) { m_fraction = fraction;}
84
86 void setTrajectory(MCParticleTrajectory* trajectory) { m_trajectory = trajectory; }
87
91 virtual void Print() const {;}
92
100 template<class Carrier> static Payload getInfo(Carrier& obj)
101 {
102 UserInfo<Info, Payload>* userinfo = dynamic_cast<UserInfo<Info, Payload>*>(obj.GetUserInformation());
103 if (!userinfo) throw(CouldNotFindUserInfo());
104 return userinfo->getData();
105 }
106
107 protected:
108
109 Payload m_data;
112 double m_fraction;
115 };
116
119
120 } // end namespace Simulation
122} // end namespace Belle2
123
124#endif /* USERINFO_H_ */
Class to save the full simulated trajectory of a particle.
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
Definition: UserInfo.h:36
virtual void Print() const
Prints information, not implemented in this class.
Definition: UserInfo.h:91
MCParticleTrajectory * getTrajectory()
Get optional particle trajectory.
Definition: UserInfo.h:71
void setFraction(double fraction)
Store optical photon propagation fraction (used for performance speed-ups)
Definition: UserInfo.h:83
MCParticleTrajectory * m_trajectory
Particle trajectory, if any.
Definition: UserInfo.h:113
void setStatus(int status)
Set status of optical photon (used for performance speed-ups)
Definition: UserInfo.h:77
UserInfo(Payload data)
The constructor of the user info class.
Definition: UserInfo.h:44
double getFraction()
Get optical photon propagation fraction (used for performance speed-ups) status=0: fraction=1 status=...
Definition: UserInfo.h:68
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition: UserInfo.h:100
void setTrajectory(MCParticleTrajectory *trajectory)
Set the optional particle trajectory.
Definition: UserInfo.h:86
int m_status
optical photon: status
Definition: UserInfo.h:111
double m_fraction
optical photon: propagation fraction
Definition: UserInfo.h:112
Payload getData()
Returns the payloaded data.
Definition: UserInfo.h:50
Payload m_data
The data which is payloaded to the specified class.
Definition: UserInfo.h:109
int getStatus()
Get status of optical photon (used for performance speed-ups) 0 initial 1 prescaled in StackingAction...
Definition: UserInfo.h:59
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
Abstract base class for different kinds of events.