Belle II Software  release-05-02-19
UserInfo.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter, Andreas Moll, Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef USERINFO_H_
12 #define USERINFO_H_
13 
14 #include <framework/core/FrameworkExceptions.h>
15 #include <mdst/dataobjects/MCParticleGraph.h>
16 #include <simulation/dataobjects/MCParticleTrajectory.h>
17 
18 #include "G4VUserTrackInformation.hh"
19 #include "G4VUserPrimaryParticleInformation.hh"
20 
21 
22 namespace Belle2 {
28  namespace Simulation {
29 
30  //Define exceptions
32  BELLE2_DEFINE_EXCEPTION(CouldNotFindUserInfo, "No User Information was found !");
33 
38  template<class Info, class Payload> class UserInfo: public Info {
39 
40  public:
41 
46  explicit UserInfo(Payload data) : Info(), m_data(data), m_status(0), m_fraction(1.0), m_trajectory(nullptr) {}
47 
52  Payload getData() { return m_data; }
53 
61  int getStatus() {return m_status;}
62 
70  double getFraction() {return m_fraction;}
71 
73  MCParticleTrajectory* getTrajectory() { return m_trajectory; }
74 
79  void setStatus(int status) { m_status = status;}
80 
85  void setFraction(double fraction) { m_fraction = fraction;}
86 
88  void setTrajectory(MCParticleTrajectory* trajectory) { m_trajectory = trajectory; }
89 
93  virtual void Print() const {;}
94 
102  template<class Carrier> static Payload getInfo(Carrier& obj)
103  {
104  UserInfo<Info, Payload>* userinfo = dynamic_cast<UserInfo<Info, Payload>*>(obj.GetUserInformation());
105  if (!userinfo) throw(CouldNotFindUserInfo());
106  return userinfo->getData();
107  }
108 
109  protected:
110 
111  Payload m_data;
113  int m_status;
114  double m_fraction;
117  };
118 
121 
122  } // end namespace Simulation
124 } // end namespace Belle2
125 
126 #endif /* USERINFO_H_ */
Belle2::Simulation::UserInfo::getTrajectory
MCParticleTrajectory * getTrajectory()
Get optional particle trajectory.
Definition: UserInfo.h:81
Belle2::Simulation::UserInfo::getInfo
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition: UserInfo.h:110
Belle2::Simulation::UserInfo::setTrajectory
void setTrajectory(MCParticleTrajectory *trajectory)
Set the optional particle trajectory.
Definition: UserInfo.h:96
Belle2::Simulation::UserInfo::UserInfo
UserInfo(Payload data)
The constructor of the user info class.
Definition: UserInfo.h:54
Belle2::Simulation::UserInfo
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
Definition: UserInfo.h:46
Belle2::Simulation::UserInfo::setStatus
void setStatus(int status)
Set status of optical photon (used for performance speed-ups)
Definition: UserInfo.h:87
Belle2::Simulation::UserInfo::getStatus
int getStatus()
Get status of optical photon (used for performance speed-ups) 0 initial 1 prescaled in StackingAction...
Definition: UserInfo.h:69
Belle2::MCParticleTrajectory
Class to save the full simulated trajectory of a particle.
Definition: MCParticleTrajectory.h:32
Belle2::Simulation::UserInfo::getData
Payload getData()
Returns the payloaded data.
Definition: UserInfo.h:60
Belle2::Simulation::UserInfo::setFraction
void setFraction(double fraction)
Store optical photon propagation fraction (used for performance speed-ups)
Definition: UserInfo.h:93
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Simulation::UserInfo::getFraction
double getFraction()
Get optical photon propagation fraction (used for performance speed-ups) status=0: fraction=1 status=...
Definition: UserInfo.h:78
Belle2::Simulation::UserInfo::m_status
int m_status
optical photon: status
Definition: UserInfo.h:121
Belle2::Simulation::UserInfo::m_data
Payload m_data
The data which is payloaded to the specified class.
Definition: UserInfo.h:119
Belle2::Simulation::UserInfo::m_fraction
double m_fraction
optical photon: propagation fraction
Definition: UserInfo.h:122
Belle2::Simulation::UserInfo::m_trajectory
MCParticleTrajectory * m_trajectory
Particle trajectory, if any.
Definition: UserInfo.h:123
BELLE2_DEFINE_EXCEPTION
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
Definition: FrameworkExceptions.h:46
Belle2::Simulation::UserInfo::Print
virtual void Print() const
Prints information, not implemented in this class.
Definition: UserInfo.h:101