1 #ifndef CROMBIE_CORRECTION_H 2 #define CROMBIE_CORRECTION_H 1 14 std::map<std::string, std::unique_ptr<TFile>>
files;
34 Correction(std::string
filename,
const std::string& histname,
const std::string& denom =
"");
43 double get(
const int bin);
44 using minmax = std::pair<double, double>;
56 std::unique_ptr<TFile> handle {TFile::Open(filename.data())};
61 hist =
static_cast<H*
>(in->Get(histname.data())->Clone());
63 hist->Divide(static_cast<H*>(in->Get(denom.data())));
65 auto* axis =
hist->GetXaxis();
66 xminmax.first = axis->GetBinCenter(axis->GetFirst());
67 xminmax.second = axis->GetBinCenter(axis->GetLast());
69 if (dynamic_cast<const TH2*>(
hist)) {
70 axis =
hist->GetYaxis();
71 yminmax.first = axis->GetBinCenter(axis->GetFirst());
72 yminmax.second = axis->GetBinCenter(axis->GetLast());
88 return hist->GetBinContent(bin);
93 return std::max(mm.first, std::min(mm.second, val));