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 
6 #include "G4Allocator.hh"
7 
8 class TrackInformation : public G4VUserTrackInformation {
9 public:
10  ~TrackInformation() override {}
11  inline void *operator new(size_t);
12  inline void operator delete(void *TrackInformation);
13 
14  bool storeTrack() const { return storeTrack_; }
16  void storeTrack(bool v) {
17  if (v)
18  storeTrack_ = v;
19  if (v == true)
20  putInHistory();
21  }
22 
23  bool isPrimary() const { return isPrimary_; }
24  void isPrimary(bool v) { isPrimary_ = v; }
25 
26  bool hasHits() const { return hasHits_; }
27  void hasHits(bool v) { hasHits_ = v; }
28 
31 
32  bool isInHistory() const { return isInHistory_; }
33  void putInHistory() { isInHistory_ = true; }
34 
35  bool isAncestor() const { return flagAncestor_; }
36  void setAncestor() { flagAncestor_ = true; }
37 
38  // Calo section
39  int getIDonCaloSurface() const { return idOnCaloSurface_; }
40  void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p) {
42  idCaloVolume_ = ical;
46  }
47  int getIDCaloVolume() const { return idCaloVolume_; }
48  int getIDLastVolume() const { return idLastVolume_; }
49  bool caloIDChecked() const { return caloIDChecked_; }
50  void setCaloIDChecked(bool f) { caloIDChecked_ = f; }
53  double caloSurfaceParticleP() const { return caloSurfaceParticleP_; }
55 
56  // Generator information
57  int genParticlePID() const { return genParticlePID_; }
58  void setGenParticlePID(int id) { genParticlePID_ = id; }
59  double genParticleP() const { return genParticleP_; }
60  void setGenParticleP(double p) { genParticleP_ = p; }
61 
62  // remember the PID of particle entering the CASTOR detector. This is needed
63  // in order to scale the hadronic response
64  bool hasCastorHit() const { return hasCastorHit_; }
65  void setCastorHitPID(const int pid) {
66  hasCastorHit_ = true;
68  }
69  int getCastorHitPID() const { return castorHitPID_; }
70 
71  void Print() const override;
72 
73 private:
75  bool isPrimary_;
76  bool hasHits_;
86 
89 
90  // Restrict construction to friends
92  : G4VUserTrackInformation(),
93  storeTrack_(false),
94  isPrimary_(false),
95  hasHits_(false),
96  isGeneratedSecondary_(false),
97  isInHistory_(false),
98  flagAncestor_(false),
99  idOnCaloSurface_(0),
100  idCaloVolume_(-1),
101  idLastVolume_(-1),
102  caloIDChecked_(false),
103  genParticlePID_(-1),
104  caloSurfaceParticlePID_(0),
105  genParticleP_(0),
106  caloSurfaceParticleP_(0),
107  hasCastorHit_(false),
108  castorHitPID_(0) {}
109  friend class NewTrackAction;
110 };
111 
112 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
113 
114 inline void *TrackInformation::operator new(size_t) {
116  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
117  return (void *)fpTrackInformationAllocator->MallocSingle();
118 }
119 
120 inline void TrackInformation::operator delete(void *trkInfo) {
121  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
122 }
123 
124 #endif
int getCastorHitPID() const
bool storeTrack() const
int getIDonCaloSurface() const
void storeTrack(bool v)
can only be set to true, cannot be reset to false!
double genParticleP() const
void setGenParticlePID(int id)
G4ThreadLocal G4Allocator< TrackInformation > * fpTrackInformationAllocator
void hasHits(bool v)
void isGeneratedSecondary(bool v)
void setCastorHitPID(const int pid)
bool hasHits() const
int getIDCaloVolume() const
bool isGeneratedSecondary() const
int genParticlePID() const
void setCaloSurfaceParticlePID(int id)
bool isAncestor() const
void Print() const override
void setCaloSurfaceParticleP(double p)
int caloSurfaceParticlePID() const
double f[11][100]
void isPrimary(bool v)
int getIDLastVolume() const
bool isInHistory() const
bool hasCastorHit() const
double caloSurfaceParticleP_
void setGenParticleP(double p)
bool isPrimary() const
~TrackInformation() override
bool caloIDChecked() const
void setCaloIDChecked(bool f)
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
double caloSurfaceParticleP() const