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// Processor Action to work on TrackingGeometry
28
29 ATH_MSG_VERBOSE("Start processing the TrackingGeometry recursively");
30 // retrieve the highest tracking volume
31 Trk::TrackingVolume* worldVolume = tgeo.highestTrackingVolume();
32 if (worldVolume){
33 ATH_MSG_VERBOSE("TrackingVolume '" << worldVolume->volumeName() << "' retrieved as highest level node.");
34 return process(*worldVolume, 0);
35 }
36 // abort job
37 ATH_MSG_FATAL("No highest level TrackingVolume found. Stopping recursive parsing, abort job.");
38 return StatusCode::FAILURE;
39}
40
41// Processor Action to work on TrackingVolumes
44 std::stringstream displayBuffer;
45 for (size_t il = 0; il < level; ++il) displayBuffer << " ";
46 // formatted screen output
47 ATH_MSG_VERBOSE(displayBuffer.str() << "TrackingVolume '" << tvol.volumeName() << "'");
48
49 // create the action on the volume part of the TrackingVolume
50 if (processNode(tvol, level).isFailure() ){
51 ATH_MSG_FATAL("Failed to call processNode(const TrackingVolume&). Aborting.");
52 return StatusCode::FAILURE;
53 }
54
55 // Process the contained layers if they exist
56 Trk::LayerArray* layerArray = tvol.confinedLayers();
57 if (layerArray) {
58 // display output
59 auto layers = layerArray->arrayObjects();
60 ATH_MSG_VERBOSE(displayBuffer.str() << "--> has " << layers.size() << " confined layers." );
61 for (const auto & layIter : layers){
62 if (!layIter)
63 ATH_MSG_WARNING("Zero-pointer found in LayerArray - indicates problem !");
64 if ((layIter) && process(*layIter, level).isFailure()){
65 ATH_MSG_FATAL("Failed to call process(const Layer&) on confined layers. Aborting.");
66 return StatusCode::FAILURE;
67 }
68 }
69 }
70
71 // Process the boundary surface layers
72 auto bSurfaces = tvol.boundarySurfaces();
73 for (auto & bSurface : bSurfaces){
74 if (bSurface->surfaceRepresentation().associatedLayer()){
75 ATH_MSG_VERBOSE(displayBuffer.str() << "--> has a boundary layer." );
76 if (process(
77 const_cast<Trk::Layer&>(
78 *bSurface->surfaceRepresentation().associatedLayer()),level)
79 .isFailure()) {
80 ATH_MSG_FATAL("Failed to call process(const Layer&) on boundary "
81 "layer. Aborting.");
82 return StatusCode::FAILURE;
83 }
84 }
85 }
86
87
88 // Process the contained TrackingVolumes (recursively) if they exist
89 Trk::BinnedArray< Trk::TrackingVolume >* confinedVolumes = tvol.confinedVolumes();
90 // register the next round
91 if (confinedVolumes) {
92 auto volumes = confinedVolumes->arrayObjects();
93 for (const auto & volumesIter : volumes){
94 if (!volumesIter)
95 ATH_MSG_WARNING("Zero-pointer found in VolumeArray - indicates problem !");
96 if (volumesIter && process(*volumesIter, ++level).isFailure() ){
97 ATH_MSG_FATAL("Failed to call process(const TrackingVolume&) on confined volumes. Aborting.");
98 return StatusCode::FAILURE;
99 }
100 }
101 }
102
103 // return
104 return StatusCode::SUCCESS;
105
106}
107
108// Processor Action to work on Layers
109StatusCode Trk::RecursiveGeometryProcessor::process(Trk::Layer& lay, size_t level) const {
110
111 std::stringstream displayBuffer;
112 for (size_t il = 0; il < level; ++il) displayBuffer << " ";
113 ATH_MSG_VERBOSE(displayBuffer.str() << " processing Layer with Index: " << lay.layerIndex() );
114
115 // process the node itself
116 if (processNode(lay, level).isFailure()){
117 ATH_MSG_FATAL("Failed to call processNode(const Layer&). Aborting.");
118 return StatusCode::FAILURE;
119 }
120 // get the subsurface array
121 Trk::SurfaceArray* surfArray = lay.surfaceArray();
122 if (surfArray) {
123 std::span<Trk::Surface * const > layerSurfaces = surfArray->arrayObjects();
124 ATH_MSG_VERBOSE(displayBuffer.str() << " ---> has " << layerSurfaces.size() << " surfaces on the layer.");
125
126 auto laySurfIter = layerSurfaces.begin();
127 auto laySurfIterEnd = layerSurfaces.end();
128 // loop over the surfaces and draw them
129 for ( ; laySurfIter != laySurfIterEnd; ++laySurfIter) {
130 if (!(*laySurfIter))
131 ATH_MSG_WARNING("Zero-pointer found in SurfaceArray - indicates problem !");
132 if ((*laySurfIter) && process(**laySurfIter, level).isFailure()){
133 ATH_MSG_FATAL("Failed to call process(const Surface&) on confined layer surfaces. Aborting.");
134 return StatusCode::FAILURE;
135 }
136 }
137 }
138 // return SUCCESS
139 return StatusCode::SUCCESS;
140}
141
142// Processor Action to work on Surfaces
143StatusCode Trk::RecursiveGeometryProcessor::process(Trk::Surface& surf, size_t level) const {
144 return processNode(surf, level);
145}
146
147// Processor Action to work on TrackingVolume - to be overloaded
149 return StatusCode::SUCCESS;
150}
151
152// Processor Action to work on Layers - to be overloaded
154 return StatusCode::SUCCESS;
155}
156// Processor Action to work on Surfaces - to be overloaded
158 return StatusCode::SUCCESS;
159}
#define ATH_MSG_FATAL(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.
StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Current implementation: write root visualization to file stream.
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.
virtual StatusCode processNode(const TrackingVolume &tvol, size_t level=0) const
Dedicated action for the different processors.
Abstract Base Class for tracking surfaces.
Definition Surface.h:79
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