6#include <FairBaseParSet.h>
7#include <FairGeoParSet.h>
9#include <FairParRootFileIo.h>
10#include <FairParSet.h>
11#include <FairRuntimeDb.h>
12#include <fairlogger/Logger.h>
25 void add_parameter(FairParSet* par, FairRuntimeDb* rtdb)
28 if (rtdb->addContainer(par); par ==
nullptr)
30 throw R3B::runtime_error(
"Calibration parameter becomes nullptr!");
39 auto trig_module_id = -1;
40 auto res = RE2::FullMatch(line_str,
41 R
"(.*\[(\d+)\]\[(\d+)\]\[(\d+)\]\s+\=\s+(\d+);)",
52 trig_id_map.try_emplace((plane_id *
BarsPerPlane) + bar_id + 1, std::make_pair(-1, -1)).first->second;
55 module_nums.first = trig_module_id + 1;
59 module_nums.second = trig_module_id + 1;
68 for (
const auto& [bar_number, trig_ids] : trig_id_map)
70 auto has_trig_id = (trig_ids.first != -1) and (trig_ids.second != -1);
73 LOGP(error,
"Trig module numbers are incomplete for the bar number {}!", bar_number);
84 program_options.add_option(
"-s, --severity",
log_level_,
"Set the severity level");
89 .add_option(
"-o, --output",
output_par_file_name_,
"Set the filename of the ouput parameter root file.")
91 program_options.add_option(
"-e, --exp-id",
exp_id_,
"Set the experiment id, such as \"s118\"")->required(
true);
93 .add_option(
"--offspill-pos",
offspill_pos_,
"Set the TPAT bit position of neuland offspill data")
102 if (not ifile.is_open())
106 auto line_string = std::string{};
107 std::getline(ifile, line_string,
'\n');
111 while (std::getline(ifile, line_string,
'\n'))
113 parsing_a_line(line_string, trig_id_map);
120 if (not RE2::FullMatch(line_str, R
"(.*\[(\d+)\]\[\d+\]\[\d+\];)", &num_of_planes_))
122 throw R3B::runtime_error(fmt::format(
"Failed to extract the plane number from the string {:?}.", line_str));
130 if (not check_trig_id_map(trig_id_map))
135 auto base_par = std::make_unique<R3B::Neuland::CalibrationBasePar>();
137 base_par->set_exp_ids(
exp_id_);
139 base_par->set_trig_id_map(std::move(trig_id_map));
141 auto rtdb = std::unique_ptr<FairRuntimeDb>(FairRuntimeDb::instance());
142 auto parOut = std::make_unique<FairParRootFileIo>(
false);
144 add_parameter(base_par.release(), rtdb.get());
145 add_parameter(std::make_unique<FairBaseParSet>().release(), rtdb.get());
146 add_parameter(std::make_unique<FairGeoParSet>().release(), rtdb.get());
147 rtdb->setOutput(parOut.release());
150 rtdb->writeContainers();
void init() override
Initialization of a CLI program.
std::string output_par_file_name_
std::string input_header_file_name_
void run() override
Run the CLI program.
void parsing_first_line(const std::string &line_str)
auto parsing_header_file() -> CalibrationBasePar::TrigIDMap
void setup_options(CLI::App &program_options) override
Setup the CLI options given to the program.
std::unordered_map< int, std::pair< int, int > > TrigIDMap
Simulation of NeuLAND Bar/Paddle.
constexpr auto BarsPerPlane