ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::EnergyLossRecorder Class Reference

#include <EnergyLossRecorder.h>

Inheritance diagram for G4UA::EnergyLossRecorder:
Collaboration diagram for G4UA::EnergyLossRecorder:

Classes

struct  Config

Public Member Functions

 EnergyLossRecorder (const Config &config)
virtual void BeginOfRunAction (const G4Run *) override
virtual void EndOfRunAction (const G4Run *) override
virtual void BeginOfEventAction (const G4Event *) override
virtual void EndOfEventAction (const G4Event *) override
virtual void UserSteppingAction (const G4Step *) override

Private Attributes

Config m_config
unsigned int m_entries

Detailed Description

Definition at line 39 of file EnergyLossRecorder.h.

Constructor & Destructor Documentation

◆ EnergyLossRecorder()

EnergyLossRecorder::EnergyLossRecorder ( const Config & config)

Definition at line 24 of file EnergyLossRecorder.cxx.

25 : m_config(config)
26 , m_entries(0)
27 {
28
29 }

Member Function Documentation

◆ BeginOfEventAction()

void EnergyLossRecorder::BeginOfEventAction ( const G4Event * )
overridevirtual

Definition at line 40 of file EnergyLossRecorder.cxx.

41 {
42 }

◆ BeginOfRunAction()

void EnergyLossRecorder::BeginOfRunAction ( const G4Run * )
overridevirtual

Definition at line 32 of file EnergyLossRecorder.cxx.

33 {
34 }

◆ EndOfEventAction()

void EnergyLossRecorder::EndOfEventAction ( const G4Event * )
overridevirtual

Definition at line 44 of file EnergyLossRecorder.cxx.

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 }

◆ EndOfRunAction()

void EnergyLossRecorder::EndOfRunAction ( const G4Run * )
overridevirtual

Definition at line 36 of file EnergyLossRecorder.cxx.

37 {
38 }

◆ UserSteppingAction()

void EnergyLossRecorder::UserSteppingAction ( const G4Step * aStep)
overridevirtual

Definition at line 54 of file EnergyLossRecorder.cxx.

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 }
Eigen::Matrix< double, 3, 1 > Vector3D

Member Data Documentation

◆ m_config

Config G4UA::EnergyLossRecorder::m_config
private

Definition at line 56 of file EnergyLossRecorder.h.

◆ m_entries

unsigned int G4UA::EnergyLossRecorder::m_entries
private

Definition at line 57 of file EnergyLossRecorder.h.


The documentation for this class was generated from the following files: