ATLAS Offline Software
Loading...
Searching...
No Matches
MuonMaterialDecoratorTool.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
9#include "ActsPlugins/Root/RootMaterialDecorator.hpp"
10#include "ActsPlugins/Json/JsonMaterialDecorator.hpp"
11#include "ActsPlugins/Json/MaterialMapJsonConverter.hpp"
12
13
14
15namespace MuonGMR4 {
17
18 void MuonMaterialDecoratorTool::visitSurface(Acts::Surface& surface){
19 bool hasMat = surface.hasMaterial();
20 m_matDecorator->decorate(surface);
21 if (hasMat != surface.hasMaterial()) {
22 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" Decorated "<<surface.geometryId()<<" with material");
23 }
24 }
25
27 const Acts::Logging::Level level = ActsTrk::actsLevelVector(msg().level());
28 std::string fullPath = std::format("{:}/{:}", m_materialMapFolder.value() , m_materialMapFile.value());
29 if (fullPath.size() && fullPath[0] != '/') fullPath = PathResolverFindCalibFile(fullPath);
30
31 if(fullPath.empty()){
32 ATH_MSG_ERROR(__func__<<"() "<<__LINE__<<" Could not find material map file: "
33 <<m_materialMapFolder.value() + "/" + m_materialMapFile.value());
34 return StatusCode::FAILURE;
35 }
36 ATH_MSG_INFO("Loading material map from " << fullPath);
37
38 // Json (or Cbor) maps are read with the Json reader, everything else keeps the Root reader
39 if (fullPath.ends_with(".json") || fullPath.ends_with(".cbor")) {
40 Acts::MaterialMapJsonConverter::Config converterConfig;
41 m_matDecorator = std::make_unique<Acts::JsonMaterialDecorator>(converterConfig, fullPath, level);
42 } else {
43 ActsPlugins::RootMaterialDecorator::Config decoratorConfig;
44 decoratorConfig.fileName = fullPath;
45 m_matDecorator = std::make_unique<ActsPlugins::RootMaterialDecorator>(decoratorConfig, level);
46 }
47 return StatusCode::SUCCESS;
48 }
49
51 m_matDecorator.reset();
52 return StatusCode::SUCCESS;
53 }
54}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< std::string > m_materialMapFolder
std::unique_ptr< Acts::IMaterialDecorator > m_matDecorator
virtual void visitSurface(Acts::Surface &surface) override final
virtual StatusCode initialize() override final
virtual StatusCode finalize() override final
Gaudi::Property< std::string > m_materialMapFile
Material map file, read with the Json reader for '.json' / '.cbor' and with the Root reader otherwise...
Acts::Logging::Level actsLevelVector(MSG::Level lvl)
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
MsgStream & msg
Definition testRead.cxx:32