ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::LayerMaterialProvider Class Reference

#include <LayerMaterialProvider.h>

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

Public Member Functions

 LayerMaterialProvider (const std::string &, const std::string &, const IInterface *)
 Constructor. More...
 
virtual ~LayerMaterialProvider ()
 Destructor. More...
 
virtual StatusCode initialize () override
 
virtual StatusCode process (TrackingGeometry &tgeo) const override
 Processor Action to work on TrackingGeometry& tgeo. More...
 
virtual StatusCode process (TrackingVolume &tvol, size_t level=0) const override
 Processor Action to work on TrackingVolumes - the level is for the hierachy tree. More...
 
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. More...
 
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. More...
 

Private Member Functions

void dumpMaterialMap (const LayerMaterialMap &layerMaterialMap) const
 

Private Attributes

SG::ReadCondHandleKey< LayerMaterialMapm_layerMaterialMapKey
 
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.

Constructor & Destructor Documentation

◆ LayerMaterialProvider()

Trk::LayerMaterialProvider::LayerMaterialProvider ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Constructor.

Definition at line 24 of file LayerMaterialProvider.cxx.

25 : base_class(t,n,p)
26 {
27  declareProperty ("LayerMaterialMapName", m_layerMaterialMapName,
28  "If LayerMaterialMapKey is not set, then fall back to retrieving this from the detector store.");
29 }

◆ ~LayerMaterialProvider()

Trk::LayerMaterialProvider::~LayerMaterialProvider ( )
virtualdefault

Destructor.

Member Function Documentation

◆ dumpMaterialMap()

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

Definition at line 239 of file LayerMaterialProvider.cxx.

240 {
241  if (msgLvl (MSG::VERBOSE)) {
242  static std::atomic_flag flag ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT;
243  if (!flag.test_and_set()) {
244  ATH_MSG_VERBOSE("Listing the layer indeces found in the loaded LayerMaterialMap");
245  for ( const auto & lmIter : layerMaterialMap ){
246  ATH_MSG_VERBOSE(" -> Found map for layer with index " << lmIter.first);
247  }
248  }
249  }
250 }

◆ initialize()

StatusCode Trk::LayerMaterialProvider::initialize ( )
overridevirtual

Definition at line 36 of file LayerMaterialProvider.cxx.

37 {
39  return StatusCode::SUCCESS;
40 }

◆ process() [1/6]

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

Definition at line 192 of file LayerMaterialProvider.cxx.

195 {
196  // skip Layers w/o material
197  if (!lay.layerMaterialProperties())
198  return StatusCode::SUCCESS;
199 
200  // get the layer index for assignment
201  Trk::LayerIndex lIndex = lay.layerIndex();
202 
203  // display
204  std::stringstream displayBuffer;
205  for (size_t il = 0; il < level; ++il)
206  displayBuffer << " ";
207 
208  // find the layer and assign the material properties
209  auto lmIter = layerMaterialMap.find(lIndex);
210  if (lmIter != layerMaterialMap.end()) {
211  ATH_MSG_VERBOSE(displayBuffer.str()
212  << "---[+] found material for Layer with Index: "
213  << lIndex.value());
214  if (lay.surfaceRepresentation().isFree()) {
215  ATH_MSG_VERBOSE(displayBuffer.str()
216  << "---[!] the Layer is not owned by the "
217  "TrackingGeometry, could indicate problem.");
218  } else {
219  ATH_MSG_VERBOSE(displayBuffer.str()
220  << "---[+] the Layer is owned by the TrackingGeometry.");
221  }
222  lay.assignMaterialProperties(*((*lmIter).second));
223  } else {
224  ATH_MSG_WARNING(displayBuffer.str()
225  << "---[!] could not find material for Layer with Index: "
226  << lIndex.value());
227  return StatusCode::RECOVERABLE;
228  }
229  return StatusCode::SUCCESS;
230 }

◆ 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 176 of file LayerMaterialProvider.cxx.

