ATLAS Offline Software
Loading...
Searching...
No Matches
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
19Trk::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{
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,
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
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
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,
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
147 // cache the last lead parameters
149 // create new neutral curvilinear parameters at the path limit reached
150 double pDiff = eCell.pathLimit - cPath;
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
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}
#define EX_MSG_DEBUG(navstep, step, idx, x)
#define EX_MSG_VERBOSE(navstep, step, idx, x)
#define EX_MSG_FATAL(navstep, step, idx, x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
MagneticFieldProperties mFieldMode
what magnetic field mode to be used, default : fullField
T * lastLeadParameters
this is for caching the last valid
const Surface * endSurface
keep track of the destination surface - can be optionally 0
T * endParameters
by pointer - are newly created and can be optionally 0
int navigationStep
a counter of the navigation Step
T * leadParameters
the one last truely valid parameter in the stream
bool pathLimitReached(double tolerance=0.001) const
the materialLimitReached
double pathLimit
the maximal limit of the extrapolation
bool checkConfigurationMode(ExtrapolationMode::eMode em) const
check the configuration mode
ParticleHypothesis pHypothesis
what particle hypothesis to be used, default : pion
double pathLength
the path length accumulated
void stepTransport(const Surface &sf, double pathLength=0., const TransportJacobian *tjac=nullptr)
fill transport information - path length and TransportJacobian
std::string m_sopPostfix
prefix for screen output
std::string m_sopPrefix
< SCREEN output formatting (SOP) - unify amongst extrapolation engines
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
~PropagationEngine()
Destructor.
StatusCode initialize()
AlgTool initialize method.
DoubleProperty m_pathLimitTolerance
PropagationEngine(const std::string &, const std::string &, const IInterface *)
Constructor.
StringProperty m_sopPostfix_prop
ToolHandle< IPropagator > m_propagator
StatusCode finalize()
AlgTool finalize method.
StringProperty m_sopPrefix_prop
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
Abstract Base Class for tracking surfaces.
PropDirection
PropDirection, enum for direction of the propagation.
@ anyDirection
CurvilinearParametersT< NeutralParametersDim, Neutral, PlaneSurface > NeutralCurvilinearParameters
ExtrapolationCell< TrackParameters > ExCellCharged
ExtrapolationCell< NeutralParameters > ExCellNeutral
Amg::Vector3D position