ATLAS Offline Software
ActsMaterialJsonWriterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "ActsInterop/Logger.h"
9 
10 #include <Acts/Material/TrackingGeometryMaterial.hpp>
11 #include <fstream>
12 #include <ios>
13 #include <iostream>
14 #include <stdexcept>
15 
16 ActsMaterialJsonWriterTool::ActsMaterialJsonWriterTool(const std::string &type, const std::string &name,
17  const IInterface *parent)
18  : base_class(type, name, parent)
19 {
20 }
21 
23 {
24 }
25 
28 {
29  ATH_MSG_INFO("Starting Material writer");
30 
31  return StatusCode::SUCCESS;
32 }
33 
34 void
35 ActsMaterialJsonWriterTool::write(const ActsGeometryContext& gctx, const Acts::TrackingGeometryMaterial& detMaterial) const
36 {
37  // Setup the converter config
38  Acts::MaterialMapJsonConverter::Config cfg;
39  cfg.context = gctx.context();
40  cfg.processSensitives = m_processSensitives;
41  cfg.processApproaches = m_processApproaches;
42  cfg.processRepresenting = m_processRepresenting;
43  cfg.processBoundaries = m_processBoundaries;
44  cfg.processVolumes = m_processVolumes;
45  cfg.processDenseVolumes = m_processDenseVolumes;
46  cfg.processNonMaterial = m_processNonMaterial;
47 
48  // Evoke the converter
49  Acts::MaterialMapJsonConverter jmConverter(cfg, Acts::Logging::INFO);
50  auto jout = jmConverter.materialMapsToJson(detMaterial);
51  // And write the file
52  std::ofstream ofj(m_filePath);
53  ofj << std::setw(4) << jout << std::endl;
54 }
55 
56 void
57 ActsMaterialJsonWriterTool::write(const ActsGeometryContext& gctx, const Acts::TrackingGeometry& tGeometry) const
58 {
59  // Setup the converter config
60  Acts::MaterialMapJsonConverter::Config cfg;
61  cfg.context = gctx.context();
62  cfg.processSensitives = m_processSensitives;
63  cfg.processApproaches = m_processApproaches;
64  cfg.processRepresenting = m_processRepresenting;
65  cfg.processBoundaries = m_processBoundaries;
66  cfg.processVolumes = m_processVolumes;
67  cfg.processDenseVolumes = m_processDenseVolumes;
68  cfg.processNonMaterial = m_processNonMaterial;
69 
70  // Evoke the converter
71  Acts::MaterialMapJsonConverter jmConverter(cfg, Acts::Logging::INFO);
72  auto jout = jmConverter.trackingGeometryToJson(tGeometry);
73  // And write the file
74  std::ofstream ofj(m_filePath);
75  ofj << std::setw(4) << jout << std::endl;
76 }
ActsMaterialJsonWriterTool::initialize
virtual StatusCode initialize() override
Definition: ActsMaterialJsonWriterTool.cxx:27
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ActsGeometryContext.h
ActsMaterialJsonWriterTool::m_processBoundaries
Gaudi::Property< bool > m_processBoundaries
Definition: ActsMaterialJsonWriterTool.h:53
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ActsMaterialJsonWriterTool::m_processRepresenting
Gaudi::Property< bool > m_processRepresenting
Definition: ActsMaterialJsonWriterTool.h:52
ActsMaterialJsonWriterTool::m_processSensitives
Gaudi::Property< bool > m_processSensitives
Definition: ActsMaterialJsonWriterTool.h:50
ActsGeometryContext::context
Acts::GeometryContext context() const
Definition: ActsGeometryContext.h:45
ActsMaterialJsonWriterTool::m_processDenseVolumes
Gaudi::Property< bool > m_processDenseVolumes
Definition: ActsMaterialJsonWriterTool.h:55
ActsMaterialJsonWriterTool::write
virtual void write(const ActsGeometryContext &gctx, const Acts::TrackingGeometryMaterial &detMaterial) const override
Definition: ActsMaterialJsonWriterTool.cxx:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsMaterialJsonWriterTool::m_filePath
Gaudi::Property< std::string > m_filePath
Definition: ActsMaterialJsonWriterTool.h:49
ActsMaterialJsonWriterTool::m_processApproaches
Gaudi::Property< bool > m_processApproaches
Definition: ActsMaterialJsonWriterTool.h:51
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
ActsMaterialJsonWriterTool::ActsMaterialJsonWriterTool
ActsMaterialJsonWriterTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ActsMaterialJsonWriterTool.cxx:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
ActsMaterialJsonWriterTool::m_processVolumes
Gaudi::Property< bool > m_processVolumes
Definition: ActsMaterialJsonWriterTool.h:54
ActsMaterialJsonWriterTool.h
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
ActsMaterialJsonWriterTool::~ActsMaterialJsonWriterTool
~ActsMaterialJsonWriterTool()
Definition: ActsMaterialJsonWriterTool.cxx:22
Logger.h
ActsMaterialJsonWriterTool::m_processNonMaterial
Gaudi::Property< bool > m_processNonMaterial
Definition: ActsMaterialJsonWriterTool.h:56