Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:34:06

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