ATLAS Offline Software
MaterialAllocator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // MaterialAllocator.h
7 // Header file for class MaterialAllocator
8 //
9 // (c) ATLAS Detector software
11 
12 #ifndef TRKIPATFITTER_MATERIALALLOCATOR_H
13 #define TRKIPATFITTER_MATERIALALLOCATOR_H
14 
15 //<<<<<< INCLUDES a>>>>>>
16 
17 #include <memory>
18 #include <mutex>
19 
21 #include "GaudiKernel/ServiceHandle.h"
22 #include "GaudiKernel/ToolHandle.h"
34 
35 //<<<<<< CLASS DECLARATIONS >>>>>>
36 
37 class MessageHelper;
38 namespace Trk {
39 class FitMeasurement;
40 class FitParameters;
41 class IExtrapolator;
42 class IIntersector;
43 class TrackingVolume;
44 class TrackStateOnSurface;
45 class Volume;
46 
50 class MaterialAllocator : public AthAlgTool, virtual public IMaterialAllocator {
51  public:
52  // standard AlgTool methods
53  MaterialAllocator(const std::string& type, const std::string& name,
54  const IInterface* parent);
55  virtual ~MaterialAllocator() = default; // destructor
56 
57  // standard Athena methods
58  virtual StatusCode initialize() override;
59  virtual StatusCode finalize() override;
60 
61  // add leading material effects to track
62  virtual void addLeadingMaterial(std::vector<FitMeasurement*>& measurements,
63  ParticleHypothesis particleHypothesis,
64  FitParameters& fitParameters,
65  Garbage_t& garbage) const override;
66 
67  // allocate material
68  virtual void allocateMaterial(std::vector<FitMeasurement*>& measurements,
69  ParticleHypothesis particleHypothesis,
70  FitParameters& fitParameters,
71  const TrackParameters& startParameters,
72  Garbage_t& garbage) const override;
73 
74  // initialize scattering (needs to know X0 integral)
75  virtual void initializeScattering(
76  std::vector<FitMeasurement*>& measurements) const override;
77 
78  // material TSOS between spectrometer entrance surface and parameters given in
79  // spectrometer */
80  virtual std::vector<const TrackStateOnSurface*>* leadingSpectrometerTSOS(
81  const TrackParameters& spectrometerParameters,
82  Garbage_t& garbage) const override;
83 
84  // order measurements by distance from startPosition
85  virtual void orderMeasurements(std::vector<FitMeasurement*>& measurements,
86  Amg::Vector3D startDirection,
87  Amg::Vector3D startPosition) const override;
88 
89  // has material been reallocated?
90  virtual bool reallocateMaterial(std::vector<FitMeasurement*>& measurements,
91  FitParameters& fitParameters,
92  Garbage_t& garbage) const override;
93 
94  private:
95  // add material delimiters to control aggregation
97  std::vector<FitMeasurement*>& measurements) const;
98 
99  // memory management
100  static void deleteMaterial(
101  const std::vector<const TrackStateOnSurface*>* material,
102  Garbage_t& garbage);
103 
104  // extrapolateM wrapper
105  const std::vector<const TrackStateOnSurface*>* extrapolatedMaterial(
106  const ToolHandle<IExtrapolator>& extrapolator,
107  const TrackParameters& parameters, const Surface& surface,
108  PropDirection dir, const BoundaryCheck& boundsCheck,
109  ParticleHypothesis particleHypothesis, Garbage_t& garbage) const;
110 
111  // allocate material in inner detector
112  void indetMaterial(std::vector<FitMeasurement*>& measurements,
113  ParticleHypothesis particleHypothesis,
114  const TrackParameters& startParameters,
115  Garbage_t& garbage) const;
116 
117  // material aggregation
118  std::pair<FitMeasurement*, FitMeasurement*> materialAggregation(
119  const std::vector<const TrackStateOnSurface*>& material,
120  std::vector<FitMeasurement*>& measurements, double particleMass) const;
121 
122  void materialAggregation(std::vector<FitMeasurement*>& measurements,
123  double particleMass) const;
124 
125  // material measurement corresponding to TrackStateOnSurface
127  double outwardsEnergy,
128  double particleMass);
129 
130  // VERBOSE print of measurements
131  void printMeasurements(std::vector<FitMeasurement*>& measurements) const;
132 
133  // allocate material in spectrometer
134  void spectrometerMaterial(std::vector<FitMeasurement*>& measurements,
135  ParticleHypothesis particleHypothesis,
136  FitParameters& fitParameters,
137  const TrackParameters& startParameters,
138  Garbage_t& garbage) const;
139 
140  // configurables (svc/tools then options)
141  ToolHandle<IExtrapolator> m_extrapolator{
142  this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator", ""};
143  ToolHandle<IIntersector> m_intersector{
144  this, "Intersector", "Trk::RungeKuttaIntersector/RungeKuttaIntersector",
145  ""};
147  this, "TrackingGeometrySvc","", ""};
149  this, "TrackingVolumesSvc", "Trk::TrackingVolumesSvc/TrackingVolumesSvc",
150  ""};
151  ToolHandle<IPropagator> m_stepPropagator{
152  this, "STEP_Propagator", "Trk::STEP_Propagator/AtlasSTEP_Propagator", ""};
153 
155  this, "TrackingGeometryReadKey", "AtlasTrackingGeometry",
156  "Key of the TrackingGeometry conditions data."};
157 
159  static const std::string vol_name = "MuonSpectrometerEntrance";
161  if (m_trackingGeometryReadKey.empty()) {
162  return m_trackingGeometrySvc->trackingGeometry()->trackingVolume(
163  vol_name);
164  }
166  m_trackingGeometryReadKey, Gaudi::Hive::currentContext());
167  if (!handle.isValid()) {
168  ATH_MSG_WARNING("Could not retrieve a valid tracking geometry");
169  return nullptr;
170  }
171  return handle.cptr()->trackingVolume(vol_name);
172  }
173 
177  unsigned m_maxWarnings;
178 
179  // configurable parameters and tolerances (for aggregation rules and Coulomb
180  // scattering constants)
187 
188  // constants
191 
193 
194  // count warnings
195  std::unique_ptr<MessageHelper> m_messageHelper;
196 
198  public:
199  bool operator()(const std::pair<double, FitMeasurement*>& x,
200  const std::pair<double, FitMeasurement*>& y) const {
201  return x.first < y.first;
202  }
203  };
204 };
205 
206 } // namespace Trk
207 
208 #endif // TRKIPATFITTER_MATERIALALLOCATOR_H
Trk::MaterialAllocator::printMeasurements
void printMeasurements(std::vector< FitMeasurement * > &measurements) const
Definition: MaterialAllocator.cxx:1899
Trk::MaterialAllocator::m_scattererMinGap
double m_scattererMinGap
Definition: MaterialAllocator.h:182
Trk::y
@ y
Definition: ParamDefs.h:62
TrackParameters.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::MagneticFieldProperties
Definition: MagneticFieldProperties.h:31
Trk::MaterialAllocator::m_allowReordering
bool m_allowReordering
Definition: MaterialAllocator.h:175
MessageHelper
Definition: MessageHelper.h:16
Trk::MaterialAllocator::m_maxWarnings
unsigned m_maxWarnings
Definition: MaterialAllocator.h:177
Trk::MaterialAllocator::m_scatteringLogCoeff
double m_scatteringLogCoeff
Definition: MaterialAllocator.h:184
Trk::MaterialAllocator::m_messageHelper
std::unique_ptr< MessageHelper > m_messageHelper
Definition: MaterialAllocator.h:195
Trk::MaterialAllocator::m_stepPropagator
ToolHandle< IPropagator > m_stepPropagator
Definition: MaterialAllocator.h:151
Trk::MaterialAllocator::m_stepField
Trk::MagneticFieldProperties m_stepField
Definition: MaterialAllocator.h:192
Trk::MaterialAllocator::m_trackingGeometryReadKey
SG::ReadCondHandleKey< TrackingGeometry > m_trackingGeometryReadKey
Definition: MaterialAllocator.h:154
Trk::MaterialAllocator::allocateMaterial
virtual void allocateMaterial(std::vector< FitMeasurement * > &measurements, ParticleHypothesis particleHypothesis, FitParameters &fitParameters, const TrackParameters &startParameters, Garbage_t &garbage) const override
IMaterialAllocator interface: allocate material.
Definition: MaterialAllocator.cxx:520
Trk::MaterialAllocator::spectrometerMaterial
void spectrometerMaterial(std::vector< FitMeasurement * > &measurements, ParticleHypothesis particleHypothesis, FitParameters &fitParameters, const TrackParameters &startParameters, Garbage_t &garbage) const
Definition: MaterialAllocator.cxx:2009
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:205
Trk::MaterialAllocator::m_calorimeterVolume
const Trk::Volume * m_calorimeterVolume
Definition: MaterialAllocator.h:189
Trk::MaterialAllocator::initialize
virtual StatusCode initialize() override
Definition: MaterialAllocator.cxx:74
Trk::MaterialAllocator::m_aggregateMaterial
bool m_aggregateMaterial
Definition: MaterialAllocator.h:174
Trk::MaterialAllocator::addLeadingMaterial
virtual void addLeadingMaterial(std::vector< FitMeasurement * > &measurements, ParticleHypothesis particleHypothesis, FitParameters &fitParameters, Garbage_t &garbage) const override
IMaterialAllocator interface: add leading material effects to fit measurements and parameters.
Definition: MaterialAllocator.cxx:133
IExtrapolator.h
IPropagator.h
Trk::MaterialAllocator::m_scatteringConstant
double m_scatteringConstant
Definition: MaterialAllocator.h:183
Trk::MaterialAllocator::MaterialAllocator
MaterialAllocator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MaterialAllocator.cxx:38
Trk::MaterialAllocator::deleteMaterial
static void deleteMaterial(const std::vector< const TrackStateOnSurface * > *material, Garbage_t &garbage)
Definition: MaterialAllocator.cxx:990
Trk::MaterialAllocator::m_useStepPropagator
int m_useStepPropagator
Definition: MaterialAllocator.h:176
MagneticFieldProperties.h
Trk::MaterialAllocator::finalize
virtual StatusCode finalize() override
Definition: MaterialAllocator.cxx:127
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
IMaterialAllocator.h
GeoPrimitives.h
Trk::MaterialAllocator::orderMeasurements
virtual void orderMeasurements(std::vector< FitMeasurement * > &measurements, Amg::Vector3D startDirection, Amg::Vector3D startPosition) const override
IMaterialAllocator interface: clear temporary TSOS.
Definition: MaterialAllocator.cxx:696
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
Trk::MaterialAllocator::compareByDistance::operator()
bool operator()(const std::pair< double, FitMeasurement * > &x, const std::pair< double, FitMeasurement * > &y) const
Definition: MaterialAllocator.h:199
Trk::MaterialAllocator::m_indetVolume
const Trk::Volume * m_indetVolume
Definition: MaterialAllocator.h:190
Trk::FitMeasurement
Definition: FitMeasurement.h:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::MaterialAllocator::m_orderingTolerance
double m_orderingTolerance
Definition: MaterialAllocator.h:181
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trk::IMaterialAllocator::Garbage_t
std::vector< std::unique_ptr< const TrackStateOnSurface > > Garbage_t
Definition: IMaterialAllocator.h:40
Trk::MaterialAllocator::measurementFromTSOS
static FitMeasurement * measurementFromTSOS(const TrackStateOnSurface &tsos, double outwardsEnergy, double particleMass)
Definition: MaterialAllocator.cxx:1881
Trk::MaterialAllocator::addSpectrometerDelimiters
void addSpectrometerDelimiters(std::vector< FitMeasurement * > &measurements) const
Definition: MaterialAllocator.cxx:877
Trk::MaterialAllocator::compareByDistance
Definition: MaterialAllocator.h:197
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::MaterialAllocator::m_sectorMaxPhi
double m_sectorMaxPhi
Definition: MaterialAllocator.h:185
Trk::MaterialAllocator::m_intersector
ToolHandle< IIntersector > m_intersector
Definition: MaterialAllocator.h:143
Trk::MaterialAllocator::getSpectrometerEntrance
const Trk::TrackingVolume * getSpectrometerEntrance() const
Definition: MaterialAllocator.h:158
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::MaterialAllocator
Main Fitter tool providing the implementation for the different fitting, extension and refitting use ...
Definition: MaterialAllocator.h:50
ReadCondHandleKey.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
Trk::MaterialAllocator::m_trackingGeometrySvc
ServiceHandle< ITrackingGeometrySvc > m_trackingGeometrySvc
Definition: MaterialAllocator.h:146
Trk::IMaterialAllocator
Definition: IMaterialAllocator.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::MaterialAllocator::indetMaterial
void indetMaterial(std::vector< FitMeasurement * > &measurements, ParticleHypothesis particleHypothesis, const TrackParameters &startParameters, Garbage_t &garbage) const
Definition: MaterialAllocator.cxx:1053
Trk::MaterialAllocator::m_trackingVolumesSvc
ServiceHandle< ITrackingVolumesSvc > m_trackingVolumesSvc
Definition: MaterialAllocator.h:148
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
IIntersector.h
Trk::MaterialAllocator::~MaterialAllocator
virtual ~MaterialAllocator()=default
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
Trk::MaterialAllocator::reallocateMaterial
virtual bool reallocateMaterial(std::vector< FitMeasurement * > &measurements, FitParameters &fitParameters, Garbage_t &garbage) const override
IMaterialAllocator interface: has material been reallocated?
Definition: MaterialAllocator.cxx:752
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::MaterialAllocator::materialAggregation
std::pair< FitMeasurement *, FitMeasurement * > materialAggregation(const std::vector< const TrackStateOnSurface * > &material, std::vector< FitMeasurement * > &measurements, double particleMass) const
Definition: MaterialAllocator.cxx:1468
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
ITrackingGeometrySvc.h
Trk::MaterialAllocator::m_extrapolator
ToolHandle< IExtrapolator > m_extrapolator
Definition: MaterialAllocator.h:141
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::TrackingGeometry::trackingVolume
const TrackingVolume * trackingVolume(const std::string &name) const
return the tracking Volume by name, 0 if it doesn't exist
Trk::MaterialAllocator::initializeScattering
virtual void initializeScattering(std::vector< FitMeasurement * > &measurements) const override
IMaterialAllocator interface: initialize scattering (needs to know X0 integral)
Definition: MaterialAllocator.cxx:537
Trk::MaterialAllocator::m_stationMaxGap
double m_stationMaxGap
Definition: MaterialAllocator.h:186
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
TrackingGeometry.h
Trk::FitParameters
Definition: FitParameters.h:29
AthAlgTool
Definition: AthAlgTool.h:26
Trk::x
@ x
Definition: ParamDefs.h:61
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::Volume
Definition: Volume.h:35
Trk::TrackingVolume
Definition: TrackingVolume.h:121
ITrackingVolumesSvc.h
Trk::MaterialAllocator::extrapolatedMaterial
const std::vector< const TrackStateOnSurface * > * extrapolatedMaterial(const ToolHandle< IExtrapolator > &extrapolator, const TrackParameters &parameters, const Surface &surface, PropDirection dir, const BoundaryCheck &boundsCheck, ParticleHypothesis particleHypothesis, Garbage_t &garbage) const
Definition: MaterialAllocator.cxx:1002
Trk::MaterialAllocator::leadingSpectrometerTSOS
virtual std::vector< const TrackStateOnSurface * > * leadingSpectrometerTSOS(const TrackParameters &spectrometerParameters, Garbage_t &garbage) const override
IMaterialAllocator interface: material TSOS between spectrometer entrance surface and parameters give...
Definition: MaterialAllocator.cxx:608
ServiceHandle
Definition: ClusterMakerTool.h:37
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67