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 PAR03HIT_HH 27 #define PAR03HIT_HH 28 29 #include "G4Allocator.hh" 30 #include "G4RotationMatrix.hh" 31 #include "G4THitsCollection.hh" 32 #include "G4ThreeVector.hh" 33 #include "G4VHit.hh" 34 35 class G4AttDef; 36 class G4AttValue; 37 class G4LogicalVolume; 38 39 /** 40 * @brief Hit class to store energy deposited in the sensitive detector. 41 * 42 * Hit class registers position and energy deposited within the sensitive 43 * detector. Cell ID is stored using identifiers of readout segmentation (z, 44 * phi, rho). Additionally, pointer to cell logical volume, its position and 45 * rotation are saved for visualisation purposes. Time allows to filter hits in 46 * visualisation. Type of hit allows to distinguish between hits originating 47 * from full simulation (type 0) and fast simulation (type 1). 48 * 49 */ 50 51 class Par03Hit : public G4VHit 52 { 53 public: 54 Par03Hit(); 55 Par03Hit(const Par03Hit& aRight); 56 virtual ~Par03Hit(); 57 58 const Par03Hit& operator=(const Par03Hit& aRight); 59 int operator==(const Par03Hit& aRight) const; 60 61 inline void* operator new(size_t); 62 inline void operator delete(void* aHit); 63 /// Visualise hits. If pointer to the logical volume was set, cell shape is 64 /// drawn taking into account proper radial position (taken from fRhoId) 65 virtual void Draw(); 66 /// Retrieve atributes' names in order to allow filtering 67 virtual const std::map<G4String, G4AttDef>* GetAttDefs() const; 68 /// Create attributes for the visualisation. 69 virtual std::vector<G4AttValue>* CreateAttValues() const; 70 /// Print hit properties. 71 virtual void Print(); 72 /// Set position 73 inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; } 74 /// Get position 75 inline G4ThreeVector GetPos() const { return fPos; } 76 /// Set rotation 77 inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; } 78 /// Get rotation 79 inline G4RotationMatrix GetRot() const { return fRot; } 80 /// Set energy 81 inline void SetEdep(G4double aEdep) { fEdep = aEdep; } 82 /// Add energy to previous value 83 inline void AddEdep(G4double aEdep) { fEdep += aEdep; } 84 /// Get energy 85 inline G4double GetEdep() const { return fEdep; } 86 /// Set Z id of the cell in the readout segmentation 87 inline void SetZid(G4int aZ) { fZId = aZ; } 88 /// Get Z id of the cell in the readout segmentation 89 inline G4int GetZid() const { return fZId; } 90 /// Set Rho id of the cell in the readout segmentation 91 inline void SetRhoId(G4int aRho) { fRhoId = aRho; } 92 /// Get rho id of the cell in the readout segmentation 93 inline G4int GetRhoId() const { return fRhoId; } 94 /// Set phi id of the cell in the readout segmentation 95 inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; } 96 /// Get phi id of the cell in the readout segmentation 97 inline G4int GetPhiId() const { return fPhiId; } 98 /// Set time 99 inline void SetTime(G4double aTime) { fTime = aTime; } 100 /// Get time 101 inline G4double GetTime() const { return fTime; } 102 /// Set type (0 = full sim, 1 = fast sim) 103 inline void SetType(G4int aType) { fType = aType; } 104 /// Get type (0 = full sim, 1 = fast sim) 105 inline G4int GetType() const { return fType; } 106 // Set pointer to cell logical volume 107 inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; } 108 // Get pointer to cell logical volume 109 inline const G4LogicalVolume* GetLogVol() { return fLogVol; } 110 111 public: 112 /// Energy deposit 113 G4double fEdep = 0; 114 /// Z ID of readout cell 115 G4int fZId = -1; 116 /// Rho ID of readout cell 117 G4int fRhoId = -1; 118 /// Phi ID of readout cell 119 G4int fPhiId = -1; 120 /// Position 121 G4ThreeVector fPos; 122 /// Rotation 123 G4RotationMatrix fRot; 124 /// Time 125 G4double fTime = -1; 126 /// Type: 0 = full sim, 1 = fast sim 127 G4int fType = -1; 128 /// Pointer to logical volume for visualisation 129 G4LogicalVolume* fLogVol = nullptr; 130 }; 131 132 typedef G4THitsCollection<Par03Hit> Par03HitsCollection; 133 134 extern G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator; 135 136 inline void* Par03Hit::operator new(size_t) 137 { 138 if (!Par03HitAllocator) Par03HitAllocator = new G4Allocator<Par03Hit>; 139 return (void*)Par03HitAllocator->MallocSingle(); 140 } 141 142 inline void Par03Hit::operator delete(void* aHit) 143 { 144 Par03HitAllocator->FreeSingle((Par03Hit*)aHit); 145 } 146 147 #endif /* PAR03HIT_HH */ 148