Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:15

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 // Hadrontherapy advanced example for Geant4
0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
0028 
0029 #ifndef HadrontherapyDetectorHit_h
0030 #define HadrontherapyDetectorHit_h 1
0031 
0032 
0033 #include "G4VHit.hh"
0034 #include "G4THitsCollection.hh"
0035 #include "G4Allocator.hh"
0036 
0037 
0038 class HadrontherapyDetectorHit : public G4VHit
0039 {
0040 public:
0041   HadrontherapyDetectorHit();
0042   HadrontherapyDetectorHit(const HadrontherapyDetectorHit&);
0043   virtual ~HadrontherapyDetectorHit();
0044  
0045  
0046   const HadrontherapyDetectorHit& operator=(const HadrontherapyDetectorHit&);
0047  
0048   G4bool operator==(const HadrontherapyDetectorHit&) const;
0049 
0050 //******************************MT
0051 inline void* operator new(size_t);
0052 inline void operator delete(void*);
0053 //******************************MT
0054 
0055 private:
0056   G4int xHitID; // Hit x voxel 
0057   G4int zHitID; // Hit z voxel
0058   G4int yHitID; // Hit y voxel 
0059   G4double energyDeposit; // Energy deposit associated with the hit
0060 
0061 public:
0062   // Methods to get the information - energy deposit and associated
0063   // position in the phantom - of the hits stored in the hits collection  
0064  
0065   inline G4int GetXID() // Get x index of the voxel 
0066   {return xHitID;}
0067 
0068   inline G4int GetZID() // Get y index of the voxel   
0069   {return zHitID;}
0070 
0071   inline G4int GetYID() // Get z index of the voxel  
0072   {return yHitID;}
0073    
0074   inline G4double GetEdep() // Get energy deposit
0075   {return energyDeposit;}
0076  
0077   // Methods to store the information of the hit ( energy deposit, position in the phantom )
0078   // in the hits collection
0079 
0080   inline void SetEdepAndPosition(G4int xx, G4int yy, G4int zz, G4double eDep)
0081   {
0082     xHitID = xx;
0083     yHitID = yy;
0084     zHitID = zz;
0085     energyDeposit = eDep;
0086   }
0087 };
0088 
0089 typedef G4THitsCollection<HadrontherapyDetectorHit> HadrontherapyDetectorHitsCollection;
0090 //******************************MT
0091 extern G4ThreadLocal G4Allocator<HadrontherapyDetectorHit>* HadrontherapyDetectorHitAllocator;
0092 //******************************MT
0093 
0094 inline void* HadrontherapyDetectorHit::operator new(size_t)
0095 {
0096  
0097   
0098  if(!HadrontherapyDetectorHitAllocator) 
0099   HadrontherapyDetectorHitAllocator= new G4Allocator<HadrontherapyDetectorHit>;
0100  void *aHit;
0101 
0102  aHit = (void *) HadrontherapyDetectorHitAllocator->MallocSingle();
0103  return aHit;
0104 
0105 }
0106 
0107 inline void HadrontherapyDetectorHit::operator delete(void *aHit)
0108 {
0109 if(!HadrontherapyDetectorHitAllocator) 
0110   HadrontherapyDetectorHitAllocator= new G4Allocator<HadrontherapyDetectorHit>;
0111 
0112 HadrontherapyDetectorHitAllocator->FreeSingle((HadrontherapyDetectorHit*) aHit);
0113 }
0114 
0115 #endif