ATLAS Offline Software
Loading...
Searching...
No Matches
MaterialManipulation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
18
19
20Trk::MaterialManipulation::MaterialManipulation(const std::string& name, ISvcLocator* pSvcLocator)
21: AthAlgorithm(name,pSvcLocator),
22 m_inputLayerMaterialMapName("/GLOBAL/TrackingGeo/Input"),
24 m_outputLayerMaterialMapName("/GLOBAL/TrackingGeo/Output"),
26{
27 declareProperty("LayerMaterialManipulator", m_layerMaterialManipulator);
28 // input - output definition
29 declareProperty("LayerMaterialMapNameInput", m_inputLayerMaterialMapName);
30 declareProperty("LayerMaterialMapNameOutput", m_outputLayerMaterialMapName);
31
32}
33
35= default;
36
38{
39 ATH_MSG_INFO("initialize()");
40
41 if (!m_layerMaterialManipulator.empty() && m_layerMaterialManipulator.retrieve().isFailure()){
42 ATH_MSG_FATAL("Could not retrieve LayerMaterial manipulator - although configured. Aborting.");
43 return StatusCode::FAILURE;
44 }
45 return StatusCode::SUCCESS;
46}
47
48
50{
51 ATH_MSG_VERBOSE("MaterialManipulation execute() start");
52
53 Trk::LayerMaterialMap* outputLayerMaterialMap = nullptr;
54
55 // make sure this is only done once
57
58 // -------------------------------------------------------------------------------
60 ATH_MSG_FATAL( "Could not retrieve LayerMaterialMap wiht name '" << m_inputLayerMaterialMapName << "'. Aborting.");
61 return StatusCode::FAILURE;
62 } else
63 ATH_MSG_DEBUG( "Retrieved LayerMaterialMap wiht name '" << m_inputLayerMaterialMapName << "' for " << m_inputLayerMaterialMap->size() << " layers.");
64
65 // create the output material map
66 outputLayerMaterialMap = new Trk::LayerMaterialMap();
67 // now create the new one and manipulate
68 for ( const auto & lmIter : (*m_inputLayerMaterialMap) ){
69 // copy the layer material
70 ATH_MSG_VERBOSE(" -> Found map for layer with index " << lmIter.first);
71 // use the virtual constructor
72 const Trk::LayerMaterialProperties* lmp = nullptr;
73 // manipulate it if needed
74 if (!m_layerMaterialManipulator.empty())
75 lmp = m_layerMaterialManipulator->processLayerMaterial(lmIter.first,*(lmIter.second));
76 else
77 lmp = lmIter.second->clone();
78 // and insert into the map
79 (*outputLayerMaterialMap)[lmIter.first] = lmp;
80 }
81
82 // get the element table - and copy it over if there's none
83 const ElementTable* eTable = m_inputLayerMaterialMap->elementTable();
84 if (eTable){
85 auto tElementTable = std::make_shared<Trk::ElementTable>(*eTable);
86 outputLayerMaterialMap->updateElementTable(tElementTable);
87 }
88 // finally write it to StoreGate
89 if ( (detStore()->record(outputLayerMaterialMap, m_outputLayerMaterialMapName, false)).isFailure()){
90 ATH_MSG_ERROR("Writing of LayerMaterialMap with name '" << m_outputLayerMaterialMapName << "' was not successful." );
91 delete outputLayerMaterialMap;
92 } else
93 ATH_MSG_INFO("Successfully wrote LayerMaterialMap with name '" << m_outputLayerMaterialMapName << "' to the detector store.");
94
95 }
96 return StatusCode::SUCCESS;
97
98}
99
100
102{
103
104 ATH_MSG_INFO("========================================================================================= ");
105 ATH_MSG_INFO("finalize() starts ...");
106 return StatusCode::SUCCESS;
107}
#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)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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()
virtual StatusCode execute() override
standard Athena-Algorithm method
virtual StatusCode finalize() override
standard Athena-Algorithm method
ToolHandle< ILayerMaterialManipulator > m_layerMaterialManipulator
MaterialManipulation(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
const LayerMaterialMap * m_inputLayerMaterialMap
output material properties
std::string m_inputLayerMaterialMapName
< input material properties
~MaterialManipulation()
Default Destructor.
virtual StatusCode initialize() override
standard Athena-Algorithm method