Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PropagationEngine.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 // PropagationEngine.cxx, (c) ATLAS Detector software
8 
9 // STL
10 #include <sstream>
11 // Trk include
14 #include "TrkSurfaces/Surface.h"
16 //https://svnweb.cern.ch/trac/atlasoff/browser/Tracking/TrkEvent/TrkEventPrimitives/trunk/TrkEventPrimitives/PropDirection.h
17 
18 // constructor
19 Trk::PropagationEngine::PropagationEngine(const std::string& t, const std::string& n, const IInterface* p)
20 : AthAlgTool(t,n,p)
21 {
22  declareInterface<Trk::IPropagationEngine>(this);
23 }
24 
25 // destructor
27 = default;
28 
29 
30 // the interface method initialize
32 {
33  m_sopPrefix = m_sopPrefix_prop;
34  m_sopPostfix = m_sopPostfix_prop;
35 
36  if (m_propagator.retrieve().isFailure()){
37  EX_MSG_FATAL( "", "initialize", "", "failed to retrieve propagator '"<< m_propagator << "'. Aborting." );
38  return StatusCode::FAILURE;
39  } else
40  EX_MSG_DEBUG( "", "initialize", "", "successfully retrieved '" << m_propagator << "'." );
41 
42  EX_MSG_DEBUG( "", "initialize", "", "successful" );
43  return StatusCode::SUCCESS;
44 }
45 
46 // the interface method finalize
48 {
49  EX_MSG_DEBUG( "", "finalize", "", "successful" );
50  return StatusCode::SUCCESS;
51 }
52 
53 
56  const Trk::Surface& sf,
57  Trk::PropDirection pDir,
58  Trk::BoundaryCheck bcheck,
59  bool returnCurvilinear) const
60 {
61  EX_MSG_DEBUG(++eCell.navigationStep, "propagate", "char", "propagation engine called with charged parameters with propagation direction " << pDir );
62 
63  double propLength = -1.;
65  // the path limit
66  propLength = eCell.pathLimit > 0 ? (eCell.pathLimit-eCell.pathLength) : eCell.pathLimit;
67  EX_MSG_VERBOSE(eCell.navigationStep, "propagate", "char", "available step length for this propagation " << propLength );
68  }
69  // it is the final propagation if it is the endSurface
70  bool finalPropagation = (eCell.endSurface == (&sf));
71 
72  std::optional<Trk::TransportJacobian> tjac{};
73  // we need to first fill the propagation parameters in order to be able to updates & fallbacks
74  //release, otherwise need to change the Trk::ExCell code
75  auto *pParameters = m_propagator->propagate(
76  Gaudi::Hive::currentContext(),
77  *eCell.leadParameters,
78  sf,
79  pDir,
80  bcheck,
81  eCell.mFieldMode,
82  tjac,
83  propLength,
84  eCell.pHypothesis,
85  returnCurvilinear).release();
86  // set the return type according to how the propagation went
87  if (pParameters){
88  // cache the last lead parameters, useful in case a navigation error occured
89  eCell.lastLeadParameters = eCell.leadParameters;
90  // assign the lead and end parameters
91  eCell.leadParameters = pParameters;
92  // check what to do with the path Length
94  // add the new propagation length to the path length
95  eCell.pathLength += propLength;
96  // check if Limit reached
97  if (eCell.pathLimitReached(m_pathLimitTolerance)){
98  EX_MSG_VERBOSE(eCell.navigationStep, "propagate", "char", "path limit of " << eCell.pathLimit << " successfully reached -> stopping." );
100  }
101  }
102 
103  // check if the propagation was called with directly, then lead parameters become end parameters
105  eCell.endParameters = eCell.leadParameters;
106 
107  // return Success only if it is the final propagation - the extrapolation engine knows that
109  }
110  // return - recovered means that the leadParameters are the input ones
112 }
113 
116  const Trk::Surface& sf,
117  Trk::PropDirection pDir,
118  Trk::BoundaryCheck bcheck,
119  bool returnCurvilinear) const
120 {
121  EX_MSG_DEBUG(++eCell.navigationStep, "propagate", "neut", "propagation engine called with neutral parameters with propagation direction " << pDir );
122  // leave this for the moment, can re replaced by an appropriate propagator call later
123  if (eCell.leadParameters->covariance()){
124  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "propagation of neutral parameters with covariances requested. This is not supported for the moment.");
125  }
126  // the pathLimit cache so far
127  double cPath = eCell.pathLength;
128  // it is the final propagation if it is the endSurface
129  bool finalPropagation = (eCell.endSurface == (&sf));
130  // intersect the surface
131  Trk::Intersection sfIntersection = (pDir!=Trk::anyDirection) ? sf.straightLineIntersection(eCell.leadParameters->position(),
132  pDir*eCell.leadParameters->momentum().unit(),
133  true, bcheck) :
134  sf.straightLineIntersection(eCell.leadParameters->position(),
135  eCell.leadParameters->momentum().unit(),
136  false, bcheck);
137  // we have a valid intersection
138  if (sfIntersection.valid){
139  // fill the transport information - only if the propation direction is not 0 ('anyDirection')
140  if (pDir!=Trk::anyDirection){
141  double pLength = (sfIntersection.position-eCell.leadParameters->position()).mag();
142  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "path length of " << pLength << " added to the extrapolation cell (limit = " << eCell.pathLimit << ")" );
143  eCell.stepTransport(sf,pLength);
144  }
145  // now check if it is valud it's further away than the pathLimit
146  if (eCell.pathLimitReached(m_pathLimitTolerance)){
147  // cache the last lead parameters
148  eCell.lastLeadParameters = eCell.leadParameters;
149  // create new neutral curvilinear parameters at the path limit reached
150  double pDiff = eCell.pathLimit - cPath;
151  eCell.leadParameters = new Trk::NeutralCurvilinearParameters(eCell.leadParameters->position()+pDiff*eCell.leadParameters->momentum().unit(),
152  eCell.leadParameters->momentum(),
153  0.);
154  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "path limit of " << eCell.pathLimit << " reached. Stopping extrapolation.");
156  }
157  // cache the last lead parameters
158  eCell.lastLeadParameters = eCell.leadParameters;
159  // now exchange the lead parameters
160  // create the new curvilinear paramters at the surface intersection -> if so, trigger the success
161  eCell.leadParameters = returnCurvilinear ? new Trk::NeutralCurvilinearParameters(sfIntersection.position, eCell.leadParameters->momentum(), 0.) :
162  sf.createUniqueNeutralParameters(sfIntersection.position, eCell.leadParameters->momentum(), 0.).release();
163 
164  // check if the propagation was called with directly, then lead parameters become end parameters
166  eCell.endParameters = eCell.leadParameters;
167 
168  // return success for the final destination or in progress
170 
171  } else {
172  // give some screen output
173  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "intersection with the surface did not succeed.");
174  }
175  // return - recovered means that the leadParameters are the input ones
177 }
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
Trk::Intersection
Definition: Intersection.h:24
Trk::PropagationEngine::propagate
virtual ExtrapolationCode propagate(ExCellCharged &ecCell, const Surface &sf, PropDirection dir=alongMomentum, BoundaryCheck bcheck=true, bool returnCurvilinear=true) const
resolve the boundary situation - for charged particles
Definition: PropagationEngine.cxx:55
Surface.h
Trk::ExtrapolationCell::pHypothesis
ParticleHypothesis pHypothesis
what particle hypothesis to be used, default : pion
Definition: ExtrapolationCell.h:279
Trk::ExtrapolationMode::StopWithPathLimit
@ StopWithPathLimit
Definition: ExtrapolationCell.h:50
Trk::PropagationEngine::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: PropagationEngine.cxx:47
Trk::ExtrapolationCell::stepTransport
void stepTransport(const Surface &sf, double pathLength=0., const TransportJacobian *tjac=nullptr)
fill transport information - path length and TransportJacobian
Definition: ExtrapolationCell.h:568
PropDirection.h
IPropagator.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::ExtrapolationCell::pathLimitReached
bool pathLimitReached(double tolerance=0.001) const
the materialLimitReached
Definition: ExtrapolationCell.h:397
Trk::ExtrapolationCode::SuccessDestination
@ SuccessDestination
Definition: ExtrapolationCell.h:112
Trk::ExtrapolationCode::FailureDestination
@ FailureDestination
Definition: ExtrapolationCell.h:120
Trk::ExtrapolationCell::pathLength
double pathLength
the path length accumulated
Definition: ExtrapolationCell.h:269
Trk::ExtrapolationCell::navigationStep
int navigationStep
a counter of the navigation Step
Definition: ExtrapolationCell.h:268
Trk::PropagationEngine::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: PropagationEngine.cxx:31
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
EX_MSG_FATAL
#define EX_MSG_FATAL(navstep, step, idx, x)
Definition: ExtrapolationMacros.h:16
Trk::ExtrapolationCode::Recovered
@ Recovered
Definition: ExtrapolationCell.h:119
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::NeutralCurvilinearParameters
CurvilinearParametersT< NeutralParametersDim, Neutral, PlaneSurface > NeutralCurvilinearParameters
Definition: NeutralParameters.h:27
Trk::ExtrapolationCode
Definition: ExtrapolationCell.h:105
Trk::ExtrapolationCell::endParameters
T * endParameters
by pointer - are newly created and can be optionally 0
Definition: ExtrapolationCell.h:238
Trk::ExtrapolationCode::SuccessPathLimit
@ SuccessPathLimit
Definition: ExtrapolationCell.h:115
Trk::Intersection::position
Amg::Vector3D position
Definition: Intersection.h:25
Trk::ExtrapolationCell::checkConfigurationMode
bool checkConfigurationMode(ExtrapolationMode::eMode em) const
check the configuration mode
Definition: ExtrapolationCell.h:352
Trk::ExtrapolationCell::lastLeadParameters
T * lastLeadParameters
this is for caching the last valid
Definition: ExtrapolationCell.h:258
Trk::PropagationEngine::~PropagationEngine
~PropagationEngine()
Destructor.
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
Trk::ExtrapolationCell::pathLimit
double pathLimit
the maximal limit of the extrapolation
Definition: ExtrapolationCell.h:270
Trk::ExtrapolationMode::Direct
@ Direct
Definition: ExtrapolationCell.h:48
PropagationEngine.h
EX_MSG_DEBUG
#define EX_MSG_DEBUG(navstep, step, idx, x)
Definition: ExtrapolationMacros.h:13
Trk::Intersection::valid
bool valid
Definition: Intersection.h:28
EX_MSG_VERBOSE
#define EX_MSG_VERBOSE(navstep, step, idx, x)
Definition: ExtrapolationMacros.h:14
Trk::ExtrapolationCell
Definition: ExtrapolationCell.h:231
Trk::ExtrapolationCell::leadParameters
T * leadParameters
the one last truely valid parameter in the stream
Definition: ExtrapolationCell.h:246
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::PropagationEngine::PropagationEngine
PropagationEngine(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: PropagationEngine.cxx:19
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
AthAlgTool
Definition: AthAlgTool.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::ExtrapolationCell::endSurface
const Surface * endSurface
keep track of the destination surface - can be optionally 0
Definition: ExtrapolationCell.h:244
Trk::ExtrapolationCell::mFieldMode
MagneticFieldProperties mFieldMode
what magnetic field mode to be used, default : fullField
Definition: ExtrapolationCell.h:281
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
Trk::ExtrapolationCode::InProgress
@ InProgress
Definition: ExtrapolationCell.h:111