ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::LayerMaterialProvider Class Reference

AlgTool that retrieves the LayerMaterial from COOL and loads it onto the geometry. More...

#include <LayerMaterialProvider.h>

Inheritance diagram for Trk::LayerMaterialProvider:
Collaboration diagram for Trk::LayerMaterialProvider:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode process (TrackingGeometry &tgeo) const override
 Processor Action to work on TrackingGeometry& tgeo.
virtual StatusCode process (TrackingVolume &tvol, size_t level=0) const override
 Processor Action to work on TrackingVolumes - the level is for the hierachy tree.
StatusCode process (TrackingVolume &lay, const LayerMaterialMap &layerMaterialMap, size_t level) const
virtual StatusCode process (Layer &lay, size_t level=0) const override
 Processor Action to work on Layers.
StatusCode process (Layer &lay, const LayerMaterialMap &layerMaterialMap, size_t level) const
virtual StatusCode process (Surface &surf, size_t level=0) const override
 Processor Action to work on Surfaces.

Private Member Functions

void dumpMaterialMap (const LayerMaterialMap &layerMaterialMap) const

Private Attributes

SG::ReadCondHandleKey< LayerMaterialMapm_layerMaterialMapKey
Gaudi::Property< std::string > m_layerMaterialMapName

Detailed Description

AlgTool that retrieves the LayerMaterial from COOL and loads it onto the geometry.

Author
Andre.nosp@m.as.S.nosp@m.alzbu.nosp@m.rger.nosp@m.@cern.nosp@m..ch

Definition at line 38 of file LayerMaterialProvider.h.

Member Function Documentation

◆ dumpMaterialMap()

void Trk::LayerMaterialProvider::dumpMaterialMap ( const LayerMaterialMap & layerMaterialMap) const
private

Definition at line 227 of file LayerMaterialProvider.cxx.

228{
229 if (msgLvl (MSG::VERBOSE)) {
230 static std::atomic_flag flag ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT;
231 if (!flag.test_and_set()) {
232 ATH_MSG_VERBOSE("Listing the layer indeces found in the loaded LayerMaterialMap");
233 for ( const auto & lmIter : layerMaterialMap ){
234 ATH_MSG_VERBOSE(" -> Found map for layer with index " << lmIter.first);
235 }
236 }
237 }
238}
#define ATH_MSG_VERBOSE(x)
#define ATLAS_THREAD_SAFE
bool flag
Definition master.py:29

◆ initialize()

StatusCode Trk::LayerMaterialProvider::initialize ( )
overridevirtual

Definition at line 24 of file LayerMaterialProvider.cxx.

25{
27 return StatusCode::SUCCESS;
28}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadCondHandleKey< LayerMaterialMap > m_layerMaterialMapKey

◆ process() [1/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::Layer & lay,
const LayerMaterialMap & layerMaterialMap,
size_t level ) const

Definition at line 180 of file LayerMaterialProvider.cxx.

183{
184 // skip Layers w/o material
185 if (!lay.layerMaterialProperties())
186 return StatusCode::SUCCESS;
187
188 // get the layer index for assignment
189 Trk::LayerIndex lIndex = lay.layerIndex();
190
191 // display
192 std::stringstream displayBuffer;
193 for (size_t il = 0; il < level; ++il)
194 displayBuffer << " ";
195
196 // find the layer and assign the material properties
197 auto lmIter = layerMaterialMap.find(lIndex);
198 if (lmIter != layerMaterialMap.end()) {
199 ATH_MSG_VERBOSE(displayBuffer.str()
200 << "---[+] found material for Layer with Index: "
201 << lIndex.value());
202 if (lay.surfaceRepresentation().isFree()) {
203 ATH_MSG_VERBOSE(displayBuffer.str()
204 << "---[!] the Layer is not owned by the "
205 "TrackingGeometry, could indicate problem.");
206 } else {
207 ATH_MSG_VERBOSE(displayBuffer.str()
208 << "---[+] the Layer is owned by the TrackingGeometry.");
209 }
210 lay.assignMaterialProperties(*((*lmIter).second));
211 } else {
212 ATH_MSG_WARNING(displayBuffer.str()
213 << "---[!] could not find material for Layer with Index: "
214 << lIndex.value());
215 return StatusCode::RECOVERABLE;
216 }
217 return StatusCode::SUCCESS;
218}
#define ATH_MSG_WARNING(x)
int value() const
layerIndex expressed in an integer
Definition LayerIndex.h:71
void assignMaterialProperties(const LayerMaterialProperties &, double scale=1.0)
assignMaterialPropeties
Definition Layer.cxx:177
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
const LayerIndex & layerIndex() const
get the layerIndex
bool isFree() const
Returns 'true' if this surface is 'free', i.e.

◆ process() [2/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::Layer & lay,
size_t level = 0 ) const
overridevirtual

