53 template <
typename Derived>
62 distribution = std::unique_ptr<TH1>(
dynamic_cast<TH1*
>(hist->Clone()));
63 distribution->SetDirectory(
nullptr);
65 distribution->SetNameTitle(name.c_str(), name.c_str());
75 fmt::format(
"Writting histogram {} into sink file {}", distribution->GetName(), sink->GetName()));
76 sink->WriteObject(distribution.get(), distribution->GetName());
80 void Write2Par(
int moduleID,
Map2CalPar& t_cal_par, std::map<FTType, FTChannel2TimeRelation> valueErrors)
84 for (
const auto& [type, rel] : valueErrors)
86 R3BLOG(debug4, fmt::format(
"type: {} CalRelSize: {}",
FTType2Str(type), rel.value_error.size()));
99 template <
typename... Args>
102 auto* hist =
static_cast<typename Derived::HistType*
>(
GetDistribution(type));
103 hist->Fill(std::forward<Args>(args)...);
112 FTBaseCal(std::string_view hist_name,
int moduleNum,
const std::vector<FTType>& types)
121 for (
const auto& type : types)
136 explicit ModuleCal(std::string_view hist_name,
int mID);
138 template <
typename Strategy>
142 auto correlations = std::map<FTType, FTChannel2TimeRelation>{};
143 for (
const auto& [ftType, distribution2D] : distributions)
145 auto* hist =
static_cast<HistType*
>(distribution2D.get());
148 correlations.insert_or_assign(ftType, strategy.GetChannel2Time(hist));
160 explicit PlaneCal(std::string_view hist_name,
int mID);
170 auto correlations = std::map<FTType, FTChannel2TimeRelation>{};
171 for (
const auto& [ftType, distribution2D] : distributions)
173 auto* hist2D =
static_cast<HistType*
>(distribution2D.get());
174 auto* hist1D = hist2D->ProjectionY(
"projection", barNum, barNum);
175 if (hist1D !=
nullptr)
177 correlations.insert_or_assign(ftType, strategy.
GetChannel2Time(hist1D));
185 template <
typename CalType>
194 template <
typename... AdditionalPar>
195 void Fill(
FTType type,
int ftValue,
int moduleNum, AdditionalPar&&... pars)
197 auto iter =
cals_.find(moduleNum);
198 if (iter ==
cals_.end())
200 iter =
cals_.emplace(moduleNum, CalType{
hist_name_, moduleNum }).first;
202 iter->second.Fill(type, ftValue, std::forward<AdditionalPar>(pars)...);
205 template <
typename Strategy>
208 for (
auto& [_, cal] :
cals_)
210 cal.Write_to_par(write_strategy, t_cal_par);
216 for (
auto& [_, cal] :
cals_)
218 cal.WriteHist2File(sink);
#define R3BLOG(severity, x)
void SetModuleParam(int module_num, TCalVFTXModulePar par)
std::map< FTType, std::unique_ptr< TH1 > > fTDistribution_
void InitAllDistributions(TH1 *hist)
auto GetModuleNum() const -> const auto &
auto GetAllDistributions() -> const auto &
void AddFineTime(FTType type, Args &&... args)
auto GetHistName() const -> const auto &
auto GetDistribution(FTType type)
FTBaseCal(std::string_view hist_name, int moduleNum, const std::vector< FTType > &types)
std::string_view hist_name_
void Write2Par(int moduleID, Map2CalPar &t_cal_par, std::map< FTType, FTChannel2TimeRelation > valueErrors)
void EmptyInitAllDistributions(const std::vector< FTType > &types)
void WriteHist2File(TDirectory *sink)
TCalVFTXModulePar::ValueErrors ValueErrors
TCalVFTXModulePar::ValueErrors ValueErrors
auto GetChannel2Time(TH1 *hist) const -> FTChannel2TimeRelation
FTCalErrorMethod error_method_
auto Get_cycle_period() const -> auto
void Set_error_method(FTCalErrorMethod method)
void Set_cycle_period(double time)
void Set_max_bin_number(int num)
void Writer_to_TCalPar(const Strategy &write_strategy, Map2CalPar &t_cal_par)
void WriteHist2File(TDirectory *sink)
FTEngine(std::string hist_name)
void Fill(FTType type, int ftValue, int moduleNum, AdditionalPar &&... pars)
std::map< int, CalType > cals_
void Fill(FTType type, int ftValue)
ModuleCal(std::string_view hist_name, int mID)
void Write_to_par(const Strategy &strategy, Map2CalPar &t_cal_par)
void Write_to_par(const FTCalStrategy &strategy, Map2CalPar &t_cal_par)
void Fill(FTType type, int ftValue, int barID)
PlaneCal(std::string_view hist_name, int mID)
std::vector< ValueError< double > > ValueErrors
void Set_correlation(std::map< FTType, FTChannel2TimeRelation > correlation)
auto FTType2Str(FTType type) -> std::string_view
constexpr auto BarsPerPlane
constexpr auto Neuland_PlaneBar2ModuleNum(int planeNum, int barNum) -> int