Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 #ifndef PAR04HIT_HH 27 #define PAR04HIT_HH 28 29 #include "G4Allocator.hh" // for G4Allocator 30 #include "G4RotationMatrix.hh" // for G4RotationMatrix 31 #include "G4THitsCollection.hh" // for G4THitsCollection 32 #include "G4ThreeVector.hh" // for G4ThreeVector 33 #include "G4VHit.hh" // for G4VHit 34 35 #include <G4Types.hh> // for G4int, G4double 36 #include <map> // for map 37 #include <stddef.h> // for size_t 38 #include <tls.hh> // for G4ThreadLocal 39 #include <vector> // for vector 40 class G4AttDef; 41 class G4AttValue; 42 class G4LogicalVolume; 43 class G4String; 44 45 /** 46 * @brief Hit class to store energy deposited in the sensitive detector. 47 * 48 * Hit class registers position and energy deposited within the sensitive 49 * detector. Cell ID is stored using identifiers of readout segmentation (z, 50 * phi, rho). Additionally, pointer to cell logical volume, its position and 51 * rotation are saved for visualisation purposes. Time allows to filter hits in 52 * visualisation. Type of hit allows to distinguish between hits originating 53 * from full simulation (type 0) and fast simulation (type 1). 54 * 55 */ 56 57 class Par04Hit : public G4VHit 58 { 59 public: 60 Par04Hit(); 61 Par04Hit(const Par04Hit& aRight); 62 virtual ~Par04Hit(); 63 64 const Par04Hit& operator=(const Par04Hit& aRight); 65 int operator==(const Par04Hit& aRight) const; 66 67 inline void* operator new(size_t); 68 inline void operator delete(void* aHit); 69 /// Visualise hits. If pointer to the logical volume was set, cell shape is 70 /// drawn taking into account proper radial position (taken from fRhoId) 71 virtual void Draw() final; 72 /// Retrieve atributes' names in order to allow filtering 73 virtual const std::map<G4String, G4AttDef>* GetAttDefs() const final; 74 /// Create attributes for the visualisation. 75 virtual std::vector<G4AttValue>* CreateAttValues() const final; 76 /// Print hit properties. 77 virtual void Print() final; 78 /// Set position 79 inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; } 80 /// Get position 81 inline G4ThreeVector GetPos() const { return fPos; } 82 /// Set rotation 83 inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; } 84 /// Get rotation 85 inline G4RotationMatrix GetRot() const { return fRot; } 86 /// Set energy 87 inline void SetEdep(G4double aEdep) { fEdep = aEdep; } 88 /// Add energy to previous value 89 inline void AddEdep(G4double aEdep) { fEdep += aEdep; } 90 /// Get energy 91 inline G4double GetEdep() const { return fEdep; } 92 /// Set number of deposits per hit/cell 93 inline void SetNdep(G4int aNdep) { fNdep = aNdep; } 94 /// Add number of deposits to previous value, by defualt increment 95 inline void AddNdep(G4int aNdep = 1) { fNdep += aNdep; } 96 /// Get number of deposits per hit/cell 97 inline G4int GetNdep() const { return fNdep; } 98 /// Set Z id of the cell in the readout segmentation 99 inline void SetZid(G4int aZ) { fZId = aZ; } 100 /// Get Z id of the cell in the readout segmentation 101 inline G4int GetZid() const { return fZId; } 102 /// Set Rho id of the cell in the readout segmentation 103 inline void SetRhoId(G4int aRho) { fRhoId = aRho; } 104 /// Get rho id of the cell in the readout segmentation 105 inline G4int GetRhoId() const { return fRhoId; } 106 /// Set phi id of the cell in the readout segmentation 107 inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; } 108 /// Get phi id of the cell in the readout segmentation 109 inline G4int GetPhiId() const { return fPhiId; } 110 /// Set time 111 inline void SetTime(G4double aTime) { fTime = aTime; } 112 /// Get time 113 inline G4double GetTime() const { return fTime; } 114 /// Set type (0 = full sim, 1 = fast sim) 115 inline void SetType(G4int aType) { fType = aType; } 116 /// Get type (0 = full sim, 1 = fast sim) 117 inline G4int GetType() const { return fType; } 118 // Set pointer to cell logical volume 119 inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; } 120 // Get pointer to cell logical volume 121 inline const G4LogicalVolume* GetLogVol() { return fLogVol; } 122 123 public: 124 /// Energy deposit 125 G4double fEdep = 0; 126 /// Counter of deposits in a hit/cell 127 G4int fNdep = 0; 128 /// Z ID of readout cell 129 G4int fZId = -1; 130 /// Rho ID of readout cell 131 G4int fRhoId = -1; 132 /// Phi ID of readout cell 133 G4int fPhiId = -1; 134 /// Position 135 G4ThreeVector fPos = {-1, -1, -1}; 136 /// Rotation 137 G4RotationMatrix fRot; 138 /// Time 139 G4double fTime = -1; 140 /// Type: 0 = full sim, 1 = fast sim 141 G4int fType = -1; 142 /// Pointer to logical volume for visualisation 143 G4LogicalVolume* fLogVol = nullptr; 144 }; 145 146 typedef G4THitsCollection<Par04Hit> Par04HitsCollection; 147 148 extern G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator; 149 150 inline void* Par04Hit::operator new(size_t) 151 { 152 if (!Par04HitAllocator) Par04HitAllocator = new G4Allocator<Par04Hit>; 153 return (void*)Par04HitAllocator->MallocSingle(); 154 } 155 156 inline void Par04Hit::operator delete(void* aHit) 157 { 158 Par04HitAllocator->FreeSingle((Par04Hit*)aHit); 159 } 160 161 #endif /* PAR04HIT_HH */ 162