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#pragma once
10
11#include <framework/core/FrameworkExceptions.h>
12#include <mdst/dataobjects/MCParticleGraph.h>
13#include <simulation/dataobjects/MCParticleTrajectory.h>
14
15#include "G4VUserTrackInformation.hh"
16#include "G4VUserPrimaryParticleInformation.hh"
17
18
19namespace Belle2 {
24
25 namespace Simulation {
26
27 //Define exceptions
29 BELLE2_DEFINE_EXCEPTION(CouldNotFindUserInfo, "No User Information was found !");
30
35 template<class Info, class Payload> class UserInfo: public Info {
36
37 public:
38
43 explicit UserInfo(Payload data) : Info(), m_data(data), m_status(0), m_fraction(1.0), m_trajectory(nullptr) {}
44
49 Payload getData() { return m_data; }
50
58 int getStatus() {return m_status;}
59
67 double getFraction() {return m_fraction;}
68
71
76 void setStatus(int status) { m_status = status;}
77
82 void setFraction(double fraction) { m_fraction = fraction;}
83
85 void setTrajectory(MCParticleTrajectory* trajectory) { m_trajectory = trajectory; }
86
90 virtual void Print() const {;}
91
99 template<class Carrier> static Payload getInfo(Carrier& obj)
100 {
101 UserInfo<Info, Payload>* userinfo = dynamic_cast<UserInfo<Info, Payload>*>(obj.GetUserInformation());
102 if (!userinfo) throw(CouldNotFindUserInfo());
103 return userinfo->getData();
104 }
105
106 protected:
107
108 Payload m_data;
109
111 double m_fraction;
113
114 };
115
118
119 } // end namespace Simulation
121} // end namespace Belle2
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:35
virtual void Print() const
Prints information, not implemented in this class.
Definition UserInfo.h:90
MCParticleTrajectory * getTrajectory()
Get optional particle trajectory.
Definition UserInfo.h:70
void setFraction(double fraction)
Store optical photon propagation fraction (used for performance speed-ups)
Definition UserInfo.h:82
void setStatus(int status)
Set status of optical photon (used for performance speed-ups)
Definition UserInfo.h:76
UserInfo(Payload data)
The constructor of the user info class.
Definition UserInfo.h:43
double getFraction()
Get optical photon propagation fraction (used for performance speed-ups) status=0: fraction=1 status=...
Definition UserInfo.h:67
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition UserInfo.h:99
void setTrajectory(MCParticleTrajectory *trajectory)
Set the optional particle trajectory.
Definition UserInfo.h:85
Payload getData()
Returns the payloaded data.
Definition UserInfo.h:49
int getStatus()
Get status of optical photon (used for performance speed-ups) 0 initial 1 prescaled in StackingAction...
Definition UserInfo.h:58
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
Abstract base class for different kinds of events.