ATLAS Offline Software
Loading...
Searching...
No Matches
ExtrapolationCell.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ExtrapolationCell.h, (c) ATLAS Detector software
8
9#ifndef TRKEXUTILS_EXTRAPOLATIONCELL_H
10#define TRKEXUTILS_EXTRAPOLATIONCELL_H
20#include "TrkSurfaces/Surface.h"
21
22#ifndef TRKEXUTILS_CHECKPATHMACRO
23#define TRKEXUTILS_CHECKPATHMACRO
24#define reachedLimit(current, limit, tolerance) \
25 ((limit) > 0 && \
26 (((current) < (limit)) \
27 ? ((current) - (limit)) * ((current) - (limit)) / ((limit) * (limit)) < \
28 (tolerance) * (tolerance) \
29 : true))
30#endif
31
32namespace Trk {
33
34class MaterialProperties;
35class TrackingVolume;
36class Layer;
37// class Surface;
38
43{
44
45public:
46 enum eMode
47 {
48 Direct = 1, // call propagator directly, no navigation
49 Destination = 2, // try to hit the destination, if not other means to stop
50 StopWithPathLimit = 3, // stop when the path limit is reached
52 4, // stop when the material limit is reached in X0
54 5, // stop when the material limit is reached in L0
55 StopAtBoundary = 6, // stop at the next ID / Calo / MS boundary
56 CollectSensitive = 7, // collect parameters on sensitive elements
57 CollectPassive = 8, // collect parameters on passive layers
58 CollectBoundary = 9, // collect parameters on boundary parameters
59 CollectMaterial = 10, // collect all material on the way
60 CollectJacobians = 11, // collect the transport jacobians
61 CollectPathSteps = 12, // collect the single path steps
62 AvoidFallback = 13, // don't fallback to propagation
63 FATRAS = 14 // force initial radialDirection to be outward
64 };
65};
66
71{
72public:
74 ExtrapolationConfig(unsigned int evalue = 0)
75 : m_value(evalue)
76 {}
77
80 : m_value(eConfig.m_value)
81 {}
82
85 {
86 // set the bit corresponding to this mode
87 m_value |= (1 << int(em));
88 }
89
92 {
93 // check if the bit is set or not
94 return (m_value & (1 << int(em)));
95 }
96
97private:
98 unsigned int m_value;
99};
100
105{
106
107public:
108 enum eCode
109 {
110 Unset = 0, // no code set yet
111 InProgress = 1, // successful : extrapolation in process
112 SuccessDestination = 2, // successful : destination reached
114 3, // successful : boundary reached & configured to do so
116 4, // successful : path limit reached & configured to do so
118 5, // successful : material limit reached & configured to do so
119 Recovered = 6, // successful : recovered & configured to do so
120 FailureDestination = 7, // failure : could not reach destination
121 FailureLoop = 8, // failure : loop or oscillation between volumes
122 FailureNavigation = 9, // failure : general navigation failure
123 FailureUpdateKill = 10, // failure : updated track under threshold
124 FailureConfiguration = 11, // failure : general configuration failure
125 LeftKnownWorld = 12 // successful ? failure ? if we just knew ...
126 };
127
130
131 /* create a simple extrapolation code */
133 : code(c)
134 {}
135
138 {
139 code = ec;
140 return (*this);
141 }
142
144 bool operator==(const eCode& ec) const { return (ec == code); }
145
147 bool operator!=(const eCode& ec) const { return (ec != code); }
148
150 bool inProgress() const { return (code == InProgress); }
151
153 bool isSuccess() const { return (code > InProgress && code < Recovered); }
154
157 {
158 return (code > SuccessDestination && code < Recovered);
159 }
160
163 {
164 return (code > InProgress && code <= FailureDestination);
165 }
166
168 bool isFailure() const { return (code > Recovered); }
169
171 bool isFailureOrRecovered() const { return (code > SuccessMaterialLimit); };
172
174 const std::string& toString() const { return s_ecodeNames[code]; }
175
176private:
177 static const std::vector<std::string> s_ecodeNames;
178};
179
186template<class T>
188{
189public:
190 const T* parameters;
192 const Layer*
199 const TransportJacobian*
201 double pathLength;
202 float time;
203
204 ExtrapolationStep(const T* pars = 0, const Surface* sf = nullptr,
205 const ExtrapolationConfig& eConfig = ExtrapolationConfig(),
206 const MaterialProperties* mprop = nullptr,
207 const TransportJacobian* tjac = nullptr,
208 double pLength = -1.)
209 : parameters(pars),
210 surface(sf),
211 layer(nullptr),
212 stepConfiguration(eConfig),
213 material(mprop),
214 materialPosition(Amg::Vector3D(0., 0., 0.)),
215 materialScaling(1.),
216 transportJacobian(tjac),
217 pathLength(pLength),
218 time(0) {}
219};
220
228
229template<class T>
231{
232public:
234 const TrackingVolume*
237
243 const Surface*
245
247 const TrackingVolume*
252
255 const Surface*
257
263
267
269 double pathLength;
270 double pathLimit;
271
272 double materialX0;
274 double materialL0;
277
290
291 std::vector<ExtrapolationStep<T>>
293
296
297 float time;
299 float zOaTrX;
300 float zX;
301
303 ExtrapolationCell(T& sParameters,
305 unsigned int econfig = 1)
306 : startParameters(&sParameters)
307 , startVolume(nullptr)
308 , startLayer(nullptr)
309 , endParameters(0)
310 , endVolume(nullptr)
311 , endLayer(nullptr)
312 , endSurface(nullptr)
313 , leadParameters(&sParameters)
314 , leadVolume(nullptr)
315 , leadLayer(nullptr)
316 , leadLayerSurface(nullptr)
318 , lastBoundarySurface(nullptr)
319 , lastLeadParameters(&sParameters)
320 , propDirection(pDir)
321 , radialDirection(1)
323 , navigationStep(0)
324 , pathLength(0.)
325 , pathLimit(-1)
326 , materialX0(0.)
327 , materialLimitX0(-1.)
328 , materialL0(0.)
329 , materialLimitL0(-1.)
330 , materialProcess(0)
335 , sensitiveCurvilinear(false)
338 , time(0)
339 , eLoss(nullptr)
340 , zOaTrX(0.)
341 , zX(0.)
342 {}
343
346 {
347 // set the bit corresponding to this mode
348 extrapolationConfiguration.addMode(em);
349 }
350
353 {
354 // check if the bit is set or not
355 return extrapolationConfiguration.checkMode(em);
356 }
357
359 bool onLastBoundary() const
360 {
362 }
363
366 void stepParameters(const T* pars, ExtrapolationMode::eMode fillMode);
367
370 void stepTransport(const Surface& sf,
371 double pathLength = 0.,
372 const TransportJacobian* tjac = nullptr);
373
376 void addMaterial(double sfactor, const MaterialProperties* mprop = nullptr);
377 void addMaterial(double step, const Material* mat = nullptr);
378
381 void stepMaterial(const Surface& sf,
382 const Layer* lay,
383 const Amg::Vector3D& position,
384 double sfactor,
385 const MaterialProperties* mprop = nullptr);
386
388 bool initialVolume() const { return (leadVolume == startVolume); }
389
392 {
393 return (leadVolume == endVolume && endVolume);
394 }
395
402
413
416
419
422
425 {
426 pHypothesis = hypo;
427 }
428
431 {
432 // in FATRAS extrapolation mode force radial direction to be outwards (+1)
434 radialDirection = 1;
435 else {
436 // if the endSurface is given, it is used to evaluate the radial direction
437 // else the leadParamenters are used
438 if (endSurface) {
439 if (leadParameters->position().perp() >
440 endSurface->globalReferencePoint().perp())
441 radialDirection = -1;
442 } else {
443 if (leadParameters->position().perp() >
444 (leadParameters->position() +
445 propDirection * leadParameters->momentum().unit())
446 .perp())
447 radialDirection = -1;
448 }
449 }
450 }
451
455 {
456 // this checks the radial compatibility - not needed for outwards moving
457 if (radialDirection > 0)
458 return true;
459 // this was radially inwards moving and stays like this
460 if (leadParameters->position().perp() >
461 (leadParameters->position() +
462 propDirection * leadParameters->momentum().unit())
463 .perp())
464 return true;
465 // radial direction changed
466 return false;
467 }
468
469private:
470 std::vector<const T*> m_garbageCollection;
471};
472
473template<class T>
474void
476{
481 endParameters = 0;
482 endVolume = 0;
483 endLayer = 0;
484 endSurface = 0;
486 leadVolume = 0;
487 leadLayer = 0;
492 navigationStep = 0;
493 pathLength = 0.;
494 materialX0 = 0.;
495 materialL0 = 0.;
496 if (eLoss)
497 eLoss->set(0., 0., 0., 0., 0., 0.);
498 // clear the vector
499 extrapolationSteps.clear();
500}
501
502template<class T>
503void
505{
506 // set the leadParameters to the endParameters if anything happened here and
507 // the code wass succesful
509 // end parameters are the last lead parameters !< @TODO check if we need a
510 // clone here! should not be necessary
511 endParameters = leadParameters->clone();
512 }
513 // now do the cleanup - will delete the step content if eCode is failure
514 emptyGarbageBin(ec);
515 delete eLoss;
516}
517
518template<class T>
519void
521{
522 for (auto bC : m_garbageCollection)
523 delete bC;
524 m_garbageCollection.clear();
525 // in case of failure of the extrapolation stream, clear all the caches
526 if (ec.isFailure()) {
527 for (auto& es : extrapolationSteps) {
528 delete es.parameters;
529 delete es.transportJacobian;
530 }
531 // now clear the vector
532 extrapolationSteps.clear();
533 }
534}
535
536template<class T>
537void
540{
541 // this is the garbage bin collection
542 if (!checkConfigurationMode(fillMode)) {
543 // only dump them in the garbage bin
544 m_garbageCollection.push_back(parameters);
545 return;
546 }
547 // find out if you want to attach or you need a new one
548 // current step surface
549 const Surface* cssf = &(parameters->associatedSurface());
550 // get the last step surface - if it is identical with the current one ->
551 // attach information
552 const Surface* lssf =
553 extrapolationSteps.size()
554 ? extrapolationSteps[extrapolationSteps.size() - 1].surface
555 : 0;
556 // create a new step
557 if (cssf != lssf)
559 // fill the parameters, the surface and add the mode
560 extrapolationSteps[extrapolationSteps.size() - 1].parameters = parameters;
561 extrapolationSteps[extrapolationSteps.size() - 1].surface = cssf;
562 extrapolationSteps[extrapolationSteps.size() - 1].stepConfiguration.addMode(
563 fillMode);
564}
565
566template<class T>
567void
569 double pLength,
570 const TransportJacobian* tjac)
571{
572 // find out if you want to attach or you need a new one
573 // current step surface
574 const Surface* cssf = &sf;
575 // get the last step surface - if it is identical with the current one ->
576 // attach information
577 const Surface* lssf =
578 extrapolationSteps.size()
579 ? extrapolationSteps[extrapolationSteps.size() - 1].surface
580 : 0;
581 // only create a new step for a transport jacobian
582 if (tjac) {
583 // create a new step
584 if (cssf != lssf)
586 // set the surface
587 extrapolationSteps[extrapolationSteps.size() - 1].surface = cssf;
588 // set the the transport information
589 extrapolationSteps[extrapolationSteps.size() - 1].transportJacobian = tjac;
590 extrapolationSteps[extrapolationSteps.size() - 1].stepConfiguration.addMode(
592 // fill the step path length
593 if (pLength > 0.) {
594 extrapolationSteps[extrapolationSteps.size() - 1].pathLength = pLength;
596 .stepConfiguration.addMode(Trk::ExtrapolationMode::CollectPathSteps);
597 }
598 } else {
599 // let's just fill the pathLength information
600 pathLength += pLength;
601 }
602}
603
604template<class T>
605void
607 const MaterialProperties* mprop)
608{
609
610 // fill the material if there
611 if (mprop) {
612 // the overal material
613 materialX0 += sfactor * mprop->thicknessInX0();
614 materialL0 += sfactor * mprop->thicknessInL0();
615 zOaTrX += mprop->zOverAtimesRho() * sfactor * mprop->thicknessInX0();
616 zX += mprop->averageZ() * sfactor * mprop->thicknessInX0();
617 }
618}
619
620template<class T>
621void
623{
624
625 // fill the material if there
626 if (mat && step > 0.) {
627 // the overal material
628 materialX0 += step / mat->X0;
629 materialL0 += step / mat->L0;
630 zOaTrX += mat->zOverAtimesRho() * step / mat->X0;
631 zX += mat->averageZ() * step / mat->X0;
632 }
633}
634
635template<class T>
636void
638 const Layer* lay,
639 const Amg::Vector3D& mposition,
640 double sfactor,
641 const MaterialProperties* mprop)
642{
643
644 // add material to the global counter
645 addMaterial(sfactor, mprop);
646 // find out if you want to attach or you need a new one
647 // current step surface
648 const Surface* cssf = &sf;
649 // get the last step surface - if it is identical with the current one ->
650 // attach information
651 const Surface* lssf =
652 extrapolationSteps.size()
653 ? extrapolationSteps[extrapolationSteps.size() - 1].surface
654 : 0;
655 // create a new step
656 if (cssf != lssf)
658 // set the surface
659 extrapolationSteps[extrapolationSteps.size() - 1].surface = cssf;
660 extrapolationSteps[extrapolationSteps.size() - 1].layer = lay;
661 // fill the material if there
662 if (mprop) {
663 // record the step information
664 extrapolationSteps[extrapolationSteps.size() - 1].material = mprop;
665 extrapolationSteps[extrapolationSteps.size() - 1].stepConfiguration.addMode(
667 extrapolationSteps[extrapolationSteps.size() - 1].materialPosition =
668 mposition;
669 extrapolationSteps[extrapolationSteps.size() - 1].materialScaling = sfactor;
670 }
671}
672
673} // end of namespace
674
675#endif // TRKEXUTILS_EXTRAPOLATIONCELL_H
676
#define reachedLimit(current, limit, tolerance)
Eigen::Matrix< double, 3, 1 > Vector3D
This class describes energy loss material effects in the ATLAS tracking EDM.
Definition EnergyLoss.h:34
void addMaterial(double step, const Material *mat=nullptr)
bool initialVolume() const
check if this is the initial volume
void finalize(const ExtrapolationCode &ec)
finalize call - this one is called by the ExtrapoaltionEngine
void stepMaterial(const Surface &sf, const Layer *lay, const Amg::Vector3D &position, double sfactor, const MaterialProperties *mprop=nullptr)
fill or attach material, jacobian, step length
bool onLastBoundary() const
check if you are still at the last boundary surface
void addConfigurationMode(ExtrapolationMode::eMode em)
add a configuration mode
void addMaterial(double sfactor, const MaterialProperties *mprop=nullptr)
fill or attach material, jacobian, step length
ExtrapolationCell(T &sParameters, PropDirection pDir=alongMomentum, unsigned int econfig=1)
start parameters are compulsory
void stepParameters(const T *pars, ExtrapolationMode::eMode fillMode)
fill or attach the parameters from a step - memory management steered by extrapolationConfiguration
void restartAtDestination()
prepare destination as new start point - optimised for Kalman filtering
bool materialLimitReached(double tolerance=0.001) const
the materialLimitReached
std::vector< ExtrapolationStep< TrackParameters > > extrapolationSteps
void setParticleHypothesis(const ParticleHypothesis &hypo)
set ParticleHypothesis
bool pathLimitReached(double tolerance=0.001) const
the materialLimitReached
bool checkRadialCompatibility() const
check whether the propagation stays compatible with initial radial direction
std::vector< const TrackParameters * > m_garbageCollection
bool checkConfigurationMode(ExtrapolationMode::eMode em) const
check the configuration mode
void emptyGarbageBin(const ExtrapolationCode &ec)
memory cleanup
bool finalVolumeReached() const
trigger for final volume
void stepTransport(const Surface &sf, double pathLength=0., const TransportJacobian *tjac=nullptr)
fill transport information - path length and TransportJacobian
void setRadialDirection()
estimate the radial direction of the extrapolation cell
ExtrapolationCode & operator=(const eCode &ec)
assigment operator - because we can
static const std::vector< std::string > s_ecodeNames
const std::string & toString() const
toString
bool operator==(const eCode &ec) const
== operator to eCode
bool isFailure() const
return failure
bool isSuccessBeforeDestination() const
return sucess other than destination reached
bool isSuccess() const
return success
bool isSuccessOrRecovered() const
return success or recovered
bool inProgress() const
return inProgress
eCode code
the actual code
bool operator!=(const eCode &ec) const
!= operator to eCode
bool isFailureOrRecovered() const
return failure or recovered
ExtrapolationConfig(unsigned int evalue=0)
Constructor.
ExtrapolationConfig(const ExtrapolationConfig &eConfig)
Copy Constructor.
void addMode(ExtrapolationMode::eMode em)
add a configuration mode
bool checkMode(ExtrapolationMode::eMode em) const
check the configuration mode
enumeration to decode - for Extrapolation steering
templated class to record the different possible entities during extrapolation
const T * parameters
the parameters of this step
ExtrapolationStep(const T *pars=0, const Surface *sf=nullptr, const ExtrapolationConfig &eConfig=ExtrapolationConfig(), const MaterialProperties *mprop=nullptr, const TransportJacobian *tjac=nullptr, double pLength=-1.)
ExtrapolationConfig stepConfiguration
sensitive, passive, boundary to name the parameters
const TransportJacobian * transportJacobian
the transport jacobian from the last step
double pathLength
the path length from the last step
const Layer * layer
the associatedLayer() or materialLayer() of the surface
const MaterialProperties * material
the associated material
double materialScaling
scale factor for the material as calculated
Amg::Vector3D materialPosition
position from where the material is taken
const Surface * surface
the surface where the step is bound
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
magnetic field properties to steer the behavior of the extrapolation
Material with information about thickness of material.
float thicknessInX0() const
Return the radiationlength fraction.
float zOverAtimesRho() const
Return the .
float thicknessInL0() const
Return the nuclear interaction length fraction.
float averageZ() const
Returns the average Z of the material.
A common object to be contained by.
Definition Material.h:117
Abstract Base Class for tracking surfaces.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
This class represents the jacobian for transforming initial track parameters to new track parameters ...
Definition of ATLAS Math & Geometry primitives (Amg)
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
PropDirection
PropDirection, enum for direction of the propagation.
@ alongMomentum
@ FullField
Field is set to be realistic, but within a given Volume.
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
MaterialUpdateMode
This is a steering enum to force the material update it can be: (1) addNoise (-1) removeNoise Second ...