Back to home page

EIC code displayed by LXR

 
 

    


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

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 PAR04HIT_HH
0027 #define PAR04HIT_HH
0028 
0029 #include "G4Allocator.hh"  // for G4Allocator
0030 #include "G4RotationMatrix.hh"  // for G4RotationMatrix
0031 #include "G4THitsCollection.hh"  // for G4THitsCollection
0032 #include "G4ThreeVector.hh"  // for G4ThreeVector
0033 #include "G4VHit.hh"  // for G4VHit
0034 
0035 #include <G4Types.hh>  // for G4int, G4double
0036 #include <map>  // for map
0037 #include <stddef.h>  // for size_t
0038 #include <tls.hh>  // for G4ThreadLocal
0039 #include <vector>  // for vector
0040 class G4AttDef;
0041 class G4AttValue;
0042 class G4LogicalVolume;
0043 class G4String;
0044 
0045 /**
0046  * @brief Hit class to store energy deposited in the sensitive detector.
0047  *
0048  * Hit class registers position and energy deposited within the sensitive
0049  * detector. Cell ID is stored using identifiers of readout segmentation (z,
0050  * phi, rho). Additionally, pointer to cell logical volume, its position and
0051  * rotation are saved for visualisation purposes. Time allows to filter hits in
0052  * visualisation. Type of hit allows to distinguish between hits originating
0053  * from full simulation (type 0) and fast simulation (type 1).
0054  *
0055  */
0056 
0057 class Par04Hit : public G4VHit
0058 {
0059   public:
0060     Par04Hit();
0061     Par04Hit(const Par04Hit& aRight);
0062     virtual ~Par04Hit();
0063 
0064     const Par04Hit& operator=(const Par04Hit& aRight);
0065     int operator==(const Par04Hit& aRight) const;
0066 
0067     inline void* operator new(size_t);
0068     inline void operator delete(void* aHit);
0069     /// Visualise hits. If pointer to the logical volume was set, cell shape is
0070     /// drawn taking into account proper radial position (taken from fRhoId)
0071     virtual void Draw() final;
0072     /// Retrieve atributes' names in order to allow filtering
0073     virtual const std::map<G4String, G4AttDef>* GetAttDefs() const final;
0074     /// Create attributes for the visualisation.
0075     virtual std::vector<G4AttValue>* CreateAttValues() const final;
0076     /// Print hit properties.
0077     virtual void Print() final;
0078     /// Set position
0079     inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
0080     /// Get position
0081     inline G4ThreeVector GetPos() const { return fPos; }
0082     /// Set rotation
0083     inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
0084     /// Get rotation
0085     inline G4RotationMatrix GetRot() const { return fRot; }
0086     /// Set energy
0087     inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
0088     /// Add energy to previous value
0089     inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
0090     /// Get energy
0091     inline G4double GetEdep() const { return fEdep; }
0092     /// Set number of deposits per hit/cell
0093     inline void SetNdep(G4int aNdep) { fNdep = aNdep; }
0094     /// Add number of deposits to previous value, by defualt increment
0095     inline void AddNdep(G4int aNdep = 1) { fNdep += aNdep; }
0096     /// Get number of deposits per hit/cell
0097     inline G4int GetNdep() const { return fNdep; }
0098     /// Set Z id of the cell in the readout segmentation
0099     inline void SetZid(G4int aZ) { fZId = aZ; }
0100     /// Get Z id of the cell in the readout segmentation
0101     inline G4int GetZid() const { return fZId; }
0102     /// Set Rho id of the cell in the readout segmentation
0103     inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
0104     /// Get rho id of the cell in the readout segmentation
0105     inline G4int GetRhoId() const { return fRhoId; }
0106     /// Set phi id of the cell in the readout segmentation
0107     inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
0108     /// Get phi id of the cell in the readout segmentation
0109     inline G4int GetPhiId() const { return fPhiId; }
0110     /// Set time
0111     inline void SetTime(G4double aTime) { fTime = aTime; }
0112     /// Get time
0113     inline G4double GetTime() const { return fTime; }
0114     /// Set type (0 = full sim, 1 = fast sim)
0115     inline void SetType(G4int aType) { fType = aType; }
0116     /// Get type (0 = full sim, 1 = fast sim)
0117     inline G4int GetType() const { return fType; }
0118     // Set pointer to cell logical volume
0119     inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
0120     // Get pointer to cell logical volume
0121     inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
0122 
0123   public:
0124     /// Energy deposit
0125     G4double fEdep = 0;
0126     /// Counter of deposits in a hit/cell
0127     G4int fNdep = 0;
0128     /// Z ID of readout cell
0129     G4int fZId = -1;
0130     /// Rho ID of readout cell
0131     G4int fRhoId = -1;
0132     /// Phi ID of readout cell
0133     G4int fPhiId = -1;
0134     /// Position
0135     G4ThreeVector fPos = {-1, -1, -1};
0136     /// Rotation
0137     G4RotationMatrix fRot;
0138     /// Time
0139     G4double fTime = -1;
0140     /// Type: 0 = full sim, 1 = fast sim
0141     G4int fType = -1;
0142     /// Pointer to logical volume for visualisation
0143     G4LogicalVolume* fLogVol = nullptr;
0144 };
0145 
0146 typedef G4THitsCollection<Par04Hit> Par04HitsCollection;
0147 
0148 extern G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator;
0149 
0150 inline void* Par04Hit::operator new(size_t)
0151 {
0152   if (!Par04HitAllocator) Par04HitAllocator = new G4Allocator<Par04Hit>;
0153   return (void*)Par04HitAllocator->MallocSingle();
0154 }
0155 
0156 inline void Par04Hit::operator delete(void* aHit)
0157 {
0158   Par04HitAllocator->FreeSingle((Par04Hit*)aHit);
0159 }
0160 
0161 #endif /* PAR04HIT_HH */