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 storeTrack(bool v) {
21  if (v)
22  storeTrack_ = v;
23  if (v == true)
24  putInHistory();
25  }
26 
27  bool isPrimary() const { return isPrimary_; }
28  void isPrimary(bool v) { isPrimary_ = v; }
29 
30  bool hasHits() const { return hasHits_; }
31  void hasHits(bool v) { hasHits_ = v; }
32 
35 
36  bool isInHistory() const { return isInHistory_; }
37  void putInHistory() { isInHistory_ = true; }
38 
39  bool isAncestor() const { return flagAncestor_; }
40  void setAncestor() { flagAncestor_ = true; }
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  crossedBoundary_ = true;
63  positionAtBoundary_ = math::XYZTLorentzVectorF(track->GetPosition().x() / CLHEP::cm,
64  track->GetPosition().y() / CLHEP::cm,
65  track->GetPosition().z() / CLHEP::cm,
66  track->GetGlobalTime());
67  momentumAtBoundary_ = math::XYZTLorentzVectorF(track->GetMomentum().x() / CLHEP::GeV,
68  track->GetMomentum().y() / CLHEP::GeV,
69  track->GetMomentum().z() / CLHEP::GeV,
70  track->GetTotalEnergy() / CLHEP::GeV);
71  }
72  bool crossedBoundary() const { return crossedBoundary_; }
75  bool startedInFineVolume() const { return startedInFineVolume_; }
76  void setStartedInFineVolume(bool flag = true) {
79  }
81 
82  // Generator information
83  int genParticlePID() const { return genParticlePID_; }
84  void setGenParticlePID(int id) { genParticlePID_ = id; }
85  double genParticleP() const { return genParticleP_; }
86  void setGenParticleP(double p) { genParticleP_ = p; }
87 
88  // remember the PID of particle entering the CASTOR detector. This is needed
89  // in order to scale the hadronic response
90  bool hasCastorHit() const { return hasCastorHit_; }
91  void setCastorHitPID(const int pid) {
92  hasCastorHit_ = true;
93  castorHitPID_ = pid;
94  }
95  int getCastorHitPID() const { return castorHitPID_; }
96 
97  void Print() const override;
98 
99 private:
102  bool hasHits_;
115 
118 
121 
122  // Restrict construction to friends
124  : G4VUserTrackInformation(),
126  isPrimary_(false),
127  hasHits_(false),
131  idOnCaloSurface_(0),
132  idCaloVolume_(-1),
133  idLastVolume_(-1),
138  genParticlePID_(-1),
140  genParticleP_(0),
143  castorHitPID_(0) {}
144  friend class NewTrackAction;
145 };
146 
147 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
148 
149 inline void *TrackInformation::operator new(size_t) {
151  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
152  return (void *)fpTrackInformationAllocator->MallocSingle();
153 }
154 
155 inline void TrackInformation::operator delete(void *trkInfo) {
156  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
157 }
158 
159 #endif
bool storeTrack() const
double genParticleP() const
bool isPrimary() const
int getIDCaloVolume() const
bool crossedBoundary() const
int getCastorHitPID() const
math::XYZTLorentzVectorF momentumAtBoundary_
bool hasCastorHit() const
bool isAncestor() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
void storeTrack(bool v)
can only be set to true, cannot be reset to false!
void setGenParticlePID(int id)
G4ThreadLocal G4Allocator< TrackInformation > * fpTrackInformationAllocator
bool isInHistory() const
void setStartedInFineVolume(bool flag=true)
void hasHits(bool v)
bool caloIDChecked() const
void isGeneratedSecondary(bool v)
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 isPrimary(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
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)