ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::JsonMaterialWriterTool Class Reference

Material writer dumping the tracking geometry material map to Json/Cbor. More...

#include <JsonMaterialWriterTool.h>

Inheritance diagram for ActsTrk::JsonMaterialWriterTool:
Collaboration diagram for ActsTrk::JsonMaterialWriterTool:

Public Member Functions

 ~JsonMaterialWriterTool () override=default
virtual void writeMaterial (const ActsTrk::GeometryContext &gctx, const Acts::TrackingGeometryMaterial &detMaterial) const override

Private Attributes

Gaudi::Property< std::string > m_fileName {this, "FileName", "material-maps", "Output file base name for the Json/Cbor Material Map"}
 The base name of the output file (without extension).
Gaudi::Property< bool > m_writeJson {this, "WriteJson", true, "Write the material map in Json format"}
 Write out the map in Json format.
Gaudi::Property< bool > m_writeCbor {this, "WriteCbor", false, "Write the material map in Cbor format"}
 Write out the map in Cbor format.

Detailed Description

Material writer dumping the tracking geometry material map to Json/Cbor.

This uses the ACTS Json plugin (Acts::MaterialMapJsonConverter) to serialise the surface and volume material maps into a Json (and/or Cbor) file. The resulting file can be read back in e.g. by Acts::JsonMaterialDecorator.

Definition at line 20 of file JsonMaterialWriterTool.h.

Constructor & Destructor Documentation

◆ ~JsonMaterialWriterTool()

ActsTrk::JsonMaterialWriterTool::~JsonMaterialWriterTool ( )
overridedefault

Member Function Documentation

◆ writeMaterial()

void ActsTrk::JsonMaterialWriterTool::writeMaterial ( const ActsTrk::GeometryContext & gctx,
const Acts::TrackingGeometryMaterial & detMaterial ) const
overridevirtual

Definition at line 16 of file JsonMaterialWriterTool.cxx.

18{
19 // Set up the Athena-backed Acts logger, and take its level for the converter
20 std::unique_ptr<const Acts::Logger> logger = makeActsAthenaLogger(this, "JsonMaterialWriterTool");
21
22 // Configure the Json converter
23 Acts::MaterialMapJsonConverter::Config converterCfg;
24 converterCfg.context = gctx.context();
25
26 Acts::MaterialMapJsonConverter converter(converterCfg, logger->level());
27
28 // Convert the surface and volume material maps to Json
29 nlohmann::json jOut = converter.materialMapsToJson(detMaterial);
30
31 if (m_writeJson.value()) {
32 const std::string fileName = m_fileName.value() + ".json";
33 ATH_MSG_INFO("Writing Json material map to '" << fileName << "'");
34 std::ofstream ofj(fileName);
35 ofj << std::setw(4) << jOut << std::endl;
36 }
37
38 if (m_writeCbor.value()) {
39 const std::vector<std::uint8_t> cborOut = nlohmann::json::to_cbor(jOut);
40 const std::string fileName = m_fileName.value() + ".cbor";
41 ATH_MSG_INFO("Writing Cbor material map to '" << fileName << "'");
42 std::ofstream ofj(fileName, std::ios::out | std::ios::binary);
43 ofj.write(reinterpret_cast<const char*>(cborOut.data()), cborOut.size());
44 }
45}
#define ATH_MSG_INFO(x,...)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
Acts::GeometryContext context() const
Gaudi::Property< std::string > m_fileName
The base name of the output file (without extension).
Gaudi::Property< bool > m_writeCbor
Write out the map in Cbor format.
Gaudi::Property< bool > m_writeJson
Write out the map in Json format.
static Root::TMsgLogger logger("iLumiCalc")

Member Data Documentation

◆ m_fileName

Gaudi::Property<std::string> ActsTrk::JsonMaterialWriterTool::m_fileName {this, "FileName", "material-maps", "Output file base name for the Json/Cbor Material Map"}
private

The base name of the output file (without extension).

Definition at line 28 of file JsonMaterialWriterTool.h.

28{this, "FileName", "material-maps", "Output file base name for the Json/Cbor Material Map"};

◆ m_writeCbor

Gaudi::Property<bool> ActsTrk::JsonMaterialWriterTool::m_writeCbor {this, "WriteCbor", false, "Write the material map in Cbor format"}
private

Write out the map in Cbor format.

Definition at line 32 of file JsonMaterialWriterTool.h.

32{this, "WriteCbor", false, "Write the material map in Cbor format"};

◆ m_writeJson

Gaudi::Property<bool> ActsTrk::JsonMaterialWriterTool::m_writeJson {this, "WriteJson", true, "Write the material map in Json format"}
private

Write out the map in Json format.

Definition at line 30 of file JsonMaterialWriterTool.h.

30{this, "WriteJson", true, "Write the material map in Json format"};

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