File indexing completed on 2025-01-18 09:55:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDG4_GEANT4FASTSIMHANDLER_H
0014 #define DDG4_GEANT4FASTSIMHANDLER_H
0015
0016
0017 #include <DDG4/Geant4HitHandler.h>
0018 #include <DDG4/Geant4FastSimSpot.h>
0019
0020
0021 #include <G4VTouchable.hh>
0022 #include <G4VSensitiveDetector.hh>
0023
0024
0025 namespace dd4hep {
0026
0027
0028 namespace sim {
0029
0030
0031 class Geant4FastSimHandler;
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 class Geant4FastSimHandler : public Geant4HitHandler {
0044 public:
0045 const Geant4FastSimSpot* spot { nullptr };
0046
0047
0048 Geant4FastSimHandler() = delete;
0049
0050 Geant4FastSimHandler(const Geant4FastSimSpot* sp)
0051 : Geant4HitHandler(sp->primary, sp->touchable), spot(sp)
0052 {
0053 }
0054
0055 Geant4FastSimHandler(const Geant4FastSimHandler& copy) = delete;
0056
0057 Geant4FastSimHandler(Geant4FastSimHandler&& copy) = delete;
0058
0059 Geant4FastSimHandler& operator=(const Geant4FastSimHandler& copy) = delete;
0060
0061 Geant4FastSimHandler& operator=(Geant4FastSimHandler&& copy) = delete;
0062
0063 double energy() const {
0064 return spot->hit->GetEnergy();
0065 }
0066
0067 Momentum momentum() const {
0068 const G4ThreeVector& p = track->GetMomentum();
0069 return Momentum(p.x(), p.y(), p.z());
0070 }
0071
0072 Position avgPosition() const {
0073 const G4ThreeVector p = spot->hit->GetPosition();
0074 return Position(p.x(), p.y(), p.z());
0075 }
0076
0077 G4ThreeVector avgPositionG4() const {
0078 return spot->hit->GetPosition();
0079 }
0080
0081 Position direction() const {
0082 const G4ThreeVector p = track->GetMomentumDirection();
0083 return Position(p.x(), p.y(), p.z());
0084 }
0085
0086 G4ThreeVector momentumG4() const {
0087 return track->GetMomentum();
0088 }
0089
0090 double deposit() const {
0091 return spot->hit->GetEnergy();
0092 }
0093 G4VPhysicalVolume* volume() const {
0094 return touchable()->GetVolume();
0095 }
0096 G4LogicalVolume* logvol() const {
0097 return volume()->GetLogicalVolume();
0098 }
0099 G4VSolid* solid() const {
0100 return touchable()->GetSolid();
0101 }
0102 G4VSensitiveDetector* sd() const {
0103 G4LogicalVolume* lv = logvol();
0104 return lv ? lv->GetSensitiveDetector() : 0;
0105 }
0106 std::string sdName(const std::string& undefined = "") const {
0107 G4VSensitiveDetector* s = sd();
0108 return s ? s->GetName() : undefined;
0109 }
0110 bool isSensitive() const {
0111 G4LogicalVolume* lv = logvol();
0112 return lv ? (0 != lv->GetSensitiveDetector()) : false;
0113 }
0114 };
0115
0116 }
0117 }
0118 #endif