ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsMonitoring
src
ExtrapolationTestAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ExtrapolationTestAlg.h
"
6
7
// ATHENA
8
9
10
// ACTS
11
#include "Acts/Propagator/MaterialInteractor.hpp"
12
#include "Acts/Propagator/detail/SteppingLogger.hpp"
13
#include "Acts/Surfaces/PerigeeSurface.hpp"
14
#include "Acts/Utilities/Helpers.hpp"
15
#include "Acts/Definitions/Units.hpp"
16
#include "Acts/Utilities/Logger.hpp"
17
18
// PACKAGE
19
#include "
ActsGeometryInterfaces/GeometryContext.h
"
20
#include "
ActsGeometryInterfaces/ITrackingGeometrySvc.h
"
21
#include "
ActsInterop/Logger.h
"
22
23
// OTHER
24
#include "CLHEP/Random/RandomEngine.h"
25
26
// STL
27
#include <fstream>
28
#include <string>
29
30
using namespace
Acts::UnitLiterals;
31
32
namespace
ActsTrk
{
33
StatusCode
ExtrapolationTestAlg::initialize
() {
34
35
ATH_MSG_DEBUG
(name() <<
"::"
<< __FUNCTION__);
36
37
ATH_CHECK
(
m_rndmGenSvc
.retrieve());
38
ATH_CHECK
(
m_extrapolationTool
.retrieve());
39
ATH_CHECK
(
m_trackingGeometrySvc
.retrieve());
40
ATH_CHECK
(
m_materialTrackCollectionKey
.initialize() );
41
ATH_CHECK
(
m_tree
.init(
this
));
42
return
StatusCode::SUCCESS;
43
}
44
45
StatusCode
ExtrapolationTestAlg::finalize
() {
46
ATH_CHECK
(
m_tree
.write());
47
return
StatusCode::SUCCESS;
48
}
49
StatusCode
ExtrapolationTestAlg::execute
(
const
EventContext &ctx) {
50
51
ATH_MSG_VERBOSE
(name() <<
"::"
<< __FUNCTION__);
52
53
ATHRNG::RNGWrapper
*rngWrapper =
m_rndmGenSvc
->getEngine(
this
);
54
rngWrapper->
setSeed
(name(), ctx);
55
CLHEP::HepRandomEngine *rngEngine = rngWrapper->
getEngine
(ctx);
56
57
ATH_MSG_VERBOSE
(
"Extrapolating "
<<
m_nParticlePerEvent
<<
" particles"
);
58
59
// Write to the collection to the EventStore
60
SG::WriteHandle
materialTracks{
m_materialTrackCollectionKey
, ctx};
61
62
// Record the collection once per event if not already there
63
if
(!materialTracks.
isPresent
()) {
64
ATH_CHECK
(materialTracks.
record
(std::make_unique<ActsTrk::RecordedMaterialTrackCollection>()));
65
}
66
67
// Add the track to the recorded collection
68
auto
* coll = materialTracks.
ptr
();
69
70
for
(
size_t
i = 0; i <
m_nParticlePerEvent
; ++i) {
71
double
d0 = 0;
72
double
z0 = 0;
73
double
phi
= rngEngine->flat() * 2 * std::numbers::pi - std::numbers::pi;
74
std::vector<double> etaRange =
m_etaRange
;
75
double
etaMin = etaRange.at(0);
76
double
etaMax = etaRange.at(1);
77
double
eta
= rngEngine->flat() * std::abs(etaMax - etaMin) + etaMin;
78
79
std::vector<double> ptRange =
m_ptRange
;
80
double
ptMin = ptRange.at(0) * 1_GeV;
81
double
ptMax = ptRange.at(1) * 1_GeV;
82
83
double
pt = rngEngine->flat() * std::abs(ptMax - ptMin) + ptMin;
84
85
Acts::Vector3 momentum(pt * std::cos(
phi
), pt * std::sin(
phi
),
86
pt * std::sinh(
eta
));
87
88
double
theta
= momentum.theta();
89
90
double
charge
= rngEngine->flat() > 0.5 ? -1 : 1;
91
92
double
qop =
charge
/ momentum.norm();
93
94
auto
surface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Amg::Vector3D::Zero());
95
96
double
t = 0;
97
ATH_MSG_VERBOSE
(
"Pseudo-particle: eta: "
<<
eta
<<
" phi: "
<<
phi
);
98
99
Acts::BoundVector pars;
100
// cppcheck-suppress constStatement; will be able to initialize this directly with eigen 3.4
101
pars << d0, z0,
phi
,
theta
, qop, t;
102
std::optional<Acts::BoundMatrix> cov = std::nullopt;
103
104
if
(
charge
!= 0.) {
105
// Perigee, no alignment -> default geo context
106
Acts::BoundTrackParameters startParameters(std::move(surface), std::move(pars), std::move(cov), Acts::ParticleHypothesis::pion());
107
auto
result =
m_extrapolationTool
->propagationSteps(ctx, startParameters);
108
if
(!result.ok()) {
109
ATH_MSG_WARNING
(
"Extrapolation tool failed to extrapolate the track: "
110
<< result.error().message());
111
continue
;
112
}
113
auto
&output = result.value();
114
if
(output.first.size() == 0) {
115
ATH_MSG_WARNING
(
"Got ZERO steps from the extrapolation tool"
);
116
}
117
if
(
m_writePropStep
) {
118
ATH_CHECK
(
writePropagationSteps
(ctx, output.first));
119
}
120
121
if
(
m_writeMaterialTracks
&& coll){
122
Acts::RecordedMaterialTrack track;
123
track.first.first = Acts::Vector3::Zero();
124
track.first.second = momentum;
125
track.second = std::move(output.second);
126
coll->push_back(std::move(track));
127
}
128
}
129
130
ATH_MSG_VERBOSE
(name() <<
" execute done"
);
131
}
132
133
return
StatusCode::SUCCESS;
134
}
135
136
StatusCode
ExtrapolationTestAlg::writePropagationSteps
(
const
EventContext& ctx,
const
StepVector
& steps) {
137
m_eventNum
= ctx.eventID().event_number();
138
for
(
const
auto
& step : steps) {
139
Acts::GeometryIdentifier::Value volumeID = 0;
140
Acts::GeometryIdentifier::Value boundaryID = 0;
141
Acts::GeometryIdentifier::Value layerID = 0;
142
Acts::GeometryIdentifier::Value approachID = 0;
143
Acts::GeometryIdentifier::Value sensitiveID = 0;
144
// get the identification from the surface first
145
if
(step.surface) {
146
auto
geoID = step.surface->geometryId();
147
sensitiveID = geoID.sensitive();
148
approachID = geoID.approach();
149
layerID = geoID.layer();
150
boundaryID = geoID.boundary();
151
volumeID = geoID.volume();
152
}
153
// a current volume overwrites the surface tagged one
154
if
(step.geoID != Acts::GeometryIdentifier()) {
155
volumeID = step.geoID.volume();
156
}
157
// now fill
158
m_s_sensitiveID
.push_back(sensitiveID);
159
m_s_approachID
.push_back(approachID);
160
m_s_layerID
.push_back(layerID);
161
m_s_boundaryID
.push_back(boundaryID);
162
m_s_volumeID
.push_back(volumeID);
163
164
m_s_pX
.push_back(step.position.x());
165
m_s_pY
.push_back(step.position.y());
166
m_s_pZ
.push_back(step.position.z());
167
m_s_pR
.push_back(Acts::VectorHelpers::perp(step.position));
168
}
169
170
171
172
return
m_tree
.fill(ctx) ? StatusCode::SUCCESS : StatusCode::FAILURE;
173
}
174
175
}
ITrackingGeometrySvc.h
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
ExtrapolationTestAlg.h
GeometryContext.h
Logger.h
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition
RNGWrapper.h:56
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition
RNGWrapper.h:154
ATHRNG::RNGWrapper::getEngine
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition
RNGWrapper.h:108
ActsTrk::ExtrapolationTestAlg::m_trackingGeometrySvc
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Definition
ExtrapolationTestAlg.h:60
ActsTrk::ExtrapolationTestAlg::m_s_pZ
MuonVal::VectorBranch< float > & m_s_pZ
Global z position of the step.
Definition
ExtrapolationTestAlg.h:84
ActsTrk::ExtrapolationTestAlg::m_etaRange
Gaudi::Property< std::vector< double > > m_etaRange
Definition
ExtrapolationTestAlg.h:63
ActsTrk::ExtrapolationTestAlg::m_writePropStep
Gaudi::Property< bool > m_writePropStep
Definition
ExtrapolationTestAlg.h:69
ActsTrk::ExtrapolationTestAlg::m_s_approachID
MuonVal::VectorBranch< int > & m_s_approachID
approach identification
Definition
ExtrapolationTestAlg.h:91
ActsTrk::ExtrapolationTestAlg::m_nParticlePerEvent
Gaudi::Property< size_t > m_nParticlePerEvent
Definition
ExtrapolationTestAlg.h:65
ActsTrk::ExtrapolationTestAlg::m_s_boundaryID
MuonVal::VectorBranch< int > & m_s_boundaryID
boundary identification
Definition
ExtrapolationTestAlg.h:89
ActsTrk::ExtrapolationTestAlg::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
ExtrapolationTestAlg.cxx:49
ActsTrk::ExtrapolationTestAlg::m_s_sensitiveID
MuonVal::VectorBranch< int > & m_s_sensitiveID
sensitive identification
Definition
ExtrapolationTestAlg.h:92
ActsTrk::ExtrapolationTestAlg::m_ptRange
Gaudi::Property< std::vector< double > > m_ptRange
Definition
ExtrapolationTestAlg.h:64
ActsTrk::ExtrapolationTestAlg::m_s_pX
MuonVal::VectorBranch< float > & m_s_pX
Global x position of the step.
Definition
ExtrapolationTestAlg.h:80
ActsTrk::ExtrapolationTestAlg::finalize
virtual StatusCode finalize() override
Definition
ExtrapolationTestAlg.cxx:45
ActsTrk::ExtrapolationTestAlg::m_tree
MuonVal::MuonTesterTree m_tree
Definition
ExtrapolationTestAlg.h:75
ActsTrk::ExtrapolationTestAlg::m_extrapolationTool
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Definition
ExtrapolationTestAlg.h:58
ActsTrk::ExtrapolationTestAlg::m_s_layerID
MuonVal::VectorBranch< int > & m_s_layerID
layer identification
Definition
ExtrapolationTestAlg.h:90
ActsTrk::ExtrapolationTestAlg::m_writeMaterialTracks
Gaudi::Property< bool > m_writeMaterialTracks
Definition
ExtrapolationTestAlg.h:68
ActsTrk::ExtrapolationTestAlg::m_s_pY
MuonVal::VectorBranch< float > & m_s_pY
Global y position of the step.
Definition
ExtrapolationTestAlg.h:82
ActsTrk::ExtrapolationTestAlg::StepVector
std::vector< Acts::detail::Step > StepVector
Definition
ExtrapolationTestAlg.h:53
ActsTrk::ExtrapolationTestAlg::m_eventNum
MuonVal::ScalarBranch< int > & m_eventNum
Definition
ExtrapolationTestAlg.h:78
ActsTrk::ExtrapolationTestAlg::m_materialTrackCollectionKey
SG::WriteHandleKey< ActsTrk::RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to write.
Definition
ExtrapolationTestAlg.h:72
ActsTrk::ExtrapolationTestAlg::writePropagationSteps
StatusCode writePropagationSteps(const EventContext &ctx, const StepVector &steps)
Definition
ExtrapolationTestAlg.cxx:136
ActsTrk::ExtrapolationTestAlg::m_s_pR
MuonVal::VectorBranch< float > & m_s_pR
Global radial position of the step sqrt(x^{2} + y^{2}).
Definition
ExtrapolationTestAlg.h:86
ActsTrk::ExtrapolationTestAlg::initialize
virtual StatusCode initialize() override
Definition
ExtrapolationTestAlg.cxx:33
ActsTrk::ExtrapolationTestAlg::m_rndmGenSvc
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
Definition
ExtrapolationTestAlg.h:56
ActsTrk::ExtrapolationTestAlg::m_s_volumeID
MuonVal::VectorBranch< int > & m_s_volumeID
volume identification
Definition
ExtrapolationTestAlg.h:88
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition
StoreGate/src/VarHandleBase.cxx:400
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition
MdtCalibInput.h:31
Generated on
for ATLAS Offline Software by
1.17.0