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
{
28
delete
m_gaussDist
;
29
delete
m_flatDist
;
30
// cleanup of the surfaces
31
for
(
const
auto
& surfaceTriple :
m_referenceSurfaceTriples
) {
32
for
(
const
auto
* surface : surfaceTriple) {
33
delete
surface;
34
}
35
}
36
}
37
38
39
//================ Initialisation =================================================
40
41
StatusCode
Trk::ExtrapolatorTest::initialize
()
42
{
43
// Code entered here will be executed once at program start.
44
45
ATH_MSG_INFO
(
" initialize()"
);
46
47
ATH_CHECK
(
m_extrapolator
.retrieve() );
48
ATH_CHECK
(
m_propagator
.retrieve() );
49
50
m_magFieldProperties
=
new
Trk::MagneticFieldProperties
();
51
52
if
(
m_referenceSurfaceRadius
.size() ==
m_referenceSurfaceHalflength
.size()) {
53
// assign the size
54
m_referenceSurfaces
=
m_referenceSurfaceRadius
.size();
55
// loop over it and create the
56
std::vector<double>::iterator radiusIter =
m_referenceSurfaceRadius
.begin();
57
std::vector<double>::iterator radiusIterEnd =
m_referenceSurfaceRadius
.end();
58
std::vector<double>::iterator halfZIter =
m_referenceSurfaceHalflength
.begin();
59
60
for
( ; radiusIter != radiusIterEnd; ++radiusIter, ++halfZIter){
61
// create the Surface triplet
62
std::vector< const Trk::Surface*> surfaceTriplet;
63
surfaceTriplet.push_back(
new
Trk::DiscSurface
(
Amg::Transform3D
(
Amg::Translation3D
(0.,0.,*halfZIter)),0.,*radiusIter));
64
surfaceTriplet.push_back(
new
Trk::CylinderSurface
(
Amg::Transform3D
(),*radiusIter, *halfZIter));
65
surfaceTriplet.push_back(
new
Trk::DiscSurface
(
Amg::Transform3D
(
Amg::Translation3D
(0.,0.,-(*halfZIter))),0.,*radiusIter));
66
67
ATH_MSG_INFO
(
"Creating surfaces: R "
<< *radiusIter <<
" Z "
<< *halfZIter);
68
m_referenceSurfaceTriples
.push_back(std::move(surfaceTriplet));
69
70
m_referenceSurfaceNegativeBoundary
.push_back(atan2(*radiusIter,-(*halfZIter)));
71
m_referenceSurfacePositiveBoundary
.push_back(atan2(*radiusIter,(*halfZIter)));
72
73
}
74
}
75
76
m_gaussDist
=
new
Rndm::Numbers(randSvc(), Rndm::Gauss(0.,1.));
77
m_flatDist
=
new
Rndm::Numbers(randSvc(), Rndm::Flat(0.,1.));
78
79
msg
(MSG::INFO) <<
"initialize() successful in "
<<
endmsg
;
80
81
if
(
m_eventsPerExecute
> 0 ){
82
m_perigees
.reserve(
m_eventsPerExecute
);
83
for
(
int
i=0;i<
m_eventsPerExecute
;++i )
m_perigees
.push_back(
generatePerigee
());
84
}
85
86
return
StatusCode::SUCCESS;
87
}
88
89
//================ Finalisation =================================================
90
91
StatusCode
Trk::ExtrapolatorTest::finalize
()
92
{
93
// Code entered here will be executed once at the end of the program run.
94
return
StatusCode::SUCCESS;
95
}
96
97
Trk::Perigee
Trk::ExtrapolatorTest::generatePerigee
() {
98
// generate with random number generator
99
double
d0
=
m_gaussDist
->shoot() *
m_sigmaD0
;
100
double
z0
=
m_gaussDist
->shoot() *
m_sigmaZ0
;
101
double
phi
=
m_minPhi
+ (
m_maxPhi
-
m_minPhi
)*
m_flatDist
->shoot();
102
double
eta
=
m_minEta
+
m_flatDist
->shoot()*(
m_maxEta
-
m_minEta
);
103
double
theta
= 2.*atan(exp(-
eta
));
104
double
p =
m_minP
+
m_flatDist
->shoot()*(
m_maxP
-
m_minP
);
105
double
charge
= (
m_flatDist
->shoot() > 0.5 ) ? -1. : 1.;
106
double
qOverP
=
charge
/(p);
107
const
Trk::PerigeeSurface
perSurface;
108
return
{
d0
,
z0
,
phi
,
theta
,
qOverP
,perSurface};
109
}
110
111
//================ Execution ====================================================
112
113
StatusCode
Trk::ExtrapolatorTest::execute
(
const
EventContext& ctx)
114
{
115
116
if
(
m_eventsPerExecute
<= 0 )
runTest
(ctx,
generatePerigee
());
117
else
for
(
int
i=0;i<
m_eventsPerExecute
;++i )
runTest
(ctx,
m_perigees
[i]);
118
return
StatusCode::SUCCESS;
119
}
120
121
122
void
Trk::ExtrapolatorTest::runTest
(
const
EventContext& ctx,
const
Trk::Perigee
& initialPerigee ) {
123
Trk::PropDirection
propagationDirection =
m_direction
> 0 ?
Trk::alongMomentum
:
oppositeMomentum
;
124
125
ATH_MSG_VERBOSE
(
"Starting from : "
<< initialPerigee );
126
ATH_MSG_VERBOSE
(
" ---> with direction: "
<< propagationDirection );
127
128
129
130
std::vector< std::vector< const Trk::Surface* > >
::const_iterator
surfaceTripleIter =
m_referenceSurfaceTriples
.begin();
131
std::vector< std::vector< const Trk::Surface* > >
::const_iterator
surfaceTripleIterEnd =
m_referenceSurfaceTriples
.end();
132
133
std::vector<double>::iterator negRefIter =
m_referenceSurfaceNegativeBoundary
.begin();
134
std::vector<double>::iterator posRefIter =
m_referenceSurfacePositiveBoundary
.begin();
135
136
double
theta
= initialPerigee.parameters()[
Trk::theta
];
137
138
for
(
int
refSurface = 0 ; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter, ++negRefIter, ++posRefIter ){
139
// decide which reference surface to take
140
refSurface =
theta
< (*posRefIter) ? 2 : 1;
141
refSurface =
theta
> (*negRefIter) ? 0 : 1;
142
143
const
Trk::Surface
* destinationSurface = (*surfaceTripleIter)[refSurface];
144
145
const
auto
* destParameters =
146
m_useExtrapolator
147
?
m_extrapolator
->extrapolate(
148
ctx,
149
initialPerigee,
150
*destinationSurface,
151
propagationDirection,
152
false
,
153
static_cast<
Trk::ParticleHypothesis
>
(
m_particleType
.value())).release()
154
:
155
156
m_propagator
157
->propagate(ctx,
158
initialPerigee,
159
*destinationSurface,
160
propagationDirection,
161
false
,
162
*
m_magFieldProperties
,
163
static_cast<
Trk::ParticleHypothesis
>
(
m_particleType
.value()))
164
.release();
165
166
if
(destParameters) {
167
// intersection output
168
ATH_MSG_VERBOSE
(
" [ intersection ] with surface at (x,y,z) = "
<<
169
destParameters->position().x() <<
", "
<<
170
destParameters->position().y() <<
", "
<<
171
destParameters->position().z() );
172
}
else
if
(!destParameters)
173
ATH_MSG_DEBUG
(
" Extrapolation not successful! "
);
174
175
delete
destParameters;
176
}
177
}
178
179
//============================================================================================
180
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_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
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:41
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:97
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:122
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:91
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