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