ATLAS Offline Software
RecursiveGeometryProcessor.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // RecursiveGeometryProcessor.cxx, (c) ATLAS Detector software
8 
9 // STL
10 #include <sstream>
11 // Trk include
15 #include "TrkGeometry/Layer.h"
16 #include "TrkVolumes/Volume.h"
17 #include "TrkSurfaces/Surface.h"
18 
19 // constructor
20 Trk::RecursiveGeometryProcessor::RecursiveGeometryProcessor(const std::string& t, const std::string& n, const IInterface* p)
21 : AthAlgTool(t,n,p)
22 {
23  declareInterface<Trk::IGeometryProcessor>(this);
24 }
25 
26 // destructor
28 = default;
29 
30 
31 // the interface method initialize
33 {
34  ATH_MSG_INFO( "initialize()" );
35  return StatusCode::SUCCESS;
36 }
37 
38 // the interface method finalize
40 {
41  ATH_MSG_INFO( "finalize() successful" );
42  return StatusCode::SUCCESS;
43 }
44 
45 // Processor Action to work on TrackingGeometry
47 
48  ATH_MSG_VERBOSE("Start processing the TrackingGeometry recursively");
49  // retrieve the highest tracking volume
50  Trk::TrackingVolume* worldVolume = tgeo.highestTrackingVolume();
51  if (worldVolume){
52  ATH_MSG_VERBOSE("TrackingVolume '" << worldVolume->volumeName() << "' retrieved as highest level node.");
53  return process(*worldVolume, 0);
54  }
55  // abort job
56  ATH_MSG_FATAL("No highest level TrackingVolume found. Stopping recursive parsing, abort job.");
57  return StatusCode::FAILURE;
58 }
59 
60 // Processor Action to work on TrackingVolumes
62 
63  std::stringstream displayBuffer;
64  for (size_t il = 0; il < level; ++il) displayBuffer << " ";
65  // formatted screen output
66  ATH_MSG_VERBOSE(displayBuffer.str() << "TrackingVolume '" << tvol.volumeName() << "'");
67 
68  // create the action on the volume part of the TrackingVolume
69  if (processNode(tvol, level).isFailure() ){
70  ATH_MSG_FATAL("Failed to call processNode(const TrackingVolume&). Aborting.");
71  return StatusCode::FAILURE;
72  }
73 
74  // Process the contained layers if they exist
75  Trk::LayerArray* layerArray = tvol.confinedLayers();
76  if (layerArray) {
77  // display output
78  auto layers = layerArray->arrayObjects();
79  ATH_MSG_VERBOSE(displayBuffer.str() << "--> has " << layers.size() << " confined layers." );
80  for (const auto & layIter : layers){
81  if (!layIter)
82  ATH_MSG_WARNING("Zero-pointer found in LayerArray - indicates problem !");
83  if ((layIter) && process(*layIter, level).isFailure()){
84  ATH_MSG_FATAL("Failed to call process(const Layer&) on confined layers. Aborting.");
85  return StatusCode::FAILURE;
86  }
87  }
88  }
89 
90  // Process the boundary surface layers
91  auto bSurfaces = tvol.boundarySurfaces();
92  for (auto & bSurface : bSurfaces){
93  if (bSurface->surfaceRepresentation().associatedLayer()){
94  ATH_MSG_VERBOSE(displayBuffer.str() << "--> has a boundary layer." );
95  if (process(
96  const_cast<Trk::Layer&>(
97  *bSurface->surfaceRepresentation().associatedLayer()),level)
98  .isFailure()) {
99  ATH_MSG_FATAL("Failed to call process(const Layer&) on boundary "
100  "layer. Aborting.");
101  return StatusCode::FAILURE;
102  }
103  }
104  }
105 
106 
107  // Process the contained TrackingVolumes (recursively) if they exist
109  // register the next round
110  if (confinedVolumes) {
111  auto volumes = confinedVolumes->arrayObjects();
112  for (const auto & volumesIter : volumes){
113  if (!volumesIter)
114  ATH_MSG_WARNING("Zero-pointer found in VolumeArray - indicates problem !");
115  if (volumesIter && process(*volumesIter, ++level).isFailure() ){
116  ATH_MSG_FATAL("Failed to call process(const TrackingVolume&) on confined volumes. Aborting.");
117  return StatusCode::FAILURE;
118  }
119  }
120  }
121 
122  // return
123  return StatusCode::SUCCESS;
124 
125 }
126 
127 // Processor Action to work on Layers
129 
130  std::stringstream displayBuffer;
131  for (size_t il = 0; il < level; ++il) displayBuffer << " ";
132  ATH_MSG_VERBOSE(displayBuffer.str() << " processing Layer with Index: " << lay.layerIndex() );
133 
134  // process the node itself
135  if (processNode(lay, level).isFailure()){
136  ATH_MSG_FATAL("Failed to call processNode(const Layer&). Aborting.");
137  return StatusCode::FAILURE;
138  }
139  // get the subsurface array
140  Trk::SurfaceArray* surfArray = lay.surfaceArray();
141  if (surfArray) {
142  Trk::BinnedArraySpan<Trk::Surface * const > layerSurfaces = surfArray->arrayObjects();
143  ATH_MSG_VERBOSE(displayBuffer.str() << " ---> has " << layerSurfaces.size() << " surfaces on the layer.");
144 
145  auto laySurfIter = layerSurfaces.begin();
146  auto laySurfIterEnd = layerSurfaces.end();
147  // loop over the surfaces and draw them
148  for ( ; laySurfIter != laySurfIterEnd; ++laySurfIter) {
149  if (!(*laySurfIter))
150  ATH_MSG_WARNING("Zero-pointer found in SurfaceArray - indicates problem !");
151  if ((*laySurfIter) && process(**laySurfIter, level).isFailure()){
152  ATH_MSG_FATAL("Failed to call process(const Surface&) on confined layer surfaces. Aborting.");
153  return StatusCode::FAILURE;
154  }
155  }
156  }
157  // return SUCCESS
158  return StatusCode::SUCCESS;
159 }
160 
161 // Processor Action to work on Surfaces
163  return processNode(surf, level);
164 }
165 
166 // Processor Action to work on TrackingVolume - to be overloaded
168  return StatusCode::SUCCESS;
169 }
170 
171 // Processor Action to work on Layers - to be overloaded
173  return StatusCode::SUCCESS;
174 }
175 // Processor Action to work on Surfaces - to be overloaded
177  return StatusCode::SUCCESS;
178 }
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::RecursiveGeometryProcessor::processNode
virtual StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Dedicated action for the different processors.
Definition: RecursiveGeometryProcessor.cxx:167
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Surface.h
Trk::RecursiveGeometryProcessor::initialize
StatusCode initialize()
AlgTool initialize method.
Definition: RecursiveGeometryProcessor.cxx:32
Trk::TrackingVolume::boundarySurfaces
std::vector< SharedObject< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
Definition: TrackingVolume.cxx:982
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
Trk::RecursiveGeometryProcessor::process
virtual StatusCode process(TrackingGeometry &tgeo) const
Processor Action to work on TrackingGeometry& tgeo.
Definition: RecursiveGeometryProcessor.cxx:46
Layer.h
Trk::RecursiveGeometryProcessor::RecursiveGeometryProcessor
RecursiveGeometryProcessor(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: RecursiveGeometryProcessor.cxx:20
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
Trk::TrackingVolume::confinedLayers
const LayerArray * confinedLayers() const
Return the subLayer array.
Trk::Layer::surfaceArray
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
Trk::RecursiveGeometryProcessor::finalize
StatusCode finalize()
AlgTool finalize method.
Definition: RecursiveGeometryProcessor.cxx:39
Volume.h
Trk::TrackingGeometry::highestTrackingVolume
const TrackingVolume * highestTrackingVolume() const
return the world
beamspotman.n
n
Definition: beamspotman.py:731
Trk::TrackingGeometry
Definition: TrackingGeometry.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Trk::RecursiveGeometryProcessor::~RecursiveGeometryProcessor
virtual ~RecursiveGeometryProcessor()
Destructor.
RecursiveGeometryProcessor.h
Trk::BinnedArray::arrayObjects
virtual BinnedArraySpan< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
TrackingVolume.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::TrackingVolume::confinedVolumes
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
TrackingGeometry.h
Trk::BinnedArray
Definition: BinnedArray.h:38
AthAlgTool
Definition: AthAlgTool.h:26
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::TrackingVolume
Definition: TrackingVolume.h:121
Trk::BinnedArraySpan
std::span< T > BinnedArraySpan
Definition: BinnedArray.h:34
Trk::Layer
Definition: Layer.h:73
Trk::Layer::layerIndex
const LayerIndex & layerIndex() const
get the layerIndex