Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:33

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 #ifndef PAR03HIT_HH
0027 #define PAR03HIT_HH
0028 
0029 #include "G4Allocator.hh"
0030 #include "G4RotationMatrix.hh"
0031 #include "G4THitsCollection.hh"
0032 #include "G4ThreeVector.hh"
0033 #include "G4VHit.hh"
0034 
0035 class G4AttDef;
0036 class G4AttValue;
0037 class G4LogicalVolume;
0038 
0039 /**
0040  * @brief Hit class to store energy deposited in the sensitive detector.
0041  *
0042  * Hit class registers position and energy deposited within the sensitive
0043  * detector. Cell ID is stored using identifiers of readout segmentation (z,
0044  * phi, rho). Additionally, pointer to cell logical volume, its position and
0045  * rotation are saved for visualisation purposes. Time allows to filter hits in
0046  * visualisation. Type of hit allows to distinguish between hits originating
0047  * from full simulation (type 0) and fast simulation (type 1).
0048  *
0049  */
0050 
0051 class Par03Hit : public G4VHit
0052 {
0053   public:
0054     Par03Hit();
0055     Par03Hit(const Par03Hit& aRight);
0056     virtual ~Par03Hit();
0057 
0058     const Par03Hit& operator=(const Par03Hit& aRight);
0059     int operator==(const Par03Hit& aRight) const;
0060 
0061     inline void* operator new(size_t);
0062     inline void operator delete(void* aHit);
0063     /// Visualise hits. If pointer to the logical volume was set, cell shape is
0064     /// drawn taking into account proper radial position (taken from fRhoId)
0065     virtual void Draw();
0066     /// Retrieve atributes' names in order to allow filtering
0067     virtual const std::map<G4String, G4AttDef>* GetAttDefs() const;
0068     /// Create attributes for the visualisation.
0069     virtual std::vector<G4AttValue>* CreateAttValues() const;
0070     /// Print hit properties.
0071     virtual void Print();
0072     /// Set position
0073     inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
0074     /// Get position
0075     inline G4ThreeVector GetPos() const { return fPos; }
0076     /// Set rotation
0077     inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
0078     /// Get rotation
0079     inline G4RotationMatrix GetRot() const { return fRot; }
0080     /// Set energy
0081     inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
0082     /// Add energy to previous value
0083     inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
0084     /// Get energy
0085     inline G4double GetEdep() const { return fEdep; }
0086     /// Set Z id of the cell in the readout segmentation
0087     inline void SetZid(G4int aZ) { fZId = aZ; }
0088     /// Get Z id of the cell in the readout segmentation
0089     inline G4int GetZid() const { return fZId; }
0090     /// Set Rho id of the cell in the readout segmentation
0091     inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
0092     /// Get rho id of the cell in the readout segmentation
0093     inline G4int GetRhoId() const { return fRhoId; }
0094     /// Set phi id of the cell in the readout segmentation
0095     inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
0096     /// Get phi id of the cell in the readout segmentation
0097     inline G4int GetPhiId() const { return fPhiId; }
0098     /// Set time
0099     inline void SetTime(G4double aTime) { fTime = aTime; }
0100     /// Get time
0101     inline G4double GetTime() const { return fTime; }
0102     /// Set type (0 = full sim, 1 = fast sim)
0103     inline void SetType(G4int aType) { fType = aType; }
0104     /// Get type (0 = full sim, 1 = fast sim)
0105     inline G4int GetType() const { return fType; }
0106     // Set pointer to cell logical volume
0107     inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
0108     // Get pointer to cell logical volume
0109     inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
0110 
0111   public:
0112     /// Energy deposit
0113     G4double fEdep = 0;
0114     /// Z ID of readout cell
0115     G4int fZId = -1;
0116     /// Rho ID of readout cell
0117     G4int fRhoId = -1;
0118     /// Phi ID of readout cell
0119     G4int fPhiId = -1;
0120     /// Position
0121     G4ThreeVector fPos;
0122     /// Rotation
0123     G4RotationMatrix fRot;
0124     /// Time
0125     G4double fTime = -1;
0126     /// Type: 0 = full sim, 1 = fast sim
0127     G4int fType = -1;
0128     /// Pointer to logical volume for visualisation
0129     G4LogicalVolume* fLogVol = nullptr;
0130 };
0131 
0132 typedef G4THitsCollection<Par03Hit> Par03HitsCollection;
0133 
0134 extern G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator;
0135 
0136 inline void* Par03Hit::operator new(size_t)
0137 {
0138   if (!Par03HitAllocator) Par03HitAllocator = new G4Allocator<Par03Hit>;
0139   return (void*)Par03HitAllocator->MallocSingle();
0140 }
0141 
0142 inline void Par03Hit::operator delete(void* aHit)
0143 {
0144   Par03HitAllocator->FreeSingle((Par03Hit*)aHit);
0145 }
0146 
0147 #endif /* PAR03HIT_HH */