File indexing completed on 2024-04-06 12:29:47
0001 #ifndef SimG4CMS_CaloG4Hit_h
0002 #define SimG4CMS_CaloG4Hit_h 1
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "SimG4CMS/Calo/interface/CaloHitID.h"
0026 #include "DataFormats/Math/interface/Point3D.h"
0027 #include <iostream>
0028
0029 #include "G4Allocator.hh"
0030 #include "G4VHit.hh"
0031
0032 class CaloG4Hit : public G4VHit {
0033 public:
0034 CaloG4Hit();
0035 ~CaloG4Hit() override = default;
0036 CaloG4Hit(const CaloG4Hit& right);
0037 const CaloG4Hit& operator=(const CaloG4Hit& right);
0038 bool operator==(const CaloG4Hit&) { return false; }
0039 inline void* operator new(std::size_t);
0040 inline void operator delete(void* CaloG4Hit);
0041
0042 void Draw() override {}
0043 void Print() override;
0044
0045 public:
0046 math::XYZPoint getEntry() const { return entry; }
0047 void setEntry(double x, double y, double z) { entry.SetCoordinates(x, y, z); }
0048
0049 math::XYZPoint getEntryLocal() const { return entryLocal; }
0050 void setEntryLocal(double x, double y, double z) { entryLocal.SetCoordinates(x, y, z); }
0051
0052 math::XYZPoint getPosition() const { return pos; }
0053 void setPosition(double x, double y, double z) { pos.SetCoordinates(x, y, z); }
0054
0055 double getEM() const { return elem; }
0056 void setEM(double e) { elem = e; }
0057
0058 double getHadr() const { return hadr; }
0059 void setHadr(double e) { hadr = e; }
0060
0061 double getIncidentEnergy() const { return theIncidentEnergy; }
0062 void setIncidentEnergy(double e) { theIncidentEnergy = e; }
0063
0064 int getTrackID() const { return hitID.trackID(); }
0065
0066 uint32_t getUnitID() const { return hitID.unitID(); }
0067 double getTimeSlice() const { return hitID.timeSlice(); }
0068 int getTimeSliceID() const { return hitID.timeSliceID(); }
0069 uint16_t getDepth() const { return hitID.depth(); }
0070 bool isFinecaloTrackID() const { return hitID.isFinecaloTrackID(); }
0071
0072 CaloHitID getID() const { return hitID; }
0073 void setID(uint32_t i, double d, int j, uint16_t k = 0) { hitID.setID(i, d, j, k); }
0074 void setID(const CaloHitID& id) { hitID = id; }
0075
0076 void addEnergyDeposit(double em, double hd);
0077 void addEnergyDeposit(const CaloG4Hit& aHit);
0078
0079 double getEnergyDeposit() const { return (elem + hadr); }
0080
0081 private:
0082 math::XYZPoint entry;
0083 math::XYZPoint entryLocal;
0084 math::XYZPoint pos;
0085 double elem;
0086 double hadr;
0087 double theIncidentEnergy;
0088 CaloHitID hitID;
0089
0090
0091 };
0092
0093 class CaloG4HitLess {
0094 public:
0095 bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
0096 if (a->getTrackID() != b->getTrackID()) {
0097 return (a->getTrackID() < b->getTrackID());
0098 } else if (a->getUnitID() != b->getUnitID()) {
0099 return (a->getUnitID() < b->getUnitID());
0100 } else if (a->getDepth() != b->getDepth()) {
0101 return (a->getDepth() < b->getDepth());
0102 } else {
0103 return (a->getTimeSliceID() < b->getTimeSliceID());
0104 }
0105 }
0106 };
0107
0108 class CaloG4HitEqual {
0109 public:
0110 bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
0111 return (a->getTrackID() == b->getTrackID() && a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() &&
0112 a->getTimeSliceID() == b->getTimeSliceID());
0113 }
0114 };
0115
0116 extern G4ThreadLocal G4Allocator<CaloG4Hit>* fpCaloG4HitAllocator;
0117
0118 inline void* CaloG4Hit::operator new(std::size_t) {
0119 if (!fpCaloG4HitAllocator)
0120 fpCaloG4HitAllocator = new G4Allocator<CaloG4Hit>;
0121 return (void*)fpCaloG4HitAllocator->MallocSingle();
0122 }
0123
0124 inline void CaloG4Hit::operator delete(void* aHit) { fpCaloG4HitAllocator->FreeSingle((CaloG4Hit*)aHit); }
0125
0126 std::ostream& operator<<(std::ostream&, const CaloG4Hit&);
0127
0128 #endif