ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsGeantFollowing
src
ActsGeantFollower.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// GeantFollower.cxx, (c) ATLAS Detector software
8
9
#include "
ActsGeantFollower.h
"
10
#include "
IActsGeantFollowerHelper.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
#include "G4VSensitiveDetector.hh"
21
22
ActsGeantFollower::ActsGeantFollower
(){}
23
24
void
ActsGeantFollower::BeginOfEventAction
(
const
G4Event*)
25
{
26
m_helper
->beginEvent();
27
}
28
29
void
ActsGeantFollower::EndOfEventAction
(
const
G4Event*)
30
{
31
m_helper
->endEvent();
32
}
33
34
void
ActsGeantFollower::BeginOfRunAction
(
const
G4Run*)
35
{
36
if
(
m_helper
.retrieve()!=StatusCode::SUCCESS)
37
{
38
G4ExceptionDescription
description
;
39
description
<<
"Cannot retrieve ActsGeantFollower helper"
;
40
G4Exception(
"ActsGeantFollower"
,
"ActsGeantFollower1"
, FatalException,
description
);
41
return
;
42
}
43
return
;
44
}
45
46
void
ActsGeantFollower::UserSteppingAction
(
const
G4Step* aStep)
47
{
48
// kill secondaries and low momentum particles
49
if
(aStep->GetTrack()->GetParentID() || aStep->GetPreStepPoint()->GetMomentum().mag()<500 )
50
{
51
std::cout <<
"low pt"
<< std::endl;
52
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
53
return
;
54
}
55
56
// kill Particles outiside the tracking volume
57
if
(aStep->GetPreStepPoint()->GetPosition().z()>3000 || sqrt(aStep->GetPreStepPoint()->GetPosition().x()*aStep->GetPreStepPoint()->GetPosition().x()+aStep->GetPreStepPoint()->GetPosition().y()*aStep->GetPreStepPoint()->GetPosition().y())>1050 )
58
{
59
std::cout <<
"out"
<< std::endl;
60
aStep->GetTrack()->SetTrackStatus(fStopAndKill);
61
return
;
62
}
63
64
// get the prestep point and follow this guy
65
G4StepPoint * g4PreStep = aStep->GetPreStepPoint();
66
G4ThreeVector g4Momentum = g4PreStep->GetMomentum();
67
G4ThreeVector g4Position = g4PreStep->GetPosition();
68
69
G4Track* g4Track = aStep->GetTrack();
70
const
G4DynamicParticle* g4DynParticle = g4Track->GetDynamicParticle();
71
72
// the material information
73
const
G4TouchableHistory* touchHist =
static_cast<
const
G4TouchableHistory*
>
(aStep->GetPreStepPoint()->GetTouchable());
74
if
(touchHist) [[
likely
]]
75
{
76
// G4LogicalVolume
77
const
G4LogicalVolume *lv= touchHist->GetVolume()->GetLogicalVolume();
78
if
(lv) [[
likely
]]
79
{
80
const
G4Material *mat = lv->GetMaterial();
81
// the step information
82
double
steplength = aStep->GetStepLength();
83
// the position information
84
double
X0 = mat->GetRadlen();
85
// update the track follower when a sensor is encountered
86
// bool isSensitive = (lv->GetSensitiveDetector() != nullptr);
87
bool
isSensitive =
true
;
88
m_helper
->trackParticle(g4Position, g4Momentum, g4DynParticle->GetPDGcode(), g4DynParticle->GetCharge(), steplength, X0, isSensitive);
89
90
}
91
else
92
{
93
G4ExceptionDescription
description
;
94
description
<<
"ActsGeantFollower::SteppingAction NULL G4LogicalVolume pointer."
;
95
G4Exception(
"ActsGeantFollower"
,
"ActsGeantFollower2"
, FatalException,
description
);
96
}
97
}
98
else
99
{
100
G4ExceptionDescription
description
;
101
description
<<
"ActsGeantFollower::SteppingAction NULL G4TouchableHistory pointer."
;
102
G4Exception(
"ActsGeantFollower"
,
"ActsGeantFollower3"
, FatalException,
description
);
103
}
104
return
;
105
}
ActsGeantFollower.h
IActsGeantFollowerHelper.h
ActsGeantFollower::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
ActsGeantFollower.cxx:29
ActsGeantFollower::m_helper
ToolHandle< IActsGeantFollowerHelper > m_helper
Definition
ActsGeantFollower.h:34
ActsGeantFollower::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition
ActsGeantFollower.cxx:24
ActsGeantFollower::ActsGeantFollower
ActsGeantFollower()
Definition
ActsGeantFollower.cxx:22
ActsGeantFollower::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override
Definition
ActsGeantFollower.cxx:34
ActsGeantFollower::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
ActsGeantFollower.cxx:46
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
likely
#define likely(x)
Definition
pythonic_coracool.cxx:8
Generated on
for ATLAS Offline Software by
1.17.0