CLARION2_GEANT4/BGOHIT.hh
2022-10-17 18:02:56 -04:00

88 lines
2.2 KiB
C++

#ifndef BGOHit_h
#define BGOHit_h
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4Threading.hh"
#include <vector>
/// Calorimeter hit class
///
/// It defines data members to store the the energy deposit and track lengths
/// of charged particles in a selected volume:
/// - fEdep, fTrackLength
class BGOHit : public G4VHit
{
public:
BGOHit();
BGOHit(const BGOHit&);
virtual ~BGOHit();
// operators
const BGOHit& operator=(const BGOHit&);
G4bool operator==(const BGOHit&) const;
inline void* operator new(size_t);
inline void operator delete(void*);
// methods from base class
virtual void Draw() {}
virtual void Print();
// Set methods
void SetTrackID (G4int track) { fTrackID = track; };
void SetBGOID (G4int id) { fBGOID = id; };
void SetEdep (G4double de) { fEdep += de; };
void SetPos (G4ThreeVector xyz){ fPos = xyz; };
void SetStepLength (G4double sl) { fStepLength += sl; };
// Get methods
G4int GetTrackID() const { return fTrackID; };
G4int GetBGOID() const { return fBGOID; };
G4double GetEdep() const { return fEdep; };
G4ThreeVector GetPos() const { return fPos; };
G4double GetStepLength () const { return fStepLength ; };
private:
G4int fTrackID;
G4int fBGOID;
G4double fEdep;
G4ThreeVector fPos;
G4double fStepLength;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using BGOHitsCollection = G4THitsCollection<BGOHit>;
extern G4ThreadLocal G4Allocator<BGOHit>* BGOHitAllocator;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline void* BGOHit::operator new(size_t)
{
if (!BGOHitAllocator) BGOHitAllocator = new G4Allocator<BGOHit>;
return (void *) BGOHitAllocator->MallocSingle();
}
inline void BGOHit::operator delete(void *hit)
{
if (!BGOHitAllocator) BGOHitAllocator = new G4Allocator<BGOHit>;
BGOHitAllocator->FreeSingle((BGOHit*) hit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif