ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkG4Components
TrkG4UserActions
src
GeantFollowerMS.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
// GeantFollowerMS.cxx, (c) ATLAS Detector software
8
9
#include "
TrkG4UserActions/GeantFollowerMS.h
"
10
#include "
TrkG4UserActions/IGeantFollowerMSHelper.h
"
11
12
#include "G4Event.hh"
13
#include "G4Step.hh"
14
#include "G4Material.hh"
15
#include "G4Element.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
25
GeantFollowerMS::GeantFollowerMS
(
const
Config
& config)
26
:
m_config
(config)
27
,
m_helperPointer
(nullptr)
28
{}
29
30
void
GeantFollowerMS::BeginOfEventAction
(
const
G4Event*)
31
{
32
// FIXME: thread-unsafe tool usage in thread-local action? ATLASSIM-3562.
33
m_helperPointer
->beginEvent();
34
}
35
36
void
GeantFollowerMS::EndOfEventAction
(
const
G4Event*)
37
{
38
// FIXME: thread-unsafe tool usage in thread-local action? ATLASSIM-3562.
39
m_helperPointer
->endEvent();
40
}
41
42
void
GeantFollowerMS::BeginOfRunAction
(
const
G4Run*)
43
{
44
if
(
m_config
.helper.retrieve()!=StatusCode::SUCCESS) {
45
G4ExceptionDescription
description
;
46
description
<<
"Cannot retrieve GeantFollowerMS helper"
;
47
G4Exception(
"GeantFollowerMS"
,
"GeantFollowerMS1"
, FatalException,
description
);
48
return
;
49
}
50
m_helperPointer
= (&(*
m_config
.helper));
51
52
if
(
m_config
.trackingGeometrySvc.retrieve()!=StatusCode::SUCCESS) {
53
G4ExceptionDescription
description
;
54
description
<<
"Cannot retrieve TrackingGeometrySvc in GeantFollowerMS"
;
55
G4Exception(
"GeantFollowerMS"
,
"GeantFollowerMS2"
, FatalException,
description
);
56
return
;
57
}
58
59
}
60
61
void
GeantFollowerMS::UserSteppingAction
(
const
G4Step* aStep)
62
{
63
// kill secondaries
64
if
(aStep->GetTrack()->GetParentID()) {
65
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
66
return
;
67
}
68
69
// get the prestep point and follow this guy
70
G4StepPoint * g4PreStep = aStep->GetPreStepPoint();
71
G4ThreeVector g4Momentum = g4PreStep->GetMomentum();
72
const
G4ThreeVector& g4Position = g4PreStep->GetPosition();
73
74
G4Track* g4Track = aStep->GetTrack();
75
const
G4DynamicParticle* g4DynParticle = g4Track->GetDynamicParticle();
76
77
// the material information
78
const
G4TouchableHistory* touchHist =
79
static_cast<
const
G4TouchableHistory*
>
(aStep->GetPreStepPoint()->GetTouchable());
80
81
if
(touchHist) [[
likely
]] {
82
// G4LogicalVolume
83
const
G4LogicalVolume *lv= touchHist->GetVolume()->GetLogicalVolume();
84
85
if
(lv) [[
likely
]] {
86
const
G4Material *mat = lv->GetMaterial();
87
// the step information
88
double
steplength = aStep->GetStepLength();
89
// the position information
90
double
X0 = mat->GetRadlen();
91
// update the track follower
92
m_helperPointer
->trackParticle(g4Position, g4Momentum,
93
g4DynParticle->GetPDGcode(),
94
g4DynParticle->GetCharge(),
95
steplength, X0);
96
}
97
else
{
98
G4ExceptionDescription
description
;
99
description
<<
"GeantFollowerMS::SteppingAction NULL G4LogicalVolume pointer."
;
100
G4Exception(
"GeantFollowerMS"
,
"GeantFollowerMS3"
, FatalException,
description
);
101
}
102
}
103
else
{
104
G4ExceptionDescription
description
;
105
description
<<
"GeantFollowerMS::SteppingAction NULL G4TouchableHistory pointer."
;
106
G4Exception(
"GeantFollowerMS"
,
"GeantFollowerMS4"
, FatalException,
description
);
107
}
108
}
109
110
}
// namespace G4UA
GeantFollowerMS.h
IGeantFollowerMSHelper.h
G4UA::GeantFollowerMS::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition
GeantFollowerMS.cxx:42
G4UA::GeantFollowerMS::m_helperPointer
Trk::IGeantFollowerMSHelper * m_helperPointer
Definition
GeantFollowerMS.h:58
G4UA::GeantFollowerMS::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition
GeantFollowerMS.cxx:30
G4UA::GeantFollowerMS::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
GeantFollowerMS.cxx:36
G4UA::GeantFollowerMS::GeantFollowerMS
GeantFollowerMS(const Config &config)
Definition
GeantFollowerMS.cxx:25
G4UA::GeantFollowerMS::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
GeantFollowerMS.cxx:61
G4UA::GeantFollowerMS::m_config
Config m_config
Definition
GeantFollowerMS.h:56
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::GeantFollowerMS::Config
Definition
GeantFollowerMS.h:39
Generated on
for ATLAS Offline Software by
1.17.0