17 m_denominator_hist(0),
27 m_denominator_hist =
new TH1D(
"",
"denominator_hist", n_bins, x_min, x_max);
29 m_axis = (TAxis*) m_denominator_hist->GetXaxis()->Clone(
"");
30 m_n_bins = m_denominator_hist->GetNbinsX();
33 vector<double> *denominator_vec = 0, *numerator_vec = 0;
34 TBranch *b_denominator_vec, *b_numerator_vec;
35 denominator->SetBranchAddress(denominator_branch.c_str(), &denominator_vec, &b_denominator_vec);
36 numerator->SetBranchAddress(numerator_branch.c_str(), &numerator_vec, &b_numerator_vec);
37 unsigned long nentries_denominator =
denominator->GetEntries(), nentries_numerator = numerator->GetEntries(),
counter = 0;
38 while (
counter < nentries_denominator) {
40 for (
unsigned int i = 0,
I = denominator_vec->size();
i <
I; ++
i) m_denominator_hist->Fill((*denominator_vec)[
i]);
44 while (
counter < nentries_numerator) {
46 for (
unsigned int i = 0,
I = numerator_vec->size();
i <
I; ++
i)
m_numerator_hist->Fill((*numerator_vec)[
i]);
52 numerator->ResetBranchAddress(b_numerator_vec);
53 delete b_denominator_vec;
54 delete b_numerator_vec;
55 denominator_vec->clear();
56 delete denominator_vec;
57 numerator_vec->clear();
60 m_scale = (
double) nentries_denominator / (
double) nentries_numerator;
66 temp_entry->
SetID(m_ID);
73 m_denominator_hist =
new TH1D(
"",
"denominator_hist", n_bins, x_min, x_max);
75 m_axis = (TAxis*) m_denominator_hist->GetXaxis()->Clone(
"");
76 m_n_bins = m_denominator_hist->GetNbinsX();
88 temp_entry->
SetID(m_ID);
95 m_denominator_hist = (TH1D*) denominator_in->Clone(
"");
97 m_axis = (TAxis*) m_denominator_hist->GetXaxis()->Clone(
"");
98 m_n_bins = m_denominator_hist->GetNbinsX();
105 temp_entry->
SetID(m_ID);
112 std::cout <<
"WARNING in APReweight::~APReweight(TH1* denominator_in, TH1* numerator_in, bool isTrig) : Using histograms " <<
m_numerator_hist->GetName() <<
" and " << m_denominator_hist->GetName() <<
" the efficiency is larger than 1 for bin " <<
i <<
"! This is inconsistent and can lead to unwanted behaviour (weights > 1, variance < 0 )! Please check your input histograms. In order to avoid negative variances, the efficiency in this bin will be set to 0. " << std::endl;
121 if (err_high_in == 0) err_high_in = err_low_in;
123 m_denominator_hist =
new TH1D(
"",
"", 1, 0., 1.);
125 m_axis = (TAxis*) efficiency_in->GetXaxis()->Clone(
"");
126 m_n_bins = efficiency_in->GetNbinsX();
131 temp_entry->
ReadEfficiency(efficiency_in->GetBinContent(
i + 1), err_low_in->GetBinContent(
i + 1), err_high_in->GetBinContent(
i + 1));
133 temp_entry->
SetID(m_ID);
139 delete m_denominator_hist;
159 return m_denominator_hist;
176 if (
value >=
m_axis->GetBinLowEdge(
i) && value <= m_axis->GetBinUpEdge(
i)) {
180 if (!
m_isQuiet) cout <<
"WARNING in APReweight::GetBin: Value out of range! Returning 0." << endl;