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