ATLAS Offline Software
MaterialMapper.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 // MaterialMapper.h, (c) ATLAS Detector software
8 
9 #ifndef TRKDETDESCRTOOLS_MATERIALMAPPER_H
10 #define TRKDETDESCRTOOLS_MATERIALMAPPER_H
11 
12 // Amg
14 // Gaudi & Athena
16 #include "GaudiKernel/IIncidentListener.h"
17 #include "GaudiKernel/ITHistSvc.h"
18 // Trk
20 // ROOT
21 #include "TTree.h"
22 #include "TString.h"
24 
25 #define TRKDETDESCRTOOLS_MAXSTEPS 8000
26 #define TRKDETDESCRTOOLS_MAXLAYERHITS 5000
27 
28 class TTree;
29 
30 namespace Trk {
31 
32  class TrackingVolume;
33  class Layer;
34 
35 
43 
44  float eta;
45  float phi;
46  float path;
47  float pathInX0;
48  float pathInL0;
49  float pathZARho;
50  TTree* tree;
51 
52  VolumeTreeObject(TString name, TString title)
53  : eta(0),
54  phi(0.),
55  path(0.),
56  pathInX0(0.),
57  pathInL0(0.),
58  pathZARho(0.),
59  tree(new TTree(name,title))
60  {
61  tree->Branch("Eta", &eta, "eta/F");
62  tree->Branch("Phi", &phi, "phi/F");
63  tree->Branch("Path", &path, "path/F");
64  tree->Branch("PathInX0", &pathInX0, "pathX0/F");
65  tree->Branch("PathInL0", &pathInL0, "pathL0/F");
66  tree->Branch("PathZARho", &pathZARho, "pathZARho/F");
67  }
68  };
69 
70  struct LayerTreeObject {
71  LayerTreeObject (const LayerTreeObject&) = delete;
73 
74  // values for the full histo
75  float densedHitX;
76  float densedHitY;
77  float densedHitZ;
78  float densedHitR;
79  float densedHitPhi;
82 
84  float path;
85  float pathInX0;
86  float pathInL0;
87  float A;
88  float Z;
89  float rho;
90 
91  int layerHits;
98 
99  TTree* tree;
100 
101  LayerTreeObject(TString name, TString title)
102  : densedHitX(0.),
103  densedHitY(0.),
104  densedHitZ(0.),
105  densedHitR(0.),
106  densedHitPhi(0.),
107  densedHitTheta(0.),
108  densedHits(0),
109  correctionFactor(0.),
110  path(0.),
111  pathInX0(0.),
112  pathInL0(0.),
113  A(0.),
114  Z(0.),
115  rho(0.),
116  layerHits(0),
117  tree(new TTree(name,title))
118  {
119  tree->Branch("DensedHits", &densedHits, "densedHits/I");
120  tree->Branch("DensedHitX", &densedHitX, "densedHitX/F");
121  tree->Branch("DensedHitY", &densedHitY, "densedHitY/F");
122  tree->Branch("DensedHitZ", &densedHitZ, "densedHitZ/F");
123  tree->Branch("DensedHitR", &densedHitR, "densedHitR/F");
124  tree->Branch("DensedHitPhi", &densedHitPhi, "densedHitPhi/F");
125  tree->Branch("DensedHitTheta", &densedHitTheta, "densedHitTheta/F");
126 
127  tree->Branch("CorrFactor", &correctionFactor, "corrF/F");
128  tree->Branch("Path", &path, "pathInX0/F");
129  tree->Branch("PathInX0", &pathInX0, "pathInX0/F");
130  tree->Branch("PathInL0", &pathInL0, "pathInL0/F");
131  tree->Branch("A", &A, "a/F");
132  tree->Branch("Z", &Z, "z/F");
133  tree->Branch("Rho", &rho, "rho/F");
134  tree->Branch("Hits", &layerHits, "layerhits/I");
135  tree->Branch("HitPathInX0", &hitPathInX0, "layerhitpathInX0[layerhits]/F");
136  tree->Branch("HitPositionX", &hitPositionX, "layerhitsX[layerhits]/F");
137  tree->Branch("HitPositionY", &hitPositionY, "layerhitsY[layerhits]/F");
138  tree->Branch("HitPositionZ", &hitPositionZ, "layerhitsZ[layerhits]/F");
139  tree->Branch("HitPositionR", &hitPositionR, "layerhitsR[layerhits]/F");
140  tree->Branch("HitPositionEta", &hitPositionEta, "layerhitsR[layerhits]/F");
141  }
142  };
143 
144 
151 
152  float loc1;
153  float loc2;
154  float eta;
156  float path;
157  float pathInX0;
158  float pathInL0;
159  float A;
160  float Z;
161  float rho;
162 
164  TTree* tree;
165 
166  SurfaceTreeObject(TString name, TString title)
167  : loc1(0.),
168  loc2(0.),
169  eta(0.),
170  correctionFactor(0.),
171  path(0.),
172  pathInX0(0.),
173  pathInL0(0.),
174  A(0.),
175  Z(0.),
176  rho(0.),
177  surfaceHits(0),
178  tree(new TTree(name,title))
179  {
180  tree->Branch("Local1", &loc1, "local1/F");
181  tree->Branch("Local2", &loc2, "local2/F");
182  tree->Branch("Eta", &eta, "eta/F");
183  tree->Branch("CorrFactor", &correctionFactor, "corrF/F");
184  tree->Branch("Path", &path, "path/F");
185  tree->Branch("PathInX0", &pathInX0, "pathInX0/F");
186  tree->Branch("PathInL0", &pathInL0, "pathInL0/F");
187  tree->Branch("A", &A, "a/F");
188  tree->Branch("Z", &Z, "z/F");
189  tree->Branch("Rho", &rho, "rho/F");
190  }
191  };
192 
193 
205  public AthAlgTool, virtual public IMaterialMapper, virtual public IIncidentListener {
206 
207  public:
208 
210  MaterialMapper(const std::string&,
211  const std::string&,
212  const IInterface*);
213 
215  virtual ~MaterialMapper();
216 
219 
222 
224  void recordMaterialHit(const AssociatedMaterial& amhit, const Amg::Vector3D& projectedPosition) const;
225 
227  void recordLayerHit(const AssociatedMaterial& amhit, bool full = false) const;
228 
230  void recordSurfaceHit(const Amg::Vector2D& locpos, const AssociatedMaterial& amhit) const;
231 
233  void handle( const Incident& inc );
234 
235  private:
236 
238  void finalizeVolumeHits(bool mapped=true) const;
239 
241  void finalizeLayerHits() const;
242 
244  void finalizeSurfaceHits() const;
245 
247  void bookValidationTree();
248 
250  VolumeTreeObject* volumeTreeObject(const Layer* lay=0, const TrackingVolume* tvol=0) const;
251 
253  LayerTreeObject* layerTreeObject(const Layer& lay, bool full = false) const;
254 
256  SurfaceTreeObject* surfaceTreeObject(const Layer& lay) const;
257 
258 
259  /* Services */
262 
264 
265  // (1) ------------------------- Tree name of the total material statistics
266  unsigned int m_maxMappingEvents;
267  mutable unsigned int m_processedEvents;
268 
269  std::string m_totalMaterialTree;
270 
271  // (2) ------------------------ Ntuple output of material effects validation
273  std::string m_validationTreeName;
276 
277 
278  // Spatial information
279  mutable int m_materialSteps;
280  mutable float m_averageEta;
281  mutable float m_averagePhi;
282  mutable float m_mappedPath;
283  mutable float m_mappedPathInX0;
284  mutable float m_mappedPathInL0;
285  mutable float m_mappedPathRho;
286  mutable float m_mappedPathZARho;
287  mutable float m_unmappedPathInX0;
288  mutable int m_mapped[TRKDETDESCRTOOLS_MAXSTEPS]{};
289  mutable float m_materialAccumPathInX0[TRKDETDESCRTOOLS_MAXSTEPS]{};
290  mutable float m_materialAccumPathZARho[TRKDETDESCRTOOLS_MAXSTEPS]{};
291  mutable float m_materialStepPath[TRKDETDESCRTOOLS_MAXSTEPS]{};
292  mutable float m_materialStepX0[TRKDETDESCRTOOLS_MAXSTEPS]{};
293  mutable float m_materialStepL0[TRKDETDESCRTOOLS_MAXSTEPS]{};
294  mutable float m_materialStepZ[TRKDETDESCRTOOLS_MAXSTEPS]{};
295  mutable float m_materialStepA[TRKDETDESCRTOOLS_MAXSTEPS]{};
296  mutable float m_materialStepRho[TRKDETDESCRTOOLS_MAXSTEPS]{};
297  mutable float m_materialStepPositionX[TRKDETDESCRTOOLS_MAXSTEPS]{};
298  mutable float m_materialStepPositionY[TRKDETDESCRTOOLS_MAXSTEPS]{};
299  mutable float m_materialStepPositionZ[TRKDETDESCRTOOLS_MAXSTEPS]{};
300  mutable float m_materialStepPositionR[TRKDETDESCRTOOLS_MAXSTEPS]{};
301  mutable float m_materialProjPositionX[TRKDETDESCRTOOLS_MAXSTEPS]{};
302  mutable float m_materialProjPositionY[TRKDETDESCRTOOLS_MAXSTEPS]{};
303  mutable float m_materialProjPositionZ[TRKDETDESCRTOOLS_MAXSTEPS]{};
304  mutable float m_materialProjPositionR[TRKDETDESCRTOOLS_MAXSTEPS]{};
305  mutable float m_materialProjDistance[TRKDETDESCRTOOLS_MAXSTEPS]{};
306 
307  // Per Volume Validation
309  std::string m_volumeTreePrefix;
310  mutable std::map< const Trk::TrackingVolume*, VolumeTreeObject* > m_volumeTrees;
311  mutable std::map< const Trk::TrackingVolume*, VolumeTreeObject* > m_volumeTreesUnmapped;
312 
313  // Per Layer Validation
315  std::string m_layerTreePrefix;
316  mutable std::map< const Trk::Layer*, LayerTreeObject* > m_layerTrees;
317  mutable std::map< const Trk::Layer*, LayerTreeObject* > m_layerFullTrees;
318 
319  // Per Surface Validation
321  std::string m_surfaceTreePrefix;
322  mutable std::map< const Trk::Layer*, SurfaceTreeObject* > m_surfaceTrees;
323 
324  };
325 
326 } // end of namespace
327 
328 #endif // TRKDETDESCRTOOLS_MATERIALMAPPER_H
329 
Trk::LayerTreeObject::densedHitX
float densedHitX
Definition: MaterialMapper.h:75
Trk::LayerTreeObject::densedHitTheta
float densedHitTheta
Definition: MaterialMapper.h:80
Trk::MaterialMapper::m_surfaceTreePrefix
std::string m_surfaceTreePrefix
Definition: MaterialMapper.h:321
Trk::MaterialMapper::m_volumeTreesUnmapped
std::map< const Trk::TrackingVolume *, VolumeTreeObject * > m_volumeTreesUnmapped
Definition: MaterialMapper.h:311
Trk::MaterialMapper::m_layerTrees
std::map< const Trk::Layer *, LayerTreeObject * > m_layerTrees
Definition: MaterialMapper.h:316
Trk::SurfaceTreeObject::A
float A
Definition: MaterialMapper.h:159
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
Trk::LayerTreeObject::pathInL0
float pathInL0
Definition: MaterialMapper.h:86
Trk::MaterialMapper::m_validationTreeDescription
std::string m_validationTreeDescription
validation tree description - second argument in TTree
Definition: MaterialMapper.h:274
Trk::VolumeTreeObject::path
float path
Definition: MaterialMapper.h:46
Trk::LayerTreeObject::hitPositionR
float hitPositionR[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:96
Trk::MaterialMapper::m_mappedPathInX0
float m_mappedPathInX0
total mapped path in X0
Definition: MaterialMapper.h:283
Trk::SurfaceTreeObject::Z
float Z
Definition: MaterialMapper.h:160
Trk::LayerTreeObject::hitPathInX0
float hitPathInX0[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:92
Trk::MaterialMapper::m_volumeValidation
bool m_volumeValidation
Definition: MaterialMapper.h:308
Trk::LayerTreeObject::tree
TTree * tree
Definition: MaterialMapper.h:99
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::LayerTreeObject::pathInX0
float pathInX0
Definition: MaterialMapper.h:85
initialize
void initialize()
Definition: run_EoverP.cxx:894
Trk::MaterialMapper::m_validationTree
TTree * m_validationTree
The validation tree.
Definition: MaterialMapper.h:272
Trk::SurfaceTreeObject::pathInL0
float pathInL0
Definition: MaterialMapper.h:158
Trk::MaterialMapper::m_mappedPathRho
float m_mappedPathRho
total mapped path times rho
Definition: MaterialMapper.h:285
Trk::SurfaceTreeObject::SurfaceTreeObject
SurfaceTreeObject(TString name, TString title)
Definition: MaterialMapper.h:166
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
Trk::MaterialMapper::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: MaterialMapper.h:261
Trk::MaterialMapper::m_volumeTreePrefix
std::string m_volumeTreePrefix
Definition: MaterialMapper.h:309
Trk::SurfaceTreeObject::surfaceHits
int surfaceHits
Definition: MaterialMapper.h:163
Trk::MaterialMapper::m_layerTreePrefix
std::string m_layerTreePrefix
Definition: MaterialMapper.h:315
Trk::LayerTreeObject::Z
float Z
Definition: MaterialMapper.h:88
Trk::VolumeTreeObject::VolumeTreeObject
VolumeTreeObject(TString name, TString title)
Definition: MaterialMapper.h:52
Trk::LayerTreeObject::correctionFactor
float correctionFactor
Definition: MaterialMapper.h:83
Trk::VolumeTreeObject::pathZARho
float pathZARho
Definition: MaterialMapper.h:49
Trk::VolumeTreeObject::VolumeTreeObject
VolumeTreeObject(const VolumeTreeObject &)=delete
Trk::SurfaceTreeObject
Definition: MaterialMapper.h:148
Trk::MaterialMapper::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Definition: MaterialMapper.h:260
Trk::SurfaceTreeObject::rho
float rho
Definition: MaterialMapper.h:161
Trk::VolumeTreeObject::pathInL0
float pathInL0
Definition: MaterialMapper.h:48
Trk::VolumeTreeObject::tree
TTree * tree
Definition: MaterialMapper.h:50
Trk::LayerTreeObject::path
float path
Definition: MaterialMapper.h:84
python.RingerConstants.Layer
Layer
Definition: RingerConstants.py:42
Trk::SurfaceTreeObject::loc2
float loc2
Definition: MaterialMapper.h:153
Trk::LayerTreeObject::hitPositionEta
float hitPositionEta[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:97
Trk::MaterialMapper::m_layerFullTrees
std::map< const Trk::Layer *, LayerTreeObject * > m_layerFullTrees
Definition: MaterialMapper.h:317
Trk::LayerTreeObject::densedHitR
float densedHitR
Definition: MaterialMapper.h:78
Trk::MaterialMapper::m_materialSteps
int m_materialSteps
number of update positions
Definition: MaterialMapper.h:279
Trk::LayerTreeObject::layerHits
int layerHits
Definition: MaterialMapper.h:91
Trk::LayerTreeObject::densedHitY
float densedHitY
Definition: MaterialMapper.h:76
Trk::MaterialMapper::m_maxMappingEvents
unsigned int m_maxMappingEvents
Definition: MaterialMapper.h:266
Trk::LayerTreeObject::densedHits
int densedHits
Definition: MaterialMapper.h:81
GeoPrimitives.h
Trk::LayerTreeObject::A
float A
Definition: MaterialMapper.h:87
A
Trk::VolumeTreeObject::pathInX0
float pathInX0
Definition: MaterialMapper.h:47
Trk::MaterialMapper::m_processedEvents
unsigned int m_processedEvents
Definition: MaterialMapper.h:267
TRKDETDESCRTOOLS_MAXLAYERHITS
#define TRKDETDESCRTOOLS_MAXLAYERHITS
Definition: MaterialMapper.h:26
Trk::MaterialMapper::m_unmappedPathInX0
float m_unmappedPathInX0
total path in x0 in these events lost
Definition: MaterialMapper.h:287
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
covarianceTool.title
title
Definition: covarianceTool.py:542
AthAlgTool.h
Trk::MaterialMapper::m_mappedPathZARho
float m_mappedPathZARho
total mapped path times (Z/A)*rho
Definition: MaterialMapper.h:286
Trk::MaterialMapper::m_validationTreeFolder
std::string m_validationTreeFolder
stream/folder to for the TTree to be written out
Definition: MaterialMapper.h:275
Trk::SurfaceTreeObject::eta
float eta
Definition: MaterialMapper.h:154
Trk::SurfaceTreeObject::correctionFactor
float correctionFactor
Definition: MaterialMapper.h:155
Trk::SurfaceTreeObject::path
float path
Definition: MaterialMapper.h:156
Trk::LayerTreeObject::densedHitZ
float densedHitZ
Definition: MaterialMapper.h:77
IMaterialMapper.h
Trk::MaterialMapper::m_mappedPathInL0
float m_mappedPathInL0
total mapped path in L0
Definition: MaterialMapper.h:284
TRKDETDESCRTOOLS_MAXSTEPS
#define TRKDETDESCRTOOLS_MAXSTEPS
Definition: MaterialMapper.h:25
Trk::MaterialMapper::m_validationTreeName
std::string m_validationTreeName
validation tree name - to be accessed by this from root
Definition: MaterialMapper.h:273
Trk::MaterialMapper
Definition: MaterialMapper.h:205
Trk::AssociatedMaterial
Definition: AssociatedMaterial.h:33
Trk::MaterialMapper::m_surfaceValidation
bool m_surfaceValidation
Definition: MaterialMapper.h:320
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::LayerTreeObject
Definition: MaterialMapper.h:70
Trk::SurfaceTreeObject::tree
TTree * tree
Definition: MaterialMapper.h:164
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
find_data.full
full
Definition: find_data.py:27
Trk::MaterialMapper::m_totalMaterialTree
std::string m_totalMaterialTree
Definition: MaterialMapper.h:269
Trk::MaterialMapper::m_averagePhi
float m_averagePhi
average ogu
Definition: MaterialMapper.h:281
Trk::LayerTreeObject::operator=
LayerTreeObject & operator=(const LayerTreeObject &)=delete
Trk::VolumeTreeObject::phi
float phi
Definition: MaterialMapper.h:45
Trk::LayerTreeObject::densedHitPhi
float densedHitPhi
Definition: MaterialMapper.h:79
Trk::SurfaceTreeObject::SurfaceTreeObject
SurfaceTreeObject(const SurfaceTreeObject &)=delete
Trk::LayerTreeObject::hitPositionY
float hitPositionY[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:94
Trk::VolumeTreeObject
Definition: MaterialMapper.h:40
Trk::SurfaceTreeObject::pathInX0
float pathInX0
Definition: MaterialMapper.h:157
Trk::MaterialMapper::m_surfaceTrees
std::map< const Trk::Layer *, SurfaceTreeObject * > m_surfaceTrees
Definition: MaterialMapper.h:322
Trk::VolumeTreeObject::operator=
VolumeTreeObject & operator=(const VolumeTreeObject &)=delete
Trk::LayerTreeObject::hitPositionZ
float hitPositionZ[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:95
Trk::LayerTreeObject::rho
float rho
Definition: MaterialMapper.h:89
Trk::SurfaceTreeObject::loc1
float loc1
Definition: MaterialMapper.h:152
Trk::LayerTreeObject::LayerTreeObject
LayerTreeObject(const LayerTreeObject &)=delete
mapped
std::vector< std::string > mapped
Definition: hcg.cxx:51
Trk::VolumeTreeObject::eta
float eta
Definition: MaterialMapper.h:44
Trk::LayerTreeObject::LayerTreeObject
LayerTreeObject(TString name, TString title)
Definition: MaterialMapper.h:101
Trk::MaterialMapper::m_mappedPath
float m_mappedPath
total mapped path
Definition: MaterialMapper.h:282
Trk::IMaterialMapper
Definition: IMaterialMapper.h:37
AthAlgTool
Definition: AthAlgTool.h:26
Trk::MaterialMapper::m_averageEta
float m_averageEta
average eta
Definition: MaterialMapper.h:280
Trk::MaterialMapper::m_volumeTrees
std::map< const Trk::TrackingVolume *, VolumeTreeObject * > m_volumeTrees
Definition: MaterialMapper.h:310
checker_macros.h
Define macros for attributes used to control the static checker.
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::LayerTreeObject::hitPositionX
float hitPositionX[TRKDETDESCRTOOLS_MAXLAYERHITS]
Definition: MaterialMapper.h:93
Trk::MaterialMapper::m_materialAssociationType
int m_materialAssociationType
Definition: MaterialMapper.h:263
Trk::MaterialMapper::m_layerValidation
bool m_layerValidation
Definition: MaterialMapper.h:314
Trk::SurfaceTreeObject::operator=
SurfaceTreeObject & operator=(const SurfaceTreeObject &)=delete
Trk::Layer
Definition: Layer.h:73
ServiceHandle< IIncidentSvc >