ATLAS Offline Software
CombinedExtrapolatorTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // CombinedExtrapolatorTest.cxx, (c) ATLAS Detector software
8 
9 // Tracking
17 #include "GaudiKernel/SystemOfUnits.h"
18 
19 //================ Constructor =================================================
20 Trk::CombinedExtrapolatorTest::CombinedExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator)
21  :
22  AthAlgorithm(name,pSvcLocator),
23  m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"),
24  m_gaussDist(nullptr),
25  m_flatDist(nullptr),
26  m_sigmaD0(17.*Gaudi::Units::micrometer),
27  m_minZ0(-25000.),
28  m_maxZ0(+25000.),
29  m_minEta(-3.),
30  m_maxEta(3.),
31  m_minP(0.5*Gaudi::Units::GeV),
32  m_maxP(50000.*Gaudi::Units::GeV),
33  m_outerBoundary(nullptr),
34  m_trackingGeometry(nullptr),
35  m_particleType(Trk::muon)
36 {
37  // used algorithms and alg tools
38  declareProperty("Extrapolator", m_extrapolator);
39 
40  // algorithm steering
41  declareProperty("StartPerigeeSigmaD0" , m_sigmaD0);
42  declareProperty("StartPerigeeMinZ0" , m_minZ0);
43  declareProperty("StartPerigeeMaxZ0" , m_maxZ0);
44  declareProperty("StartPerigeeMinEta" , m_minEta);
45  declareProperty("StartPerigeeMaxEta" , m_maxEta);
46  declareProperty("StartPerigeeMinP" , m_minP);
47  declareProperty("StartPerigeeMaxP" , m_maxP);
48  declareProperty("ParticleType" , m_particleType);
49 
50 }
51 
52 //================ Destructor =================================================
53 
55 {
56  delete m_gaussDist;
57  delete m_flatDist;
58 }
59 
60 
61 //================ Initialisation =================================================
62 
64 {
65  // Code entered here will be executed once at program start.
66  msg(MSG::INFO) << " initialize()" << endmsg;
67 
68  // Get Extrapolator from ToolService
69  if (m_extrapolator.retrieve().isFailure()) {
70  msg(MSG::FATAL) << "Could not retrieve Tool " << m_extrapolator << ". Exiting."<<endmsg;
71  return StatusCode::FAILURE;
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  return StatusCode::SUCCESS;
79 }
80 
81 //================ Finalisation =================================================
82 
84 {
85  // Code entered here will be executed once at the end of the program run.
86  return StatusCode::SUCCESS;
87 }
88 
89 //================ Execution ====================================================
90 
92 {
93  msg(MSG::INFO) << " execute()" << endmsg;
94  const EventContext& ctx = Gaudi::Hive::currentContext();
95  // retrieve outer boundary
96  if (!m_outerBoundary) {
97  m_trackingGeometry = m_extrapolator->trackingGeometry();
98  m_outerBoundary = m_trackingGeometry->highestTrackingVolume();
99  if (!m_outerBoundary) {
100  msg(MSG::FATAL) << "Could not retrieve geometry boundary from " << m_extrapolator << ". Exiting."<<endmsg;
101  return StatusCode::FAILURE;
102  }
103  msg(MSG::INFO) << " boundary retrieved " << endmsg;
104  }
105 
106  // generate with random number generator
107  double d0 = m_gaussDist->shoot() * m_sigmaD0;
108  double z0 = m_minZ0 + m_flatDist->shoot() * (m_maxZ0-m_minZ0);
109  double phi = 2.*M_PI * m_flatDist->shoot() - M_PI;
110  //double eta = m_minEta + m_flatDist->shoot()*(m_maxEta-m_minEta);
111  double ctheta = -1. + 2* m_flatDist->shoot();
112  double theta = acos(ctheta);
113  double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP);
114  double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.;
115  double qOverP = charge/(p);
116 
117  // the initial perigee with random numbers
118  const Trk::PerigeeSurface perSurface;
119  Trk::Perigee initialPerigee(d0, z0, phi, theta, qOverP,perSurface);
120  // input covariance matrix
121  const Trk::TrackParameters* seed = initialPerigee.clone();
122 
123  const Trk::PerigeeSurface pSf = initialPerigee.associatedSurface();
124 
125  const Trk::TrackParameters* destParameters = m_extrapolator->extrapolateToVolume(
126  ctx,
127  *seed,
128  *m_outerBoundary,
130  (Trk::ParticleHypothesis)m_particleType).release();
131 
132  if (!destParameters || !m_extrapolator->trackingGeometry()->atVolumeBoundary(destParameters->position(),m_outerBoundary,0.001) ) {
133  msg(MSG::ERROR) << " extrapolation to outer boundary failed for input parameters: " << initialPerigee.parameters() << endmsg;
134 
135  } else {
136  // forward extrapolation ok
137  msg(MSG::INFO) << " outer boundary reached at: " << destParameters->position().perp() <<","<<destParameters->position().z() << endmsg;
138  msg(MSG::INFO) << "cov matrix:"<< destParameters->covariance() << endmsg;
139 
140  const Trk::TrackParameters* peri = m_extrapolator->extrapolate(
141  ctx,
142  *destParameters,
143  pSf,
145  false,
146  (Trk::ParticleHypothesis)m_particleType).release();
147  if ( peri) {
148  msg(MSG::INFO) << " extrapolation to perigee:input: " << initialPerigee.parameters() << endmsg;
149  msg(MSG::INFO) << " extrapolation to perigee:output: " << peri->parameters() << endmsg;
150  msg(MSG::INFO) << "cov matrix:"<< peri->covariance() << endmsg;
151  } else {
152  msg(MSG::ERROR) << " extrapolation to perigee failed for input parameters: " << destParameters->parameters() << endmsg;
153  }
154  delete peri;
155  }
156 
157  delete destParameters;
158 
159  return StatusCode::SUCCESS;
160 }
161 
162 //============================================================================================
163 
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Trk::CombinedExtrapolatorTest::m_maxP
double m_maxP
Maximal p value.
Definition: CombinedExtrapolatorTest.h:66
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PerigeeSurface.h
Trk::CombinedExtrapolatorTest::m_sigmaD0
double m_sigmaD0
Sigma of distribution for D0.
Definition: CombinedExtrapolatorTest.h:60
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
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Trk::CombinedExtrapolatorTest::m_minP
double m_minP
Minimal p value.
Definition: CombinedExtrapolatorTest.h:65
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::z0
@ z0
Definition: ParamDefs.h:64
IExtrapolator.h
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::CombinedExtrapolatorTest::m_particleType
int m_particleType
the particle typre for the extrap.
Definition: CombinedExtrapolatorTest.h:71
Trk::CombinedExtrapolatorTest::CombinedExtrapolatorTest
CombinedExtrapolatorTest(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CombinedExtrapolatorTest.cxx:20
Trk::CombinedExtrapolatorTest::m_maxEta
double m_maxEta
Maximal eta value.
Definition: CombinedExtrapolatorTest.h:64
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::CombinedExtrapolatorTest::m_maxZ0
double m_maxZ0
max Z0
Definition: CombinedExtrapolatorTest.h:62
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::m_minZ0
double m_minZ0
min Z0
Definition: CombinedExtrapolatorTest.h:61
Trk::CombinedExtrapolatorTest::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: CombinedExtrapolatorTest.cxx:83
CylinderSurface.h
Trk::ParametersBase
Definition: ParametersBase.h:55
python.SystemOfUnits.micrometer
int micrometer
Definition: SystemOfUnits.py:71
ParticleHypothesis.h
AthAlgorithm
Definition: AthAlgorithm.h:47
Athena::Units
Definition: Units.h:45
Trk::CombinedExtrapolatorTest::m_minEta
double m_minEta
Minimal eta value.
Definition: CombinedExtrapolatorTest.h:63
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::d0
@ d0
Definition: ParamDefs.h:63
Trk::CombinedExtrapolatorTest::m_extrapolator
ToolHandle< IExtrapolator > m_extrapolator
The Extrapolator to be retrieved.
Definition: CombinedExtrapolatorTest.h:54
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Trk::CombinedExtrapolatorTest::execute
StatusCode execute()
standard Athena-Algorithm method
Definition: CombinedExtrapolatorTest.cxx:91
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
Trk::CombinedExtrapolatorTest::~CombinedExtrapolatorTest
~CombinedExtrapolatorTest()
Default Destructor.
Definition: CombinedExtrapolatorTest.cxx:54
DiscSurface.h
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
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:63