CMS 3D CMS Logo

TrackInformation.h
Go to the documentation of this file.
1 #ifndef SimG4Core_TrackInformation_H
2 #define SimG4Core_TrackInformation_H
3 
4 #include "G4VUserTrackInformation.hh"
5 #include "G4Allocator.hh"
6 #include "G4Track.hh"
9 
10 class TrackInformation : public G4VUserTrackInformation {
11 public:
13  ~TrackInformation() override = default;
14  inline void *operator new(size_t);
15  inline void operator delete(void *TrackInformation);
16 
17  bool storeTrack() const { return storeTrack_; }
19  void setStoreTrack() {
20  storeTrack_ = true;
21  isInHistory_ = true;
22  }
23 
24  bool isPrimary() const { return isPrimary_; }
25  void setPrimary(bool v) { isPrimary_ = v; }
26 
27  bool hasHits() const { return hasHits_; }
28  void setHasHits(bool v) { hasHits_ = v; }
29 
32 
33  bool isInHistory() const { return isInHistory_; }
34  void putInHistory() { isInHistory_ = true; }
35 
36  bool isAncestor() const { return flagAncestor_; }
37  void setAncestor() { flagAncestor_ = true; }
38 
39  int mcTruthID() const { return mcTruthID_; }
40  void setMCTruthID(int id) { mcTruthID_ = id; }
41 
42  // Calo section
43  int getIDonCaloSurface() const { return idOnCaloSurface_; }
44  void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p) {
46  idCaloVolume_ = ical;
50  }
51  int getIDCaloVolume() const { return idCaloVolume_; }
52  int getIDLastVolume() const { return idLastVolume_; }
53  bool caloIDChecked() const { return caloIDChecked_; }
54  void setCaloIDChecked(bool f) { caloIDChecked_ = f; }
57  double caloSurfaceParticleP() const { return caloSurfaceParticleP_; }
59 
60  // Boundary crossing variables
61  void setCrossedBoundary(const G4Track *track);
62  bool crossedBoundary() const { return crossedBoundary_; }
65  bool startedInFineVolume() const { return startedInFineVolume_; }
66  void setStartedInFineVolume(bool flag = true) {
69  }
71 
72  // Generator information
73  int genParticlePID() const { return genParticlePID_; }
74  void setGenParticlePID(int id) { genParticlePID_ = id; }
75  double genParticleP() const { return genParticleP_; }
76  void setGenParticleP(double p) { genParticleP_ = p; }
77 
78  // remember the PID of particle entering the CASTOR detector. This is needed
79  // in order to scale the hadronic response
80  bool hasCastorHit() const { return hasCastorHit_; }
81  void setCastorHitPID(const int pid) {
82  hasCastorHit_ = true;
83  castorHitPID_ = pid;
84  }
85  int getCastorHitPID() const { return castorHitPID_; }
86 
87  // methods for MTD info management
88  //
89  void setFromTtoBTL() { mtdStatus_ |= 1 << 0; } // 1st bit
90  bool isFromTtoBTL() const { return (mtdStatus_ >> 0) & 1; }
91  void setFromBTLtoT() { mtdStatus_ |= 1 << 1; } // 2nd bit
92  bool isFromBTLtoT() const { return (mtdStatus_ >> 1) & 1; }
93  void setBTLdaughter() { mtdStatus_ |= 1 << 2; } // 3rd bit
94  bool isBTLdaughter() const { return (mtdStatus_ >> 2) & 1; }
95  void setBTLlooper() { mtdStatus_ |= 1 << 3; } // 4th bit
96  bool isBTLlooper() const { return (mtdStatus_ >> 3) & 1; }
97 
98  int idAtBTLentrance() const { return idAtBTLentrance_; }
100 
101  void Print() const override;
102 
103 private:
104  bool storeTrack_{false};
105  bool isPrimary_{false};
106  bool hasHits_{false};
108  bool isInHistory_{false};
109  bool flagAncestor_{false};
110  bool caloIDChecked_{false};
111  bool crossedBoundary_{false};
112  bool startedInFineVolume_{false};
114  bool hasCastorHit_{false};
116  int idCaloVolume_{-1};
117  int idLastVolume_{-1};
119  int mcTruthID_{-1};
123  uint8_t mtdStatus_{0};
124  double genParticleP_{0.};
128 };
129 
130 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
131 
132 inline void *TrackInformation::operator new(size_t) {
134  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
135  return (void *)fpTrackInformationAllocator->MallocSingle();
136 }
137 
138 inline void TrackInformation::operator delete(void *trkInfo) {
139  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
140 }
141 
142 #endif
bool storeTrack() const
double genParticleP() const
bool isPrimary() const
int getIDCaloVolume() const
void setStoreTrack()
can only be set to true, cannot be reset to false!
bool crossedBoundary() const
int getCastorHitPID() const
math::XYZTLorentzVectorF momentumAtBoundary_
bool hasCastorHit() const
bool isAncestor() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
bool isBTLdaughter() const
void setGenParticlePID(int id)
G4ThreadLocal G4Allocator< TrackInformation > * fpTrackInformationAllocator
bool isInHistory() const
void setPrimary(bool v)
void setStartedInFineVolume(bool flag=true)
bool caloIDChecked() const
void setCastorHitPID(const int pid)
double caloSurfaceParticleP() const
int caloSurfaceParticlePID() const
void setCaloSurfaceParticlePID(int id)
void setMCTruthID(int id)
void setIdAtBTLentrance(int id)
void setCaloSurfaceParticleP(double p)
double f[11][100]
~TrackInformation() override=default
bool hasHits() const
void setHasHits(bool v)
math::XYZTLorentzVectorF positionAtBoundary_
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
int getIDonCaloSurface() const
bool isGeneratedSecondary() const
int getIDLastVolume() const
int genParticlePID() const
bool isFromBTLtoT() const
void Print() const override
int mcTruthID() const
void setGenParticleP(double p)
bool isBTLlooper() const
void setGeneratedSecondary(bool v)
bool startedInFineVolumeIsSet()
bool startedInFineVolume() const
void setCaloIDChecked(bool f)
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
int idAtBTLentrance() const
bool isFromTtoBTL() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
void setCrossedBoundary(const G4Track *track)