ATLAS Offline Software
PropagationEngine.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 // 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  m_pathLimitTolerance(0.01)
22 {
23  declareInterface<Trk::IPropagationEngine>(this);
24  // steering of the screen outoput (SOP)
25  declareProperty("OutputPrefix" , m_sopPrefix);
26  declareProperty("OutputPostfix" , m_sopPostfix);
27  // the path limit tolerance
28  declareProperty("PathLimitTolerance" , m_pathLimitTolerance);
29 }
30 
31 // destructor
33 = default;
34 
35 
36 // the interface method initialize
38 {
39  if (m_propagator.retrieve().isFailure()){
40  EX_MSG_FATAL( "", "initialize", "", "failed to retrieve propagator '"<< m_propagator << "'. Aborting." );
41  return StatusCode::FAILURE;
42  } else
43  EX_MSG_DEBUG( "", "initialize", "", "successfully retrieved '" << m_propagator << "'." );
44 
45  EX_MSG_DEBUG( "", "initialize", "", "successful" );
46  return StatusCode::SUCCESS;
47 }
48 
49 // the interface method finalize
51 {
52  EX_MSG_DEBUG( "", "finalize", "", "successful" );
53  return StatusCode::SUCCESS;
54 }
55 
56 
59  const Trk::Surface& sf,
60  Trk::PropDirection pDir,
61  Trk::BoundaryCheck bcheck,
62  bool returnCurvilinear) const
63 {
64  EX_MSG_DEBUG(++eCell.navigationStep, "propagate", "char", "propagation engine called with charged parameters with propagation direction " << pDir );
65 
66  double propLength = -1.;
68  // the path limit
69  propLength = eCell.pathLimit > 0 ? (eCell.pathLimit-eCell.pathLength) : eCell.pathLimit;
70  EX_MSG_VERBOSE(eCell.navigationStep, "propagate", "char", "available step length for this propagation " << propLength );
71  }
72  // it is the final propagation if it is the endSurface
73  bool finalPropagation = (eCell.endSurface == (&sf));
74 
75  std::optional<Trk::TransportJacobian> tjac{};
76  // we need to first fill the propagation parameters in order to be able to updates & fallbacks
77  //release, otherwise need to change the Trk::ExCell code
78  auto *pParameters = m_propagator->propagate(
79  Gaudi::Hive::currentContext(),
80  *eCell.leadParameters,
81  sf,
82  pDir,
83  bcheck,
84  eCell.mFieldMode,
85  tjac,
86  propLength,
87  eCell.pHypothesis,
88  returnCurvilinear).release();
89  // set the return type according to how the propagation went
90  if (pParameters){
91  // cache the last lead parameters, useful in case a navigation error occured
92  eCell.lastLeadParameters = eCell.leadParameters;
93  // assign the lead and end parameters
94  eCell.leadParameters = pParameters;
95  // check what to do with the path Length
97  // add the new propagation length to the path length
98  eCell.pathLength += propLength;
99  // check if Limit reached
100  if (eCell.pathLimitReached(m_pathLimitTolerance)){
101  EX_MSG_VERBOSE(eCell.navigationStep, "propagate", "char", "path limit of " << eCell.pathLimit << " successfully reached -> stopping." );
103  }
104  }
105 
106  // check if the propagation was called with directly, then lead parameters become end parameters
108  eCell.endParameters = eCell.leadParameters;
109 
110  // return Success only if it is the final propagation - the extrapolation engine knows that
112  }
113  // return - recovered means that the leadParameters are the input ones
115 }
116 
119  const Trk::Surface& sf,
120  Trk::PropDirection pDir,
121  Trk::BoundaryCheck bcheck,
122  bool returnCurvilinear) const
123 {
124  EX_MSG_DEBUG(++eCell.navigationStep, "propagate", "neut", "propagation engine called with neutral parameters with propagation direction " << pDir );
125  // leave this for the moment, can re replaced by an appropriate propagator call later
126  if (eCell.leadParameters->covariance()){
127  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "propagation of neutral parameters with covariances requested. This is not supported for the moment.");
128  }
129  // the pathLimit cache so far
130  double cPath = eCell.pathLength;
131  // it is the final propagation if it is the endSurface
132  bool finalPropagation = (eCell.endSurface == (&sf));
133  // intersect the surface
134  Trk::Intersection sfIntersection = (pDir!=Trk::anyDirection) ? sf.straightLineIntersection(eCell.leadParameters->position(),
135  pDir*eCell.leadParameters->momentum().unit(),
136  true, bcheck) :
137  sf.straightLineIntersection(eCell.leadParameters->position(),
138  eCell.leadParameters->momentum().unit(),
139  false, bcheck);
140  // we have a valid intersection
141  if (sfIntersection.valid){
142  // fill the transport information - only if the propation direction is not 0 ('anyDirection')
143  if (pDir!=Trk::anyDirection){
144  double pLength = (sfIntersection.position-eCell.leadParameters->position()).mag();
145  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "path length of " << pLength << " added to the extrapolation cell (limit = " << eCell.pathLimit << ")" );
146  eCell.stepTransport(sf,pLength);
147  }
148  // now check if it is valud it's further away than the pathLimit
149  if (eCell.pathLimitReached(m_pathLimitTolerance)){
150  // cache the last lead parameters
151  eCell.lastLeadParameters = eCell.leadParameters;
152  // create new neutral curvilinear parameters at the path limit reached
153  double pDiff = eCell.pathLimit - cPath;
154  eCell.leadParameters = new Trk::NeutralCurvilinearParameters(eCell.leadParameters->position()+pDiff*eCell.leadParameters->momentum().unit(),
155  eCell.leadParameters->momentum(),
156  0.);
157  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "path limit of " << eCell.pathLimit << " reached. Stopping extrapolation.");
159  }
160  // cache the last lead parameters
161  eCell.lastLeadParameters = eCell.leadParameters;
162  // now exchange the lead parameters
163  // create the new curvilinear paramters at the surface intersection -> if so, trigger the success
164  eCell.leadParameters = returnCurvilinear ? new Trk::NeutralCurvilinearParameters(sfIntersection.position, eCell.leadParameters->momentum(), 0.) :
165  sf.createUniqueNeutralParameters(sfIntersection.position, eCell.leadParameters->momentum(), 0.).release();
166 
167  // check if the propagation was called with directly, then lead parameters become end parameters
169  eCell.endParameters = eCell.leadParameters;
170 
171  // return success for the final destination or in progress
173 
174  } else {
175  // give some screen output
176  EX_MSG_VERBOSE(eCell.navigationStep,"propagate", "neut", "intersection with the surface did not succeed.");
177  }
178  // return - recovered means that the leadParameters are the input ones
180 }
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:58
Surface.h
Trk::PropagationEngine::m_pathLimitTolerance
double m_pathLimitTolerance
Definition: PropagationEngine.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
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:50
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::IPropagationEngine::m_sopPostfix
std::string m_sopPostfix
prefix for screen output
Definition: IPropagationEngine.h:79
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:37
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::IPropagationEngine::m_sopPrefix
std::string m_sopPrefix
< SCREEN output formatting (SOP) - unify amongst extrapolation engines
Definition: IPropagationEngine.h:78
Trk::ExtrapolationCode::InProgress
@ InProgress
Definition: ExtrapolationCell.h:111