00001 #ifndef LCDG4CalHit_h 00002 #define LCDG4CalHit_h 1 00003 00004 #include "G4VHit.hh" 00005 #include "G4THitsCollection.hh" 00006 #include "G4Allocator.hh" 00007 #include "G4ThreeVector.hh" 00008 #include "G4LogicalVolume.hh" 00009 #include <vector> 00010 00011 class LCDG4CalHit : public G4VHit { 00012 00013 public: 00014 // default constructor: creates an empty hit 00015 LCDG4CalHit(); 00016 // destructor 00017 ~LCDG4CalHit(); 00018 // copy constructor 00019 LCDG4CalHit(const LCDG4CalHit &right); 00020 // assignment operator 00021 const LCDG4CalHit& operator=(const LCDG4CalHit &right); 00022 // equality comparison operator 00023 bool operator==(const LCDG4CalHit &right) const; 00024 00025 // customized new/delete operators 00026 inline void *operator new(size_t); 00027 inline void operator delete(void *aHit); 00028 00029 void Draw(); 00030 void Print(); 00031 00032 public: 00033 // set hit layer index 00034 inline void SetLayer(const G4int layer) { m_layer = layer; } 00035 // return hit layer index 00036 inline G4int GetLayer() const { return m_layer; } 00037 // set hit SysNo 00038 inline void SetSystem(const G4int sysNo) { m_sysNo = sysNo; } 00039 // return hit SysNo 00040 inline G4int GetSystem() const { return m_sysNo; } 00041 // set hit barrel/endcap flag 00042 inline void SetBarEnd(const G4int barend) { m_barend = barend; } 00043 // return hit barrel/endcap flag 00044 inline G4int GetBarEnd() const { return m_barend; } 00045 // set hit north/south flag 00046 inline void SetNorth(const G4int north) { m_north = north; } 00047 // return hit north/south flag 00048 inline G4int GetNorth() const { return m_north; } 00049 // set hit phi index 00050 inline void SetPhi(const G4int phi) { m_phi = phi; } 00051 // return hit phi index 00052 inline G4int GetPhi() const { return m_phi; } 00053 // set hit theta index 00054 inline void SetTheta(const G4int theta) { m_theta = theta; } 00055 // return hit theta index 00056 inline G4int GetTheta() const { return m_theta; } 00057 // set total energy deposited into sensitive material for this hit 00058 inline void SetEdep(const G4double de) { m_edep = de; } 00059 // return total energy deposited into sensitive material for this hit 00060 inline G4double GetEdep() const { return m_edep; } 00061 // set total energy deposited into absorber for this hit 00062 inline void SetEdepAbs(const G4double de) { m_edepabs = de; } 00063 // return total energy deposited into absorber for this hit 00064 inline G4double GetEdepAbs() const { return m_edepabs; } 00065 00066 // set ref position of this cell (center) 00067 inline void SetPos(const G4ThreeVector& xyz) { m_pos = xyz; } 00068 // return ref position of this cell 00069 inline G4ThreeVector GetPos() const { return m_pos; } 00070 // return number of particles contributing to total energy deposited 00071 inline G4int GetNMC() const {return m_nmc;} 00072 // return geant particle Id of i-th contributing particle 00073 inline G4int GetTrkID(G4int ith) const {return (*m_trkid)[ith];} 00074 // return energy deposited by idx-th contributing particle 00075 inline G4double GetEMC(G4int ith) const {return (*m_emc)[ith];} 00076 // return timing of energy deposition by idx-th contributing particle 00077 inline G4double GetTimeMC(G4int ith) const {return (*m_tmc)[ith];} 00078 00079 // return cell towerID 00080 unsigned int GetCellID() const; 00081 unsigned int sioTagToLcioTag(unsigned int sioTag) const; 00082 00083 public: 00084 G4int AddLayerLog(G4LogicalVolume* g4vxdlog, G4int startlayerNo); 00085 // Add energy deposited into sensitive material by particle mcidx 00086 G4int AddMcPart(G4int mcidx, G4double emc, G4double tmc); 00087 // Hit on absorber: Add energy emc to energy deposited on absorber 00088 void AddMcPartAbs(G4double emc) { m_edepabs += emc; } 00089 00090 private: 00091 // Layer index, = 1..Nlayers 00092 G4int m_layer; 00093 // sysNo, whatever that means... 00094 G4int m_sysNo; 00095 // barend = 0 for barrel, = 1 for endcap 00096 G4int m_barend; 00097 // north = 0 for south (z>0), = 1 for north (z<0) 00098 G4int m_north; 00099 // phi index, = 1..NphiCells 00100 G4int m_phi; 00101 // (theta|z) index, = 1..N(th|z)Cells, (th|z) means either theta or z segmts 00102 G4int m_theta; 00103 // total energy on sensitive material 00104 G4float m_edep; 00105 // total energy deposited on absorber 00106 G4float m_edepabs; 00107 G4ThreeVector m_pos; 00108 // number of geant particles contributing to this hit 00109 G4int m_nmc; 00110 // vector of particles' Ids contributing to visible energy 00111 std::vector<G4int> *m_trkid; 00112 // vector of energy contributions coming from each particle 00113 std::vector<G4double> *m_emc; 00114 // vector of timing of energy contributions coming from each particle 00115 std::vector<G4double> *m_tmc; 00116 }; 00117 00118 typedef G4THitsCollection<LCDG4CalHit> LCDG4CalHitsCollection; 00119 00120 extern G4Allocator<LCDG4CalHit> LCDG4CalHitAllocator; 00121 00122 inline void* LCDG4CalHit::operator new(size_t) { 00123 void *aHit; 00124 aHit = (void *) LCDG4CalHitAllocator.MallocSingle(); 00125 return aHit; 00126 } 00127 00128 inline void LCDG4CalHit::operator delete(void *aHit) { 00129 LCDG4CalHitAllocator.FreeSingle((LCDG4CalHit*) aHit); 00130 } 00131 00132 #endif
1.3.4