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 setBTLlooper() { mtdStatus_ |= 1 << 2; } // 3th bit
94  bool isBTLlooper() const { return (mtdStatus_ >> 2) & 1; }
95  void setInTrkFromBackscattering() { mtdStatus_ |= 1 << 3; } // 4th bit
96  bool isInTrkFromBackscattering() const { return (mtdStatus_ >> 3) & 1; }
97  void setExtSecondary() { mtdStatus_ |= 1 << 4; } //5th bit
98  bool isExtSecondary() const { return (mtdStatus_ >> 4) & 1; }
99 
100  void Print() const override;
101 
102 private:
103  bool storeTrack_{false};
104  bool isPrimary_{false};
105  bool hasHits_{false};
107  bool isInHistory_{false};
108  bool flagAncestor_{false};
109  bool caloIDChecked_{false};
110  bool crossedBoundary_{false};
111  bool startedInFineVolume_{false};
113  bool hasCastorHit_{false};
115  int idCaloVolume_{-1};
116  int idLastVolume_{-1};
118  int mcTruthID_{-1};
121  uint8_t mtdStatus_{0};
122  double genParticleP_{0.};
126 };
127 
128 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
129 
130 inline void *TrackInformation::operator new(size_t) {
132  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
133  return (void *)fpTrackInformationAllocator->MallocSingle();
134 }
135 
136 inline void TrackInformation::operator delete(void *trkInfo) {
137  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
138 }
139 
140 #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
void setGenParticlePID(int id)
G4ThreadLocal G4Allocator< TrackInformation > * fpTrackInformationAllocator
void setInTrkFromBackscattering()
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 setCaloSurfaceParticleP(double p)
double f[11][100]
bool isExtSecondary() const
bool isInTrkFromBackscattering() const
~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)
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)