ATLAS Offline Software
MaterialMapping.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 // MaterialMapping.h, (c) ATLAS Detector software
8 
9 #ifndef TRKDETDESCRALGS_MATERIALMAPPING_H
10 #define TRKDETDESCRALGS_MATERIALMAPPING_H
11 
12 // Athena & Gaudi includes
14 #include "GaudiKernel/ServiceHandle.h"
15 #include "GaudiKernel/ToolHandle.h"
18 #include "TString.h"
20 #include <fstream>
21 #include <iostream>
22 #include <map>
23 #include <string>
24 // TrkDetDescr Algs, Interfaces, Utils
28 // TrkExtrapolation
30 // TrkGeometry
32 
33 #ifdef TRKDETDESCR_MEMUSAGE
35 #endif
36 
37 #ifndef UCHARCONV
38 #define UCHARCONV
39 #define ucharbin 0.00392157 // 1./double(1.*UCHAR_MAX)
40 // int to unsigned char and vv
41 #define uchar2uint(uchar) static_cast<unsigned int>(uchar)
42 #define uint2uchar(unint) static_cast<unsigned char>(unint)
43 // double to unsigned char and vv
44 #define uchar2dfrac(uchar) double(uchar * ucharbin)
45 #define dfrac2uchar(dfrac) lrint(dfrac* UCHAR_MAX)
46 #endif
47 
48 class TTree;
49 
50 namespace Trk {
51 
52 class Layer;
53 class TrackingVolume;
54 class SurfaceMaterialRecord;
55 class LayerMaterialRecord;
56 class LayerMaterialMap;
57 class Material;
58 class MaterialProperties;
59 class BinnedLayerMaterial;
60 class CompressedLayerMaterial;
61 class ElementTable;
62 
73 {
74 
75 public:
77  MaterialMapping(const std::string& name, ISvcLocator* pSvcLocator);
78 
81 
84 
87 
90 
91 private:
93  bool associateHit(const Trk::Layer& tvol,
94  const Amg::Vector3D& pos,
95  const Amg::Vector3D& layerHitPosition,
96  double stepl,
97  const Trk::Material& mat);
98 
100  void registerVolume(const Trk::TrackingVolume& tvol, int lvl);
101 
104  Trk::LayerMaterialMap* propSet);
105 
107  void insertLayerMaterialRecord(const Trk::Layer& lay);
108 
111 
112  const TrackingGeometry& trackingGeometry() const;
113 
114  bool
116  ToolHandle<IExtrapolationEngine> m_extrapolationEngine{
117  this,
118  "ExtrapolationEngine",
119  "",
120  "Extrapolation Engine"
121  };
122 
123  std::string m_mappingVolumeName;
125 
129 
131  double m_etaCutOff;
132  int m_etaSide;
135 
136  ToolHandle<ILayerMaterialAnalyser> m_layerMaterialRecordAnalyser{
137  this,
138  "LayerMaterialRecordAnalyser",
139  "",
140  "Layer material analyser for the layer material record"
141  };
142  ToolHandleArray<ILayerMaterialAnalyser> m_layerMaterialAnalysers{
143  this,
144  "LayerMaterialAnalysers",
145  {},
146  "Layer material analysers per creator (if wanted)"
147  };
148  ToolHandleArray<ILayerMaterialCreator> m_layerMaterialCreators{
149  this,
150  "LayerMaterialCreators",
151  {},
152  "Layer material creators"
153  };
154 
157  ToolHandle<IMaterialMapper> m_materialMapper{ this,
158  "MaterialMapper",
159  "",
160  "IMaterialMapper algTool" };
163 
168 
169  // the material maps ordered with layer keys
170  std::map<const Layer*, LayerMaterialRecord>
172  std::map<const Layer*, bool>
174  double m_accumulatedMaterialXX0;
177 
178  // statistics for steps
179  size_t m_mapped;
180  size_t m_unmapped;
182 
184 
187  const EventContext& ctx) const
188  {
190  if (!handle.isValid()) {
191  ATH_MSG_FATAL("Could not load TrackingGeometry with name '"
192  << m_trackingGeometryReadKey.key() << "'. Aborting.");
194  }
195  return handle.cptr();
196  }
197 
199  this,
200  "TrackingGeometryReadKey",
201  "",
202  "Key of the TrackingGeometry conditions data."
203  };
204 
205 #ifdef TRKDETDESCR_MEMUSAGE
206  MemoryLogger m_memoryLogger;
207 #endif
208 };
209 
210 inline const Trk::TrackingGeometry&
212 {
213  const Trk::TrackingGeometry* tracking_geometry =
214  retrieveTrackingGeometry(Gaudi::Hive::currentContext());
215  if (!tracking_geometry) {
216  ATH_MSG_FATAL("Did not get valid TrackingGeometry. Aborting.");
217  throw GaudiException("MaterialMapping",
218  "Problem with TrackingGeometry loading.",
219  StatusCode::FAILURE);
220  }
221  return *tracking_geometry;
222 }
223 }
224 
225 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
Trk::MaterialMapping::m_layerMaterialCreators
ToolHandleArray< ILayerMaterialCreator > m_layerMaterialCreators
Definition: MaterialMapping.h:148
Trk::MaterialMapping::m_layerRecords
std::map< const Layer *, LayerMaterialRecord > m_layerRecords
this is the general record for the search
Definition: MaterialMapping.h:171
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::MaterialMapping::m_trackingGeometryReadKey
SG::ReadCondHandleKey< TrackingGeometry > m_trackingGeometryReadKey
Definition: MaterialMapping.h:198
Trk::MaterialMapping::m_inputEventElementTable
SG::ReadHandleKey< Trk::ElementTable > m_inputEventElementTable
input event table
Definition: MaterialMapping.h:167
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
Trk::MaterialMapping::registerVolume
void registerVolume(const Trk::TrackingVolume &tvol, int lvl)
Output information with Level.
Definition: MaterialMapping.cxx:532
Trk::MaterialMapping::m_layersRecordedPerEvent
std::map< const Layer *, bool > m_layersRecordedPerEvent
these are the layers hit per event - for empty hit scaling
Definition: MaterialMapping.h:173
Trk::MaterialMapping::m_etaCutOff
double m_etaCutOff
general steering
Definition: MaterialMapping.h:131
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
MaterialStepCollection.h
Trk::MaterialMapping::handleTrackingGeometry
StatusCode handleTrackingGeometry()
Retrieve the TrackingGeometry and its informations.
Definition: MaterialMapping.cxx:507
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
Trk::MaterialMapping::m_unmapped
size_t m_unmapped
Definition: MaterialMapping.h:180
Trk::MaterialMapping::trackingGeometry
const TrackingGeometry & trackingGeometry() const
Definition: MaterialMapping.h:211
Trk::MaterialMapping::throwFailedToGetTrackingGeometry
void throwFailedToGetTrackingGeometry() const
Definition: MaterialMapping.cxx:606
Trk::LayerMaterialMap
Definition: LayerMaterialMap.h:32
python.RingerConstants.Layer
Layer
Definition: RingerConstants.py:42
Trk::MaterialMapping::m_minCompositionFraction
double m_minCompositionFraction
minimal fraction to be accounted for the composition recording
Definition: MaterialMapping.h:162
Trk::MaterialMapping::m_accumulatedMaterialXX0
double m_accumulatedMaterialXX0
the accumulated material information
Definition: MaterialMapping.h:175
Trk::MemoryLogger
Definition: MemoryLogger.h:31
AthAlgorithm.h
GeoPrimitives.h
Trk::MaterialMapping::m_associationType
int m_associationType
Definition: MaterialMapping.h:134
Trk::MaterialMapping::m_skippedOutside
size_t m_skippedOutside
Definition: MaterialMapping.h:181
Trk::MaterialMapping::m_outputLayerMaterialSetName
std::string m_outputLayerMaterialSetName
Definition: MaterialMapping.h:128
Trk::MaterialMapping::assignLayerMaterialProperties
void assignLayerMaterialProperties(Trk::TrackingVolume &tvol, Trk::LayerMaterialMap *propSet)
create the LayerMaterialRecord *‍/
Definition: MaterialMapping.cxx:356
Trk::MaterialMapping::m_etaSide
int m_etaSide
needed for debugging: -1 negative | 0 all | 1 positive
Definition: MaterialMapping.h:132
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::MaterialMapping::m_mapComposition
bool m_mapComposition
map the composition of the material
Definition: MaterialMapping.h:161
Trk::MaterialMapping::m_elementTable
Trk::ElementTable * m_elementTable
the accumulated element table
Definition: MaterialMapping.h:165
MemoryLogger.h
ILayerMaterialCreator.h
Trk::MaterialMapping::m_mappingVolumeName
std::string m_mappingVolumeName
Definition: MaterialMapping.h:123
IMaterialMapper.h
Trk::MaterialMapping::m_layerMaterialAnalysers
ToolHandleArray< ILayerMaterialAnalyser > m_layerMaterialAnalysers
Definition: MaterialMapping.h:142
AthAlgorithm
Definition: AthAlgorithm.h:47
Trk::MaterialMapping::~MaterialMapping
~MaterialMapping()
Default Destructor.
Trk::MaterialMapping::m_extrapolationEngine
ToolHandle< IExtrapolationEngine > m_extrapolationEngine
Definition: MaterialMapping.h:116
Trk::MaterialMapping::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: MaterialMapping.cxx:88
Trk::MaterialMapping::m_materialMapper
ToolHandle< IMaterialMapper > m_materialMapper
Definition: MaterialMapping.h:157
Trk::MaterialMapping::m_mapped
size_t m_mapped
Definition: MaterialMapping.h:179
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Trk::MaterialMapping::m_accumulatedRhoS
double m_accumulatedRhoS
Definition: MaterialMapping.h:176
Trk::MaterialMapping::execute
StatusCode execute()
standard Athena-Algorithm method
Definition: MaterialMapping.cxx:116
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::MaterialMapping::m_layerMaterialRecordAnalyser
ToolHandle< ILayerMaterialAnalyser > m_layerMaterialRecordAnalyser
Definition: MaterialMapping.h:136
Trk::MaterialMapping
Definition: MaterialMapping.h:73
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::MaterialMapping::m_useLayerThickness
bool m_useLayerThickness
use the actual layer thickness
Definition: MaterialMapping.h:133
Trk::MaterialMapping::m_mapMaterial
bool m_mapMaterial
Mapper and Inspector.
Definition: MaterialMapping.h:156
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
Trk::MaterialMapping::associateHit
bool associateHit(const Trk::Layer &tvol, const Amg::Vector3D &pos, const Amg::Vector3D &layerHitPosition, double stepl, const Trk::Material &mat)
Associate the Step to the Layer.
Definition: MaterialMapping.cxx:311
Trk::MaterialMapping::m_checkForEmptyHits
bool m_checkForEmptyHits
use extrapoaltion engine to check for empty hits
Definition: MaterialMapping.h:115
Trk::ElementTable
Definition: ElementTable.h:24
Trk::MaterialMapping::MaterialMapping
MaterialMapping(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: MaterialMapping.cxx:36
Trk::MaterialMapping::insertLayerMaterialRecord
void insertLayerMaterialRecord(const Trk::Layer &lay)
Definition: MaterialMapping.cxx:585
TrackingGeometry.h
Trk::MaterialMapping::m_mappingVolume
const Trk::TrackingVolume * m_mappingVolume
Definition: MaterialMapping.h:124
Trk::Material
Definition: Material.h:116
Trk::MaterialMapping::m_inputMaterialStepCollection
SG::ReadHandleKey< MaterialStepCollection > m_inputMaterialStepCollection
output / input steering
Definition: MaterialMapping.h:127
Trk::MaterialMapping::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: MaterialMapping.cxx:406
Trk::MaterialMapping::retrieveTrackingGeometry
const TrackingGeometry * retrieveTrackingGeometry(const EventContext &ctx) const
Definition: MaterialMapping.h:186
IExtrapolationEngine.h
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Material
@ Material
Definition: MaterialTypes.h:8
Trk::MaterialMapping::m_layerMaterialScreenOutput
int m_layerMaterialScreenOutput
Definition: MaterialMapping.h:183
ILayerMaterialAnalyser.h
Trk::Layer
Definition: Layer.h:73
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67