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 G4double GetEnergy() const {return m_e;} 00027 G4int GetSlice() const {return m_slice;} 00028 00029 private: 00030 const G4int m_slice; 00031 G4double m_e; 00032 }; 00033 00034 00035 // -- new and delete overloaded operators: 00036 extern G4Allocator<AstroHit> AstroHitAllocator; 00037 00038 inline void* AstroHit::operator new(size_t) 00039 { 00040 void *aHit; 00041 aHit = (void *) AstroHitAllocator.MallocSingle(); 00042 return aHit; 00043 } 00044 inline void AstroHit::operator delete(void *aHit) 00045 { 00046 AstroHitAllocator.FreeSingle((AstroHit*) aHit); 00047 } 00048 00049 #endif