ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkG4Components
TrkG4UserActions
src
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
9
#include "
TrkG4UserActions/EnergyLossRecorder.h
"
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
18
#include "
GeoPrimitives/GeoPrimitives.h
"
19
#include "
TrkValInterfaces/IPositionMomentumWriter.h
"
20
21
namespace
G4UA
22
{
23
24
EnergyLossRecorder::EnergyLossRecorder
(
const
Config
& config)
25
:
m_config
(config)
26
,
m_entries
(0)
27
{
28
29
}
30
31
// FIXME: Why implement run action if empty?
32
void
EnergyLossRecorder::BeginOfRunAction
(
const
G4Run*)
33
{
34
}
35
36
void
EnergyLossRecorder::EndOfRunAction
(
const
G4Run*)
37
{
38
}
39
40
void
EnergyLossRecorder::BeginOfEventAction
(
const
G4Event*)
41
{
42
}
43
44
void
EnergyLossRecorder::EndOfEventAction
(
const
G4Event*)
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
54
void
EnergyLossRecorder::UserSteppingAction
(
const
G4Step* aStep)
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
EnergyLossRecorder.h
GeoPrimitives.h
IPositionMomentumWriter.h
G4UA::EnergyLossRecorder::EndOfRunAction
virtual void EndOfRunAction(const G4Run *) override
Definition
EnergyLossRecorder.cxx:36
G4UA::EnergyLossRecorder::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition
EnergyLossRecorder.cxx:40
G4UA::EnergyLossRecorder::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition
EnergyLossRecorder.cxx:32
G4UA::EnergyLossRecorder::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
EnergyLossRecorder.cxx:54
G4UA::EnergyLossRecorder::m_config
Config m_config
Definition
EnergyLossRecorder.h:56
G4UA::EnergyLossRecorder::EnergyLossRecorder
EnergyLossRecorder(const Config &config)
Definition
EnergyLossRecorder.cxx:24
G4UA::EnergyLossRecorder::m_entries
unsigned int m_entries
Definition
EnergyLossRecorder.h:57
G4UA::EnergyLossRecorder::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
EnergyLossRecorder.cxx:44
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
G4UA::EnergyLossRecorder::Config
Definition
EnergyLossRecorder.h:45
Generated on
for ATLAS Offline Software by
1.17.0