File indexing completed on 2025-01-31 09:21:46
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 PhotonHit : public G4VHit
0052 {
0053 public:
0054 PhotonHit();
0055 ~PhotonHit() = default;
0056 PhotonHit(const PhotonHit&);
0057 const PhotonHit& operator=(const PhotonHit&);
0058 G4bool operator==(const PhotonHit&) 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 << "PhotonHit id: " << fid << " pid: " << fpid
0066 << " wavelength: " << fwavelength << " time: " << ftime
0067 << " position X: " << fposition.getX() << " Y: " << fposition.getY()
0068 << " Z: " << fposition.getZ()
0069 << " direction X: " << fdirection.getX()
0070 << " Y: " << fdirection.getY() << " Z: " << fdirection.getZ()
0071 << " polarization: X:" << fpolarization.getX()
0072 << " Y: " << fpolarization.getY() << " Z: " << fpolarization.getZ()
0073 << G4endl;
0074 }
0075
0076 PhotonHit(unsigned id, unsigned pid, G4double wavelength, G4double time,
0077 G4ThreeVector position, G4ThreeVector direction,
0078 G4ThreeVector polarization);
0079 inline void SetWavelength(G4double wavelength) { fwavelength = wavelength; }
0080 inline G4double GetWavelength() { return fwavelength; }
0081 inline void SetPolarization(G4ThreeVector polarization)
0082 {
0083 fpolarization = polarization;
0084 }
0085 inline G4ThreeVector GetPolarization() const { return fpolarization; }
0086 inline void SetDirection(G4ThreeVector direction) { fdirection = direction; }
0087 inline G4ThreeVector GetDirection() const { return fdirection; }
0088 inline void SetPosition(G4ThreeVector position) { fposition = position; }
0089 inline G4ThreeVector GetPosition() const { return fposition; }
0090 inline void SetTime(G4double time) { ftime = time; }
0091 inline G4double GetTime() const { return ftime; }
0092 inline void SetPid(unsigned pid) { fpid = pid; }
0093 inline unsigned GetPid() const { return fpid; }
0094 inline void SetId(unsigned id) { fid = id; }
0095 inline unsigned GetId() const { return fid; }
0096
0097 private:
0098 unsigned int fid{ 0 };
0099 unsigned int fpid{ 0 };
0100 G4double fwavelength{ 0 };
0101 G4double ftime{ 0 };
0102 G4ThreeVector fposition{ 0, 0, 0 };
0103 G4ThreeVector fdirection{ 0, 0, 0 };
0104 G4ThreeVector fpolarization{ 0, 0, 0 };
0105 };
0106
0107 using PhotonHitsCollection = G4THitsCollection<PhotonHit>;
0108 extern G4ThreadLocal G4Allocator<PhotonHit>* PhotonHitAllocator;
0109
0110 inline void* PhotonHit::operator new(size_t)
0111 {
0112 if(!PhotonHitAllocator)
0113 {
0114 PhotonHitAllocator = new G4Allocator<PhotonHit>;
0115 }
0116 return (void*) PhotonHitAllocator->MallocSingle();
0117 }
0118
0119 inline void PhotonHit::operator delete(void* aHit)
0120 {
0121 PhotonHitAllocator->FreeSingle((PhotonHit*) aHit);
0122 }