Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 07:52:13

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 // gpaterno, October 2025
0027 //
0028 /// \file SensitiveDetectorHit.hh
0029 /// \brief Definition of the SensitiveDetectorHit class
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #ifndef SensitiveDetectorHit_h
0034 #define SensitiveDetectorHit_h 1
0035 
0036 #include "G4VHit.hh"
0037 #include "G4THitsCollection.hh"
0038 #include "G4Allocator.hh"
0039 #include "G4ThreeVector.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4Transform3D.hh"
0042 #include "G4RotationMatrix.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 /// SensitiveDetectorHit class.
0047 
0048 class G4AttDef;
0049 class G4AttValue;
0050 
0051 class SensitiveDetectorHit : public G4VHit
0052 {
0053 public:
0054     SensitiveDetectorHit() = default;
0055     ~SensitiveDetectorHit() override = default;
0056     
0057     SensitiveDetectorHit(const SensitiveDetectorHit &right) = default;
0058     SensitiveDetectorHit& operator=(const SensitiveDetectorHit &right) = default;
0059     
0060     int operator==(const SensitiveDetectorHit &right) const;
0061     
0062     inline void *operator new(size_t);
0063     inline void operator delete(void *aHit);
0064     
0065     void Draw() override;
0066     const std::map<G4String,G4AttDef>* GetAttDefs() const override;
0067     std::vector<G4AttValue>* CreateAttValues() const override;
0068     void Print() override;
0069 
0070     inline void SetTrackID(G4int z) {fTrackID = z;}
0071     inline G4int GetTrackID() const {return fTrackID;}
0072 
0073     inline void SetTrackIDP(G4int z) {fTrackIDP = z;}
0074     inline G4int GetTrackIDP() const {return fTrackIDP;}
0075 
0076     inline void SetTime(G4double t) {fTime = t;}
0077     inline G4double GetTime() const {return fTime;}
0078     
0079     inline void SetPos(G4ThreeVector xyz) {fPos = xyz;}
0080     inline G4ThreeVector GetPos() const {return fPos;}
0081     
0082     inline void SetMom(G4ThreeVector xyz) {fMom = xyz;}
0083     inline G4ThreeVector GetMom() const {return fMom;}
0084     
0085     inline void SetEnergy(G4double energy) {fEnergy = energy;}
0086     inline G4double GetEnergy() const {return fEnergy;}
0087        
0088     inline void SetType(G4int type) {fType = type;}
0089     inline G4int GetType() const {return fType;}  
0090       
0091     inline void SetParticle(G4String particle) {fParticle = particle;}
0092     inline G4String GetParticle() const {return fParticle;}
0093 
0094     inline void SetWeight(G4double weight) {fWeight = weight;}
0095     inline G4double GetWeight() const {return fWeight;}
0096 
0097     inline void SetDetID(G4int did) {fDetID = did;}
0098     inline G4int GetDetID() const {return fDetID;}
0099     
0100 private:
0101     G4int fTrackID = -1;
0102     G4int fTrackIDP = -1;
0103     G4double fTime = 0;
0104     G4ThreeVector fPos = G4ThreeVector(0., 0., 0.);
0105     G4ThreeVector fMom = G4ThreeVector(0., 0., 0.);
0106     G4double fEnergy = 0.;
0107     G4int fType = -11;
0108     G4String fParticle = "";
0109     G4double fWeight = -1;
0110     G4int fDetID = -1;
0111 };
0112 
0113 using SensitiveDetectorHitsCollection = G4THitsCollection<SensitiveDetectorHit>;
0114 
0115 extern G4ThreadLocal G4Allocator<SensitiveDetectorHit>* SensitiveDetectorHitAllocator;
0116 
0117 inline void* SensitiveDetectorHit::operator new(size_t)
0118 {
0119   if (!SensitiveDetectorHitAllocator) SensitiveDetectorHitAllocator = 
0120       new G4Allocator<SensitiveDetectorHit>;
0121   return (void *) SensitiveDetectorHitAllocator->MallocSingle();
0122 }
0123 
0124 inline void SensitiveDetectorHit::operator delete(void* aHit)
0125 {
0126   SensitiveDetectorHitAllocator->FreeSingle((SensitiveDetectorHit*) aHit);
0127 }
0128 
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0131 
0132 #endif