CMS 3D CMS Logo

TrackInformation.h
Go to the documentation of this file.
1 #ifndef SimG4Core_TrackInformation_H
2 #define SimG4Core_TrackInformation_H
3 
5 #include "G4VUserTrackInformation.hh"
6 #include "G4Allocator.hh"
7 #include "G4Track.hh"
11 
12 class TrackInformation : public G4VUserTrackInformation {
13 public:
14  ~TrackInformation() override{};
15  inline void *operator new(size_t);
16  inline void operator delete(void *TrackInformation);
17 
18  bool storeTrack() const { return storeTrack_; }
20  void setStoreTrack() {
21  storeTrack_ = true;
22  isInHistory_ = true;
23  }
24 
25  bool isPrimary() const { return isPrimary_; }
26  void setPrimary(bool v) { isPrimary_ = v; }
27 
28  bool hasHits() const { return hasHits_; }
29  void setHasHits(bool v) { hasHits_ = v; }
30 
33 
34  bool isInHistory() const { return isInHistory_; }
35  void putInHistory() { isInHistory_ = true; }
36 
37  bool isAncestor() const { return flagAncestor_; }
38  void setAncestor() { flagAncestor_ = true; }
39 
40  // Calo section
41  int getIDonCaloSurface() const { return idOnCaloSurface_; }
42  void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p) {
44  idCaloVolume_ = ical;
48  }
49  int getIDCaloVolume() const { return idCaloVolume_; }
50  int getIDLastVolume() const { return idLastVolume_; }
51  bool caloIDChecked() const { return caloIDChecked_; }
52  void setCaloIDChecked(bool f) { caloIDChecked_ = f; }
55  double caloSurfaceParticleP() const { return caloSurfaceParticleP_; }
57 
58  // Boundary crossing variables
59  void setCrossedBoundary(const G4Track *track) {
60  crossedBoundary_ = true;
61  positionAtBoundary_ = math::XYZTLorentzVectorF(track->GetPosition().x() / CLHEP::cm,
62  track->GetPosition().y() / CLHEP::cm,
63  track->GetPosition().z() / CLHEP::cm,
64  track->GetGlobalTime());
65  momentumAtBoundary_ = math::XYZTLorentzVectorF(track->GetMomentum().x() / CLHEP::GeV,
66  track->GetMomentum().y() / CLHEP::GeV,
67  track->GetMomentum().z() / CLHEP::GeV,
68  track->GetTotalEnergy() / CLHEP::GeV);
69  }
70  bool crossedBoundary() const { return crossedBoundary_; }
73  bool startedInFineVolume() const { return startedInFineVolume_; }
74  void setStartedInFineVolume(bool flag = true) {
77  }
79 
80  // Generator information
81  int genParticlePID() const { return genParticlePID_; }
82  void setGenParticlePID(int id) { genParticlePID_ = id; }
83  double genParticleP() const { return genParticleP_; }
84  void setGenParticleP(double p) { genParticleP_ = p; }
85 
86  // remember the PID of particle entering the CASTOR detector. This is needed
87  // in order to scale the hadronic response
88  bool hasCastorHit() const { return hasCastorHit_; }
89  void setCastorHitPID(const int pid) {
90  hasCastorHit_ = true;
91  castorHitPID_ = pid;
92  }
93  int getCastorHitPID() const { return castorHitPID_; }
94 
95  void Print() const override;
96 
97 private:
99  bool isPrimary_;
100  bool hasHits_;
113 
116 
119 
120  // Restrict construction to friends
122  : G4VUserTrackInformation(),
124  isPrimary_(false),
125  hasHits_(false),
129  idOnCaloSurface_(0),
130  idCaloVolume_(-1),
131  idLastVolume_(-1),
136  genParticlePID_(-1),
138  genParticleP_(0),
141  castorHitPID_(0) {}
142  friend class NewTrackAction;
143 };
144 
145 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
146 
147 inline void *TrackInformation::operator new(size_t) {
149  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
150  return (void *)fpTrackInformationAllocator->MallocSingle();
151 }
152 
153 inline void TrackInformation::operator delete(void *trkInfo) {
154  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
155 }
156 
157 #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
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 setCaloSurfaceParticleP(double p)
double f[11][100]
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
void Print() const override
void setGenParticleP(double p)
~TrackInformation() override
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)
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)