ATLAS Offline Software
Loading...
Searching...
No Matches
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
20Trk::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
128StatusCode Trk::RecursiveGeometryProcessor::process(Trk::Layer& lay, size_t level) const {
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 std::span<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
162StatusCode Trk::RecursiveGeometryProcessor::process(Trk::Surface& surf, size_t level) const {
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}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Base Class for a Detector Layer in the Tracking realm.
Definition Layer.h:72
const SurfaceArray * surfaceArray() const
Return the entire SurfaceArray, returns nullptr if no SurfaceArray.
const LayerIndex & layerIndex() const
get the layerIndex
RecursiveGeometryProcessor(const std::string &, const std::string &, const IInterface *)
Constructor.
virtual StatusCode process(TrackingGeometry &tgeo) const
Processor Action to work on TrackingGeometry& tgeo.
StatusCode initialize()
AlgTool initialize method.
virtual ~RecursiveGeometryProcessor()
Destructor.
StatusCode finalize()
AlgTool finalize method.
virtual StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Dedicated action for the different processors.
Abstract Base Class for tracking surfaces.
The TrackingGeometry class is the owner of the constructed TrackingVolumes.
const TrackingVolume * highestTrackingVolume() const
return the world
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure,...
const LayerArray * confinedLayers() const
Return the subLayer array.
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
std::vector< std::shared_ptr< BoundarySurface< TrackingVolume > > > & boundarySurfaces()
Method to return the BoundarySurfaces.
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
const std::string process
BinnedArray< Layer > LayerArray
simply for the eye
BinnedArray< Surface > SurfaceArray
Definition Layer.h:40