DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4FastSimSpot.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4FASTSIMSPOT_H
14 #define DDG4_GEANT4FASTSIMSPOT_H
15 
16 // Framework include files
17 #include <DDG4/Defs.h>
18 
19 // Geant4 include files
20 #include <G4Version.hh>
21 
22 #if G4VERSION_NUMBER < 1070
23 
24 #include <G4ThreeVector.hh>
25 
26 class G4FastHit
27 {
28  public:
29  G4FastHit() = default;
30  G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy)
31  : fEnergy(aEnergy), fPosition(aPosition) {}
32  G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy, G4bool /* aDebug */)
33  : fEnergy(aEnergy), fPosition(aPosition) {}
34  virtual ~G4FastHit() = default;
35 
37  inline void SetEnergy(const G4double& aEnergy) { fEnergy = aEnergy; }
39  inline G4double GetEnergy() const { return fEnergy; }
41  inline void SetPosition(const G4ThreeVector& aPosition) { fPosition = aPosition; }
43  inline G4ThreeVector GetPosition() const { return fPosition; }
44  private:
46  G4double fEnergy {0e0};
48  G4ThreeVector fPosition { };
49 };
50 #else
51 #include <G4FastHit.hh>
52 #endif
53 
54 #include <G4Track.hh>
55 #include <G4FastTrack.hh>
56 #include <G4ThreeVector.hh>
57 #include <G4TouchableHandle.hh>
58 
60 namespace dd4hep {
61 
63  namespace sim {
64 
66 
72  public:
74  Geant4FastSimSpot() = delete;
76  Geant4FastSimSpot(const G4FastHit* h, const G4FastTrack* trk);
78  Geant4FastSimSpot(const G4FastHit* h, const G4FastTrack* trk, G4VTouchable* t);
80  ~Geant4FastSimSpot() = default;
81 
83  G4ThreeVector hitPosition() const { return hit->GetPosition(); }
85  double energy() const { return hit->GetEnergy(); }
87  G4VPhysicalVolume* volume() const { return touchable->GetVolume(); }
88 
90  G4ThreeVector trackPosition() const { return primary->GetPosition(); }
92  G4ThreeVector trackMomentum() const { return primary->GetMomentum(); }
94  double kineticEnergy() const { return primary->GetKineticEnergy(); }
96  const G4ParticleDefinition* trackDefinition() const
97  { return primary->GetParticleDefinition(); }
99  G4ThreeVector particleLocalDirection() const
100  { return track->GetPrimaryTrackLocalDirection(); }
102  G4ThreeVector particleLocalMomentum() const
103  { return track->GetPrimaryTrackLocalMomentum(); }
105  G4ThreeVector particleLocalPosition() const
106  { return track->GetPrimaryTrackLocalPosition(); }
107 
109  double distanceToOut() const;
111  G4ThreeVector particleDirection() const;
113  G4ThreeVector particleMomentum() const;
115  G4ThreeVector particlePosition() const;
116 
117  public:
118  const G4FastHit* hit { nullptr };
119  const G4FastTrack* track { nullptr };
120  const G4Track* primary { nullptr };
121  G4VTouchable* touchable { nullptr };
122  };
123 
126  const G4FastTrack* trk,
127  G4VTouchable* t)
128  : hit(h), track(trk), primary(trk->GetPrimaryTrack()), touchable(t)
129  {
130  }
131 
134  const G4FastTrack* trk)
135  : hit(h), track(trk), primary(trk->GetPrimaryTrack())
136  {
137  }
138 
140  inline G4ThreeVector Geant4FastSimSpot::particleMomentum() const {
141  auto mom = track->GetPrimaryTrackLocalMomentum();
142  return track->GetInverseAffineTransformation()->TransformPoint(mom);
143  }
144 
146  inline G4ThreeVector Geant4FastSimSpot::particleDirection() const {
147  auto dir = track->GetPrimaryTrackLocalDirection();
148  return track->GetInverseAffineTransformation()->TransformPoint(dir);
149  }
150 
152  inline G4ThreeVector Geant4FastSimSpot::particlePosition() const {
153  auto pos = track->GetPrimaryTrackLocalPosition();
154  return track->GetInverseAffineTransformation()->TransformPoint(pos);
155  }
156 
158  inline double Geant4FastSimSpot::distanceToOut() const {
159  auto pos = track->GetPrimaryTrackLocalPosition();
160  auto dir = track->GetPrimaryTrackLocalDirection();
161  return track->GetEnvelopeSolid()->DistanceToOut(pos, dir);
162  }
163 
164 
165  } // End namespace sim
166 } // End namespace dd4hep
167 #endif // DDG4_GEANT4FASTSIMSPOT_H
dd4hep::sim::Geant4FastSimSpot::touchable
G4VTouchable * touchable
Definition: Geant4FastSimSpot.h:121
dd4hep::sim::Geant4FastSimSpot::~Geant4FastSimSpot
~Geant4FastSimSpot()=default
Default destructor.
dd4hep::sim::Geant4FastSimSpot::trackPosition
G4ThreeVector trackPosition() const
Primary track position.
Definition: Geant4FastSimSpot.h:90
dd4hep::sim::Geant4FastSimSpot::track
const G4FastTrack * track
Definition: Geant4FastSimSpot.h:119
dd4hep::sim::Geant4FastSimSpot::kineticEnergy
double kineticEnergy() const
Primary track kinetic energy.
Definition: Geant4FastSimSpot.h:94
G4FastHit::SetPosition
void SetPosition(const G4ThreeVector &aPosition)
Set position.
Definition: Geant4FastSimSpot.h:41
dd4hep::sim::Geant4FastSimSpot::energy
double energy() const
Energy deposit of the spot.
Definition: Geant4FastSimSpot.h:85
G4FastHit::~G4FastHit
virtual ~G4FastHit()=default
dd4hep::sim::Geant4FastSimSpot
Spot definition for fast simulation and GFlash.
Definition: Geant4FastSimSpot.h:71
dd4hep::sim::Geant4FastSimSpot::hit
const G4FastHit * hit
Definition: Geant4FastSimSpot.h:118
G4FastHit
Definition: Geant4FastSimSpot.h:27
dd4hep::sim::Geant4FastSimSpot::particleLocalMomentum
G4ThreeVector particleLocalMomentum() const
Particle's local momentum in the region's envelope solid.
Definition: Geant4FastSimSpot.h:102
dd4hep::sim::Geant4FastSimSpot::particleLocalDirection
G4ThreeVector particleLocalDirection() const
Particle's local direction in the region's envelope solid.
Definition: Geant4FastSimSpot.h:99
dd4hep::sim::Geant4FastSimSpot::primary
const G4Track * primary
Definition: Geant4FastSimSpot.h:120
G4FastHit::fPosition
G4ThreeVector fPosition
position
Definition: Geant4FastSimSpot.h:48
dd4hep::sim::Geant4FastSimSpot::hitPosition
G4ThreeVector hitPosition() const
Spot's hit position.
Definition: Geant4FastSimSpot.h:83
G4FastHit::G4FastHit
G4FastHit(const G4ThreeVector &aPosition, G4double aEnergy, G4bool)
Definition: Geant4FastSimSpot.h:32
G4FastHit::G4FastHit
G4FastHit(const G4ThreeVector &aPosition, G4double aEnergy)
Definition: Geant4FastSimSpot.h:30
G4FastHit::SetEnergy
void SetEnergy(const G4double &aEnergy)
Set energy.
Definition: Geant4FastSimSpot.h:37
dd4hep::sim::Geant4FastSimSpot::particleLocalPosition
G4ThreeVector particleLocalPosition() const
Particle's local position in the region's envelope solid.
Definition: Geant4FastSimSpot.h:105
dd4hep::sim::Geant4FastSimSpot::distanceToOut
double distanceToOut() const
Distance to exit point from the region's envelope solid.
Definition: Geant4FastSimSpot.h:158
dd4hep::sim::Geant4FastSimSpot::particleMomentum
G4ThreeVector particleMomentum() const
Particle's global momentum in the region's envelope solid.
Definition: Geant4FastSimSpot.h:140
dd4hep::sim::Geant4FastSimSpot::volume
G4VPhysicalVolume * volume() const
Access the physical volume of the hit.
Definition: Geant4FastSimSpot.h:87
dd4hep::sim::Geant4FastSimSpot::Geant4FastSimSpot
Geant4FastSimSpot()=delete
Default constructor disabled.
dd4hep::sim::Geant4FastSimSpot::particlePosition
G4ThreeVector particlePosition() const
Particle's global position in the region's envelope solid.
Definition: Geant4FastSimSpot.h:152
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4FastSimSpot::particleDirection
G4ThreeVector particleDirection() const
Particle's global direction in the region's envelope solid.
Definition: Geant4FastSimSpot.h:146
G4FastHit::GetEnergy
G4double GetEnergy() const
Get energy.
Definition: Geant4FastSimSpot.h:39
G4FastHit::G4FastHit
G4FastHit()=default
G4FastHit::GetPosition
G4ThreeVector GetPosition() const
Get position.
Definition: Geant4FastSimSpot.h:43
Defs.h
dd4hep::sim::Geant4FastSimSpot::trackMomentum
G4ThreeVector trackMomentum() const
Primary track momentum.
Definition: Geant4FastSimSpot.h:92
G4FastHit::fEnergy
G4double fEnergy
energy
Definition: Geant4FastSimSpot.h:46
dd4hep::sim::Geant4FastSimSpot::trackDefinition
const G4ParticleDefinition * trackDefinition() const
Primary track particle definition.
Definition: Geant4FastSimSpot.h:96