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 
17 ActsMaterialJsonWriterTool::ActsMaterialJsonWriterTool(const std::string &type, const std::string &name,
18  const IInterface *parent)
19  : base_class(type, name, parent)
20 {
21 }
22 
24 {
25 }
26 
29 {
30  ATH_MSG_INFO("Starting Material writer");
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 void
37  const Acts::TrackingGeometryMaterial& detMaterial) const {
38  // Setup the converter config
39  Acts::MaterialMapJsonConverter::Config cfg;
40  cfg.context = gctx.context();
41  cfg.processSensitives = m_processSensitives;
42  cfg.processApproaches = m_processApproaches;
43  cfg.processRepresenting = m_processRepresenting;
44  cfg.processBoundaries = m_processBoundaries;
45  cfg.processVolumes = m_processVolumes;
46  cfg.processDenseVolumes = m_processDenseVolumes;
47  cfg.processNonMaterial = m_processNonMaterial;
48 
49  // Evoke the converter
50  Acts::MaterialMapJsonConverter jmConverter(cfg, Acts::Logging::INFO);
51  auto jout = jmConverter.materialMapsToJson(detMaterial);
52  // And write the file
53  std::ofstream ofj(m_filePath);
54  ofj << std::setw(4) << jout << std::endl;
55 }
56 
57 void
59  const Acts::TrackingGeometry& tGeometry) const {
60  // Setup the converter config
61  Acts::MaterialMapJsonConverter::Config cfg;
62  cfg.context = gctx.context();
63  cfg.processSensitives = m_processSensitives;
64  cfg.processApproaches = m_processApproaches;
65  cfg.processRepresenting = m_processRepresenting;
66  cfg.processBoundaries = m_processBoundaries;
67  cfg.processVolumes = m_processVolumes;
68  cfg.processDenseVolumes = m_processDenseVolumes;
69  cfg.processNonMaterial = m_processNonMaterial;
70 
71  // Evoke the converter
72  Acts::MaterialMapJsonConverter jmConverter(cfg, Acts::Logging::INFO);
73  auto jout = jmConverter.trackingGeometryToJson(tGeometry);
74  // And write the file
75  std::ofstream ofj(m_filePath);
76  ofj << std::setw(4) << jout << std::endl;
77 }
ActsMaterialJsonWriterTool::initialize
virtual StatusCode initialize() override
Definition: ActsMaterialJsonWriterTool.cxx:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ActsMaterialJsonWriterTool::m_processBoundaries
Gaudi::Property< bool > m_processBoundaries
Definition: ActsMaterialJsonWriterTool.h:54
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ActsMaterialJsonWriterTool::m_processRepresenting
Gaudi::Property< bool > m_processRepresenting
Definition: ActsMaterialJsonWriterTool.h:53
ActsMaterialJsonWriterTool::m_processSensitives
Gaudi::Property< bool > m_processSensitives
Definition: ActsMaterialJsonWriterTool.h:51
GeometryContext.h
ActsMaterialJsonWriterTool::m_processDenseVolumes
Gaudi::Property< bool > m_processDenseVolumes
Definition: ActsMaterialJsonWriterTool.h:56
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
ActsTrk::GeometryContext
Definition: GeometryContext.h:28
ActsMaterialJsonWriterTool::m_filePath
Gaudi::Property< std::string > m_filePath
Definition: ActsMaterialJsonWriterTool.h:50
ActsMaterialJsonWriterTool::m_processApproaches
Gaudi::Property< bool > m_processApproaches
Definition: ActsMaterialJsonWriterTool.h:52
ActsMaterialJsonWriterTool::ActsMaterialJsonWriterTool
ActsMaterialJsonWriterTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ActsMaterialJsonWriterTool.cxx:17
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:55
ActsMaterialJsonWriterTool::write
virtual void write(const ActsTrk::GeometryContext &gctx, const Acts::TrackingGeometryMaterial &detMaterial) const override
Definition: ActsMaterialJsonWriterTool.cxx:36
ActsMaterialJsonWriterTool.h
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
ActsMaterialJsonWriterTool::~ActsMaterialJsonWriterTool
~ActsMaterialJsonWriterTool()
Definition: ActsMaterialJsonWriterTool.cxx:23
Logger.h
ActsMaterialJsonWriterTool::m_processNonMaterial
Gaudi::Property< bool > m_processNonMaterial
Definition: ActsMaterialJsonWriterTool.h:57
ActsTrk::GeometryContext::context
Acts::GeometryContext context() const
Definition: GeometryContext.h:46