Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:16

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 //
0027 /// \file B4/B4c/include/CalorHit.hh
0028 /// \brief Definition of the B4c::CalorHit class
0029 
0030 #ifndef B4cCalorHit_h
0031 #define B4cCalorHit_h 1
0032 
0033 #include "G4Allocator.hh"
0034 #include "G4THitsCollection.hh"
0035 #include "G4Threading.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4VHit.hh"
0038 #include "globals.hh"
0039 
0040 namespace B4c
0041 {
0042 
0043 /// Calorimeter hit class
0044 ///
0045 /// It defines data members to store the the energy deposit and track lengths
0046 /// of charged particles in a selected volume:
0047 /// - fEdep, fTrackLength
0048 
0049 class CalorHit : public G4VHit
0050 {
0051   public:
0052     CalorHit() = default;
0053     CalorHit(const CalorHit&) = default;
0054     ~CalorHit() override = default;
0055 
0056     // operators
0057     CalorHit& operator=(const CalorHit&) = default;
0058     G4bool operator==(const CalorHit&) const;
0059 
0060     inline void* operator new(size_t);
0061     inline void operator delete(void*);
0062 
0063     // methods from base class
0064     void Draw() override {}
0065     void Print() override;
0066 
0067     // methods to handle data
0068     void Add(G4double de, G4double dl);
0069 
0070     // get methods
0071     G4double GetEdep() const;
0072     G4double GetTrackLength() const;
0073 
0074   private:
0075     G4double fEdep = 0.;  ///< Energy deposit in the sensitive volume
0076     G4double fTrackLength = 0.;  ///< Track length in the  sensitive volume
0077 };
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 using CalorHitsCollection = G4THitsCollection<CalorHit>;
0082 
0083 extern G4ThreadLocal G4Allocator<CalorHit>* CalorHitAllocator;
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 inline void* CalorHit::operator new(size_t)
0088 {
0089   if (!CalorHitAllocator) {
0090     CalorHitAllocator = new G4Allocator<CalorHit>;
0091   }
0092   void* hit;
0093   hit = (void*)CalorHitAllocator->MallocSingle();
0094   return hit;
0095 }
0096 
0097 inline void CalorHit::operator delete(void* hit)
0098 {
0099   if (!CalorHitAllocator) {
0100     CalorHitAllocator = new G4Allocator<CalorHit>;
0101   }
0102   CalorHitAllocator->FreeSingle((CalorHit*)hit);
0103 }
0104 
0105 inline void CalorHit::Add(G4double de, G4double dl)
0106 {
0107   fEdep += de;
0108   fTrackLength += dl;
0109 }
0110 
0111 inline G4double CalorHit::GetEdep() const
0112 {
0113   return fEdep;
0114 }
0115 
0116 inline G4double CalorHit::GetTrackLength() const
0117 {
0118   return fTrackLength;
0119 }
0120 
0121 }  // namespace B4c
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 #endif