ATLAS Offline Software
Loading...
Searching...
No Matches
MaterialManipulation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// MaterialManipulation.cxx, (c) ATLAS Detector software
8
9// Gaudi Units
10#include "GaudiKernel/SystemOfUnits.h"
11//TrkDetDescr Algs, Interfaces, Utils
17
18
20{
21 ATH_MSG_INFO("initialize()");
22
23 if (!m_layerMaterialManipulator.empty() && m_layerMaterialManipulator.retrieve().isFailure()){
24 ATH_MSG_FATAL("Could not retrieve LayerMaterial manipulator - although configured. Aborting.");
25 return StatusCode::FAILURE;
26 }
27 return StatusCode::SUCCESS;
28}
29
30
31StatusCode Trk::MaterialManipulation::execute(const EventContext& /*ctx*/)
32{
33 ATH_MSG_VERBOSE("MaterialManipulation execute() start");
34
35 Trk::LayerMaterialMap* outputLayerMaterialMap = nullptr;
36
37 // make sure this is only done once
39
40 // -------------------------------------------------------------------------------
42 ATH_MSG_FATAL( "Could not retrieve LayerMaterialMap wiht name '" << m_inputLayerMaterialMapName << "'. Aborting.");
43 return StatusCode::FAILURE;
44 } else
45 ATH_MSG_DEBUG( "Retrieved LayerMaterialMap wiht name '" << m_inputLayerMaterialMapName << "' for " << m_inputLayerMaterialMap->size() << " layers.");
46
47 // create the output material map
48 outputLayerMaterialMap = new Trk::LayerMaterialMap();
49 // now create the new one and manipulate
50 for ( const auto & lmIter : (*m_inputLayerMaterialMap) ){
51 // copy the layer material
52 ATH_MSG_VERBOSE(" -> Found map for layer with index " << lmIter.first);
53 // use the virtual constructor
54 const Trk::LayerMaterialProperties* lmp = nullptr;
55 // manipulate it if needed
56 if (!m_layerMaterialManipulator.empty())
57 lmp = m_layerMaterialManipulator->processLayerMaterial(lmIter.first,*(lmIter.second));
58 else
59 lmp = lmIter.second->clone();
60 // and insert into the map
61 (*outputLayerMaterialMap)[lmIter.first] = lmp;
62 }
63
64 // get the element table - and copy it over if there's none
65 const ElementTable* eTable = m_inputLayerMaterialMap->elementTable();
66 if (eTable){
67 auto tElementTable = std::make_shared<Trk::ElementTable>(*eTable);
68 outputLayerMaterialMap->updateElementTable(tElementTable);
69 }
70 // finally write it to StoreGate
71 if ( (detStore()->record(outputLayerMaterialMap, m_outputLayerMaterialMapName, false)).isFailure()){
72 ATH_MSG_ERROR("Writing of LayerMaterialMap with name '" << m_outputLayerMaterialMapName << "' was not successful." );
73 delete outputLayerMaterialMap;
74 } else
75 ATH_MSG_INFO("Successfully wrote LayerMaterialMap with name '" << m_outputLayerMaterialMapName << "' to the detector store.");
76
77 }
78 return StatusCode::SUCCESS;
79
80}
81
82
84{
85
86 ATH_MSG_INFO("========================================================================================= ");
87 ATH_MSG_INFO("finalize() starts ...");
88 return StatusCode::SUCCESS;
89}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
This class extends the DataVector<Trk::LayerMaterialProperties> by an elementTable;.
void updateElementTable(const std::shared_ptr< const ElementTable > &eTable)
update method
This virtual base class encapsulates the logics to build pre/post/full update material for Layer stru...
virtual LayerMaterialProperties * clone() const =0
Pseudo-Constructor clone().
Gaudi::Property< std::string > m_outputLayerMaterialMapName
Gaudi::Property< std::string > m_inputLayerMaterialMapName
< input material properties
virtual StatusCode finalize() override
standard Athena-Algorithm method
ToolHandle< ILayerMaterialManipulator > m_layerMaterialManipulator
const LayerMaterialMap * m_inputLayerMaterialMap
output material properties
virtual StatusCode execute(const EventContext &ctx) override
standard Athena-Algorithm method
virtual StatusCode initialize() override
standard Athena-Algorithm method