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
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:355
CaloHitID::depth
uint16_t depth() const
Definition: CaloHitID.h:24
CaloG4Hit::getUnitID
uint32_t getUnitID() const
Definition: CaloG4Hit.h:65
pos
Definition: PixelAliasList.h:18
CaloHitID::trackID
int trackID() const
Definition: CaloHitID.h:23
CaloG4Hit::elem
double elem
Definition: CaloG4Hit.h:83
CaloG4Hit::getEntryLocal
math::XYZPoint getEntryLocal() const
Definition: CaloG4Hit.h:49
DDAxes::x
CaloHitID.h
CaloG4Hit::pos
math::XYZPoint pos
Definition: CaloG4Hit.h:82
CaloHitID::unitID
uint32_t unitID() const
Definition: CaloHitID.h:20
CaloG4Hit::getTimeSlice
double getTimeSlice() const
Definition: CaloG4Hit.h:66
Utilities.operator
operator
Definition: Utilities.py:24
CaloG4Hit::getID
CaloHitID getID() const
Definition: CaloG4Hit.h:70
CaloG4HitEqual
Definition: CaloG4Hit.h:106
CaloG4Hit::hadr
double hadr
Definition: CaloG4Hit.h:84
CaloG4Hit::entry
math::XYZPoint entry
Definition: CaloG4Hit.h:80
CaloG4HitLess::operator()
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:93
CaloHitID::setID
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
fpCaloG4HitAllocator
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:11
CaloG4Hit::entryLocal
math::XYZPoint entryLocal
Definition: CaloG4Hit.h:81
CaloG4Hit::getEnergyDeposit
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
DDAxes::z
CaloG4Hit::hitID
CaloHitID hitID
Definition: CaloG4Hit.h:86
CaloHitID::timeSlice
double timeSlice() const
Definition: CaloHitID.h:22
CaloG4HitEqual::operator()
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:108
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:85
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:91
CaloG4Hit::getTimeSliceID
int getTimeSliceID() const
Definition: CaloG4Hit.h:67
CaloG4Hit::Draw
void Draw() override
Definition: CaloG4Hit.h:42
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
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:71
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:68
CaloG4Hit::setID
void setID(const CaloHitID &id)
Definition: CaloG4Hit.h:72
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37