Processor Action to work on Layers.

Definition at line 164 of file LayerMaterialProvider.cxx.

165{
166 const LayerMaterialMap* layerMaterialMap = nullptr;
167 if (!m_layerMaterialMapKey.key().empty()) {
168 SG::ReadCondHandle<LayerMaterialMap> layerMaterialMapH(
170 layerMaterialMap = *layerMaterialMapH;
171 } else {
172 ATH_CHECK(detStore()->retrieve(layerMaterialMap, m_layerMaterialMapName));
173 }
174 dumpMaterialMap(*layerMaterialMap);
175 ATH_CHECK(process(lay, *layerMaterialMap, level));
176 return StatusCode::SUCCESS;
177}
void dumpMaterialMap(const LayerMaterialMap &layerMaterialMap) const
Gaudi::Property< std::string > m_layerMaterialMapName
const std::string process

◆ process() [3/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::Surface & surf,
size_t level = 0 ) const
overridevirtual

Processor Action to work on Surfaces.

Definition at line 221 of file LayerMaterialProvider.cxx.

221 {
222 return StatusCode::SUCCESS;
223}

◆ process() [4/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::TrackingGeometry & tgeo) const
overridevirtual

Processor Action to work on TrackingGeometry& tgeo.

Definition at line 32 of file LayerMaterialProvider.cxx.

33{
34 const LayerMaterialMap* layerMaterialMap = nullptr;
35 if (!m_layerMaterialMapKey.key().empty()) {
36 SG::ReadCondHandle<LayerMaterialMap> layerMaterialMapH (m_layerMaterialMapKey);
37 layerMaterialMap = *layerMaterialMapH;
38 }
39 else {
40 ATH_CHECK( detStore()->retrieve (layerMaterialMap, m_layerMaterialMapName) );
41 }
42 dumpMaterialMap (*layerMaterialMap);
43
44 ATH_MSG_VERBOSE("Start processing the TrackingGeometry recursively");
45 // retrieve the highest tracking volume
46 Trk::TrackingVolume* worldVolume = tgeo.highestTrackingVolume();
47 // check for the world volume
48 if (worldVolume){
49 // TrackingVolume : confined layers
50 ATH_MSG_VERBOSE("TrackingVolume '" << worldVolume->volumeName() << "' retrieved as highest level node.");
51 if (process(*worldVolume, *layerMaterialMap, 0).isFailure() ) {
52 ATH_MSG_FATAL("Could not load material maps for provided TrackingGeometry, abort job.");
53 return StatusCode::FAILURE;
54 }
55 // Boundary layers
56 if (!tgeo.boundaryLayers().empty()){
57 ATH_MSG_VERBOSE("TrackingGeometry has " << tgeo.numBoundaryLayers() << " unique boundary layers, loading material.");
58 for (const auto& bLayerIter : tgeo.boundaryLayers() ){
59 Trk::Layer* lay = bLayerIter.first;
60 int layCount = bLayerIter.second;
61 int layIndex = lay->layerIndex().value();
62 // only move on if layer index is different from 0
63 if (layIndex){
64 StatusCode sc( process(*lay, *layerMaterialMap, 0) );
65 // @TODO Currently recoverable errors are treated as failure. Is this the intended behaviour ? Elsewhere recoverable errors are treated as recoverable
66 if (sc.isSuccess())
67 ATH_MSG_DEBUG("---[B] Boundary layer with " << layCount << " references : successfully loaded material map for layer " << layIndex );
68 // else if (sc.isRecoverable())
69 // ATH_MSG_WARNING("Failed to call process(const Layer&) on layers - but recoverable.");
70 else {
71 ATH_MSG_FATAL("Failed to call process(const Layer&) on layer. Aborting.");
72 return StatusCode::FAILURE;
73 }
74 }
75 } // loop over layers
76 }// we have boundary layers
77 return StatusCode::SUCCESS;
78 } // we have a world volume
79 // abort job
80 ATH_MSG_FATAL("No highest level TrackingVolume found. Stopping recursive parsing, abort job.");
81 return StatusCode::FAILURE;
82}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
const std::map< Layer *, int > & boundaryLayers()
Return the unique BoundarySurfaces with MaterialInformation.
const TrackingVolume * highestTrackingVolume() const
return the world
size_t numBoundaryLayers() const
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ process() [5/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::TrackingVolume & tvol,
const LayerMaterialMap & layerMaterialMap,
size_t level ) const

Definition at line 103 of file LayerMaterialProvider.cxx.

106{
107 std::stringstream displayBuffer;
108 for (size_t il = 0; il < level; ++il) displayBuffer << " ";
109 // formatted screen output
110 ATH_MSG_VERBOSE(displayBuffer.str() << "TrackingVolume '" << tvol.volumeName() << "'");
111
112 // @TODO add boundary surfaces
113
114 // Process the contained layers
115 Trk::LayerArray* layerArray = tvol.confinedLayers();
116 if (layerArray) {
117 // display output
118 std::span<Trk::Layer * const> layers = layerArray->arrayObjects();
119 ATH_MSG_VERBOSE(displayBuffer.str() << "--> has " << layers.size() << " confined layers." );
120 for ( const auto & layIter : layers ){
121 if (!layIter)
122 ATH_MSG_WARNING("Zero-pointer found in LayerArray - indicates problem !");
123 else {
124 // get the layer index and only process if it's an indexed layer
125 int layIndex = layIter->layerIndex().value();
126 if (layIndex){
127 StatusCode sc = process(*layIter, layerMaterialMap, level);
128 if (sc.isSuccess())
129 ATH_MSG_DEBUG(displayBuffer.str() << "---[M] Material layer: successfully loaded material map for layer " << layIndex );
130 else if (sc.isRecoverable())
131 ATH_MSG_WARNING("Failed to call process(const Layer&) on layers - but recoverable.");
132 else {
133 ATH_MSG_FATAL("Failed to call process(const Layer&) on layer. Aborting.");
134 return StatusCode::FAILURE;
135 }
136 } else
137 ATH_MSG_DEBUG(displayBuffer.str() << "---[o] Navigation layer: skipping.");
138 }
139 }
140 }
141
142 // Process the contained TrackingVolumes (recursively) if they exist
143 Trk::BinnedArray<Trk::TrackingVolume >* confinedVolumes = tvol.confinedVolumes();
144 // register the next round
145 if (confinedVolumes) {
146 std::span<Trk::TrackingVolume * const> volumes = confinedVolumes->arrayObjects();
147 std::span<Trk::TrackingVolume * const>::iterator volumesIter = volumes.begin();
148 for (; volumesIter != volumes.end(); ++volumesIter){
149 if (!(*volumesIter))
150 ATH_MSG_WARNING("Zero-pointer found in VolumeArray - indicates problem !");
151 if ((*volumesIter) && process(**volumesIter, layerMaterialMap, ++level).isFailure() ){
152 ATH_MSG_FATAL("Failed to call process(const TrackingVolume&) on confined volumes. Aborting.");
153 return StatusCode::FAILURE;
154 }
155 }
156 }
157
158 // return
159 return StatusCode::SUCCESS;
160}
virtual std::span< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
const LayerArray * confinedLayers() const
Return the subLayer array.
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
layers(flags, cells_name, *args, **kw)
Here we define wrapper functions to set up all of the standard corrections.
BinnedArray< Layer > LayerArray
simply for the eye

◆ process() [6/6]

StatusCode Trk::LayerMaterialProvider::process ( Trk::TrackingVolume & tvol,
size_t level = 0 ) const
overridevirtual

Processor Action to work on TrackingVolumes - the level is for the hierachy tree.

Definition at line 86 of file LayerMaterialProvider.cxx.

88{
89 const LayerMaterialMap* layerMaterialMap = nullptr;
90 if (!m_layerMaterialMapKey.key().empty()) {
91 SG::ReadCondHandle<LayerMaterialMap> layerMaterialMapH (m_layerMaterialMapKey);
92 layerMaterialMap = *layerMaterialMapH;
93 }
94 else {
95 ATH_CHECK( detStore()->retrieve (layerMaterialMap, m_layerMaterialMapName) );
96 }
97 dumpMaterialMap (*layerMaterialMap);
98 ATH_CHECK( process (tvol, *layerMaterialMap, level) );
99 return StatusCode::SUCCESS;
100}
virtual StatusCode process(TrackingGeometry &tgeo) const override
Processor Action to work on TrackingGeometry& tgeo.

Member Data Documentation

◆ m_layerMaterialMapKey

SG::ReadCondHandleKey<LayerMaterialMap> Trk::LayerMaterialProvider::m_layerMaterialMapKey
private
Initial value:
{ this, "LayerMaterialMapKey", "/GLOBAL/TrackingGeo/LayerMaterialV2",
"COOL folder for material map" }

Definition at line 73 of file LayerMaterialProvider.h.

74 { this, "LayerMaterialMapKey", "/GLOBAL/TrackingGeo/LayerMaterialV2",
75 "COOL folder for material map" };

◆ m_layerMaterialMapName

Gaudi::Property<std::string> Trk::LayerMaterialProvider::m_layerMaterialMapName
private
Initial value:
{this, "LayerMaterialMapName", "",
"If LayerMaterialMapKey is not set, then fall back to retrieving this from the detector store."}

Definition at line 77 of file LayerMaterialProvider.h.

78 {this, "LayerMaterialMapName", "",
79 "If LayerMaterialMapKey is not set, then fall back to retrieving this from the detector store."};

The documentation for this class was generated from the following files: