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
62{
63 msg(MSG::INFO) << " execute()" << endmsg;
64 const EventContext& ctx = Gaudi::Hive::currentContext();
65 // retrieve outer boundary
66 if (!m_outerBoundary) {
67 m_trackingGeometry = m_extrapolator->trackingGeometry();
68 m_outerBoundary = m_trackingGeometry->highestTrackingVolume();
69 if (!m_outerBoundary) {
70 msg(MSG::FATAL) << "Could not retrieve geometry boundary from " << m_extrapolator << ". Exiting."<<endmsg;
71 return StatusCode::FAILURE;
72 }
73 msg(MSG::INFO) << " boundary retrieved " << endmsg;
74 }
75
76 // generate with random number generator
77 double d0 = m_gaussDist->shoot() * m_sigmaD0;
78 double z0 = m_minZ0 + m_flatDist->shoot() * (m_maxZ0-m_minZ0);
79 double phi = 2.*M_PI * m_flatDist->shoot() - M_PI;
80 double ctheta = -1. + 2* m_flatDist->shoot();
81 double theta = acos(ctheta);
82 double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP);
83 double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.;
84 double qOverP = charge/(p);
85
86 // the initial perigee with random numbers
87 const Trk::PerigeeSurface perSurface;
88 Trk::Perigee initialPerigee(d0, z0, phi, theta, qOverP,perSurface);
89 // input covariance matrix
90 const Trk::TrackParameters* seed = initialPerigee.clone();
91
92 const Trk::PerigeeSurface& pSf = initialPerigee.associatedSurface();
93
94 const Trk::TrackParameters* destParameters = m_extrapolator->extrapolateToVolume(
95 ctx,
96 *seed,
99 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
100
101 if (!destParameters || !Trk::TrackingGeometry::atVolumeBoundary(destParameters->position(),m_outerBoundary,0.001) ) {
102 msg(MSG::ERROR) << " extrapolation to outer boundary failed for input parameters: " << initialPerigee.parameters() << endmsg;
103
104 } else {
105 // forward extrapolation ok
106 msg(MSG::INFO) << " outer boundary reached at: " << destParameters->position().perp() <<","<<destParameters->position().z() << endmsg;
107 msg(MSG::INFO) << "cov matrix:"<< destParameters->covariance() << endmsg;
108
109 const Trk::TrackParameters* peri = m_extrapolator->extrapolate(
110 ctx,
111 *destParameters,
112 pSf,
114 false,
115 static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
116 if ( peri) {
117 msg(MSG::INFO) << " extrapolation to perigee:input: " << initialPerigee.parameters() << endmsg;
118 msg(MSG::INFO) << " extrapolation to perigee:output: " << peri->parameters() << endmsg;
119 msg(MSG::INFO) << "cov matrix:"<< peri->covariance() << endmsg;
120 } else {
121 msg(MSG::ERROR) << " extrapolation to perigee failed for input parameters: " << destParameters->parameters() << endmsg;
122 }
123 delete peri;
124 }
125
126 delete destParameters;
127
128 return StatusCode::SUCCESS;
129}
130
131//============================================================================================
132
#define M_PI
#define endmsg
double charge(const T &p)
Definition AtlasPID.h:997
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
StatusCode initialize()
standard Athena-Algorithm method
const Trk::TrackingVolume * m_outerBoundary
StatusCode finalize()
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.
StatusCode execute()
standard Athena-Algorithm method
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