CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
28 #include <iostream>
29 
30 #include "G4Allocator.hh"
31 #include "G4VHit.hh"
32 
33 class CaloG4Hit : public G4VHit {
34 
35 public:
36 
37  CaloG4Hit();
38  ~CaloG4Hit();
39  CaloG4Hit(const CaloG4Hit &right);
40  const CaloG4Hit& operator=(const CaloG4Hit &right);
41  bool operator==(const CaloG4Hit &){return false;}
42  inline void * operator new(size_t);
43  inline void operator delete(void * CaloG4Hit);
44 
45  void Draw(){}
46  void Print();
47 
48 public:
49 
50  math::XYZPoint getEntry() const {return entry;}
51  void setEntry(double x, double y, double z) {entry.SetCoordinates(x,y,z);}
52 
54  void setEntryLocal(double x, double y, double z) {entryLocal.SetCoordinates(x,y,z);}
55 
56  math::XYZPoint getPosition() const {return pos;}
57  void setPosition(double x, double y, double z) {pos.SetCoordinates(x,y,z);}
58 
59  double getEM() const {return elem;}
60  void setEM (double e) {elem = e;}
61 
62  double getHadr() const {return hadr;}
63  void setHadr (double e) {hadr = e;}
64 
65  double getIncidentEnergy() const {return theIncidentEnergy;}
67 
68  int getTrackID() const {return hitID.trackID();}
69  uint32_t getUnitID() const {return hitID.unitID();}
70  double getTimeSlice() const {return hitID.timeSlice();}
71  int getTimeSliceID() const {return hitID.timeSliceID();}
72  uint16_t getDepth() const {return hitID.depth();}
73 
74  CaloHitID getID() const {return hitID;}
75  void setID (uint32_t i, double d, int j, uint16_t k=0) { hitID.setID(i,d,j,k);}
76  void setID (const CaloHitID& id) {hitID = id;}
77 
78  void addEnergyDeposit(double em, double hd);
79  void addEnergyDeposit(const CaloG4Hit& aHit);
80 
81  double getEnergyDeposit() const {return (elem+hadr);}
82 
83 private:
84 
85  math::XYZPoint entry; //Entry point (Global coordinate)
86  math::XYZPoint entryLocal; //Entry point (Local coordinate)
87  math::XYZPoint pos; //Position (Global coordinate)
88  double elem; //EnergyDeposit of EM particles
89  double hadr; //EnergyDeposit of HD particles
90  double theIncidentEnergy; //Energy of the primary particle
91  CaloHitID hitID; //Identification number of the hit given
92  //by primary particle, Cell ID, Time of
93  //the hit
94 };
95 
97 public:
98  bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) {
99  if (a->getTrackID() != b->getTrackID()) {
100  return (a->getTrackID() < b->getTrackID());
101  } else if (a->getUnitID() != b->getUnitID()) {
102  return (a->getUnitID() < b->getUnitID());
103  } else if (a->getDepth() != b->getDepth()) {
104  return (a->getDepth() < b->getDepth());
105  } else {
106  return (a->getTimeSliceID() < b->getTimeSliceID());
107  }
108  }
109 };
110 
112 public:
113  bool operator()( const CaloG4Hit* a, const CaloG4Hit* b) {
114  return (a->getTrackID() == b->getTrackID() &&
115  a->getUnitID() == b->getUnitID() &&
116  a->getDepth() == b->getDepth() &&
117  a->getTimeSliceID() == b->getTimeSliceID());
118  }
119 };
120 
121 extern G4ThreadLocal G4Allocator<CaloG4Hit> *fpCaloG4HitAllocator;
122 
123 inline void * CaloG4Hit::operator new(size_t) {
125  new G4Allocator<CaloG4Hit>;
126  return (void*)fpCaloG4HitAllocator->MallocSingle();
127 }
128 
129 inline void CaloG4Hit::operator delete(void * aHit) {
130  fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*) aHit);
131 }
132 
133 std::ostream& operator<<(std::ostream&, const CaloG4Hit&);
134 
135 #endif
int i
Definition: DBlmapReader.cc:9
math::XYZPoint getPosition() const
Definition: CaloG4Hit.h:56
G4ThreadLocal G4Allocator< CaloG4Hit > * fpCaloG4HitAllocator
Definition: CaloG4Hit.cc:10
void setIncidentEnergy(double e)
Definition: CaloG4Hit.h:66
void setEntryLocal(double x, double y, double z)
Definition: CaloG4Hit.h:54
uint16_t getDepth() const
Definition: CaloG4Hit.h:72
double getIncidentEnergy() const
Definition: CaloG4Hit.h:65
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:98
double timeSlice() const
Definition: CaloHitID.h:24
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
uint16_t depth() const
Definition: CaloHitID.h:26
CaloHitID getID() const
Definition: CaloG4Hit.h:74
tuple d
Definition: ztail.py:151
void addEnergyDeposit(double em, double hd)
Definition: CaloG4Hit.cc:47
CaloHitID hitID
Definition: CaloG4Hit.h:91
int timeSliceID() const
Definition: CaloHitID.h:23
math::XYZPoint entry
Definition: CaloG4Hit.h:85
int trackID() const
Definition: CaloHitID.h:25
bool operator()(const CaloG4Hit *a, const CaloG4Hit *b)
Definition: CaloG4Hit.h:113
void setEM(double e)
Definition: CaloG4Hit.h:60
void setID(uint32_t i, double d, int j, uint16_t k=0)
Definition: CaloG4Hit.h:75
int j
Definition: DBlmapReader.cc:9
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:44
const CaloG4Hit & operator=(const CaloG4Hit &right)
Definition: CaloG4Hit.cc:34
int getTrackID() const
Definition: CaloG4Hit.h:68
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double hadr
Definition: CaloG4Hit.h:89
double b
Definition: hdecay.h:120
math::XYZPoint entryLocal
Definition: CaloG4Hit.h:86
int getTimeSliceID() const
Definition: CaloG4Hit.h:71
double getEM() const
Definition: CaloG4Hit.h:59
void setHadr(double e)
Definition: CaloG4Hit.h:63
void Draw()
Definition: CaloG4Hit.h:45
double theIncidentEnergy
Definition: CaloG4Hit.h:90
math::XYZPoint pos
Definition: CaloG4Hit.h:87
void setPosition(double x, double y, double z)
Definition: CaloG4Hit.h:57
void setEntry(double x, double y, double z)
Definition: CaloG4Hit.h:51
double a
Definition: hdecay.h:121
double getTimeSlice() const
Definition: CaloG4Hit.h:70
double elem
Definition: CaloG4Hit.h:88
math::XYZPoint getEntryLocal() const
Definition: CaloG4Hit.h:53
math::XYZPoint getEntry() const
Definition: CaloG4Hit.h:50
void Print()
Definition: CaloG4Hit.cc:59
uint32_t getUnitID() const
Definition: CaloG4Hit.h:69
uint32_t unitID() const
Definition: CaloHitID.h:22
double getHadr() const
Definition: CaloG4Hit.h:62
double getEnergyDeposit() const
Definition: CaloG4Hit.h:81
~CaloG4Hit()
Definition: CaloG4Hit.cc:21
void setID(const CaloHitID &id)
Definition: CaloG4Hit.h:76
bool operator==(const CaloG4Hit &)
Definition: CaloG4Hit.h:41