Back to home page

EIC code displayed by LXR

 
 

    


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

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 radiobiology/include/Hit.hh
0027 /// \brief Definition of the RadioBio::Hit class
0028 
0029 #ifndef RadiobiologyHit_h
0030 #define RadiobiologyHit_h 1
0031 
0032 #include "G4Allocator.hh"
0033 #include "G4THitsCollection.hh"
0034 #include "G4ThreeVector.hh"
0035 #include "G4TouchableHandle.hh"
0036 #include "G4VHit.hh"
0037 #include "G4VPhysicalVolume.hh"
0038 
0039 #include "tls.hh"
0040 
0041 class G4ParticleDefinition;
0042 
0043 namespace RadioBio
0044 {
0045 
0046 /// Detector hit class
0047 ///
0048 /// It defines data members to store the trackID, particle type,
0049 /// mean kinetic energy, energy deposit, initial energy, track length,
0050 /// electronic energy, physical volume and voxel index
0051 
0052 class Hit : public G4VHit
0053 {
0054   public:
0055     Hit();
0056     Hit(const Hit&);
0057     ~Hit() override = default;
0058 
0059     // Operators
0060     const Hit& operator=(const Hit&);
0061     G4int operator==(const Hit&) const;
0062 
0063     inline void* operator new(size_t);
0064     inline void operator delete(void*);
0065 
0066     // Methods from base class
0067     void Draw() override;
0068     void Print() override;
0069 
0070     // Set methods
0071     void SetTrackID(G4int track) { fTrackID = track; }
0072     void SetPartType(const G4ParticleDefinition* part) { fParticleType = part; }
0073     void SetEkinMean(double EkinMean) { fEkinMean = EkinMean; }
0074     void SetDeltaE(double DeltaE) { fDeltaE = DeltaE; }
0075     void SetEinit(G4double e) { fEinit = e; }
0076     void SetTrackLength(G4double x) { fTrackLength = x; }
0077     void SetElectronEnergy(G4double elEnergy) { fElectronEnergy = elEnergy; }
0078     void SetPhysicalVolume(G4VPhysicalVolume* PV) { fPhysicalVolume = PV; }
0079     void SetVoxelIndexes(const G4TouchableHandle& TH);
0080 
0081     // Get methods
0082     G4int GetTrackID() const { return fTrackID; }
0083     const G4ParticleDefinition* GetPartType() const { return fParticleType; }
0084     G4double GetEkinMean() { return fEkinMean; }
0085     G4double GetDeltaE() { return fDeltaE; }
0086     G4double GetEinit() const { return fEinit; }
0087     G4double GetTrackLength() const { return fTrackLength; }
0088     G4double GetElectronEnergy() const { return fElectronEnergy; }
0089     G4VPhysicalVolume* GetPhysicalVolume() const { return fPhysicalVolume; }
0090     G4int GetXindex() { return fxIndex; }
0091     G4int GetYindex() { return fyIndex; }
0092     G4int GetZindex() { return fzIndex; }
0093 
0094   private:
0095     // Variables
0096     G4int fTrackID = -1;
0097     const G4ParticleDefinition* fParticleType = nullptr;
0098     G4double fEkinMean = 0.;
0099     G4double fDeltaE = 0.;
0100     G4double fEinit = 0.;
0101     G4double fTrackLength = 0.;
0102     G4double fElectronEnergy = 0.;
0103     G4VPhysicalVolume* fPhysicalVolume = nullptr;
0104     G4int fxIndex = -1;
0105     G4int fyIndex = -1;
0106     G4int fzIndex = -1;
0107 };
0108 
0109 // Definition of a HitColletion
0110 typedef G4THitsCollection<Hit> RadioBioHitsCollection;
0111 
0112 // Definition of the Allocator
0113 extern G4ThreadLocal G4Allocator<Hit>* RadioBioHitAllocator;
0114 
0115 inline void* Hit::operator new(size_t)
0116 {
0117   if (!RadioBioHitAllocator) RadioBioHitAllocator = new G4Allocator<Hit>;
0118   return (void*)RadioBioHitAllocator->MallocSingle();
0119 }
0120 
0121 inline void Hit::operator delete(void* hit)
0122 {
0123   RadioBioHitAllocator->FreeSingle((Hit*)hit);
0124 }
0125 
0126 }  // namespace RadioBio
0127 
0128 #endif  // RadioBioHit_h