177 {
178  const LayerMaterialMap* layerMaterialMap = nullptr;
179  if (!m_layerMaterialMapKey.key().empty()) {
180  SG::ReadCondHandle<LayerMaterialMap> layerMaterialMapH(
182  layerMaterialMap = *layerMaterialMapH;
183  } else {
184  ATH_CHECK(detStore()->retrieve(layerMaterialMap, m_layerMaterialMapName));
185  }
186  dumpMaterialMap(*layerMaterialMap);
187  ATH_CHECK(process(lay, *layerMaterialMap, level));
188  return StatusCode::SUCCESS;
189 }

◆ 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 233 of file LayerMaterialProvider.cxx.

233  {
234  return StatusCode::SUCCESS;
235 }

◆ process() [4/6]

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

Processor Action to work on TrackingGeometry& tgeo.

Definition at line 44 of file LayerMaterialProvider.cxx.

45 {
46  const LayerMaterialMap* layerMaterialMap = nullptr;
47  if (!m_layerMaterialMapKey.key().empty()) {
49  layerMaterialMap = *layerMaterialMapH;
50  }
51  else {
52  ATH_CHECK( detStore()->retrieve (layerMaterialMap, m_layerMaterialMapName) );
53  }
54  dumpMaterialMap (*layerMaterialMap);
55 
56  ATH_MSG_VERBOSE("Start processing the TrackingGeometry recursively");
57  // retrieve the highest tracking volume
58  Trk::TrackingVolume* worldVolume = tgeo.highestTrackingVolume();
59  // check for the world volume
60  if (worldVolume){
61  // TrackingVolume : confined layers
62  ATH_MSG_VERBOSE("TrackingVolume '" << worldVolume->volumeName() << "' retrieved as highest level node.");
63  if (process(*worldVolume, *layerMaterialMap, 0).isFailure() ) {
64  ATH_MSG_FATAL("Could not load material maps for provided TrackingGeometry, abort job.");
65  return StatusCode::FAILURE;
66  }
67  // Boundary layers
68  if (!tgeo.boundaryLayers().empty()){
69  ATH_MSG_VERBOSE("TrackingGeometry has " << tgeo.numBoundaryLayers() << " unique boundary layers, loading material.");
70  for (const auto& bLayerIter : tgeo.boundaryLayers() ){
71  Trk::Layer* lay = bLayerIter.first;
72  int layCount = bLayerIter.second;
73  int layIndex = lay->layerIndex().value();
74  // only move on if layer index is different from 0
75  if (layIndex){
76  StatusCode sc( process(*lay, *layerMaterialMap, 0) );
77  // @TODO Currently recoverable errors are treated as failure. Is this the intended behaviour ? Elsewhere recoverable errors are treated as recoverable
78  if (sc.isSuccess())
79  ATH_MSG_DEBUG("---[B] Boundary layer with " << layCount << " references : successfully loaded material map for layer " << layIndex );
80  // else if (sc.isRecoverable())
81  // ATH_MSG_WARNING("Failed to call process(const Layer&) on layers - but recoverable.");
82  else {
83  ATH_MSG_FATAL("Failed to call process(const Layer&) on layer. Aborting.");
84  return StatusCode::FAILURE;
85  }
86  }
87  } // loop over layers
88  }// we have boundary layers
89  return StatusCode::SUCCESS;
90  } // we have a world volume
91  // abort job
92  ATH_MSG_FATAL("No highest level TrackingVolume found. Stopping recursive parsing, abort job.");
93  return StatusCode::FAILURE;
94 }

◆ process() [5/6]

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

Definition at line 115 of file LayerMaterialProvider.cxx.

118 {
119  std::stringstream displayBuffer;
120  for (size_t il = 0; il < level; ++il) displayBuffer << " ";
121  // formatted screen output
122  ATH_MSG_VERBOSE(displayBuffer.str() << "TrackingVolume '" << tvol.volumeName() << "'");
123 
124  // @TODO add boundary surfaces
125 
126  // Process the contained layers
127  Trk::LayerArray* layerArray = tvol.confinedLayers();
128  if (layerArray) {
129  // display output
131  ATH_MSG_VERBOSE(displayBuffer.str() << "--> has " << layers.size() << " confined layers." );
132  for ( const auto & layIter : layers ){
133  if (!layIter)
134  ATH_MSG_WARNING("Zero-pointer found in LayerArray - indicates problem !");
135  else {
136  // get the layer index and only process if it's an indexed layer
137  int layIndex = layIter->layerIndex().value();
138  if (layIndex){
139  StatusCode sc = process(*layIter, layerMaterialMap, level);
140  if (sc.isSuccess())
141  ATH_MSG_DEBUG(displayBuffer.str() << "---[M] Material layer: successfully loaded material map for layer " << layIndex );
142  else if (sc.isRecoverable())
143  ATH_MSG_WARNING("Failed to call process(const Layer&) on layers - but recoverable.");
144  else {
145  ATH_MSG_FATAL("Failed to call process(const Layer&) on layer. Aborting.");
146  return StatusCode::FAILURE;
147  }
148  } else
149  ATH_MSG_DEBUG(displayBuffer.str() << "---[o] Navigation layer: skipping.");
150  }
151  }
152  }
153 
154  // Process the contained TrackingVolumes (recursively) if they exist
156  // register the next round
157  if (confinedVolumes) {
160  for (; volumesIter != volumes.end(); ++volumesIter){
161  if (!(*volumesIter))
162  ATH_MSG_WARNING("Zero-pointer found in VolumeArray - indicates problem !");
163  if ((*volumesIter) && process(**volumesIter, layerMaterialMap, ++level).isFailure() ){
164  ATH_MSG_FATAL("Failed to call process(const TrackingVolume&) on confined volumes. Aborting.");
165  return StatusCode::FAILURE;
166  }
167  }
168  }
169 
170  // return
171  return StatusCode::SUCCESS;
172 }

◆ 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 98 of file LayerMaterialProvider.cxx.

100 {
101  const LayerMaterialMap* layerMaterialMap = nullptr;
102  if (!m_layerMaterialMapKey.key().empty()) {
104  layerMaterialMap = *layerMaterialMapH;
105  }
106  else {
107  ATH_CHECK( detStore()->retrieve (layerMaterialMap, m_layerMaterialMapName) );
108  }
109  dumpMaterialMap (*layerMaterialMap);
110  ATH_CHECK( process (tvol, *layerMaterialMap, level) );
111  return StatusCode::SUCCESS;
112 }

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 76 of file LayerMaterialProvider.h.

◆ m_layerMaterialMapName

std::string Trk::LayerMaterialProvider::m_layerMaterialMapName
private

Definition at line 80 of file LayerMaterialProvider.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PlotCalibFromCool.il
il
Definition: PlotCalibFromCool.py:381
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Trk::TrackingGeometry::numBoundaryLayers
size_t numBoundaryLayers() const
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
Trk::LayerMaterialProvider::m_layerMaterialMapName
std::string m_layerMaterialMapName
Definition: LayerMaterialProvider.h:80
Trk::TrackingVolume::confinedLayers
const LayerArray * confinedLayers() const
Return the subLayer array.
Trk::LayerMaterialProvider::dumpMaterialMap
void dumpMaterialMap(const LayerMaterialMap &layerMaterialMap) const
Definition: LayerMaterialProvider.cxx:239
Trk::Layer::assignMaterialProperties
void assignMaterialProperties(const LayerMaterialProperties &, double scale=1.0)
assignMaterialPropeties
Definition: Layer.cxx:191
Trk::TrackingGeometry::highestTrackingVolume
const TrackingVolume * highestTrackingVolume() const
return the world
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::Layer::surfaceRepresentation
virtual const Surface & surfaceRepresentation() const =0
Transforms the layer into a Surface representation for extrapolation.
Trk::LayerIndex
Definition: LayerIndex.h:37
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
master.flag
bool flag
Definition: master.py:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::LayerIndex::value
int value() const
layerIndex expressed in an integer
Definition: LayerIndex.h:71
Trk::LayerMaterialProvider::m_layerMaterialMapKey
SG::ReadCondHandleKey< LayerMaterialMap > m_layerMaterialMapKey
Definition: LayerMaterialProvider.h:77
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk::TrackingVolume::volumeName
const std::string & volumeName() const
Returns the VolumeName - for debug reason, might be depreciated later.
Trk::LayerMaterialProvider::process
virtual StatusCode process(TrackingGeometry &tgeo) const override
Processor Action to work on TrackingGeometry& tgeo.
Definition: LayerMaterialProvider.cxx:44
Trk::BinnedArray::arrayObjects
virtual BinnedArraySpan< T *const > arrayObjects()=0
Return all objects of the Array non-const we can still modify the T.
Trk::TrackingGeometry::boundaryLayers
const std::map< Layer *, int > & boundaryLayers()
Return the unique BoundarySurfaces with MaterialInformation.
Trk::Surface::isFree
bool isFree() const
Returns 'true' if this surface is 'free', i.e.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::TrackingVolume::confinedVolumes
const TrackingVolumeArray * confinedVolumes() const
Return the subLayer array.
Trk::Layer::layerMaterialProperties
const LayerMaterialProperties * layerMaterialProperties() const
getting the LayerMaterialProperties including full/pre/post update
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
Trk::BinnedArray
Definition: BinnedArray.h:38
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
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