Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:49:52

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 GB03HodoHit.hh
0027 /// \brief Definition of the GB03HodoHit class
0028 
0029 /// The  hit class.
0030 ///
0031 /// It defines data members to store the the kinetic energy,
0032 /// Hit postion, particle PDG id:
0033 /// - fEkin, fEncoding, fPos
0034 ///
0035 
0036 #ifndef GB03HodoHit_h
0037 #define GB03HodoHit_h 1
0038 
0039 #include "G4Allocator.hh"
0040 #include "G4THitsCollection.hh"
0041 #include "G4ThreeVector.hh"
0042 #include "G4VHit.hh"
0043 
0044 class GB03HodoHit : public G4VHit
0045 {
0046   public:
0047     GB03HodoHit() = default;
0048     GB03HodoHit(const GB03HodoHit&);
0049     ~GB03HodoHit() override = default;
0050 
0051     // operators
0052     const GB03HodoHit& operator=(const GB03HodoHit&);
0053     G4bool operator==(const GB03HodoHit&) const;
0054 
0055     inline void* operator new(size_t);
0056     inline void operator delete(void*);
0057 
0058     // methods from base class
0059     void Draw() override;
0060     void Print() override;
0061 
0062     // methods to handle data
0063     void Set(G4int id, G4double ek, G4double pw, G4ThreeVector xyz)
0064     {
0065       fEkin = ek;
0066       fWeight = pw;
0067       fEncoding = id;
0068       fPos = xyz;
0069     }
0070     void SetEkin(G4double ek) { fEkin = ek; }
0071     void SetWeight(G4double pw) { fWeight = pw; }
0072     void SetId(G4int id) { fEncoding = id; }
0073     void SetPos(G4ThreeVector xyz) { fPos = xyz; }
0074 
0075     // get methods
0076     G4double GetEkin() const { return fEkin; }
0077     G4double GetWeight() const { return fWeight; }
0078     G4int GetId() const { return fEncoding; }
0079     G4ThreeVector GetPos() const { return fPos; }
0080 
0081   private:
0082     G4double fEkin{0.0};  ///< Kinetic energy
0083     G4double fWeight{0.0};  ///< Track weight
0084     G4int fEncoding{0};  ///< PDG integer identifier
0085     G4ThreeVector fPos;  ///< Hit position
0086 };
0087 
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 
0090 using GB03HodoHitsCollection = G4THitsCollection<GB03HodoHit>;
0091 
0092 extern G4ThreadLocal G4Allocator<GB03HodoHit>* GB03HodoHitAllocator;
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0095 
0096 inline void* GB03HodoHit::operator new(size_t)
0097 {
0098   if (GB03HodoHitAllocator == nullptr) {
0099     GB03HodoHitAllocator = new G4Allocator<GB03HodoHit>;
0100   }
0101   void* hit;
0102   hit = (void*)GB03HodoHitAllocator->MallocSingle();
0103   return hit;
0104 }
0105 
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0107 
0108 inline void GB03HodoHit::operator delete(void* hit)
0109 {
0110   GB03HodoHitAllocator->FreeSingle((GB03HodoHit*)hit);
0111 }
0112 
0113 #endif