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