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