CMS 3D CMS Logo

TrackWithHistory.h
Go to the documentation of this file.
1 #ifndef SimG4Core_TrackWithHistory_H
2 #define SimG4Core_TrackWithHistory_H
3 
4 #include "G4Track.hh"
7 
8 #include "G4Allocator.hh"
9 
10 class G4PrimaryParticle;
16 public:
20  TrackWithHistory(const G4Track *g4track, int pID);
21  TrackWithHistory(const G4PrimaryParticle *, int trackID, const math::XYZVectorD &pos, const double time);
22  ~TrackWithHistory() = default;
23 
24  inline void *operator new(std::size_t);
25  inline void operator delete(void *TrackWithHistory);
26 
27  int trackID() const { return trackID_; }
28  int particleID() const { return pdgID_; }
29  int parentID() const { return parentID_; }
30  int genParticleID() const { return genParticleID_; }
31  int vertexID() const { return vertexID_; }
32  int processType() const { return procType_; }
33  int getIDAtBoundary() const { return idAtBoundary_; }
34 
35  void setTrackID(int i) { trackID_ = i; }
36  void setParentID(int i) { parentID_ = i; }
37  void setVertexID(int i) { vertexID_ = i; }
39 
40  double totalEnergy() const { return totalEnergy_; }
41  double time() const { return time_; }
42  double weight() const { return weight_; }
43  void setToBeSaved() { saved_ = true; }
44  bool storeTrack() const { return storeTrack_; }
45  bool saved() const { return saved_; }
46  bool crossedBoundary() const { return crossedBoundary_; }
47 
48  const math::XYZVectorD &momentum() const { return momentum_; }
49  const math::XYZVectorD &vertexPosition() const { return vertexPosition_; }
50 
51  // Boundary crossing variables
55  crossedBoundary_ = true;
56  idAtBoundary_ = id;
59  }
62 
63  // tracker surface
68  tkSurfaceMomentum_ = mom;
69  }
70 
71 private:
72  int trackID_;
73  int pdgID_;
74  int parentID_;
75  int genParticleID_{-1};
76  int vertexID_{-1};
77  int idAtBoundary_{-1};
78  int procType_{0};
79  double totalEnergy_;
80  double time_; // lab system
81  double weight_;
88  bool storeTrack_{false};
89  bool saved_{false};
90  bool crossedBoundary_{false};
91 };
92 
93 extern G4ThreadLocal G4Allocator<TrackWithHistory> *fpTrackWithHistoryAllocator;
94 
95 inline void *TrackWithHistory::operator new(size_t) {
97  fpTrackWithHistoryAllocator = new G4Allocator<TrackWithHistory>;
98  return (void *)fpTrackWithHistoryAllocator->MallocSingle();
99 }
100 
101 inline void TrackWithHistory::operator delete(void *aTwH) {
102  fpTrackWithHistoryAllocator->FreeSingle((TrackWithHistory *)aTwH);
103 }
104 
105 #endif
G4ThreadLocal G4Allocator< TrackWithHistory > * fpTrackWithHistoryAllocator
void setParentID(int i)
int parentID() const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
math::XYZVectorD vertexPosition_
void setSurfacePosMom(const math::XYZVectorD &pos, const math::XYZTLorentzVectorD &mom)
const math::XYZVectorD & momentum() const
math::XYZVectorD momentum_
bool storeTrack() const
double weight() const
const math::XYZVectorD & vertexPosition() const
double totalEnergy() const
void setGenParticleID(int i)
double time() const
const math::XYZVectorD & trackerSurfacePosition() const
math::XYZTLorentzVectorF positionAtBoundary_
bool crossedBoundary() const
int genParticleID() const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
~TrackWithHistory()=default
void setTrackID(int i)
int vertexID() const
int getIDAtBoundary() const
math::XYZTLorentzVectorF momentumAtBoundary_
void setVertexID(int i)
double f[11][100]
TrackWithHistory(const G4Track *g4track, int pID)
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
bool saved() const
math::XYZTLorentzVectorD tkSurfaceMomentum_
const math::XYZTLorentzVectorF & getMomentumAtBoundary() const
int processType() const
math::XYZVectorD tkSurfacePosition_
static int position[264][3]
Definition: ReadPGInfo.cc:289
int trackID() const
void setCrossedBoundaryPosMom(int id, const math::XYZTLorentzVectorF &position, const math::XYZTLorentzVectorF &momentum)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
int particleID() const
const math::XYZTLorentzVectorF & getPositionAtBoundary() const