ATLAS Offline Software
MaterialEffectsUpdator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 // MaterialEffectsUpdator.h, c) ATLAS Detector software
8 
9 #ifndef TRKEXTOOLS_MATERIALEFFECTSUPDATOR_H
10 #define TRKEXTOOLS_MATERIALEFFECTSUPDATOR_H
11 
13 // Trk
17 // Gaudi
19 #include "GaudiKernel/ToolHandle.h"
20 
21 #include <string>
22 #include <vector>
23 
24 #include <boost/thread/tss.hpp>
25 
26 #define TRKEXTOOLS_MAXUPDATES 100
27 #ifndef COVARIANCEUPDATEWITHCHECK
28 #define COVARIANCEUPDATEWITHCHECK(cov, sign, value) \
29  cov += (sign > 0 ? value : (value > cov ? 0 : sign * value))
30 #endif
31 
32 namespace Trk {
33 
34 class Layer;
35 // class TrackParameters;
36 class MaterialProperties;
37 class IEnergyLossUpdator;
38 class IMultipleScatteringUpdator;
39 class IMaterialMapper;
40 
70  : public AthAlgTool
71  , virtual public IMaterialEffectsUpdator
72 {
73 
74 public:
76  MaterialEffectsUpdator(const std::string&,
77  const std::string&,
78  const IInterface*);
79 
82 
84  virtual StatusCode initialize() override;
85  /*
86  * The concrete cache class for this specialization of the
87  * IMaterialEffectsUpdator
88  */
93  virtual std::unique_ptr<TrackParameters> update(
94  ICache& cache,
95  const TrackParameters* parm,
96  const Layer& sf,
99  MaterialUpdateMode matupmode = addNoise) const override
100  {
101  return updateImpl(cache, parm, sf, dir, particle, matupmode);
102  }
107  virtual std::unique_ptr<TrackParameters> update(
108  ICache& cache,
109  const TrackParameters* parm,
110  const MaterialEffectsOnTrack& meff,
112  MaterialUpdateMode matupmode = addNoise) const override
113  {
114  return updateImpl(cache, parm, meff, particle, matupmode);
115  }
116 
120  virtual std::unique_ptr<TrackParameters> preUpdate(
121  ICache& cache,
122  const TrackParameters* parm,
123  const Layer& sf,
126  MaterialUpdateMode matupmode = addNoise) const override
127  {
128  return preUpdateImpl(cache, parm, sf, dir, particle, matupmode);
129  }
130 
135  virtual std::unique_ptr<TrackParameters> postUpdate(
136  ICache& cache,
137  const TrackParameters& parm,
138  const Layer& sf,
141  MaterialUpdateMode matupmode = addNoise) const override final
142  {
143  return postUpdateImpl(cache, parm, sf, dir, particle, matupmode);
144  }
146  virtual std::unique_ptr<TrackParameters> update(
147  ICache& cache,
148  const TrackParameters& parm,
149  const MaterialProperties& mprop,
150  double pathcorrection,
153  MaterialUpdateMode matupmode = addNoise) const override final
154  {
155  return updateImpl(
156  cache, parm, mprop, pathcorrection, dir, particle, matupmode);
157  }
158 
161  virtual void validationAction(ICache& cache) const override final
162  {
163  validationActionImpl(cache);
164  }
165 
170  virtual void modelAction(ICache& cache, const TrackParameters* parm = nullptr)
171  const override final
172  {
173  modelActionImpl(cache, parm);
174  }
175 
176 public:
177  /*
178  * Public methods using the TLS cache.
179  */
180  virtual std::unique_ptr<TrackParameters> update(
181  const TrackParameters* parm,
182  const Layer& sf,
185  MaterialUpdateMode matupmode = addNoise) const override final
186  {
187 
188  ICache& cache = getTLSCache();
189  return updateImpl(cache, parm, sf, dir, particle, matupmode);
190  }
191 
192  virtual std::unique_ptr<TrackParameters> update(
193  const TrackParameters* parm,
194  const MaterialEffectsOnTrack& meff,
196  MaterialUpdateMode matupmode = addNoise) const override final
197  {
198  ICache& cache = getTLSCache();
199  return updateImpl(cache, parm, meff, particle, matupmode);
200  }
201 
202  virtual std::unique_ptr<TrackParameters> preUpdate(
203  const TrackParameters* parm,
204  const Layer& sf,
207  MaterialUpdateMode matupmode = addNoise) const override final
208  {
209  ICache& cache = getTLSCache();
210  return preUpdateImpl(cache, parm, sf, dir, particle, matupmode);
211  }
212 
213  virtual std::unique_ptr<TrackParameters> postUpdate(
214  const TrackParameters& parm,
215  const Layer& sf,
218  MaterialUpdateMode matupmode = addNoise) const override final
219  {
220  ICache& cache = getTLSCache();
221  return postUpdateImpl(cache, parm, sf, dir, particle, matupmode);
222  }
223 
224  virtual std::unique_ptr<TrackParameters> update(
225  const TrackParameters& parm,
226  const MaterialProperties& mprop,
227  double pathcorrection,
230  MaterialUpdateMode matupmode = addNoise) const override final
231  {
232  ICache& cache = getTLSCache();
233  return updateImpl(
234  cache, parm, mprop, pathcorrection, dir, particle, matupmode);
235  }
236 
237  virtual void validationAction() const override final
238  {
239  ICache& cache = getTLSCache();
240  validationActionImpl(cache);
241  }
242 
243  virtual void modelAction(
244  const TrackParameters* parm = nullptr) const override final
245  {
246  ICache& cache = getTLSCache();
247  modelActionImpl(cache, parm);
248  }
249 
250 private:
251  /* The acutal implementation methods using the tool's
252  * concrete Cache*/
253  std::unique_ptr<TrackParameters> updateImpl(
254  ICache& cache,
255  const TrackParameters* parm,
256  const Layer& sf,
259  MaterialUpdateMode matupmode = addNoise) const;
260 
261  std::unique_ptr<TrackParameters> updateImpl(
262  ICache& cache,
263  const TrackParameters* parm,
264  const MaterialEffectsOnTrack& meff,
266  MaterialUpdateMode matupmode = addNoise) const;
267 
268  std::unique_ptr<TrackParameters> preUpdateImpl(
269  ICache& cache,
270  const TrackParameters* parm,
271  const Layer& sf,
274  MaterialUpdateMode matupmode = addNoise) const;
275 
276  std::unique_ptr<TrackParameters> postUpdateImpl(
277  ICache& cache,
278  const TrackParameters& parm,
279  const Layer& sf,
282  MaterialUpdateMode matupmode = addNoise) const;
283 
284  std::unique_ptr<TrackParameters> updateImpl(
285  ICache& cache,
286  const TrackParameters* parm,
287  const MaterialProperties& mprop,
288  double pathcorrection,
291  MaterialUpdateMode matupmode = addNoise) const;
292 
293  std::unique_ptr<TrackParameters> updateImpl(
294  ICache& cache,
295  const TrackParameters& parm,
296  const MaterialProperties& mprop,
297  double pathcorrection,
300  MaterialUpdateMode matupmode = addNoise) const;
301 
302  static void validationActionImpl(ICache& cache);
303 
304  static void modelActionImpl(ICache& cache,
305  const TrackParameters* parm = nullptr);
306 
308  bool checkCovariance(AmgSymMatrix(5) & updated) const;
310  const TrackParameters* parm) const;
311 
312  /* Private Class members*/
314  bool m_doEloss;
316  bool m_doMs;
317 
321 
325 
326  // ------------ validation variables
327  // -------------------------------------------------
330  bool m_landauMode;
334  // ------------------------------
335  double m_momentumCut;
336  double m_momentumMax;
338 
339  ToolHandle<IEnergyLossUpdator> m_eLossUpdator;
340  ToolHandle<IMultipleScatteringUpdator> m_msUpdator;
341  ToolHandle<IMaterialMapper> m_materialMapper;
342 
343  /*
344  * TLS part
345  */
346  mutable boost::thread_specific_ptr<ICache> m_cache_tls;
348  {
349  ICache* cache = m_cache_tls.get();
350  if (!cache) {
351  cache = new ICache();
352  m_cache_tls.reset(cache);
353  }
354  return *cache;
355  }
356 };
357 } // end of namespace
358 
359 #endif // TRKEXTOOLS_MATERIALEFFECTSUPDATOR_H
360 
Trk::MaterialEffectsUpdator::initialize
virtual StatusCode initialize() override
AlgTool initailize method.
Definition: MaterialEffectsUpdator.cxx:91
Trk::MaterialEffectsUpdator::validationAction
virtual void validationAction() const override final
Validation Action: outside access to internal validation steps Optional.
Definition: MaterialEffectsUpdator.h:237
Trk::MaterialEffectsUpdator::m_momentumCut
double m_momentumCut
Minimal momentum cut for update.
Definition: MaterialEffectsUpdator.h:335
Trk::MaterialEffectsUpdator::m_useMostProbableEloss
bool m_useMostProbableEloss
use the most probable energy loss
Definition: MaterialEffectsUpdator.h:320
Trk::IMaterialEffectsUpdator::ICache
Cache class to allow passing information to/between calls.
Definition: IMaterialEffectsUpdator.h:63
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
Trk::MaterialEffectsUpdator::~MaterialEffectsUpdator
virtual ~MaterialEffectsUpdator()
Virtual destructor.
Trk::MaterialEffectsUpdator::modelAction
virtual void modelAction(const TrackParameters *parm=nullptr) const override final
Model Action: Provides the possibility of doing non-local MaterialEffectsUpdates for different models...
Definition: MaterialEffectsUpdator.h:243
Trk::MaterialEffectsUpdator::modelActionImpl
static void modelActionImpl(ICache &cache, const TrackParameters *parm=nullptr)
Definition: MaterialEffectsUpdator.cxx:814
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(ICache &cache, const TrackParameters *parm, const MaterialEffectsOnTrack &meff, Trk::ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override
Updator interface (full update for a layer) according to user input through MaterialEffectsOnTrack —>...
Definition: MaterialEffectsUpdator.h:107
TrackParameters.h
Trk::MaterialEffectsUpdator::m_validationMode
bool m_validationMode
Switch for validation mode.
Definition: MaterialEffectsUpdator.h:328
Trk::MaterialEffectsUpdator::m_validationIgnoreUnmeasured
bool m_validationIgnoreUnmeasured
Ignore unmeasured TrackParameters (Navigation!)
Definition: MaterialEffectsUpdator.h:329
Trk::MaterialEffectsUpdator::preUpdate
virtual std::unique_ptr< TrackParameters > preUpdate(ICache &cache, const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override
Updator interface (pre-update for a layer): —> ALWAYS pointer to new TrackParameters is returned.
Definition: MaterialEffectsUpdator.h:120
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Updator interface (full update for a layer):
Definition: MaterialEffectsUpdator.h:180
Trk::MaterialEffectsUpdator::m_msgOutputValidationDirection
bool m_msgOutputValidationDirection
validation direction used for screen output
Definition: MaterialEffectsUpdator.h:322
Trk::MaterialEffectsUpdator::postUpdate
virtual std::unique_ptr< TrackParameters > postUpdate(ICache &cache, const TrackParameters &parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Updator interface (post-update for a layer): —> ALWAYS pointer to new TrackParameters is returned if ...
Definition: MaterialEffectsUpdator.h:135
Trk::MaterialEffectsUpdator::m_eLossUpdator
ToolHandle< IEnergyLossUpdator > m_eLossUpdator
AlgoTool for EnergyLoss updates.
Definition: MaterialEffectsUpdator.h:339
Trk::MaterialEffectsUpdator::m_xKalmanStraggling
bool m_xKalmanStraggling
the momentum Error as calculated in xKalman
Definition: MaterialEffectsUpdator.h:319
Trk::MaterialEffectsUpdator::getTLSCache
ICache & getTLSCache() const
Definition: MaterialEffectsUpdator.h:347
Trk::MaterialEffectsUpdator::m_materialMapper
ToolHandle< IMaterialMapper > m_materialMapper
the material mapper for recording the layer material
Definition: MaterialEffectsUpdator.h:341
Trk::MaterialEffectsUpdator::m_validationDirection
int m_validationDirection
validation direction
Definition: MaterialEffectsUpdator.h:333
PropDirection.h
Trk::MaterialEffectsUpdator::MaterialEffectsUpdator
MaterialEffectsUpdator(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
Definition: MaterialEffectsUpdator.cxx:39
Trk::MaterialUpdateMode
MaterialUpdateMode
This is a steering enum to force the material update it can be: (1) addNoise (-1) removeNoise Second ...
Definition: MaterialUpdateMode.h:18
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(const TrackParameters &parm, const MaterialProperties &mprop, double pathcorrection, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Updator interface: MaterialProperties based material update.
Definition: MaterialEffectsUpdator.h:224
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
python.RingerConstants.Layer
Layer
Definition: RingerConstants.py:42
Trk::MaterialEffectsUpdator::m_doEloss
bool m_doEloss
steer energy loss On/Off from outside
Definition: MaterialEffectsUpdator.h:315
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
Trk::MaterialEffectsUpdator::validationAction
virtual void validationAction(ICache &cache) const override final
Validation Action - calls the writing and resetting of the TTree variables.
Definition: MaterialEffectsUpdator.h:161
Trk::MaterialEffectsUpdator::m_doCompoundLayerCheck
bool m_doCompoundLayerCheck
turn on/off the necessary checks when we may have compound layers
Definition: MaterialEffectsUpdator.h:313
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::MaterialEffectsUpdator::m_cache_tls
boost::thread_specific_ptr< ICache > m_cache_tls
Definition: MaterialEffectsUpdator.h:346
Trk::pion
@ pion
Definition: ParticleHypothesis.h:29
AthAlgTool.h
Trk::MaterialEffectsUpdator::m_forcedMomentum
double m_forcedMomentum
Forced momentum value.
Definition: MaterialEffectsUpdator.h:337
Trk::MaterialEffectsUpdator::m_momentumMax
double m_momentumMax
Maximal momentum cut for update.
Definition: MaterialEffectsUpdator.h:336
Trk::MaterialEffectsUpdator::updateImpl
std::unique_ptr< TrackParameters > updateImpl(ICache &cache, const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const
Definition: MaterialEffectsUpdator.cxx:140
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(ICache &cache, const TrackParameters &parm, const MaterialProperties &mprop, double pathcorrection, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Dedicated Updator interface:-> create new track parameters.
Definition: MaterialEffectsUpdator.h:146
Trk::MaterialEffectsUpdator::m_landauMode
bool m_landauMode
If in Landau mode, error propagation is done as for landaus.
Definition: MaterialEffectsUpdator.h:331
Trk::MaterialEffectsUpdator::m_msUpdator
ToolHandle< IMultipleScatteringUpdator > m_msUpdator
AlgoTool for MultipleScatterin effects.
Definition: MaterialEffectsUpdator.h:340
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::MaterialEffectsUpdator::validationActionImpl
static void validationActionImpl(ICache &cache)
Definition: MaterialEffectsUpdator.cxx:806
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(const TrackParameters *parm, const MaterialEffectsOnTrack &meff, Trk::ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
User updator interface (full update for a layer):
Definition: MaterialEffectsUpdator.h:192
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
IMaterialEffectsUpdator.h
Trk::MaterialEffectsUpdator::postUpdate
virtual std::unique_ptr< TrackParameters > postUpdate(const TrackParameters &parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Updator interface (pre-update for a layer):
Definition: MaterialEffectsUpdator.h:213
MaterialUpdateMode.h
Trk::MaterialEffectsUpdator::checkCovariance
bool checkCovariance(AmgSymMatrix(5) &updated) const
A simple check method for the 'removeNoise' update model.
Definition: MaterialEffectsUpdator.cxx:819
Trk::MaterialProperties
Definition: MaterialProperties.h:40
Trk::MaterialEffectsUpdator::m_msgOutputCorrections
bool m_msgOutputCorrections
screen output of actual corrections
Definition: MaterialEffectsUpdator.h:324
Trk::MaterialEffectsUpdator::m_doMs
bool m_doMs
steer multiple scattering On/Off from outside
Definition: MaterialEffectsUpdator.h:316
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::MaterialEffectsUpdator::m_forceMomentum
bool m_forceMomentum
Force the momentum to be a specific value.
Definition: MaterialEffectsUpdator.h:318
Trk::addNoise
@ addNoise
Definition: MaterialUpdateMode.h:19
Trk::MaterialEffectsUpdator
Definition: MaterialEffectsUpdator.h:72
Trk::IMaterialEffectsUpdator
Definition: IMaterialEffectsUpdator.h:45
Trk::MaterialEffectsUpdator::preUpdate
virtual std::unique_ptr< TrackParameters > preUpdate(const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override final
Updator interface (pre-update for a layer):
Definition: MaterialEffectsUpdator.h:202
Trk::MaterialEffectsUpdator::modelAction
virtual void modelAction(ICache &cache, const TrackParameters *parm=nullptr) const override final
Only has an effect if m_landauMode == true.
Definition: MaterialEffectsUpdator.h:170
AthAlgTool
Definition: AthAlgTool.h:26
Trk::MaterialEffectsUpdator::update
virtual std::unique_ptr< TrackParameters > update(ICache &cache, const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const override
Updator interface (full update for a layer) —> ALWAYS pointer to new TrackParameters is returned.
Definition: MaterialEffectsUpdator.h:93
Trk::MaterialEffectsUpdator::finalLandauCovarianceUpdate
TrackParameters * finalLandauCovarianceUpdate(const TrackParameters *parm) const
Trk::MaterialEffectsUpdator::postUpdateImpl
std::unique_ptr< TrackParameters > postUpdateImpl(ICache &cache, const TrackParameters &parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const
Definition: MaterialEffectsUpdator.cxx:408
Trk::Layer
Definition: Layer.h:73
Trk::MaterialEffectsUpdator::ICache
IMaterialEffectsUpdator::ICache ICache
Definition: MaterialEffectsUpdator.h:89
Trk::MaterialEffectsUpdator::preUpdateImpl
std::unique_ptr< TrackParameters > preUpdateImpl(ICache &cache, const TrackParameters *parm, const Layer &sf, PropDirection dir=alongMomentum, ParticleHypothesis particle=pion, MaterialUpdateMode matupmode=addNoise) const
Definition: MaterialEffectsUpdator.cxx:354