#ifndef StripHit_h #define StripHit_h 1 /* * Define user class StripHit. * * We define "our" hit format : it is caracterized by its plane and strip * numbers, and an energy value, the accumulated energy in this strip */ #include "G4VHit.hh" #include "G4Allocator.hh" #include "G4ThreeVector.hh" #include "G4THitsCollection.hh" #include "G4Types.hh" /* * This class stores information of a hit. * * It contains * - strip and plane number * - deposited energy * - position information */ class StripHit : public G4VHit { public: /// Constructor StripHit(const G4int strip, const G4int plane, const G4bool isPrimary, G4int track, G4int Z); /// Destructor ~StripHit(); //! Print on screen a Hit void Print(); public: //The new and delete operators are overloaded for performances reasons: // -- Tricky business here... :-(, but provided for you below inline void *operator new(size_t); inline void operator delete(void *aHit); public: //simple set and get methods void SetKE(const double ke) { K_E = ke; } void AddEdep(const double e) { eDep += e; } void SetHitTime(const double t) { hit_time = t; } void SetPosition(const G4ThreeVector & pos) { position = pos; } void SetParticleName(const G4String p_name) { ParticleName = p_name; } G4double GetKE() const { return K_E;} G4double GetEdep() const { return eDep;} G4double GetHitTime() const { return hit_time;} G4ThreeVector GetPosition() const { return position; } G4int GetStripNumber() const { return stripNumber; } G4int GetPlaneNumber() const { return planeNumber; } G4int GetTrackNumber() const { return trackNumber; } G4bool GetIsPrimary() const { return isPrimary; } G4String GetParticleName() const { return ParticleName; } G4int GetParticleZ() const { return ParticleZ; } private: const G4int stripNumber, planeNumber, trackNumber, ParticleZ; G4double K_E; G4double eDep; G4double hit_time; G4ThreeVector position; const G4bool isPrimary; G4String ParticleName; }; // Define the "hit collection" using the template class G4THitsCollection: typedef G4THitsCollection StripHitCollection; // -- new and delete overloaded operators: extern G4ThreadLocal G4Allocator* StripHitAllocator; inline void* StripHit::operator new(size_t) { //void *aHit; //aHit = (void *) StripHitAllocator.MallocSingle(); //return aHit; if(!StripHitAllocator) StripHitAllocator = new G4Allocator; return (void *) StripHitAllocator->MallocSingle(); } inline void StripHit::operator delete(void *aHit) { //StripHitAllocator.FreeSingle((StripHit*) aHit); StripHitAllocator->FreeSingle((StripHit*) aHit); } #endif