R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandBaseParJson.h
Go to the documentation of this file.
1#pragma once
2#include "R3BNeulandBasePar.h"
4#include <nlohmann/json.hpp>
5#include <nlohmann/json_fwd.hpp>
6#include <string>
7#include <utility>
8
9namespace R3B::Neuland
10{
11 template <>
12 inline void to_json(nlohmann::ordered_json& json_obj, const CalibrationBasePar& options)
13 {
14 json_obj = nlohmann::ordered_json{ { "expIDs", options.get_exp_ids() },
15 { "num_of_planes", options.get_num_of_planes() },
16 { "offspill", options.get_offspill_tpat_pos() },
17 { "trig_mapping", options.get_trig_id_map() } };
18 }
19
20 template <>
21 inline void from_json(const nlohmann::ordered_json& json_obj, CalibrationBasePar& options)
22 {
23
24 auto offspill_tpat_pos = 0;
25 auto num_of_planes = 0;
26 auto exp_ids = std::string{};
27 auto trigIDMap = CalibrationBasePar::TrigIDMap{};
28
29 json_obj.at("expIDs").get_to(exp_ids);
30 json_obj.at("num_of_planes").get_to(num_of_planes);
31 json_obj.at("offspill").get_to(offspill_tpat_pos);
32
33 options.set_num_of_planes(num_of_planes);
34 options.set_offspill_tpat_pos(offspill_tpat_pos);
35 options.set_exp_ids(exp_ids);
36
37 for (const auto& jsonEntry : json_obj.at("trig_mapping"))
38 {
39 const auto moduleID = jsonEntry.at("barID").template get<int>();
40 const auto trigID_left = jsonEntry.at("trigID_left").template get<int>();
41 const auto trigID_right = jsonEntry.at("trigID_right").template get<int>();
42 trigIDMap.insert({ moduleID, std::make_pair(trigID_left, trigID_right) });
43 }
44 options.set_trig_id_map(std::move(trigIDMap));
45 }
46
47} // namespace R3B::Neuland
auto get_trig_id_map() const -> const auto &
void set_trig_id_map(TrigIDMap trigIDMap)
void set_num_of_planes(int num_of_plane)
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > TrigIDMap
void set_exp_ids(const std::string &exp_ids)
auto get_offspill_tpat_pos() const -> int
auto get_exp_ids() const -> const auto &
Simulation of NeuLAND Bar/Paddle.
void from_json(const nlohmann::ordered_json &json_obj, GeneratorFactory::Options &options)
void to_json(nlohmann::ordered_json &json_obj, const GeneratorFactory::Options &options)