ATLAS Offline Software
Loading...
Searching...
No Matches
CombinedExtrapolatorTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
6// CombinedExtrapolatorTest.cxx, (c) ATLAS Detector software
8
9// Tracking
16
17//================ Constructor =================================================
18Trk::CombinedExtrapolatorTest::CombinedExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator)
19 :
20 AthAlgorithm(name, pSvcLocator) {}
21
22//================ Destructor =================================================
23
28
29//================ Initialisation =================================================
30
32 // Code entered here will be executed once at program start.
33 msg(MSG::INFO) << " initialize()" << endmsg;
34
35 // Get Extrapolator from ToolService
36 if (m_extrapolator.retrieve().isFailure()) {
37 msg(MSG::FATAL) << "Could not retrieve Tool " << m_extrapolator << ". Exiting." << endmsg;
38 return StatusCode::FAILURE;
39 }
40
41 m_gaussDist = new Rndm::Numbers(randSvc(), Rndm::Gauss(0., 1.));
42 m_flatDist = new Rndm::Numbers(randSvc(), Rndm::Flat(0., 1.));
43
44 msg(MSG::INFO) << "initialize() successful in " << endmsg;
45 return StatusCode::SUCCESS;
46}
47
48//================ Finalisation =================================================
49
51 // Code entered here will be executed once at the end of the program run.
52 return StatusCode::SUCCESS;
53}
54
55//================ Execution ====================================================
56
57StatusCode Trk::CombinedExtrapolatorTest::execute(const EventContext& ctx) {
58 msg(MSG::INFO) << " execute()" << endmsg;
59 // retrieve outer boundary
60 if (!m_outerBoundary) {
61 m_trackingGeometry = m_extrapolator->trackingGeometry();
62 m_outerBoundary = m_trackingGeometry->highestTrackingVolume();
63 if (!m_outerBoundary) {
64 msg(MSG::FATAL) << "Could not retrieve geometry boundary from " << m_extrapolator << ". Exiting." << endmsg;
65 return StatusCode::FAILURE;
66 }
67 msg(MSG::INFO) << " boundary retrieved " << endmsg;
68 }
69
70 // generate with random number generator
71 double d0 = m_gaussDist->shoot() * m_sigmaD0;
72 double z0 = m_minZ0 + m_flatDist->shoot() * (m_maxZ0 - m_minZ0);
73 double phi = 2. * M_PI * m_flatDist->shoot() - M_PI;
74 double ctheta = -1. + 2 * m_flatDist->shoot();
75 double theta = acos(ctheta);
76 double p = m_minP + m_flatDist->shoot() * (m_maxP - m_minP);
77 double charge = (m_flatDist->shoot() > 0.5) ? -1. : 1.;
78 double qOverP = charge / (p);
79
80 // the initial perigee with random numbers
81 const Trk::PerigeeSurface perSurface;
82 Trk::Perigee initialPerigee(d0, z0, phi, theta, qOverP, perSurface);
83 // input covariance matrix
84 const Trk::TrackParameters* seed = initialPerigee.clone();
85
86 const Trk::PerigeeSurface& pSf = initialPerigee.associatedSurface();
87
88 const Trk::TrackParameters* destParameters = m_extrapolator->extrapolateToVolume(
89 ctx,
90 *seed,
93 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
94
95 if (!destParameters || !Trk::TrackingGeometry::atVolumeBoundary(destParameters->position(), m_outerBoundary, 0.001)) {
96 msg(MSG::ERROR) << " extrapolation to outer boundary failed for input parameters: " <<
97 initialPerigee.parameters() << endmsg;
98 } else {
99 // forward extrapolation ok
100 msg(MSG::INFO) << " outer boundary reached at: " << destParameters->position().perp() << "," <<
101 destParameters->position().z() << endmsg;
102 msg(MSG::INFO) << "cov matrix:" << destParameters->covariance() << endmsg;
103
104 const Trk::TrackParameters* peri = m_extrapolator->extrapolate(
105 ctx,
106 *destParameters,
107 pSf,
109 false,
110 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
111 if (peri) {
112 msg(MSG::INFO) << " extrapolation to perigee:input: " << initialPerigee.parameters() << endmsg;
113 msg(MSG::INFO) << " extrapolation to perigee:output: " << peri->parameters() << endmsg;
114 msg(MSG::INFO) << "cov matrix:" << peri->covariance() << endmsg;
115 } else {
116 msg(MSG::ERROR) << " extrapolation to perigee failed for input parameters: " << destParameters->parameters() <<
117 endmsg;
118 }
119 delete peri;
120 }
121
122 delete destParameters;
123
124 return StatusCode::SUCCESS;
125}
126
127//============================================================================================
#define M_PI
#define endmsg
double charge(const T &p)
Definition AtlasPID.h:1003
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
StatusCode initialize()
standard Athena-Algorithm method
const Trk::TrackingVolume * m_outerBoundary
StatusCode finalize()
standard Athena-Algorithm method
StatusCode execute(const EventContext &ctx)
standard Athena-Algorithm method
const Trk::TrackingGeometry * m_trackingGeometry
Rndm::Numbers * m_gaussDist
Random Number setup.
ToolHandle< IExtrapolator > m_extrapolator
The Extrapolator to be retrieved.
CombinedExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
const Amg::Vector3D & position() const
Access method for the position.
virtual ParametersT< DIM, T, S > * clone() const override final
Virtual clone.
virtual const S & associatedSurface() const override final
Access to the Surface method.
Class describing the Line to which the Perigee refers to.
static bool atVolumeBoundary(const Amg::Vector3D &gp, const TrackingVolume *vol, double tol)
check position at volume boundary
@ 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.
ParametersBase< TrackParametersDim, Charged > TrackParameters
MsgStream & msg
Definition testRead.cxx:32