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  idAtBoundary_ = track->GetTrackID();
64  positionAtBoundary_ = math::XYZTLorentzVectorF(track->GetPosition().x() / CLHEP::cm,
65  track->GetPosition().y() / CLHEP::cm,
66  track->GetPosition().z() / CLHEP::cm,
67  track->GetGlobalTime());
69  track->GetMomentum().y() / CLHEP::GeV,
70  track->GetMomentum().z() / CLHEP::GeV,
71  track->GetKineticEnergy() / CLHEP::GeV);
72  }
73  bool crossedBoundary() const { return crossedBoundary_; }
76  int getIDAtBoundary() const { return idAtBoundary_; }
77 
78  // Generator information
79  int genParticlePID() const { return genParticlePID_; }
80  void setGenParticlePID(int id) { genParticlePID_ = id; }
81  double genParticleP() const { return genParticleP_; }
82  void setGenParticleP(double p) { genParticleP_ = p; }
83 
84  // remember the PID of particle entering the CASTOR detector. This is needed
85  // in order to scale the hadronic response
86  bool hasCastorHit() const { return hasCastorHit_; }
87  void setCastorHitPID(const int pid) {
88  hasCastorHit_ = true;
89  castorHitPID_ = pid;
90  }
91  int getCastorHitPID() const { return castorHitPID_; }
92 
93  void Print() const override;
94 
95 private:
97  bool isPrimary_;
98  bool hasHits_;
110 
113 
116 
117  // Restrict construction to friends
119  : G4VUserTrackInformation(),
121  isPrimary_(false),
122  hasHits_(false),
126  idOnCaloSurface_(0),
127  idCaloVolume_(-1),
128  idLastVolume_(-1),
131  genParticlePID_(-1),
133  genParticleP_(0),
136  castorHitPID_(0) {}
137  friend class NewTrackAction;
138 };
139 
140 extern G4ThreadLocal G4Allocator<TrackInformation> *fpTrackInformationAllocator;
141 
142 inline void *TrackInformation::operator new(size_t) {
144  fpTrackInformationAllocator = new G4Allocator<TrackInformation>;
145  return (void *)fpTrackInformationAllocator->MallocSingle();
146 }
147 
148 inline void TrackInformation::operator delete(void *trkInfo) {
149  fpTrackInformationAllocator->FreeSingle((TrackInformation *)trkInfo);
150 }
151 
152 #endif
TrackInformation::Print
void Print() const override
Definition: TrackInformation.cc:8
TrackInformation::castorHitPID_
int castorHitPID_
Definition: TrackInformation.h:115
TrackInformation::caloSurfaceParticleP
double caloSurfaceParticleP() const
Definition: TrackInformation.h:57
TrackInformation::isPrimary
void isPrimary(bool v)
Definition: TrackInformation.h:28
TrackInformation::positionAtBoundary_
math::XYZTLorentzVectorF positionAtBoundary_
Definition: TrackInformation.h:108
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
TrackInformation::getIDonCaloSurface
int getIDonCaloSurface() const
Definition: TrackInformation.h:43
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
TrackInformation::isGeneratedSecondary
bool isGeneratedSecondary() const
Definition: TrackInformation.h:33
TrackInformation::getIDLastVolume
int getIDLastVolume() const
Definition: TrackInformation.h:52
TrackInformation::hasCastorHit_
bool hasCastorHit_
Definition: TrackInformation.h:114
TrackInformation::caloSurfaceParticleP_
double caloSurfaceParticleP_
Definition: TrackInformation.h:112
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
TrackInformation::setAncestor
void setAncestor()
Definition: TrackInformation.h:40
TrackInformation::flagAncestor_
bool flagAncestor_
Definition: TrackInformation.h:101
math::XYZTLorentzVectorF
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
TrackInformation::setIDonCaloSurface
void setIDonCaloSurface(int id, int ical, int last, int pdgID, double p)
Definition: TrackInformation.h:44
TrackInformation::hasHits
bool hasHits() const
Definition: TrackInformation.h:30
TrackInformation::idCaloVolume_
int idCaloVolume_
Definition: TrackInformation.h:103
TrackInformation::~TrackInformation
~TrackInformation() override
Definition: TrackInformation.h:14
TrackInformation::putInHistory
void putInHistory()
Definition: TrackInformation.h:37
TrackInformation::getMomentumAtBoundary
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
Definition: TrackInformation.h:75
TrackInformation::setCaloIDChecked
void setCaloIDChecked(bool f)
Definition: TrackInformation.h:54
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TrackInformation::genParticlePID
int genParticlePID() const
Definition: TrackInformation.h:79
TrackInformation::idOnCaloSurface_
int idOnCaloSurface_
Definition: TrackInformation.h:102
TrackInformation::genParticleP_
double genParticleP_
Definition: TrackInformation.h:112
TrackInformation::storeTrack_
bool storeTrack_
Definition: TrackInformation.h:96
Utilities.operator
operator
Definition: Utilities.py:24
TrackInformation::getIDAtBoundary
int getIDAtBoundary() const
Definition: TrackInformation.h:76
TrackInformation::idAtBoundary_
bool idAtBoundary_
Definition: TrackInformation.h:107
dqmdumpme.last
last
Definition: dqmdumpme.py:56
TrackInformation::setGenParticleP
void setGenParticleP(double p)
Definition: TrackInformation.h:82
TrackInformation::isPrimary
bool isPrimary() const
Definition: TrackInformation.h:27
TrackInformation::idLastVolume_
int idLastVolume_
Definition: TrackInformation.h:104
fpTrackInformationAllocator
G4ThreadLocal G4Allocator< TrackInformation > * fpTrackInformationAllocator
Definition: TrackInformation.cc:6
TrackInformation::caloSurfaceParticlePID_
int caloSurfaceParticlePID_
Definition: TrackInformation.h:111
TrackInformation::hasHits_
bool hasHits_
Definition: TrackInformation.h:98
TrackInformation::getIDCaloVolume
int getIDCaloVolume() const
Definition: TrackInformation.h:51
TrackInformation::isAncestor
bool isAncestor() const
Definition: TrackInformation.h:39
TrackInformation::TrackInformation
TrackInformation()
Definition: TrackInformation.h:118
TrackInformation::isGeneratedSecondary_
bool isGeneratedSecondary_
Definition: TrackInformation.h:99
TrackInformation::getPositionAtBoundary
const math::XYZTLorentzVectorF & getPositionAtBoundary() const
Definition: TrackInformation.h:74
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
GeV
const double GeV
Definition: MathUtil.h:16
TrackInformation::getCastorHitPID
int getCastorHitPID() const
Definition: TrackInformation.h:91
TrackInformation::setCrossedBoundary
void setCrossedBoundary(const G4Track *track)
Definition: TrackInformation.h:61
TrackInformation::isPrimary_
bool isPrimary_
Definition: TrackInformation.h:97
TrackInformation::setGenParticlePID
void setGenParticlePID(int id)
Definition: TrackInformation.h:80
LorentzVector.h
TrackInformation
Definition: TrackInformation.h:12
TrackInformation::isInHistory_
bool isInHistory_
Definition: TrackInformation.h:100
TrackInformation::storeTrack
bool storeTrack() const
Definition: TrackInformation.h:18
TrackInformation::momentumAtBoundary_
math::XYZTLorentzVectorF momentumAtBoundary_
Definition: TrackInformation.h:109
TrackInformation::genParticleP
double genParticleP() const
Definition: TrackInformation.h:81
TrackInformation::hasCastorHit
bool hasCastorHit() const
Definition: TrackInformation.h:86
TrackInformation::crossedBoundary
bool crossedBoundary() const
Definition: TrackInformation.h:73
TrackInformation::storeTrack
void storeTrack(bool v)
can only be set to true, cannot be reset to false!
Definition: TrackInformation.h:20
TrackInformation::genParticlePID_
int genParticlePID_
Definition: TrackInformation.h:111
TrackInformation::crossedBoundary_
bool crossedBoundary_
Definition: TrackInformation.h:106
NewTrackAction
Definition: NewTrackAction.h:14
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TrackInformation::caloSurfaceParticlePID
int caloSurfaceParticlePID() const
Definition: TrackInformation.h:55
TrackInformation::isGeneratedSecondary
void isGeneratedSecondary(bool v)
Definition: TrackInformation.h:34
TrackInformation::setCaloSurfaceParticlePID
void setCaloSurfaceParticlePID(int id)
Definition: TrackInformation.h:56
TrackInformation::hasHits
void hasHits(bool v)
Definition: TrackInformation.h:31
Exception.h
TrackInformation::caloIDChecked
bool caloIDChecked() const
Definition: TrackInformation.h:53
TrackInformation::isInHistory
bool isInHistory() const
Definition: TrackInformation.h:36
TrackInformation::setCaloSurfaceParticleP
void setCaloSurfaceParticleP(double p)
Definition: TrackInformation.h:58
TrackInformation::caloIDChecked_
bool caloIDChecked_
Definition: TrackInformation.h:105
TrackInformation::setCastorHitPID
void setCastorHitPID(const int pid)
Definition: TrackInformation.h:87
Vector3D.h