ATLAS Offline Software
Loading...
Searching...
No Matches
EnergyLossRecorder.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// EnergyLossRecorder.cxx, (c) ATLAS Detector software
8
10#include "G4Step.hh"
11#include "G4StepPoint.hh"
12#include "G4ThreeVector.hh"
13#include "G4Material.hh"
14#include "G4Element.hh"
15#include "G4TouchableHistory.hh"
16#include "G4LogicalVolume.hh"
17// TrkValInterfaces
20
21namespace G4UA
22{
23
30
31 // FIXME: Why implement run action if empty?
33 {
34 }
35
37 {
38 }
39
41 {
42 }
43
45 {
46 if (m_config.pmWriter) {
47 // FIXME: thread-unsafe usage of a component in a thread-local action?
48 // See ATLASSIM-3562.
49 m_config.pmWriter->finalizeTrack();
50 }
51 m_entries = 0;
52 }
53
55 {
56 // kill secondary particles
57 if (aStep->GetTrack()->GetParentID()) {
58 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
59 return;
60 }
61 if(!m_config.pmWriter) return;
62 // we require a minimum amount of material for recording the step
63
64 // the material information
65 const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
66 // G4LogicalVolume
67 const G4LogicalVolume *lv= touchHist ? touchHist->GetVolume()->GetLogicalVolume() : nullptr;
68 const G4Material *mat = lv ? lv->GetMaterial() : nullptr;
69
70 // log the information // cut off air
71 if (mat && mat->GetRadlen() < 200000.) {
72 // keep primary particles - calculate the kinematics for them
73 G4ThreeVector pos = aStep->GetPreStepPoint()->GetPosition();
74 double px = aStep->GetPreStepPoint()->GetMomentum().x();
75 double py = aStep->GetPreStepPoint()->GetMomentum().y();
76 double pz = aStep->GetPreStepPoint()->GetMomentum().z();
77 Amg::Vector3D position(pos.x(),pos.y(),pos.z());
78 Amg::Vector3D momentum(px ,py, pz);
79
80 // record the starting parameters at the first step
81 if (m_entries==0) {
82 // increase the counter
83 ++m_entries;
84 double m = aStep->GetTrack()->GetDynamicParticle()->GetMass();
85 int pdgCode = aStep->GetTrack()->GetDynamicParticle()->GetPDGcode();
86 m_config.pmWriter->initializeTrack(position,momentum,m,pdgCode);
87 }
88 else {
89 m_config.pmWriter->recordTrackState(position,momentum);
90 }
91 }
92 }
93
94} // namespace G4UA
virtual void EndOfRunAction(const G4Run *) override
virtual void BeginOfEventAction(const G4Event *) override
virtual void BeginOfRunAction(const G4Run *) override
virtual void UserSteppingAction(const G4Step *) override
EnergyLossRecorder(const Config &config)
virtual void EndOfEventAction(const G4Event *) override
Eigen::Matrix< double, 3, 1 > Vector3D