00001 #ifndef AstroHit_h 00002 #define AstroHit_h 1 00003 00004 // --------------------------------------------------------------------------- 00005 // -- We define "our" hit format : it is caracterized by an G4int value, which 00006 // -- is the slice number, and an energy value, the accumulated energy in this 00007 // -- slice. 00008 // --------------------------------------------------------------------------- 00009 00010 #include "G4VHit.hh" 00011 #include "G4Allocator.hh" 00012 00013 class AstroHit : public G4VHit { 00014 public: 00015 AstroHit(G4int slice); 00016 ~AstroHit(); 00017 00018 public: 00019 // -- The new and delete operators are overloaded for performances reasons: 00020 // -- Tricky business here... :-(, but provided for you below 00021 inline void *operator new(size_t); 00022 inline void operator delete(void *aHit); 00023 00024 public: 00025 void addE(double e) {m_e += e;} 00026 void accumulateProton(G4double eKin) {m_eKproton += eKin, m_nbProton++;} 00027 G4double GetEnergy() const {return m_e ;} 00028 G4double GetProtonTotalEkin() const {return m_eKproton ;} 00029 G4double GetProtonMeanEkin() const {G4double mean(-1.); if (m_nbProton>0) mean = m_eKproton / m_nbProton; return mean;} 00030 G4int GetNbProton() const {return m_nbProton ;} 00031 G4int GetSlice() const {return m_slice;} 00032 00033 private: 00034 const G4int m_slice; 00035 G4double m_e; 00036 G4double m_eKproton; 00037 G4int m_nbProton; 00038 }; 00039 00040 00041 // -- new and delete overloaded operators: 00042 extern G4Allocator<AstroHit> AstroHitAllocator; 00043 00044 inline void* AstroHit::operator new(size_t) 00045 { 00046 void *aHit; 00047 aHit = (void *) AstroHitAllocator.MallocSingle(); 00048 return aHit; 00049 } 00050 inline void AstroHit::operator delete(void *aHit) 00051 { 00052 AstroHitAllocator.FreeSingle((AstroHit*) aHit); 00053 } 00054 00055 #endif