 |
Belle II Software
release-05-02-19
|
11 #include <simulation/kernel/TrackingAction.h>
12 #include <simulation/kernel/UserInfo.h>
13 #include <simulation/kernel/SensitiveDetectorBase.h>
14 #include <framework/logging/Logger.h>
15 #include <framework/gearbox/Unit.h>
17 #include <G4TrackingManager.hh>
19 #include <G4ParticleDefinition.hh>
20 #include <G4ParticleTypes.hh>
21 #include <G4EmProcessSubType.hh>
22 #include <G4DecayProcessType.hh>
24 #include <G4ParticleTable.hh>
27 using namespace Belle2::Simulation;
30 G4UserTrackingAction(), m_mcParticleGraph(mcParticleGraph),
31 m_ignoreOpticalPhotons(false),
32 m_ignoreSecondaries(false), m_secondariesEnergyCut(0.0),
33 m_ignoreBremsstrahlungPhotons(false), m_bremsstrahlungPhotonsEnergyCut(0.0),
34 m_ignorePairConversions(false), m_pairConversionsEnergyCut(0.0),
35 m_storeTrajectories(false), m_distanceTolerance(0),
63 if (track->GetCurrentStepNumber() > 0)
return;
65 const G4DynamicParticle* dynamicParticle = track->GetDynamicParticle();
70 const bool isPrimary = dynamicParticle->GetPrimaryParticle() !=
nullptr;
71 bool neutral_llp =
false;
73 const G4PrimaryParticle* primaryParticle = dynamicParticle->GetPrimaryParticle();
74 if (primaryParticle->GetUserInformation() !=
nullptr) {
77 if (primaryParticle->GetParticleDefinition() == G4ParticleTable::GetParticleTable()->FindParticle(
"LongLivedNeutralParticle")) {
81 B2WARNING(track->GetDefinition()->GetPDGEncoding() <<
" has no MCParticle user information !");
88 G4ThreeVector dpMom = dynamicParticle->GetMomentum() / CLHEP::MeV *
Unit::MeV;
95 G4ThreeVector trVtxPos = track->GetVertexPosition() / CLHEP::mm *
Unit::mm;
102 currParticle.
setPDG(dynamicParticle->GetPDGcode());
105 currParticle.
setMomentum(dpMom.x(), dpMom.y(), dpMom.z());
114 }
else if (track->GetCreatorProcess() !=
nullptr) {
116 const int& processSubType = track->GetCreatorProcess()->GetProcessSubType();
120 if (processSubType >=
static_cast<int>(DECAY) && processSubType <=
static_cast<int>(DECAY_External))
133 (
m_storeTrajectories == 2 && track->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())) {
139 }
catch (CouldNotFindUserInfo& exc) {
147 G4StepPoint* postStep = track->GetStep()->GetPostStepPoint();
154 for (G4Track* daughterTrack : *fpTrackingManager->GimmeSecondaries()) {
158 if (daughterTrack->GetDynamicParticle()->GetPrimaryParticle() == NULL &&
159 daughterTrack->GetUserInformation() == NULL) {
161 const_cast<G4Track*
>(daughterTrack)->SetUserInformation(
new TrackInfo(daughterParticle));
166 if (daughterTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {
171 if (track->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {
173 TrackInfo* daughterInfo =
dynamic_cast<TrackInfo*
>(daughterTrack->GetUserInformation());
178 }
else if (daughterTrack->GetCreatorProcess()->GetProcessSubType() == fBremsstrahlung) {
186 }
else if (daughterTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) {
207 if (track->GetTrackStatus() == fSuspend)
return;
210 if (postStep->GetStepStatus() == fWorldBoundary) {
215 if (track->GetKineticEnergy() <= 0.0) {
220 G4ThreeVector decVtx = postStep->GetPosition() / CLHEP::mm *
Unit::mm;
232 }
catch (CouldNotFindUserInfo& exc) {
void setTrackID(int trackID)
Set the track ID for the particle.
StoreArray< MCParticleTrajectory > m_storeMCTrajectories
Store array for the Trajectories.
@ c_StoppedInDetector
bit 3: Particle was stopped in the detector (the simulation volume).
bool m_ignoreSecondaries
do not store secondaries in MCParticles
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
@ c_negativeWeight
Flip the sign of the weight to become negative if the original element got re-attributed.
void setStoreTrajectories(int store, double distanceTolerance)
Sets the trajectory option to enable storing of the simulated particle trajectories.
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
void setIgnore(bool ignore=true)
Set or remove the ignore flag.
bool m_ignoreBremsstrahlungPhotons
do not store bremsstrahlung photons in MCParticles
TrackingAction(MCParticleGraph &mcParticleGraph)
Constructor.
Class to build, validate and sort a particle decay chain.
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
void setDecayVertex(const TVector3 &vertex)
Set decay vertex.
void setStatus(int status)
Set status of optical photon (used for performance speed-ups)
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
double m_bremsstrahlungPhotonsEnergyCut
kinetic energy cut for stored bremsstrahlung photons [MeV]
void PreUserTrackingAction(const G4Track *track)
Checks if the particle associated to the track is already in the MCParticle list.
@ c_LeftDetector
bit 2: Particle left the detector (the simulation volume).
int getStatus()
Get status of optical photon (used for performance speed-ups) 0 initial 1 prescaled in StackingAction...
virtual ~TrackingAction()
Destructor.
static const double MeV
[megaelectronvolt]
Class to save the full simulated trajectory of a particle.
void simplify(float distanceTolerance)
Simplify the trajectory using the Ramer-Douglas-Peuker algorithm.
void setProductionTime(float time)
Set production time.
double m_secondariesEnergyCut
kinetic energy cut for stored secondaries [MeV]
void setSecondaryPhysicsProcess(int physicsProcess)
Sets the physics process type of a secondary particle.
void setFraction(double fraction)
Store optical photon propagation fraction (used for performance speed-ups)
RelationArray m_relMCTrajectories
RelationArry for the relation between MCParticles and Trajectories.
Abstract base class for different kinds of events.
void setPDG(int pdg)
Set PDG code of the particle.
double getFraction()
Get optical photon propagation fraction (used for performance speed-ups) status=0: fraction=1 status=...
double m_pairConversionsEnergyCut
kinetic energy cut for stored e+ or e- from pair conversions [MeV]
GraphParticle & addParticle()
Add new particle to the graph.
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
void setProductionVertex(const TVector3 &vertex)
Set production vertex position.
void addStatus(unsigned short int bitmask)
Add bitmask to current status.
double m_distanceTolerance
distance tolerance to merge trajectory points
MCParticleGraph & m_mcParticleGraph
< Reference to the MCParticle graph which is updated by the tracking action.
void PostUserTrackingAction(const G4Track *track)
Updates the data of the MCParticle associated with the Geant4 track.
void setEnergy(float energy)
Set energy.
static const double mm
[millimeters]
bool m_ignorePairConversions
do not store e+ or e- from pair conversions in MCparticles
void setMass(float mass)
Set particle mass.
bool m_ignoreOpticalPhotons
do not store optical photons in MCParticles
A Class to store the Monte Carlo particle information.
void decaysInto(GraphParticle &daughter)
Tells the graph that this particle decays into daughter.
Accessor to arrays stored in the data store.
void setDecayTime(float time)
Set decay time.
int m_storeTrajectories
Store trajectories for 0=none, 1=primary or 2=all particles.
void setMomentum(const TVector3 &momentum)
Set particle momentum.
void setValidVertex(bool valid)
Set indication wether vertex and time information is valid or just default.
Class to represent Particle data in graph.
float getProductionTime() const
Return production time in ns.