CMS 3D CMS Logo

CaloG4Hit.h
Go to the documentation of this file.
1 #ifndef SimG4CMS_CaloG4Hit_h
2 #define SimG4CMS_CaloG4Hit_h 1
3 // File: CaloG4Hit.h
5 // Date: 10.02 Taken from CMSCaloHit
6 //
7 // Hit class for Calorimeters (Ecal, Hcal, ...)
8 //
9 // One Hit object should be created
10 // -for each new particle entering the calorimeter
11 // -for each detector unit (= crystal or fibre or scintillator layer)
12 // -for each nanosecond of the shower development
13 //
14 // This implies that all hit objects created for a given shower
15 // have the same value for
16 // - Entry (= local coordinates of the entrance point of the particle
17 // in the unit where the shower starts)
18 // - the TrackID (= Identification number of the incident particle)
19 // - the IncidentEnergy (= energy of that particle)
20 //
21 // Modified:
22 //
24 
27 #include <iostream>
28 
29 #include "G4Allocator.hh"
30 #include "G4VHit.hh"
31 
32 class CaloG4Hit : public G4VHit {
33 public:
34  CaloG4Hit();
35  ~CaloG4Hit() override;
36  CaloG4Hit(const CaloG4Hit& right);
37  const CaloG4Hit& operator=(const CaloG4Hit& right);
38  bool operator==(const CaloG4Hit&) { return false; }
39  inline void* operator new(size_t);
40  inline void operator delete(void* CaloG4Hit);
41 
42  void Draw() override {}
43  void Print() override;
44 
45 public:
46  math::XYZPoint getEntry() const { return entry; }
47  void setEntry(double x, double y, double z) { entry.SetCoordinates(x, y, z); }
48 
50  void setEntryLocal(double x, double y, double z) { entryLocal.SetCoordinates(x, y, z); }
51 
52  math::XYZPoint getPosition() const { return pos; }
53  void setPosition(double x, double y, double z) { pos.SetCoordinates(x, y, z); }
54 
55  double getEM() const { return elem; }
56  void setEM(double e) { elem = e; }
57 
58  double getHadr() const { return hadr; }
59  void setHadr(double e) { hadr = e; }
60 
61  double getIncidentEnergy() const { return theIncidentEnergy; }
62  void setIncidentEnergy(double e) { theIncidentEnergy = e; }
63 
64  int getTrackID() const { return hitID.trackID(); }
65 
66  uint32_t getUnitID() const { return hitID.unitID(); }
67  double getTimeSlice() const { return hitID.timeSlice(); }
68  int getTimeSliceID() const { return hitID.timeSliceID(); }
69  uint16_t getDepth() const { return hitID.depth(); }
70  bool isFinecaloTrackID() const { return hitID.isFinecaloTrackID(); }
71 
72  CaloHitID getID() const { return hitID; }
73  void setID(uint32_t i, double d, int j, uint16_t k = 0) { hitID.setID(i, d, j, k); }
74  void setID(const CaloHitID& id) { hitID = id; }
75 
76  void addEnergyDeposit(double em, double hd);
77  void addEnergyDeposit(const CaloG4Hit& aHit);
78 
79  double getEnergyDeposit() const { return (elem + hadr); }
80 
81 private:
82  math::XYZPoint entry; //Entry point (Global coordinate)
83  math::XYZPoint entryLocal; //Entry point (Local coordinate)
84  math::XYZPoint pos; //Position (Global coordinate)
85  double elem; //EnergyDeposit of EM particles
86  double hadr; //EnergyDeposit of HD particles
87  double theIncidentEnergy; //Energy of the primary particle
88  CaloHitID hitID; //Identification number of the hit given
89  //by primary particle, Cell ID, Time of
90  //the hit
91 };
92 
94 public:
95  bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
96  if (a->getTrackID() != b->getTrackID()) {
97  return (a->getTrackID() < b->getTrackID());
98  } else if (a->getUnitID() != b->getUnitID()) {
99  return (a->getUnitID() < b->getUnitID());
100  } else if (a->getDepth() != b->getDepth()) {
101  return (a->getDepth() < b->getDepth());
102  } else {
103  return (a->getTimeSliceID() < b->getTimeSliceID());
104  }
105  }
106 };
107 
109 public:
110  bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
111  return (a->getTrackID() == b->getTrackID() && a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() &&
112  a->getTimeSliceID() == b->getTimeSliceID());
113  }
114 };
115 
116 extern G4ThreadLocal G4Allocator<CaloG4Hit>* fpCaloG4HitAllocator;
117 
118 inline void* CaloG4Hit::operator new(size_t) {
120  fpCaloG4HitAllocator = new G4Allocator<CaloG4Hit>;
121  return (void*)fpCaloG4HitAllocator->MallocSingle();
122 }
123 
124 inline void CaloG4Hit::operator delete(void* aHit) { fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*)aHit); }
125 
126 std::ostream& operator<<(std::ostream&, const CaloG4Hit&);
127 
128 #endif
int getTrackID() const
Definition: CaloG4Hit.h:64
math::XYZPoint getEntryLocal() const
Definition: CaloG4Hit.h:49
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:11
double getEM() const
Definition: CaloG4Hit.h:55
void setIncidentEnergy(double e)
Definition: CaloG4Hit.h:62
void setEntryLocal(double x, double y, double z)
Definition: CaloG4Hit.h:50
bool isFinecaloTrackID() const
Definition: CaloHitID.h:30
uint16_t getDepth() const
Definition: CaloG4Hit.h:69
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:95
double getHadr() const
Definition: CaloG4Hit.h:58
int timeSliceID() const
Definition: CaloHitID.h:21
void addEnergyDeposit(double em, double hd)
Definition: CaloG4Hit.cc:45
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
CaloHitID hitID
Definition: CaloG4Hit.h:88
bool isFinecaloTrackID() const
Definition: CaloG4Hit.h:70
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:46
math::XYZPoint entry
Definition: CaloG4Hit.h:82
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:110
void setEM(double e)
Definition: CaloG4Hit.h:56
void setID(uint32_t i, double d, int j, uint16_t k=0)
Definition: CaloG4Hit.h:73
uint32_t unitID() const
Definition: CaloHitID.h:20
d
Definition: ztail.py:151
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:41
const CaloG4Hit & operator=(const CaloG4Hit &right)
Definition: CaloG4Hit.cc:33
int getTimeSliceID() const
Definition: CaloG4Hit.h:68
~CaloG4Hit() override
Definition: CaloG4Hit.cc:21
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double hadr
Definition: CaloG4Hit.h:86
double b
Definition: hdecay.h:120
math::XYZPoint entryLocal
Definition: CaloG4Hit.h:83
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
double timeSlice() const
Definition: CaloHitID.h:22
uint32_t getUnitID() const
Definition: CaloG4Hit.h:66
void setHadr(double e)
Definition: CaloG4Hit.h:59
double theIncidentEnergy
Definition: CaloG4Hit.h:87
math::XYZPoint pos
Definition: CaloG4Hit.h:84
void setPosition(double x, double y, double z)
Definition: CaloG4Hit.h:53
void setEntry(double x, double y, double z)
Definition: CaloG4Hit.h:47
double a
Definition: hdecay.h:121
double getTimeSlice() const
Definition: CaloG4Hit.h:67
double elem
Definition: CaloG4Hit.h:85
void Draw() override
Definition: CaloG4Hit.h:42
CaloHitID getID() const
Definition: CaloG4Hit.h:72
double getIncidentEnergy() const
Definition: CaloG4Hit.h:61
void Print() override
Definition: CaloG4Hit.cc:52
int trackID() const
Definition: CaloHitID.h:23
std::ostream & operator<<(std::ostream &, const CaloG4Hit &)
Definition: CaloG4Hit.cc:54
void setID(const CaloHitID &id)
Definition: CaloG4Hit.h:74
uint16_t depth() const
Definition: CaloHitID.h:24
bool operator==(const CaloG4Hit &)
Definition: CaloG4Hit.h:38