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
29
30
31//================ Initialisation =================================================
32
34{
35 // Code entered here will be executed once at program start.
36 msg(MSG::INFO) << " initialize()" << endmsg;
37
38 // Get Extrapolator from ToolService
39 if (m_extrapolator.retrieve().isFailure()) {
40 msg(MSG::FATAL) << "Could not retrieve Tool " << m_extrapolator << ". Exiting."<<endmsg;
41 return StatusCode::FAILURE;
42 }
43
44 m_gaussDist = new Rndm::Numbers(randSvc(), Rndm::Gauss(0.,1.));
45 m_flatDist = new Rndm::Numbers(randSvc(), Rndm::Flat(0.,1.));
46
47 msg(MSG::INFO) << "initialize() successful in " << endmsg;
48 return StatusCode::SUCCESS;
49}
50
51//================ Finalisation =================================================
52
54{
55 // Code entered here will be executed once at the end of the program run.
56 return StatusCode::SUCCESS;
57}
58
59//================ Execution ====================================================
60
61StatusCode Trk::CombinedExtrapolatorTest::execute(const EventContext& ctx)
62{
63 msg(MSG::INFO) << " execute()" << endmsg;
64 // retrieve outer boundary
65 if (!m_outerBoundary) {
66 m_trackingGeometry = m_extrapolator->trackingGeometry();
67 m_outerBoundary = m_trackingGeometry->highestTrackingVolume();
68 if (!m_outerBoundary) {
69 msg(MSG::FATAL) << "Could not retrieve geometry boundary from " << m_extrapolator << ". Exiting."<<endmsg;
70 return StatusCode::FAILURE;
71 }
72 msg(MSG::INFO) << " boundary retrieved " << endmsg;
73 }
74
75 // generate with random number generator
76 double d0 = m_gaussDist->shoot() * m_sigmaD0;
77 double z0 = m_minZ0 + m_flatDist->shoot() * (m_maxZ0-m_minZ0);
78 double phi = 2.*M_PI * m_flatDist->shoot() - M_PI;
79 double ctheta = -1. + 2* m_flatDist->shoot();
80 double theta = acos(ctheta);
81 double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP);
82 double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.;
83 double qOverP = charge/(p);
84
85 // the initial perigee with random numbers
86 const Trk::PerigeeSurface perSurface;
87 Trk::Perigee initialPerigee(d0, z0, phi, theta, qOverP,perSurface);
88 // input covariance matrix
89 const Trk::TrackParameters* seed = initialPerigee.clone();
90
91 const Trk::PerigeeSurface& pSf = initialPerigee.associatedSurface();
92
93 const Trk::TrackParameters* destParameters = m_extrapolator->extrapolateToVolume(
94 ctx,
95 *seed,
98 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
99
100 if (!destParameters || !Trk::TrackingGeometry::atVolumeBoundary(destParameters->position(),m_outerBoundary,0.001) ) {
101 msg(MSG::ERROR) << " extrapolation to outer boundary failed for input parameters: " << initialPerigee.parameters() << endmsg;
102
103 } else {
104 // forward extrapolation ok
105 msg(MSG::INFO) << " outer boundary reached at: " << destParameters->position().perp() <<","<<destParameters->position().z() << endmsg;
106 msg(MSG::INFO) << "cov matrix:"<< destParameters->covariance() << endmsg;
107
108 const Trk::TrackParameters* peri = m_extrapolator->extrapolate(
109 ctx,
110 *destParameters,
111 pSf,
113 false,
114 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
115 if ( peri) {
116 msg(MSG::INFO) << " extrapolation to perigee:input: " << initialPerigee.parameters() << endmsg;
117 msg(MSG::INFO) << " extrapolation to perigee:output: " << peri->parameters() << endmsg;
118 msg(MSG::INFO) << "cov matrix:"<< peri->covariance() << endmsg;
119 } else {
120 msg(MSG::ERROR) << " extrapolation to perigee failed for input parameters: " << destParameters->parameters() << endmsg;
121 }
122 delete peri;
123 }
124
125 delete destParameters;
126
127 return StatusCode::SUCCESS;
128}
129
130//============================================================================================
131
#define M_PI
#define endmsg
double charge(const T &p)
Definition AtlasPID.h:997
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