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());
82 std::map<FTType, FTChannel2TimeRelation> valueErrors)
86 for (
const auto& [type, rel] : valueErrors)
88 R3BLOG(debug4, fmt::format(
"type: {} CalRelSize: {}",
FTType2Str(type), rel.value_error.size()));
101 template <
typename... Args>
104 auto* hist =
static_cast<typename Derived::HistType*
>(
GetDistribution(type));
105 hist->Fill(std::forward<Args>(args)...);
114 FTBaseCal(std::string_view hist_name,
unsigned int moduleNum,
const std::vector<FTType>& types)
123 for (
const auto& type : types)
138 explicit ModuleCal(std::string_view hist_name,
unsigned int mID);
140 template <
typename Strategy>
144 auto correlations = std::map<FTType, FTChannel2TimeRelation>{};
145 for (
const auto& [ftType, distribution2D] : distributions)
147 auto* hist =
static_cast<HistType*
>(distribution2D.get());
150 correlations.insert_or_assign(ftType, strategy.GetChannel2Time(hist));
162 explicit PlaneCal(std::string_view hist_name,
unsigned int mID);
172 auto correlations = std::map<FTType, FTChannel2TimeRelation>{};
173 for (
const auto& [ftType, distribution2D] : distributions)
175 auto* hist2D =
static_cast<HistType*
>(distribution2D.get());
176 auto* hist1D = hist2D->ProjectionY(
"projection", barNum, barNum);
177 if (hist1D !=
nullptr)
179 correlations.insert_or_assign(ftType, strategy.
GetChannel2Time(hist1D));
187 template <
typename CalType>
196 template <
typename... AdditionalPar>
197 void Fill(
FTType type,
unsigned int ftValue,
unsigned int moduleNum, AdditionalPar&&... pars)
199 auto iter =
cals_.find(moduleNum);
200 if (iter ==
cals_.end())
202 iter =
cals_.emplace(moduleNum, CalType{
hist_name_, moduleNum }).first;
204 iter->second.Fill(type, ftValue, std::forward<AdditionalPar>(pars)...);
207 template <
typename Strategy>
210 for (
auto& [_, cal] :
cals_)
212 cal.Write_to_par(write_strategy, t_cal_par);
218 for (
auto& [_, cal] :
cals_)
220 cal.WriteHist2File(sink);
225 std::map<unsigned int, CalType>
cals_;
#define R3BLOG(severity, x)
void SetModuleParam(unsigned int module_num, TCalVFTXModulePar par)
std::map< FTType, std::unique_ptr< TH1 > > fTDistribution_
void InitAllDistributions(TH1 *hist)
auto GetModuleNum() const -> const auto &
FTBaseCal(std::string_view hist_name, unsigned int moduleNum, const std::vector< FTType > &types)
void Write2Par(unsigned int moduleID, Map2CalPar &t_cal_par, std::map< FTType, FTChannel2TimeRelation > valueErrors)
auto GetAllDistributions() -> const auto &
void AddFineTime(FTType type, Args &&... args)
auto GetHistName() const -> const auto &
auto GetDistribution(FTType type)
std::string_view hist_name_
void EmptyInitAllDistributions(const std::vector< FTType > &types)
void WriteHist2File(TDirectory *sink)
TCalVFTXModulePar::ValueErrors ValueErrors
TCalVFTXModulePar::ValueErrors ValueErrors
void Set_max_bin_number(unsigned int num)
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)
unsigned int max_bin_number_
void Writer_to_TCalPar(const Strategy &write_strategy, Map2CalPar &t_cal_par)
std::map< unsigned int, CalType > cals_
void WriteHist2File(TDirectory *sink)
void Fill(FTType type, unsigned int ftValue, unsigned int moduleNum, AdditionalPar &&... pars)
FTEngine(std::string hist_name)
void Fill(FTType type, unsigned int ftValue)
ModuleCal(std::string_view hist_name, unsigned 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, unsigned int ftValue, unsigned int barID)
PlaneCal(std::string_view hist_name, unsigned 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(unsigned int planeNum, unsigned int barNum) -> unsigned int