ATLAS Offline Software
GeantFollower.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // GeantFollower.cxx, (c) ATLAS Detector software
8 
12 
13 #include "G4Event.hh"
14 #include "G4Step.hh"
15 #include "G4Material.hh"
16 #include "G4StepPoint.hh"
17 #include "G4TouchableHistory.hh"
18 #include "G4LogicalVolume.hh"
19 #include "G4DynamicParticle.hh"
20 #include "G4Track.hh"
21 
22 namespace G4UA{
23 
24 
26  : m_config(config)
27  , m_helperPointer(nullptr)
28  {}
29 
30  void GeantFollower::BeginOfEventAction(const G4Event*)
31  {
33  }
34 
35  void GeantFollower::EndOfEventAction(const G4Event*)
36  {
38  }
39 
41  {
42  if(m_config.helper.retrieve()!=StatusCode::SUCCESS)
43  {
44  G4ExceptionDescription description;
45  description << "Cannot retrieve GeantFollower helper";
46  G4Exception("GeantFollower", "GeantFollower1", FatalException, description);
47  return;
48  }
49 
51  }
52 
53  void GeantFollower::UserSteppingAction(const G4Step* aStep)
54  {
55  // kill secondaries
56  if (aStep->GetTrack()->GetParentID())
57  {
58  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
59  return;
60  }
61 
62  // get the prestep point and follow this guy
63  G4StepPoint * g4PreStep = aStep->GetPreStepPoint();
64  G4ThreeVector g4Momentum = g4PreStep->GetMomentum();
65  const G4ThreeVector& g4Position = g4PreStep->GetPosition();
66 
67  G4Track* g4Track = aStep->GetTrack();
68  const G4DynamicParticle* g4DynParticle = g4Track->GetDynamicParticle();
69 
70  // the material information
71  const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
72  if(ATH_LIKELY(touchHist))
73  {
74  // G4LogicalVolume
75  const G4LogicalVolume *lv= touchHist->GetVolume()->GetLogicalVolume();
76  if(ATH_LIKELY(lv))
77  {
78  const G4Material *mat = lv->GetMaterial();
79  // the step information
80  double steplength = aStep->GetStepLength();
81  // the position information
82  double X0 = mat->GetRadlen();
83  // update the track follower
84  m_helperPointer->trackParticle(g4Position,g4Momentum,g4DynParticle->GetPDGcode(),g4DynParticle->GetCharge(),steplength,X0);
85  }
86  else
87  {
88  G4ExceptionDescription description;
89  description << "GeantFollower::SteppingAction NULL G4LogicalVolume pointer.";
90  G4Exception("GeantFollower", "GeantFollower2", FatalException, description);
91  }
92  }
93  else
94  {
95  G4ExceptionDescription description;
96  description << "GeantFollower::SteppingAction NULL G4TouchableHistory pointer.";
97  G4Exception("GeantFollower", "GeantFollower3", FatalException, description);
98  }
99  }
100 
101 } // namespace G4UA
G4UA::GeantFollower::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition: GeantFollower.cxx:35
G4UA::GeantFollower::GeantFollower
GeantFollower(const Config &config)
Definition: GeantFollower.cxx:25
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
G4UA::GeantFollower::Config::helper
ToolHandle< Trk::IGeantFollowerHelper > helper
FIXME: Public tool handle. See ATLASSIM-3561.
Definition: GeantFollower.h:41
Trk::IGeantFollowerHelper::trackParticle
virtual void trackParticle(const G4ThreeVector &pos, const G4ThreeVector &mom, int pdg, double charge, float t, float X0)=0
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
G4UA::GeantFollower::m_config
Config m_config
Definition: GeantFollower.h:53
G4UA::GeantFollower::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition: GeantFollower.cxx:53
Trk::IGeantFollowerHelper::beginEvent
virtual void beginEvent()=0
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
pdg_comparison.X0
X0
Definition: pdg_comparison.py:314
AthUnlikelyMacros.h
G4UA::GeantFollower::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition: GeantFollower.cxx:40
GeantFollower.h
IGeantFollowerHelper.h
G4UA::GeantFollower::Config
Definition: GeantFollower.h:39
ATH_LIKELY
#define ATH_LIKELY(x)
Definition: AthUnlikelyMacros.h:16
G4UA::GeantFollower::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition: GeantFollower.cxx:30
G4UA::GeantFollower::m_helperPointer
Trk::IGeantFollowerHelper * m_helperPointer
Definition: GeantFollower.h:55
Trk::IGeantFollowerHelper::endEvent
virtual void endEvent()=0
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88