8#include <boost/algorithm/string/classification.hpp>
9#include <boost/algorithm/string/split.hpp>
10#include <boost/algorithm/string/trim.hpp>
12#include <fairlogger/Logger.h>
13#include <fmt/format.h>
28 const auto bar_num = ((module_num - 1) %
BarsPerPlane) + 1;
48 template <
typename T =
double>
51 return static_cast<T
>((plane_id + 0.5) *
BarSize_Z);
53 template <
typename T =
double>
61#ifdef HAS_CPP_STANDARD_23
62 template <
typename Option>
63 void parse_io_branch_names(
const Option& option,
64 std::vector<std::string>&
read,
66 std::vector<std::string>& write,
69 LOGP(info,
"Task {:?} is enabled", option.name);
70 auto resolve_branch_names = [](
const std::string& input, std::vector<std::string>& output) ->
void
73 boost::split(output, input, boost::is_any_of(
";"));
75 std::for_each(output.begin(), output.end(), [](
auto& name) ->
void { boost::trim(name); });
77 std::erase(output,
"");
80 resolve_branch_names(option.read,
read);
81 if (
read.size() != read_num)
84 "Task {:?} requires {} read branch(es) but only received {} branch(es)! Parsed string: {:?}",
90 resolve_branch_names(option.write, write);
91 if (write.size() != write_num)
94 "Task {:?} requires {} write branch(es) but only received {} branch(es)! Parsed string: {:?}",
102 constexpr auto trim_space(std::string_view input) -> std::string_view
104 auto pos = input.find_first_not_of(
' ');
105 if (pos == std::string_view::npos)
109 auto output = input.substr(pos);
110 pos = output.find_last_not_of(
' ');
111 if (pos == std::string_view::npos)
115 output = output.substr(0, pos + 1);
119 constexpr auto get_from_sep_string(std::size_t target_idx, std::string_view input, std::string_view sep =
";")
123 auto last_string = std::string_view{};
124 auto res_string = input;
125 while (std::cmp_less_equal(idx, target_idx))
127 auto pos = res_string.find_first_of(sep);
128 if (pos != std::string_view::npos)
130 last_string = trim_space(res_string.substr(0, pos));
131 res_string = res_string.substr(pos + 1);
135 return trim_space(res_string);
137 if (not last_string.empty())
149 auto* cumulative =
histogram->GetCumulative();
156 static constexpr auto QUANTILES_NUM = 2;
157 const auto quantiles =
158 std::array<double, QUANTILES_NUM>{ 0.5 - (quantile_ratio / 2.), 0.5 + (quantile_ratio / 2.) };
159 auto x_pos = std::array<double, QUANTILES_NUM>{};
160 histogram->GetQuantiles(QUANTILES_NUM, x_pos.data(), quantiles.data());
static constexpr auto ModuleID2PlaneNum(int moduleID) -> int
static constexpr auto IsModuleNumHorizontal(int module_num) -> bool
static constexpr auto ModuleNum2BarID(int module_num) -> int
static constexpr auto ModuleID2PlaneID(int moduleID) -> int
static constexpr auto PlaneID2ZPos(int plane_id) -> T
static constexpr auto IsPlaneIDVertical(int plane_id) -> bool
static constexpr auto IsPlaneIDHorizontal(int plane_id) -> bool
static constexpr auto GetBarVerticalDisplacement(int module_num) -> double
static constexpr auto Neuland_PlaneBar2ModuleNum(int planeNum, int barNum) -> int
static constexpr auto ModuleNum2ZPos(int module_num) -> T
Simulation of NeuLAND Bar/Paddle.
auto calculate_hist_quantiles(TH1 *histogram, double quantile_ratio) -> std::array< double, 2 >
constexpr auto BarsPerPlane
auto calculate_CDF_with_quantiles(TH1 *histogram, double ratio) -> std::pair< TH1 *, std::array< double, 2 > >
constexpr auto BarSize_XY
constexpr auto FirstHorizontalPlane
auto calculate_cdf(TH1 *histogram) -> TH1 *