ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkExtrapolation
TrkExAlgs
src
ExtrapolatorTest.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
// ExtrapolatorTest.cxx, (c) ATLAS Detector software
8
9
// Tracking
10
#include "
TrkExAlgs/ExtrapolatorTest.h
"
11
#include "
TrkSurfaces/CylinderSurface.h
"
12
#include "
TrkSurfaces/DiscSurface.h
"
13
#include "
TrkEventPrimitives/ParticleHypothesis.h
"
14
#include "
EventPrimitives/EventPrimitives.h
"
15
#include "
TrkGeometry/MagneticFieldProperties.h
"
16
// std
17
#include <cmath>
18
19
//================ Constructor =================================================
20
21
Trk::ExtrapolatorTest::ExtrapolatorTest
(
const
std::string& name, ISvcLocator* pSvcLocator) :
22
AthAlgorithm
(name, pSvcLocator) {}
23
24
//================ Destructor =================================================
25
26
Trk::ExtrapolatorTest::~ExtrapolatorTest
() {
27
delete
m_gaussDist
;
28
delete
m_flatDist
;
29
// cleanup of the surfaces
30
for
(
const
auto
& surfaceTriple :
m_referenceSurfaceTriples
) {
31
for
(
const
auto
* surface : surfaceTriple) {
32
delete
surface;
33
}
34
}
35
}
36
37
//================ Initialisation =================================================
38
39
StatusCode
Trk::ExtrapolatorTest::initialize
() {
40
// Code entered here will be executed once at program start.
41
42
ATH_MSG_INFO
(
" initialize()"
);
43
44
ATH_CHECK
(
m_extrapolator
.retrieve());
45
ATH_CHECK
(
m_propagator
.retrieve());
46
47
m_magFieldProperties
=
new
Trk::MagneticFieldProperties
();
48
49
if
(
m_referenceSurfaceRadius
.size() ==
m_referenceSurfaceHalflength
.size()) {
50
// assign the size
51
m_referenceSurfaces
=
m_referenceSurfaceRadius
.size();
52
// loop over it and create the
53
std::vector<double>::iterator radiusIter =
m_referenceSurfaceRadius
.begin();
54
std::vector<double>::iterator radiusIterEnd =
m_referenceSurfaceRadius
.end();
55
std::vector<double>::iterator halfZIter =
m_referenceSurfaceHalflength
.begin();
56
57
for
(; radiusIter != radiusIterEnd; ++radiusIter, ++halfZIter) {
58
// create the Surface triplet
59
std::vector< const Trk::Surface*> surfaceTriplet;
60
surfaceTriplet.push_back(
new
Trk::DiscSurface
(
Amg::Transform3D
(
Amg::Translation3D
(0., 0., *halfZIter)), 0.,
61
*radiusIter));
62
surfaceTriplet.push_back(
new
Trk::CylinderSurface
(
Amg::Transform3D
(), *radiusIter, *halfZIter));
63
surfaceTriplet.push_back(
new
Trk::DiscSurface
(
Amg::Transform3D
(
Amg::Translation3D
(0., 0., -(*halfZIter))), 0.,
64
*radiusIter));
65
66
ATH_MSG_INFO
(
"Creating surfaces: R "
<< *radiusIter <<
" Z "
<< *halfZIter);
67
m_referenceSurfaceTriples
.push_back(std::move(surfaceTriplet));
68
69
m_referenceSurfaceNegativeBoundary
.push_back(atan2(*radiusIter, -(*halfZIter)));
70
m_referenceSurfacePositiveBoundary
.push_back(atan2(*radiusIter, (*halfZIter)));
71
}
72
}
73
74
m_gaussDist
=
new
Rndm::Numbers(randSvc(), Rndm::Gauss(0., 1.));
75
m_flatDist
=
new
Rndm::Numbers(randSvc(), Rndm::Flat(0., 1.));
76
77
msg
(MSG::INFO) <<
"initialize() successful in "
<<
endmsg
;
78
79
if
(
m_eventsPerExecute
> 0) {
80
m_perigees
.reserve(
m_eventsPerExecute
);
81
for
(
int
i = 0; i <
m_eventsPerExecute
; ++i)
m_perigees
.push_back(
generatePerigee
());
82
}
83
84
return
StatusCode::SUCCESS;
85
}
86
87
//================ Finalisation =================================================
88
89
StatusCode
Trk::ExtrapolatorTest::finalize
() {
90
// Code entered here will be executed once at the end of the program run.
91
return
StatusCode::SUCCESS;
92
}
93
94
Trk::Perigee
Trk::ExtrapolatorTest::generatePerigee
() {
95
// generate with random number generator
96
double
d0
=
m_gaussDist
->shoot() *
m_sigmaD0
;
97
double
z0
=
m_gaussDist
->shoot() *
m_sigmaZ0
;
98
double
phi
=
m_minPhi
+ (
m_maxPhi
-
m_minPhi
) *
m_flatDist
->shoot();
99
double
eta
=
m_minEta
+
m_flatDist
->shoot() * (
m_maxEta
-
m_minEta
);
100
double
theta
= 2. * atan(exp(-
eta
));
101
double
p =
m_minP
+
m_flatDist
->shoot() * (
m_maxP
-
m_minP
);
102
double
charge
= (
m_flatDist
->shoot() > 0.5) ? -1. : 1.;
103
double
qOverP
=
charge
/ (p);
104
const
Trk::PerigeeSurface
perSurface;
105
106
return
{
107
d0
,
z0
,
phi
,
theta
,
qOverP
, perSurface
108
};
109
}
110
111
//================ Execution ====================================================
112
113
StatusCode
Trk::ExtrapolatorTest::execute
(
const
EventContext& ctx) {
114
if
(
m_eventsPerExecute
<= 0)
runTest
(ctx,
generatePerigee
());
115
else
for
(
int
i = 0; i <
m_eventsPerExecute
; ++i)
runTest
(ctx,
m_perigees
[i]);
116
return
StatusCode::SUCCESS;
117
}
118
119
void
Trk::ExtrapolatorTest::runTest
(
const
EventContext& ctx,
const
Trk::Perigee
& initialPerigee) {
120
Trk::PropDirection
propagationDirection =
m_direction
> 0 ?
Trk::alongMomentum
:
oppositeMomentum
;
121
122
ATH_MSG_VERBOSE
(
"Starting from : "
<< initialPerigee);
123
ATH_MSG_VERBOSE
(
" ---> with direction: "
<< propagationDirection);
124
125
126
127
std::vector< std::vector< const Trk::Surface* > >
::const_iterator
surfaceTripleIter =
128
m_referenceSurfaceTriples
.begin();
129
std::vector< std::vector< const Trk::Surface* > >
::const_iterator
surfaceTripleIterEnd =
130
m_referenceSurfaceTriples
.end();
131
132
std::vector<double>::iterator negRefIter =
m_referenceSurfaceNegativeBoundary
.begin();
133
std::vector<double>::iterator posRefIter =
m_referenceSurfacePositiveBoundary
.begin();
134
135
double
theta
= initialPerigee.parameters()[
Trk::theta
];
136
137
for
(
int
refSurface = 0; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter, ++negRefIter, ++posRefIter) {
138
// decide which reference surface to take
139
refSurface =
theta
< (*posRefIter) ? 2 : 1;
140
refSurface =
theta
> (*negRefIter) ? 0 : 1;
141
142
const
Trk::Surface
* destinationSurface = (*surfaceTripleIter)[refSurface];
143
144
const
auto
* destParameters =
145
m_useExtrapolator
146
?
m_extrapolator
->extrapolate(
147
ctx,
148
initialPerigee,
149
*destinationSurface,
150
propagationDirection,
151
false
,
152
static_cast<
Trk::ParticleHypothesis
>
(
m_particleType
.value())).release()
153
:
154
155
m_propagator
156
->propagate(ctx,
157
initialPerigee,
158
*destinationSurface,
159
propagationDirection,
160
false
,
161
*
m_magFieldProperties
,
162
static_cast<
Trk::ParticleHypothesis
>
(
m_particleType
.value()))
163
.release();
164
165
if
(destParameters) {
166
// intersection output
167
ATH_MSG_VERBOSE
(
" [ intersection ] with surface at (x,y,z) = "
<<
168
destParameters->position().x() <<
", "
<<
169
destParameters->position().y() <<
", "
<<
170
destParameters->position().z());
171
}
else
if
(!destParameters)
ATH_MSG_DEBUG
(
" Extrapolation not successful! "
);
172
173
delete
destParameters;
174
}
175
}
176
177
//============================================================================================
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
CylinderSurface.h
DiscSurface.h
EventPrimitives.h
ExtrapolatorTest.h
MagneticFieldProperties.h
ParticleHypothesis.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
const_iterator
Trk::CylinderSurface
Class for a CylinderSurface in the ATLAS detector.
Definition
CylinderSurface.h:55
Trk::DiscSurface
Class for a DiscSurface in the ATLAS detector.
Definition
DiscSurface.h:54
Trk::ExtrapolatorTest::m_gaussDist
Rndm::Numbers * m_gaussDist
Random Number setup.
Definition
ExtrapolatorTest.h:76
Trk::ExtrapolatorTest::m_extrapolator
ToolHandle< IExtrapolator > m_extrapolator
The Extrapolator to be retrieved.
Definition
ExtrapolatorTest.h:70
Trk::ExtrapolatorTest::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition
ExtrapolatorTest.cxx:39
Trk::ExtrapolatorTest::ExtrapolatorTest
ExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition
ExtrapolatorTest.cxx:21
Trk::ExtrapolatorTest::m_sigmaD0
DoubleProperty m_sigmaD0
Definition
ExtrapolatorTest.h:80
Trk::ExtrapolatorTest::m_referenceSurfaceRadius
DoubleArrayProperty m_referenceSurfaceRadius
Definition
ExtrapolatorTest.h:100
Trk::ExtrapolatorTest::m_maxEta
DoubleProperty m_maxEta
Definition
ExtrapolatorTest.h:86
Trk::ExtrapolatorTest::~ExtrapolatorTest
~ExtrapolatorTest()
Default Destructor.
Definition
ExtrapolatorTest.cxx:26
Trk::ExtrapolatorTest::m_particleType
IntegerProperty m_particleType
Definition
ExtrapolatorTest.h:94
Trk::ExtrapolatorTest::execute
StatusCode execute(const EventContext &ctx)
standard Athena-Algorithm method
Definition
ExtrapolatorTest.cxx:113
Trk::ExtrapolatorTest::m_maxP
DoubleProperty m_maxP
Definition
ExtrapolatorTest.h:90
Trk::ExtrapolatorTest::m_magFieldProperties
MagneticFieldProperties * m_magFieldProperties
magnetic field properties
Definition
ExtrapolatorTest.h:73
Trk::ExtrapolatorTest::m_referenceSurfaceNegativeBoundary
std::vector< double > m_referenceSurfaceNegativeBoundary
Definition
ExtrapolatorTest.h:105
Trk::ExtrapolatorTest::m_referenceSurfaces
unsigned int m_referenceSurfaces
member variables for algorithm properties:
Definition
ExtrapolatorTest.h:97
Trk::ExtrapolatorTest::m_minEta
DoubleProperty m_minEta
Definition
ExtrapolatorTest.h:85
Trk::ExtrapolatorTest::m_propagator
PublicToolHandle< IPropagator > m_propagator
Definition
ExtrapolatorTest.h:72
Trk::ExtrapolatorTest::generatePerigee
Trk::Perigee generatePerigee()
Definition
ExtrapolatorTest.cxx:94
Trk::ExtrapolatorTest::m_eventsPerExecute
IntegerProperty m_eventsPerExecute
Definition
ExtrapolatorTest.h:110
Trk::ExtrapolatorTest::m_sigmaZ0
DoubleProperty m_sigmaZ0
Definition
ExtrapolatorTest.h:82
Trk::ExtrapolatorTest::m_direction
IntegerProperty m_direction
Definition
ExtrapolatorTest.h:92
Trk::ExtrapolatorTest::m_minPhi
DoubleProperty m_minPhi
Definition
ExtrapolatorTest.h:83
Trk::ExtrapolatorTest::m_maxPhi
DoubleProperty m_maxPhi
Definition
ExtrapolatorTest.h:84
Trk::ExtrapolatorTest::m_perigees
std::vector< Trk::Perigee > m_perigees
Definition
ExtrapolatorTest.h:108
Trk::ExtrapolatorTest::runTest
void runTest(const EventContext &ctx, const Trk::Perigee &perigee)
Definition
ExtrapolatorTest.cxx:119
Trk::ExtrapolatorTest::m_minP
DoubleProperty m_minP
Definition
ExtrapolatorTest.h:88
Trk::ExtrapolatorTest::m_useExtrapolator
BooleanProperty m_useExtrapolator
Definition
ExtrapolatorTest.h:111
Trk::ExtrapolatorTest::m_referenceSurfaceTriples
std::vector< std::vector< const Surface * > > m_referenceSurfaceTriples
Definition
ExtrapolatorTest.h:103
Trk::ExtrapolatorTest::m_flatDist
Rndm::Numbers * m_flatDist
Definition
ExtrapolatorTest.h:77
Trk::ExtrapolatorTest::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition
ExtrapolatorTest.cxx:89
Trk::ExtrapolatorTest::m_referenceSurfaceHalflength
DoubleArrayProperty m_referenceSurfaceHalflength
Definition
ExtrapolatorTest.h:102
Trk::ExtrapolatorTest::m_referenceSurfacePositiveBoundary
std::vector< double > m_referenceSurfacePositiveBoundary
Definition
ExtrapolatorTest.h:106
Trk::MagneticFieldProperties
magnetic field properties to steer the behavior of the extrapolation
Definition
MagneticFieldProperties.h:31
Trk::PerigeeSurface
Class describing the Line to which the Perigee refers to.
Definition
PerigeeSurface.h:43
Trk::Surface
Abstract Base Class for tracking surfaces.
Definition
Surface.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition
GeoPrimitives.h:46
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition
GeoPrimitives.h:44
Trk::PropDirection
PropDirection
PropDirection, enum for direction of the propagation.
Definition
PropDirection.h:19
Trk::oppositeMomentum
@ oppositeMomentum
Definition
PropDirection.h:21
Trk::alongMomentum
@ alongMomentum
Definition
PropDirection.h:20
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
Trk::theta
@ theta
Definition
ParamDefs.h:66
Trk::qOverP
@ qOverP
perigee
Definition
ParamDefs.h:67
Trk::phi
@ phi
Definition
ParamDefs.h:75
Trk::d0
@ d0
Definition
ParamDefs.h:63
Trk::z0
@ z0
Definition
ParamDefs.h:64
Trk::ParticleHypothesis
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
Definition
ParticleHypothesis.h:28
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0