21 #include <initializer_list>
26 namespace ActsExamples {
32 if (
gauss !=
nullptr) {
35 j[
"stddev"] =
gauss->sigma;
39 auto gaussT =
f.target<
const Digitization::GaussTrunc>();
40 if (gaussT !=
nullptr) {
41 j[
"type"] =
"GaussTrunc";
43 j[
"stddev"] = gaussT->sigma;
44 j[
"range"] = gaussT->range;
48 auto gaussC =
f.target<
const Digitization::GaussClipped>();
49 if (gaussC !=
nullptr) {
50 j[
"type"] =
"GaussClipped";
52 j[
"stddev"] = gaussC->sigma;
53 j[
"range"] = gaussC->range;
54 j[
"max_attempts"] = gaussC->maxAttemps;
58 auto uniform =
f.target<
const Digitization::Uniform>();
59 if (uniform !=
nullptr) {
60 j[
"type"] =
"Uniform";
61 j[
"bindata"] = nlohmann::json(uniform->binningData);
65 auto digital =
f.target<
const Digitization::Digital>();
66 if (uniform !=
nullptr) {
67 j[
"type"] =
"Digitial";
68 j[
"bindata"] = nlohmann::json(digital->binningData);
72 auto exact =
f.target<
const Digitization::Digital>();
73 if (exact !=
nullptr) {
78 throw std::runtime_error(
"Unable to serialize smearer");
82 const nlohmann::json& j,
86 if (sType ==
"Gauss") {
88 }
else if (sType ==
"GaussTrunc") {
90 std::pair<Acts::ActsScalar, Acts::ActsScalar> range = j[
"range"];
91 f = Digitization::GaussTrunc(sigma, range);
92 }
else if (sType ==
"GaussClipped") {
94 std::pair<Acts::ActsScalar, Acts::ActsScalar> range = j[
"range"];
95 f = Digitization::GaussClipped(sigma, range);
96 }
else if (sType ==
"Uniform") {
100 }
else if (sType ==
"Digitial") {
103 f = Digitization::Uniform(
std::move(bd));
104 }
else if (sType ==
"Exact") {
105 f = Digitization::Exact{};
107 throw std::invalid_argument(
"Unknown smearer type '" + sType +
"'");
116 j[
"index"] = psc.
index;
128 std::vector<size_t> indices;
130 indices.push_back(static_cast<size_t>(
idx));
132 j[
"indices"] = indices;
142 for (
const auto& jidx : j[
"indices"]) {
143 gdc.
indices.push_back(static_cast<Acts::BoundIndices>(jidx));
154 for (
const auto& sc : sdc) {
155 j.push_back(nlohmann::json(sc));
161 for (
const auto& jpsc : j) {
180 if (j.find(
"geometric") != j.end()) {
181 nlohmann::json jgdc = j[
"geometric"];
184 if (j.find(
"smearing") != j.end()) {
185 nlohmann::json jsdc = j[
"smearing"];
192 nlohmann::json djson;
198 infile.exceptions(std::ofstream::failbit | std::ofstream::badbit);
208 outfile.exceptions(std::ofstream::failbit | std::ofstream::badbit);
210 .toJson(cfg,
nullptr)