Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 =================================================
18 Trk::CombinedExtrapolatorTest::CombinedExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator)
19  :
20  AthAlgorithm(name,pSvcLocator) {}
21 
22 //================ Destructor =================================================
23 
25 {
26  delete m_gaussDist;
27  delete m_flatDist;
28 }
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,
97  *m_outerBoundary,
99  static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release();
100 
101  if (!destParameters || !m_extrapolator->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 
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:18
PerigeeSurface.h
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::z0
@ z0
Definition: ParamDefs.h:64
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::CombinedExtrapolatorTest::CombinedExtrapolatorTest
CombinedExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CombinedExtrapolatorTest.cxx:18
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::theta
@ theta
Definition: ParamDefs.h:66
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::CombinedExtrapolatorTest::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: CombinedExtrapolatorTest.cxx:53
CylinderSurface.h
Trk::ParametersBase
Definition: ParametersBase.h:55
ParticleHypothesis.h
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::d0
@ d0
Definition: ParamDefs.h:63
charge
double charge(const T &p)
Definition: AtlasPID.h:931
Trk::CombinedExtrapolatorTest::execute
StatusCode execute()
standard Athena-Algorithm method
Definition: CombinedExtrapolatorTest.cxx:61
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
Trk::CombinedExtrapolatorTest::~CombinedExtrapolatorTest
~CombinedExtrapolatorTest()
Default Destructor.
Definition: CombinedExtrapolatorTest.cxx:24
DiscSurface.h
CombinedExtrapolatorTest.h
TrackingGeometry.h
Trk::phi
@ phi
Definition: ParamDefs.h:75
Trk::ParametersT::clone
virtual ParametersT< DIM, T, S > * clone() const override final
Virtual clone.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Trk::CombinedExtrapolatorTest::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: CombinedExtrapolatorTest.cxx:33