CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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->GetKineticEnergy() / CLHEP::GeV);
71  }
72  bool crossedBoundary() const { return crossedBoundary_; }
75  bool startedInFineVolume() const { return startedInFineVolume_; }
76  void setStartedInFineVolume(bool flag = true) {
77  startedInFineVolume_ = flag;
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
int getCastorHitPID() const
const double GeV
Definition: MathUtil.h:16
bool storeTrack() const
int getIDonCaloSurface() const
uint16_t *__restrict__ id
math::XYZTLorentzVectorF momentumAtBoundary_
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
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
void setStartedInFineVolume(bool flag=true)
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 crossedBoundary() const
bool isAncestor() const
void setCaloSurfaceParticleP(double p)
int caloSurfaceParticlePID() const
void isPrimary(bool v)
int getIDLastVolume() const
math::XYZTLorentzVectorF positionAtBoundary_
bool isInHistory() const
bool hasCastorHit() const
bool startedInFineVolume() const
void Print() const override
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
void setGenParticleP(double p)
bool isPrimary() const
~TrackInformation() override
bool caloIDChecked() const
bool startedInFineVolumeIsSet()
void setCaloIDChecked(bool f)
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
double caloSurfaceParticleP() const
tuple last
Definition: dqmdumpme.py:56
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)