ATLAS Offline Software
Loading...
Searching...
No Matches
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
16// std
17#include <cmath>
18
19//================ Constructor =================================================
20
21Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator) :
22 AthAlgorithm(name, pSvcLocator) {}
23
24//================ Destructor =================================================
25
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
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
48
50 // assign the 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) {
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
90 // Code entered here will be executed once at the end of the program run.
91 return StatusCode::SUCCESS;
92}
93
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
113StatusCode Trk::ExtrapolatorTest::execute(const EventContext& ctx) {
115 else for (int i = 0; i < m_eventsPerExecute; ++i) runTest(ctx, m_perigees[i]);
116 return StatusCode::SUCCESS;
117}
118
119void Trk::ExtrapolatorTest::runTest(const EventContext& ctx, const Trk::Perigee& initialPerigee) {
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 =
129 std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIterEnd =
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 =
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
156 ->propagate(ctx,
157 initialPerigee,
158 *destinationSurface,
159 propagationDirection,
160 false,
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//============================================================================================
Scalar eta() const
pseudorapidity method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
double charge(const T &p)
Definition AtlasPID.h:1003
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
Rndm::Numbers * m_gaussDist
Random Number setup.
ToolHandle< IExtrapolator > m_extrapolator
The Extrapolator to be retrieved.
StatusCode initialize()
standard Athena-Algorithm method
ExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
DoubleArrayProperty m_referenceSurfaceRadius
~ExtrapolatorTest()
Default Destructor.
IntegerProperty m_particleType
StatusCode execute(const EventContext &ctx)
standard Athena-Algorithm method
MagneticFieldProperties * m_magFieldProperties
magnetic field properties
std::vector< double > m_referenceSurfaceNegativeBoundary
unsigned int m_referenceSurfaces
member variables for algorithm properties:
PublicToolHandle< IPropagator > m_propagator
Trk::Perigee generatePerigee()
IntegerProperty m_eventsPerExecute
IntegerProperty m_direction
std::vector< Trk::Perigee > m_perigees
void runTest(const EventContext &ctx, const Trk::Perigee &perigee)
BooleanProperty m_useExtrapolator
std::vector< std::vector< const Surface * > > m_referenceSurfaceTriples
Rndm::Numbers * m_flatDist
StatusCode finalize()
standard Athena-Algorithm method
DoubleArrayProperty m_referenceSurfaceHalflength
std::vector< double > m_referenceSurfacePositiveBoundary
magnetic field properties to steer the behavior of the extrapolation
Class describing the Line to which the Perigee refers to.
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
Eigen::Affine3d Transform3D
Eigen::Translation< double, 3 > Translation3D
PropDirection
PropDirection, enum for direction of the propagation.
@ oppositeMomentum
@ alongMomentum
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
MsgStream & msg
Definition testRead.cxx:32