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  uint32_t getUnitID() const { return hitID.unitID(); }
66  double getTimeSlice() const { return hitID.timeSlice(); }
67  int getTimeSliceID() const { return hitID.timeSliceID(); }
68  uint16_t getDepth() const { return hitID.depth(); }
69 
70  CaloHitID getID() const { return hitID; }
71  void setID(uint32_t i, double d, int j, uint16_t k = 0) { hitID.setID(i, d, j, k); }
72  void setID(const CaloHitID& id) { hitID = id; }
73 
74  void addEnergyDeposit(double em, double hd);
75  void addEnergyDeposit(const CaloG4Hit& aHit);
76 
77  double getEnergyDeposit() const { return (elem + hadr); }
78 
79 private:
80  math::XYZPoint entry; //Entry point (Global coordinate)
81  math::XYZPoint entryLocal; //Entry point (Local coordinate)
82  math::XYZPoint pos; //Position (Global coordinate)
83  double elem; //EnergyDeposit of EM particles
84  double hadr; //EnergyDeposit of HD particles
85  double theIncidentEnergy; //Energy of the primary particle
86  CaloHitID hitID; //Identification number of the hit given
87  //by primary particle, Cell ID, Time of
88  //the hit
89 };
90 
92 public:
93  bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
94  if (a->getTrackID() != b->getTrackID()) {
95  return (a->getTrackID() < b->getTrackID());
96  } else if (a->getUnitID() != b->getUnitID()) {
97  return (a->getUnitID() < b->getUnitID());
98  } else if (a->getDepth() != b->getDepth()) {
99  return (a->getDepth() < b->getDepth());
100  } else {
101  return (a->getTimeSliceID() < b->getTimeSliceID());
102  }
103  }
104 };
105 
107 public:
108  bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
109  return (a->getTrackID() == b->getTrackID() && a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() &&
110  a->getTimeSliceID() == b->getTimeSliceID());
111  }
112 };
113 
114 extern G4ThreadLocal G4Allocator<CaloG4Hit>* fpCaloG4HitAllocator;
115 
116 inline void* CaloG4Hit::operator new(size_t) {
118  fpCaloG4HitAllocator = new G4Allocator<CaloG4Hit>;
119  return (void*)fpCaloG4HitAllocator->MallocSingle();
120 }
121 
122 inline void CaloG4Hit::operator delete(void* aHit) { fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*)aHit); }
123 
124 std::ostream& operator<<(std::ostream&, const CaloG4Hit&);
125 
126 #endif
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:52
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:11
void setIncidentEnergy(double e)
Definition: CaloG4Hit.h:62
void setEntryLocal(double x, double y, double z)
Definition: CaloG4Hit.h:50
uint16_t getDepth() const
Definition: CaloG4Hit.h:68
double getIncidentEnergy() const
Definition: CaloG4Hit.h:61
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:93
double timeSlice() const
Definition: CaloHitID.h:22
uint16_t depth() const
Definition: CaloHitID.h:24
CaloHitID getID() const
Definition: CaloG4Hit.h:70
void addEnergyDeposit(double em, double hd)
Definition: CaloG4Hit.cc:45
CaloHitID hitID
Definition: CaloG4Hit.h:86
int timeSliceID() const
Definition: CaloHitID.h:21
math::XYZPoint entry
Definition: CaloG4Hit.h:80
int trackID() const
Definition: CaloHitID.h:23
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:108
void setEM(double e)
Definition: CaloG4Hit.h:56
void setID(uint32_t i, double d, int j, uint16_t k=0)
Definition: CaloG4Hit.h:71
int k[5][pyjets_maxn]
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
const CaloG4Hit & operator=(const CaloG4Hit &right)
Definition: CaloG4Hit.cc:33
int getTrackID() const
Definition: CaloG4Hit.h:64
~CaloG4Hit() override
Definition: CaloG4Hit.cc:21
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double hadr
Definition: CaloG4Hit.h:84
double b
Definition: hdecay.h:120
math::XYZPoint entryLocal
Definition: CaloG4Hit.h:81
int getTimeSliceID() const
Definition: CaloG4Hit.h:67
double getEM() const
Definition: CaloG4Hit.h:55
void setHadr(double e)
Definition: CaloG4Hit.h:59
double theIncidentEnergy
Definition: CaloG4Hit.h:85
math::XYZPoint pos
Definition: CaloG4Hit.h:82
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:66
double elem
Definition: CaloG4Hit.h:83
math::XYZPoint getEntryLocal() const
Definition: CaloG4Hit.h:49
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:46
uint32_t getUnitID() const
Definition: CaloG4Hit.h:65
uint32_t unitID() const
Definition: CaloHitID.h:20
void Draw() override
Definition: CaloG4Hit.h:42
void Print() override
Definition: CaloG4Hit.cc:52
std::ostream & operator<<(std::ostream &, const CaloG4Hit &)
Definition: CaloG4Hit.cc:54
double getHadr() const
Definition: CaloG4Hit.h:58
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
void setID(const CaloHitID &id)
Definition: CaloG4Hit.h:72
bool operator==(const CaloG4Hit &)
Definition: CaloG4Hit.h:38