File indexing completed on 2025-01-31 09:21:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #pragma once
0045
0046 #include "G4VHit.hh"
0047 #include "G4THitsCollection.hh"
0048 #include "G4Allocator.hh"
0049 #include "G4ThreeVector.hh"
0050
0051 class TrackerHit : public G4VHit
0052 {
0053 public:
0054 TrackerHit();
0055 ~TrackerHit() = default;
0056 TrackerHit(const TrackerHit&);
0057 const TrackerHit& operator=(const TrackerHit&);
0058 G4bool operator==(const TrackerHit&) const;
0059 inline void* operator new(size_t);
0060 inline void operator delete(void*);
0061 void Draw() final;
0062
0063 inline void Print() final
0064 {
0065 G4cout << "TrackerHit id: " << fid << " Edep: " << fEdep
0066 << " X: " << fposition.getX() << " Y: " << fposition.getY()
0067 << " Z: " << fposition.getZ() << " time: " << ftime << G4endl;
0068 }
0069
0070 TrackerHit(G4double edep, G4ThreeVector position, G4double time);
0071 inline void SetEdep(G4double Edep) { fEdep = Edep; }
0072 inline G4double GetEdep() { return fEdep; }
0073 inline void SetTime(G4double time) { ftime = time; }
0074 inline G4double GetTime() const { return ftime; }
0075 inline void SetPosition(G4ThreeVector position) { fposition = position; }
0076 inline G4ThreeVector GetPosition() const { return fposition; }
0077
0078 private:
0079 G4int fid{ 0 };
0080 G4double fEdep{ 0 };
0081 G4ThreeVector fposition{ 0, 0, 0 };
0082 G4double ftime{ 0 };
0083 };
0084
0085 using TrackerHitsCollection = G4THitsCollection<TrackerHit>;
0086 extern G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator;
0087
0088 inline void* TrackerHit::operator new(size_t)
0089 {
0090 if(!TrackerHitAllocator)
0091 {
0092 TrackerHitAllocator = new G4Allocator<TrackerHit>;
0093 }
0094 return (void*) TrackerHitAllocator->MallocSingle();
0095 }
0096
0097 inline void TrackerHit::operator delete(void* aHit)
0098 {
0099 TrackerHitAllocator->FreeSingle((TrackerHit*) aHit);
0100 }