Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-22 08:27:35

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