ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
JsonMaterialWriter.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file JsonMaterialWriter.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2017-2019 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include "
ACTFW/Plugins/Json/JsonMaterialWriter.hpp
"
10
11
#include <fstream>
12
#include <ios>
13
#include <iostream>
14
#include <stdexcept>
15
16
#include "
Acts/Geometry/GeometryID.hpp
"
17
#include "
Acts/Material/BinnedSurfaceMaterial.hpp
"
18
19
FW::Json::JsonMaterialWriter::JsonMaterialWriter
(
20
const
Acts::JsonGeometryConverter::Config
& cfg,
const
std::string& fileName)
21
: m_cfg(cfg), m_fileName(fileName) {
22
// Validate the configuration
23
if
(
m_cfg
.
name
.empty()) {
24
throw
std::invalid_argument(
"Missing service name"
);
25
}
26
}
27
28
FW::Json::JsonMaterialWriter::~JsonMaterialWriter
() {}
29
30
void
FW::Json::JsonMaterialWriter::write
(
31
const
Acts::DetectorMaterialMaps
& detMaterial) {
32
// Evoke the converter
33
Acts::JsonGeometryConverter
jmConverter(m_cfg);
34
auto
jout = jmConverter.
materialMapsToJson
(detMaterial);
35
// And write the file
36
std::ofstream ofj(m_fileName);
37
ofj << std::setw(4) << jout << std::endl;
38
}
39
40
void
FW::Json::JsonMaterialWriter::write
(
41
const
Acts::TrackingGeometry
&
tGeometry
) {
42
// Evoke the converter
43
Acts::JsonGeometryConverter
jmConverter(m_cfg);
44
auto
jout = jmConverter.
trackingGeometryToJson
(tGeometry);
45
// And write the file
46
std::ofstream ofj(m_fileName);
47
ofj << std::setw(4) << jout << std::endl;
48
}
acts
blob
master
Examples
Io
Json
src
JsonMaterialWriter.cpp
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:24
using
1.8.2 with
ECCE GitHub integration