ATLAS Offline Software
MaterialMapper.cxx
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.cxx, (c) ATLAS Detector software
8 
9 // Trk include
15 #include "TrkGeometry/DiscLayer.h"
17 
18 
19 // constructor
20 Trk::MaterialMapper::MaterialMapper(const std::string& t, const std::string& n, const IInterface* p)
21 : AthAlgTool(t,n,p),
22  m_incidentSvc("IncidentSvc", n),
23  m_histSvc("THistSvc", n),
24  m_materialAssociationType(1),
25  m_maxMappingEvents(100000),
26  m_processedEvents(0),
27  m_totalMaterialTree("TotalMaterial"),
28  m_validationTree(nullptr),
29  m_validationTreeName("MaterialMapper"),
30  m_validationTreeDescription("Material Effects Updator information"),
31  m_validationTreeFolder("/val/MaterialMapper"),
32  m_materialSteps(0),
33  m_averageEta{}, m_averagePhi{}, m_mappedPath{}, m_mappedPathInX0{},
34  m_mappedPathInL0{}, m_mappedPathRho{}, m_mappedPathZARho{},
35  m_unmappedPathInX0{},
36  m_volumeValidation(true),
37  m_volumeTreePrefix("VolumeMaterial"),
38  m_layerValidation(true),
39  m_layerTreePrefix("LayerMaterial_"),
40  m_surfaceValidation(true),
41  m_surfaceTreePrefix("SurfaceMaterial_")
42 {
43  declareInterface<IMaterialMapper>(this);
44 
45  // The maximum mapping events to control the output file size
46  declareProperty("MaximumMappingEvents", m_maxMappingEvents);
47  // specification for the Validation Tree
48  declareProperty("ValidationTreeName", m_validationTreeName);
49  declareProperty("ValidationTreeDescription", m_validationTreeDescription);
50  declareProperty("ValidationTreeFolder", m_validationTreeFolder);
51  // the total material statistics
52  declareProperty("TotalMaterialTreeName", m_totalMaterialTree);
53  // declare the association type
54  declareProperty("MaterialAssociationType", m_materialAssociationType);
55  // the volume validation
56  declareProperty("TrackingVolumeValidation", m_volumeValidation);
57  declareProperty("TrackingVolumeTreePrefix", m_volumeTreePrefix);
58  // the layer Validation
59  declareProperty("DetailedLayerValidation", m_layerValidation);
60  declareProperty("DetailedLayerTreePrefix", m_layerTreePrefix);
61  // the surface Validation
62  declareProperty("DetailedSurfaceValidation", m_surfaceValidation);
63  declareProperty("DetailedSurfaceTreePrefix", m_surfaceTreePrefix);
64 
65 }
66 
67 // destructor
69 {
70  // memory cleanup
71  if (m_volumeValidation) {
72  auto volTreeIter = m_volumeTrees.begin();
73  auto endVolTreeIter = m_volumeTrees.end();
74  for ( ; volTreeIter != endVolTreeIter; delete (volTreeIter->second), ++volTreeIter) {}
75  }
76 
77  if (m_layerValidation) {
78  // delete the layer hit TTree
79  auto layTreeIter = m_layerTrees.begin();
80  auto endLayTreeIter = m_layerTrees.end();
81  for ( ; layTreeIter != endLayTreeIter; delete (layTreeIter->second), ++layTreeIter) {}
82  // delete the layer per event TTree
83  layTreeIter = m_layerFullTrees.begin();
84  endLayTreeIter = m_layerFullTrees.end();
85  for ( ; layTreeIter != endLayTreeIter; delete (layTreeIter->second), ++layTreeIter) {}
86  }
87 
88  if (m_surfaceValidation) {
89  // finalize the Hit Tree
90  auto surfTreeIter = m_surfaceTrees.begin();
91  auto endSurfTreeIter = m_surfaceTrees.end();
92  for ( ; surfTreeIter != endSurfTreeIter; delete (surfTreeIter->second), ++surfTreeIter) {}
93  }
94 }
95 
96 // Athena standard methods
97 // initialize
99 {
100 
101  // Athena/Gaudi framework
102  ATH_CHECK( m_incidentSvc.retrieve() );
103  ATH_CHECK( m_histSvc.retrieve() );
104 
105  // register to the incident service: EndEvent for histogram filling and reset
106  m_incidentSvc->addListener( this, IncidentType::EndEvent);
107 
108  // book the Tree
109  bookValidationTree();
110  return StatusCode::SUCCESS;
111 }
112 
113 // finalize
115 {
116  ATH_MSG_INFO( "finalize() successful" );
117  return StatusCode::SUCCESS;
118 }
119 
120 void Trk::MaterialMapper::recordMaterialHit(const AssociatedMaterial& amhit, const Amg::Vector3D& projectedPosition) const
121 {
122 
123  if (m_processedEvents >= m_maxMappingEvents) return;
124 
125  // ----------------------------------- Recording Hits section --------------------------------
126  const Amg::Vector3D& position = amhit.materialPosition();
127 
128  // get the tracking volume
129  const Trk::TrackingVolume* tvol = amhit.associatedTrackingVolume();
130  const Trk::Layer* lay = amhit.associatedLayer();
131 
132  if (!tvol) {
133  ATH_MSG_WARNING("Could not associate TrackingVolume to material step!");
134  return;
135  }
136 
137  // ----------------------------------- The Material Validation code --------------------------
138  const Trk::TrackingVolume* itvol = tvol;
139  while (itvol) {
140  // get the volume tree object
141  ATH_MSG_VERBOSE( "getting volTreeObj for: " << itvol->volumeName() << " at: " << itvol );
142  Trk::VolumeTreeObject* volTreeObj = volumeTreeObject(lay,itvol);
143  if (volTreeObj) {
144  // add the quantities
145  (*volTreeObj).path += amhit.steplength();
146  (*volTreeObj).pathInX0 += amhit.steplengthInX0();
147  (*volTreeObj).pathInL0 += amhit.steplengthInL0();
148  if(amhit.A() != 0.0) {
149  (*volTreeObj).pathZARho += (amhit.Z()/amhit.A())*amhit.rho()*amhit.steplength();
150  }
151  } else
152  ATH_MSG_WARNING( "Cannot find/create VolumeTreeObject for volume '" << itvol->volumeName() << "'." );
153  itvol = itvol->getMotherVolume();
154  if (itvol) ATH_MSG_VERBOSE( "motherVolume found: " << itvol->volumeName() );
155  }
156 
157  // -------------------------------- main tree section -----------------------------------------
158  // eta / phi
159  m_averageEta += position.eta();
160  m_averagePhi += position.phi();
161  // effectively crossed Z/A*rho
162  double steplength = amhit.steplength();
163  // fill the variables for spatial information & event characteristics
164  if (lay) {
165  m_mappedPath += steplength;
166  m_mappedPathInX0 += amhit.steplengthInX0();
167  m_mappedPathInL0 += amhit.steplengthInL0();
168  m_mappedPathRho += amhit.rho()*steplength;
169  if(amhit.A() != 0.0) {
170  m_mappedPathZARho += (amhit.Z()/amhit.A())*amhit.rho()*steplength;
171  }
172  ATH_MSG_VERBOSE("[ MaterialMapper ] Accumulated Path in Rho (*Z/A) = " << m_mappedPathRho << " ( " << m_mappedPathZARho << " )");
173  } else
174  m_unmappedPathInX0 += amhit.steplengthInX0();
175 
176  // mapping information
177  m_mapped[m_materialSteps] = lay ? lay->layerIndex().value() : 0;
178  // the position & step information
179  m_materialAccumPathInX0[m_materialSteps] = m_mappedPathInX0;
180  m_materialAccumPathZARho[m_materialSteps] = m_mappedPathZARho;
181  m_materialStepPath[m_materialSteps] = steplength;
182  m_materialStepX0[m_materialSteps] = amhit.x0();
183  m_materialStepL0[m_materialSteps] = amhit.l0();
184  m_materialStepA[m_materialSteps] = amhit.A();
185  m_materialStepZ[m_materialSteps] = amhit.Z();
186  m_materialStepRho[m_materialSteps] = amhit.rho();
187  m_materialStepPositionX[m_materialSteps] = position.x();
188  m_materialStepPositionY[m_materialSteps] = position.y();
189  m_materialStepPositionZ[m_materialSteps] = position.z();
190  m_materialStepPositionR[m_materialSteps] = position.perp();
191  // record the projected position as well
192  m_materialProjPositionX[m_materialSteps] = projectedPosition.x();
193  m_materialProjPositionY[m_materialSteps] = projectedPosition.y();
194  m_materialProjPositionZ[m_materialSteps] = projectedPosition.z();
195  m_materialProjPositionR[m_materialSteps] = projectedPosition.perp();
196  m_materialProjDistance[m_materialSteps] = (position-projectedPosition).mag();
197  // and increase the number of steps
198  ++m_materialSteps;
199 
200 
201  // record the layer hit
202  if (m_layerValidation) recordLayerHit(amhit);
203 }
204 
205 
207 {
208  ATH_MSG_VERBOSE( "finalizeEvent() on Volume hits " );
209 
210  auto volTreeIter = mapped ? m_volumeTrees.begin() : m_volumeTreesUnmapped.begin();
211  auto endVolTreeIter = mapped ? m_volumeTrees.end() : m_volumeTreesUnmapped.end();
212 
213  // do the loop
214  for ( ; volTreeIter != endVolTreeIter; ++volTreeIter ) {
215 
216  Trk::VolumeTreeObject* volTreeObj = volTreeIter->second;
217 
218  if (!volTreeObj) continue;
219 
220  if ((*volTreeObj).path > 0.) {
221  // spatial mapping
222  (*volTreeObj).eta = m_averageEta;
223  (*volTreeObj).phi = m_averagePhi;
224  // fill the volume Tree Object
225  (*volTreeObj).tree->Fill();
226  }
227  // reset
228  (*volTreeObj).eta = 0.;
229  (*volTreeObj).phi = 0.;
230  (*volTreeObj).path = 0.;
231  (*volTreeObj).pathInX0 = 0.;
232  (*volTreeObj).pathInL0 = 0.;
233  (*volTreeObj).pathZARho = 0.;
234 
235  }
236 }
237 
238 
240 {
241 
242  if (m_processedEvents >= m_maxMappingEvents) return;
243 
244  const Trk::Layer* lay = amhit.associatedLayer();
245  if (m_layerValidation && lay) {
246  // try to find the histogram
247  Trk::LayerTreeObject* layTreeObj = layerTreeObject(*lay,full);
248  if (layTreeObj
249  && (*layTreeObj).layerHits < TRKDETDESCRTOOLS_MAXLAYERHITS
250  && amhit.steplengthInX0() > 0.)
251  {
252 
253  const Amg::Vector3D& pos = amhit.materialPosition();
254 
255  // hit positions
256  double posX = pos.x();
257  double posY = pos.y();
258  double posZ = pos.z();
259  double posR = pos.perp();
260  double posEta = pos.eta();
261 
262  // fill the hit position --------------------
263  (*layTreeObj).hitPositionX[(*layTreeObj).layerHits] = posX;
264  (*layTreeObj).hitPositionY[(*layTreeObj).layerHits] = posY;
265  (*layTreeObj).hitPositionZ[(*layTreeObj).layerHits] = posZ;
266  (*layTreeObj).hitPositionR[(*layTreeObj).layerHits] = posR;
267  (*layTreeObj).hitPositionEta[(*layTreeObj).layerHits] = posEta;
268 
269  // increase the layer Hits
270  ++(*layTreeObj).layerHits;
271  ++(*layTreeObj).densedHits;
272 
273  // fill the densed Hit position ---------------
274  (*layTreeObj).densedHitX += posX;
275  (*layTreeObj).densedHitY += posY;
276  (*layTreeObj).densedHitZ += posZ;
277  (*layTreeObj).densedHitR += posR;
278  (*layTreeObj).densedHitPhi += pos.phi();
279  (*layTreeObj).densedHitTheta += pos.theta();
280 
281  // fill the correction factor ------------------
282  (*layTreeObj).correctionFactor += amhit.correctionFactor();
283  (*layTreeObj).path += amhit.steplength();
284  (*layTreeObj).pathInX0 += amhit.steplengthInX0();
285  (*layTreeObj).pathInL0 += amhit.steplengthInL0();
286  (*layTreeObj).A += amhit.A() * amhit.rho() * amhit.steplength();
287  (*layTreeObj).Z += amhit.Z() * amhit.rho() * amhit.steplength();
288  (*layTreeObj).rho += amhit.rho() * amhit.steplength();
289 
290  }
291  }
292 }
293 
295 {
296 
297  ATH_MSG_VERBOSE( "finalizeEvent() on Layer hits " );
298 
299  for (size_t iltm = 0; iltm < 2; ++iltm) {
300  // loop over all layer Tree objects and fill them
301  auto layObjIter = iltm ? m_layerFullTrees.begin() : m_layerTrees.begin();
302  auto endIter = iltm ? m_layerFullTrees.end() : m_layerTrees.end();
303  // do the loop
304  for ( ; layObjIter != endIter; ++layObjIter ) {
305 
306  Trk::LayerTreeObject* layTreeObj = layObjIter->second;
307 
308  if (!layTreeObj) continue;
309 
310  // get the number of single hits
311  int hits = (*layTreeObj).densedHits;
312 
313  if ((*layTreeObj).pathInX0 > 0.) {
314  if (hits>1) {
315  (*layTreeObj).densedHitX /= hits;
316  (*layTreeObj).densedHitY /= hits;
317  (*layTreeObj).densedHitZ /= hits;
318  (*layTreeObj).densedHitR /= hits;
319  (*layTreeObj).densedHitPhi /= hits;
320  (*layTreeObj).densedHitTheta /= hits;
321  (*layTreeObj).correctionFactor /= hits;
322  (*layTreeObj).A /= (*layTreeObj).rho;
323  (*layTreeObj).Z /= (*layTreeObj).rho;
324  (*layTreeObj).rho /= (*layTreeObj).path;
325  }
326  // fill the layer Tree Object
327  (*layTreeObj).tree->Fill();
328  }
329  // reset
330  (*layTreeObj).layerHits = 0;
331  (*layTreeObj).path = 0.;
332  (*layTreeObj).pathInX0 = 0.;
333  (*layTreeObj).pathInL0 = 0.;
334  (*layTreeObj).densedHits = 0;
335  (*layTreeObj).densedHitX = 0.;
336  (*layTreeObj).densedHitY = 0.;
337  (*layTreeObj).densedHitZ = 0.;
338  (*layTreeObj).densedHitR = 0.;
339  (*layTreeObj).densedHitPhi = 0.;
340  (*layTreeObj).densedHitTheta = 0.;
341  (*layTreeObj).correctionFactor = 0.;
342  (*layTreeObj).A = 0.;
343  (*layTreeObj).Z = 0.;
344  (*layTreeObj).rho = 0.;
345  }
346  }
347 }
348 
349 
351  const AssociatedMaterial& amhit) const
352 {
353 
354  if (m_processedEvents >= m_maxMappingEvents) return;
355 
356  const Trk::Layer* lay = amhit.associatedLayer();
357  if (m_surfaceValidation && lay) {
358  // try to find the histogram
359  Trk::SurfaceTreeObject* surfTreeObj = surfaceTreeObject(*lay);
360  // now fill
361  if (surfTreeObj) {
362  // fill it
363  (*surfTreeObj).loc1 += locpos[0];
364  (*surfTreeObj).loc2 += locpos[1];
365  (*surfTreeObj).eta += amhit.materialPosition().eta();
366  (*surfTreeObj).correctionFactor += amhit.correctionFactor();
367  (*surfTreeObj).path += amhit.steplength();
368  (*surfTreeObj).pathInX0 += amhit.steplengthInX0();
369  (*surfTreeObj).pathInL0 += amhit.steplengthInL0();
370  (*surfTreeObj).A += amhit.A()*amhit.steplength()*amhit.rho();
371  (*surfTreeObj).Z += amhit.Z()*amhit.steplength()*amhit.rho();
372  (*surfTreeObj).rho += amhit.rho()*amhit.steplength();
373  // increase the surface hits
374  ++(*surfTreeObj).surfaceHits;
375 
376  }
377  }
378 }
379 
380 
382 {
383 
384  ATH_MSG_VERBOSE( "finalizeEvent() on Surface hits " );
385 
386  // loop over all layer Tree objects and fill them
387  auto surfObjIter = m_surfaceTrees.begin();
388  auto endIter = m_surfaceTrees.end();
389  // do the loop
390  for ( ; surfObjIter != endIter; ++surfObjIter ) {
391  Trk::SurfaceTreeObject* surfTreeObj = surfObjIter->second;
392  // get the number of single hits
393  int hits = (*surfTreeObj).surfaceHits;
394  // fill only if hits have been there
395  if ((*surfTreeObj).pathInX0 > 0.) {
396  if (hits>1) {
397  (*surfTreeObj).loc1 /= hits;
398  (*surfTreeObj).loc2 /= hits;
399  (*surfTreeObj).eta /= hits;
400  (*surfTreeObj).correctionFactor /= hits;
401  (*surfTreeObj).A /= hits;
402  (*surfTreeObj).Z /= hits;
403  (*surfTreeObj).rho /= hits;
404  }
405  // fill the tree
406  (*surfTreeObj).tree->Fill();
407  }
408  // reset
409  (*surfTreeObj).loc1 = 0.;
410  (*surfTreeObj).loc2 = 0.;
411  (*surfTreeObj).eta = 0.;
412 
413  (*surfTreeObj).correctionFactor = 0.;
414  (*surfTreeObj).path = 0.;
415  (*surfTreeObj).pathInX0 = 0.;
416  (*surfTreeObj).pathInL0 = 0.;
417  (*surfTreeObj).rho = 0.;
418 
419  (*surfTreeObj).surfaceHits = 0;
420 
421  }
422 }
423 
424 
426 {
427  // try to find the histogram
428  auto endIter = lay ? m_volumeTrees.end() : m_volumeTreesUnmapped.end();
429  auto findIter = lay ? m_volumeTrees.end() : m_volumeTreesUnmapped.end();
430 
431  Trk::VolumeTreeObject* tvolTreeObj = nullptr;
432 
433  findIter = lay ? m_volumeTrees.find(tvol) : m_volumeTreesUnmapped.find(tvol);
434 
435  if (findIter == endIter) {
436 
437  TString tvolName = tvol->volumeName();
438  tvolName.ReplaceAll("::","_");
439 
440  TString treeName = tvolName;
441  treeName += "_";
442  treeName += m_volumeTreePrefix;
443  if (!lay) treeName += "_UNMAPPED";
444 
445  TString treeTitle = "TrackingVolume : ";
446  treeTitle += tvolName;
447  if (!lay) treeTitle += " - UNMAPPED";
448 
449  TString treeRegName = "/val/";
450  treeRegName += treeName;
451 
452  ATH_MSG_INFO( "No Tree found for " << treeTitle );
453  ATH_MSG_INFO( " -> Booking it now with register name : " << treeRegName.Data() );
454 
455  tvolTreeObj = new Trk::VolumeTreeObject(treeName, treeTitle);
456  if (lay)
457  m_volumeTrees.insert(std::make_pair(tvol,tvolTreeObj));
458  else
459  m_volumeTreesUnmapped.insert(std::make_pair(tvol,tvolTreeObj));
460 
461  // now register the Tree
462  if (m_histSvc->regTree(treeRegName.Data(), (*tvolTreeObj).tree).isFailure()) {
463  ATH_MSG_ERROR( "initialize() Could not register the validation Tree -> Switching Tree output for this volume off !" );
464  delete tvolTreeObj; tvolTreeObj = nullptr;
465  }
466 
467  } else // a tree is found
468  tvolTreeObj = findIter->second;
469 
470  return tvolTreeObj;
471 }
472 
473 
475 {
476  if (!lay.layerIndex().value()) return nullptr;
477 
478  // try to find the histogram
479 
480  Trk::LayerTreeObject* layTreeObj = nullptr;
481 
482  if (full) {
483  auto it = m_layerFullTrees.find(&lay);
484  if (it != m_layerFullTrees.end()) {
485  return it->second;
486  }
487  }
488  else {
489  auto it = m_layerTrees.find(&lay);
490  if (it != m_layerTrees.end()) {
491  return it->second;
492  }
493  }
494 
495  {
496  // check if it is a boundary MaterialLayer
497  const Trk::MaterialLayer* mLayer = dynamic_cast<const Trk::MaterialLayer*>(&lay);
498  if (mLayer)
499  ATH_MSG_INFO("MaterialLayer from BoundarySurface detected.");
500  // get the TrackingVolume
501  const Trk::TrackingVolume* enclosingVolume = lay.enclosingTrackingVolume();
502  TString tvolName = (enclosingVolume) ? enclosingVolume->volumeName() : "BoundaryLayers";
503  tvolName.ReplaceAll("::","_");
504 
505  TString treeName = tvolName;
506  treeName += "_";
507  treeName += m_layerTreePrefix;
508 
509  TString layerType = (lay.surfaceRepresentation().type() == Trk::SurfaceType::Cylinder) ?
510  "CylinderLayer_" : "DiscLayer_";
511  if (full) treeName += "full_";
512  treeName += layerType;
513  if (mLayer) treeName += "boundary_";
514  treeName += lay.layerIndex().value();
515 
516  TString treeTitle = "TrackingVolume :";
517  treeTitle += tvolName;
518 
519  TString treeRegName = "/val/";
520  treeRegName += treeName;
521 
522  ATH_MSG_INFO( "No Tree found for Layer " << lay.layerIndex().value() << " in Volume '" << tvolName << "'.");
523  ATH_MSG_INFO( " -> Booking it now with register name : " << treeRegName.Data() );
524 
525  layTreeObj = new Trk::LayerTreeObject(treeName, treeTitle);
526  if (full) m_layerFullTrees.insert(std::make_pair(&lay,layTreeObj));
527  else m_layerTrees.insert(std::make_pair(&lay,layTreeObj));
528 
529  // now register the Tree
530  if (m_histSvc->regTree(treeRegName.Data(), (*layTreeObj).tree).isFailure()) {
531  ATH_MSG_ERROR( "initialize() Could not register the validation Tree -> Switching Tree output for this layer off !" );
532  delete layTreeObj; layTreeObj = nullptr;
533  }
534 
535  }
536 
537  return layTreeObj;
538 }
539 
540 
542 {
543  // try to find the histogram
544  auto endIter = m_surfaceTrees.end();
545  auto findIter = m_surfaceTrees.end();
546 
547  Trk::SurfaceTreeObject* surfTreeObj = nullptr;
548 
549  findIter = m_surfaceTrees.find(&lay);
550  if (findIter == endIter) {
551  // get the TrackingVolume
552  const Trk::TrackingVolume* enclosingVolume = lay.enclosingTrackingVolume();
553  TString volumeName = (enclosingVolume) ? enclosingVolume->volumeName() : "Unknown";
554 
555  TString treeName = m_surfaceTreePrefix;
556  treeName += lay.layerIndex().value();
557 
558  TString treeTitle = "TrackingVolume :";
559  treeTitle += volumeName;
560 
561  TString treeRegName = "/val/";
562  treeRegName += treeName;
563 
564  ATH_MSG_INFO( "No Tree found for Layer " << lay.layerIndex().value()
565  << " in Volume '" << volumeName << "'." );
566  ATH_MSG_INFO( " -> Booking it now with register name : " << treeRegName.Data() );
567 
568  surfTreeObj = new Trk::SurfaceTreeObject(treeName, treeTitle);
569  m_surfaceTrees.insert(std::make_pair(&lay,surfTreeObj));
570 
571  // now register the Tree
572  if (m_histSvc->regTree(treeRegName.Data(), (*surfTreeObj).tree).isFailure()) {
573  ATH_MSG_INFO( "initialize() Could not register the validation Tree -> Switching Tree output for this surface off !" );
574  delete surfTreeObj; surfTreeObj = nullptr;
575  }
576 
577  } else // a tree is found
578  surfTreeObj = findIter->second;
579  return surfTreeObj;
580 }
581 
582 
583 void Trk::MaterialMapper::handle( const Incident& inc ) {
584  // check the incident type
585  if ( inc.type() == IncidentType::EndEvent && m_materialSteps){
586  // check if the hit collection already contains:
587  ATH_MSG_VERBOSE("EndEvent incident caught, finalize histogramns");
588  // average Eta / Phi
589  m_averageEta /= m_materialSteps;
590  m_averagePhi /= m_materialSteps;
591  // (a) the volume validation
592  finalizeVolumeHits(true); // trees with mapped hits
593  finalizeVolumeHits(false); // trees with unmapped hits
594  // (b) the layer validation
595  finalizeLayerHits();
596  // (c) the surface validation (reference material)
597  finalizeSurfaceHits();
598  // fill the main TTree & reset
599  m_validationTree->Fill();
600  // initialize the eta/phi
601  m_averageEta = 0.;
602  m_averagePhi = 0.;
603  // initialize the rest
604  m_materialSteps = 0;
605  m_mappedPath = 0.;
606  m_mappedPathInX0 = 0.;
607  m_mappedPathInL0 = 0.;
608  m_mappedPathRho = 0.;
609  m_mappedPathZARho = 0.;
610  // increate counter
611  ++m_processedEvents;
612  }
613  }
614 
615 
617 {
618 
619  ATH_MSG_INFO( "Booking the Validation Tree ... " );
620 
621  // (1) Main MaterialMapper TTree
622  // ------------- validation section ------------------------------------------
623  m_validationTree = new TTree(m_validationTreeName.c_str(), m_validationTreeDescription.c_str());
624 
625  // position coordinates of the update
626  m_validationTree->Branch("Eta", &m_averageEta, "averageEta/F");
627  m_validationTree->Branch("Phi", &m_averagePhi, "averagePhiF");
628  m_validationTree->Branch("Path", &m_mappedPath, "path/F");
629  m_validationTree->Branch("PathInX0", &m_mappedPathInX0, "pathInX0/F");
630  m_validationTree->Branch("PathInL0", &m_mappedPathInL0, "pathInL0/F");
631  m_validationTree->Branch("PathRho", &m_mappedPathRho, "pathRho/F");
632  m_validationTree->Branch("PathZARho", &m_mappedPathZARho, "pathZARho/F");
633  m_validationTree->Branch("UnmappedPathInX0", &m_unmappedPathInX0, "unmappedPathInX0/F");
634  m_validationTree->Branch("MaterialSteps", &m_materialSteps, "steps/I");
635  m_validationTree->Branch("Mapped", m_mapped, "mapped[steps]/I");
636  m_validationTree->Branch("MaterialAccumPathInX0", m_materialAccumPathInX0, "materialAccumPinX0[steps]/F");
637  m_validationTree->Branch("MaterialAccumPathZARho", m_materialAccumPathZARho, "materialAccumPZARho[steps]/F");
638  m_validationTree->Branch("MaterialStepPath", m_materialStepPath, "materialStepPath[steps]/F");
639  m_validationTree->Branch("MaterialStepX0", m_materialStepX0, "materialStepX0[steps]/F");
640  m_validationTree->Branch("MaterialStepL0", m_materialStepL0, "materialStepL0[steps]/F");
641  m_validationTree->Branch("MaterialStepZ", m_materialStepZ, "materialStepZ[steps]/F");
642  m_validationTree->Branch("MaterialStepA", m_materialStepA, "materialStepA[steps]/F");
643  m_validationTree->Branch("MaterialStepRho", m_materialStepRho, "materialStepRho[steps]/F");
644  m_validationTree->Branch("MaterialStepPositionX", m_materialStepPositionX , "materialStepX[steps]/F");
645  m_validationTree->Branch("MaterialStepPositionY", m_materialStepPositionY , "materialStepY[steps]/F");
646  m_validationTree->Branch("MaterialStepPositionZ", m_materialStepPositionZ , "materialStepZ[steps]/F");
647  m_validationTree->Branch("MaterialStepPositionR", m_materialStepPositionR , "materialStepR[steps]/F");
648  m_validationTree->Branch("MaterialProjPositionX", m_materialProjPositionX , "materialProjX[steps]/F");
649  m_validationTree->Branch("MaterialProjPositionY", m_materialProjPositionY , "materialProjY[steps]/F");
650  m_validationTree->Branch("MaterialProjPositionZ", m_materialProjPositionZ , "materialProjZ[steps]/F");
651  m_validationTree->Branch("MaterialProjPositionR", m_materialProjPositionR , "materialProjR[steps]/F");
652  m_validationTree->Branch("MaterialProjDistance", m_materialProjDistance , "materialProjD[steps]/F");
653 
654  // now register the Tree
655  if (m_histSvc->regTree(m_validationTreeFolder.c_str(), m_validationTree).isFailure()) {
656  ATH_MSG_ERROR("initialize() Could not register the validation Tree -> Switching ValidationMode Off !" );
657  delete m_validationTree; m_validationTree = nullptr;
658  return;
659  }
660 
661  ATH_MSG_INFO( " ... successful." );
662 
663 }
664 
665 
Trk::MaterialMapper::finalizeSurfaceHits
void finalizeSurfaceHits() const
Finalize the SingleLayer Steps.
Definition: MaterialMapper.cxx:381
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::MaterialMapper::finalizeVolumeHits
void finalizeVolumeHits(bool mapped=true) const
Finalize the Volume Steps.
Definition: MaterialMapper.cxx:206
Trk::AssociatedMaterial::steplengthInL0
double steplengthInL0() const
Access method : steplength.
Definition: AssociatedMaterial.h:182
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::AssociatedMaterial::steplength
double steplength() const
Access method : steplength.
Definition: AssociatedMaterial.h:167
Trk::TrackingVolume::getMotherVolume
const TrackingVolume * getMotherVolume() const
Return the MotherVolume - if it exists.
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::MaterialMapper::bookValidationTree
void bookValidationTree()
Validation : book the Tree.
Definition: MaterialMapper.cxx:616
DiscLayer.h
Trk::AssociatedMaterial::associatedLayer
const Trk::Layer * associatedLayer() const
Trivial Access methods.
Definition: AssociatedMaterial.h:155
beamspotman.posX
posX
Definition: beamspotman.py:1624
Trk::AssociatedMaterial::x0
double x0() const
Access method : material X0/A/Z/rho.
Definition: AssociatedMaterial.h:160
Trk::MaterialMapper::finalizeLayerHits
void finalizeLayerHits() const
Finalize the SingleLayer Steps.
Definition: MaterialMapper.cxx:294
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::SurfaceTreeObject
Definition: MaterialMapper.h:148
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::MaterialMapper::layerTreeObject
LayerTreeObject * layerTreeObject(const Layer &lay, bool full=false) const
find (&&,||) create the LayerTreeObject
Definition: MaterialMapper.cxx:474
Trk::LayerTreeObject::layerHits
int layerHits
Definition: MaterialMapper.h:91
Trk::MaterialMapper::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: MaterialMapper.cxx:98
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::Layer::surfaceRepresentation
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
Trk::MaterialMapper::handle
void handle(const Incident &inc)
Handle the incident from the incident service.
Definition: MaterialMapper.cxx:583
TRKDETDESCRTOOLS_MAXLAYERHITS
#define TRKDETDESCRTOOLS_MAXLAYERHITS
Definition: MaterialMapper.h:26
beamspotman.n
n
Definition: beamspotman.py:731
beamspotman.posZ
posZ
Definition: beamspotman.py:1624
Trk::AssociatedMaterial::A
double A() const
Definition: AssociatedMaterial.h:195
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MaterialMapper.h
dumpFileToPlots.treeName
string treeName
Definition: dumpFileToPlots.py:20
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CylinderLayer.h
Trk::AssociatedMaterial::l0
double l0() const
Definition: AssociatedMaterial.h:189
Trk::LayerIndex::value
int value() const
layerIndex expressed in an integer
Definition: LayerIndex.h:71
Trk::MaterialMapper::surfaceTreeObject
SurfaceTreeObject * surfaceTreeObject(const Layer &lay) const
find (&&,||) create the LayerTreeObject
Definition: MaterialMapper.cxx:541
Trk::AssociatedMaterial::associatedTrackingVolume
const Trk::TrackingVolume * associatedTrackingVolume() const
Trivial Access methods.
Definition: AssociatedMaterial.h:149
Trk::AssociatedMaterial
Definition: AssociatedMaterial.h:33
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Trk::MaterialMapper::volumeTreeObject
VolumeTreeObject * volumeTreeObject(const Layer *lay=0, const TrackingVolume *tvol=0) const
find (&&,||) create a VolumeTreObject
Definition: MaterialMapper.cxx:425
Trk::LayerTreeObject
Definition: MaterialMapper.h:70
Trk::AssociatedMaterial::Z
double Z() const
Definition: AssociatedMaterial.h:201
Trk::MaterialMapper::recordLayerHit
void recordLayerHit(const AssociatedMaterial &amhit, bool full=false) const
Record material hit - if various hits per uniform layer are recorded, or if you want to record one fu...
Definition: MaterialMapper.cxx:239
MaterialLayer.h
Trk::AssociatedMaterial::materialPosition
const Amg::Vector3D & materialPosition() const
Trivial Access methods.
Definition: AssociatedMaterial.h:139
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
find_data.full
full
Definition: find_data.py:27
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::MaterialMapper::recordSurfaceHit
void recordSurfaceHit(const Amg::Vector2D &locpos, const AssociatedMaterial &amhit) const
Record material hit on a surface.
Definition: MaterialMapper.cxx:350
beamspotman.posY
posY
Definition: beamspotman.py:1624
Trk::AssociatedMaterial::correctionFactor
double correctionFactor() const
Trivial Access methods.
Definition: AssociatedMaterial.h:144
TrackingVolume.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::VolumeTreeObject
Definition: MaterialMapper.h:40
Trk::Layer::enclosingTrackingVolume
const TrackingVolume * enclosingTrackingVolume() const
get the confining TrackingVolume
Trk::SurfaceType::Cylinder
@ Cylinder
Trk::AssociatedMaterial::steplengthInX0
double steplengthInX0() const
Access method : steplength.
Definition: AssociatedMaterial.h:174
mapped
std::vector< std::string > mapped
Definition: hcg.cxx:51
Trk::VolumeTreeObject::eta
float eta
Definition: MaterialMapper.h:44
AssociatedMaterial.h
Trk::AssociatedMaterial::rho
double rho() const
Definition: AssociatedMaterial.h:207
Trk::MaterialLayer
Definition: MaterialLayer.h:37
Trk::MaterialMapper::~MaterialMapper
virtual ~MaterialMapper()
Virtual destructor.
Definition: MaterialMapper.cxx:68
Trk::MaterialMapper::MaterialMapper
MaterialMapper(const std::string &, const std::string &, const IInterface *)
AlgTool like constructor.
Definition: MaterialMapper.cxx:20
Trk::MaterialMapper::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: MaterialMapper.cxx:114
MaterialAssociationType.h
AthAlgTool
Definition: AthAlgTool.h:26
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
Trk::MaterialMapper::recordMaterialHit
void recordMaterialHit(const AssociatedMaterial &amhit, const Amg::Vector3D &projectedPosition) const
Record material hit along the recording.
Definition: MaterialMapper.cxx:120
Trk::Layer
Definition: Layer.h:73
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex