Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-18 07:42: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 TrackerHit.hh
0027 /// \brief Definition of the TrackerHit class
0028 
0029 #ifndef TrackerHit_h
0030 #define TrackerHit_h 1
0031 
0032 #include "G4ParticleDefinition.hh"
0033 #include "G4THitsCollection.hh"
0034 #include "G4ThreeVector.hh"
0035 #include "G4VHit.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 class TrackerHit : public G4VHit
0040 {
0041   public:
0042     TrackerHit();
0043     TrackerHit(const TrackerHit&);
0044     ~TrackerHit() override;
0045 
0046     // operators
0047     const TrackerHit& operator=(const TrackerHit& right);
0048     G4bool operator==(const TrackerHit& right) const;
0049 
0050     inline void* operator new(size_t);
0051     inline void operator delete(void*);
0052 
0053     // Methods from base class
0054     void Draw() override;
0055     void Print() override;
0056 
0057     // Set methods
0058     inline void SetTrackID(const G4int& track) { fTrackID = track; }
0059     inline void SetPosition(const G4ThreeVector& pos) { fPos = pos; }
0060     inline void SetEdep(const G4double& edep) { fEdep = edep; }
0061     inline void SetPartDef(const G4ParticleDefinition* partDef)
0062     {
0063       fPartDef = partDef;
0064     }
0065 
0066     // Get methods
0067     inline G4int GetTrackID() const { return fTrackID; }
0068     inline G4ThreeVector GetPosition() const { return fPos; }
0069     inline G4double GetEdep() const { return fEdep; }
0070     inline const G4ParticleDefinition* GetPartDef() const { return fPartDef; }
0071 
0072   private:
0073     G4int fTrackID = 0;  // Track ID
0074     G4ThreeVector fPos = G4ThreeVector();  // Position of hit
0075     G4double fEdep = 0.;  // Energy deposit
0076     const G4ParticleDefinition* fPartDef = nullptr;  // Particle definition
0077 };
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 typedef G4THitsCollection<TrackerHit> TrackerHitColl;
0082 
0083 extern G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator;
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 inline void* TrackerHit::operator new(size_t)
0088 {
0089   if (!TrackerHitAllocator) TrackerHitAllocator = new G4Allocator<TrackerHit>;
0090   return (void*)TrackerHitAllocator->MallocSingle();
0091 }
0092 
0093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0094 
0095 inline void TrackerHit::operator delete(void* hit)
0096 {
0097   TrackerHitAllocator->FreeSingle((TrackerHit*)hit);
0098 }
0099 
0100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0101 
0102 #endif