5#define APWeightEntry_cxx
46 double val_denominator_f = (double) val_denominator;
48 double val_numerator_f = (double) val_numerator;
69 m_pdf =
new double[1000];
73 m_variance = (val_numerator_f / (val_denominator_f * val_denominator_f)) + ((val_numerator_f * val_numerator_f) / (val_denominator_f * val_denominator_f * val_denominator_f));
79 double step = (sig_high - sig_low) * 1e-3;
80 const double inv_scale = 1. / scale;
84 double temp_value = sig_low;
85 double arr_position = sig_low;
87 for (
int i = 0; i < 1000; ++i) {
88 temp_value = exp(
m_val_numerator * log(arr_position * inv_scale)+(-val_numerator_f - val_denominator_f - 2.) * log((arr_position * inv_scale) + 1.) - shift);
89 if (temp_value != temp_value) temp_value = 0.;
90 m_pdf[i] = temp_value;
95 m_bins[1000] = arr_position;
106 m_pdf =
new double[1000];
107 m_bins =
new double[1001];
109 const double inv_val_denominator_f = 1. / val_denominator_f;
115 if (val_numerator_f == 0) {
117 sig_high = std::min(1., (8. * inv_val_denominator_f));
119 if (val_numerator_f == val_denominator_f) {
120 sig_low = std::max(0., (1. - 8. * inv_val_denominator_f));
124 double step = fabs(sig_high - sig_low) * 1e-3;
126 if (val_numerator_f == 0 || val_numerator_f == val_denominator_f) {
132 double temp_value = sig_low;
133 double arr_position = sig_low;
135 if (val_numerator_f == 0) {
136 for (
int i = 0; i < 1000; ++i) {
137 temp_value = exp(val_denominator_f * log(1. - arr_position) - shift);
138 m_pdf[i] = temp_value;
141 arr_position += step;
144 if (val_numerator_f == val_denominator_f) {
145 for (
int i = 0; i < 1000; ++i) {
146 temp_value = exp(val_numerator_f * log(arr_position) - shift);
147 m_pdf[i] = temp_value;
150 arr_position += step;
153 for (
int i = 0; i < 1000; ++i) {
154 temp_value = exp(val_numerator_f * log(arr_position) + (val_denominator_f - val_numerator_f) * log(1. - arr_position) - shift);
155 m_pdf[i] = temp_value;
158 arr_position += step;
162 m_bins[1000] = arr_position;
181 const std::vector<int>& n_dim_origin) {
237 double rn = random->Rndm();
238 int ibin = TMath::BinarySearch(1000,
m_cumul, rn);
280 for (
int i = 0; i < 1000; ++i) {
290 for (
int i = 0; i < 1000; ++i) {
293 const double inv_normalize = 1. /
m_cumul[1000];
294 for (
int i = 1; i < 1000; ++i) {
Thread-local TRandom generator.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
double GetStatUncertHigh() const
Get upper bound of asymmetric statistical uncertainty.
void SetID(unsigned int id)
Set the internal ID (used by APReweight/APReweight2D/APReweight3D/APReweightND).
const std::vector< int > & GetOriginalDimensions() const
Returns the dimensions and amounts of bins for each dimension of the original histogram.
double GetStatUncertLow() const
Get lower bound of asymmetric statistical uncertainty.
double GetSysUncert2() const
Get absolute systematic uncertainty squared value of efficiency/weight.
virtual ~APWeightEntry()
Default destructor.
bool m_is_nan
Flag, set to true if denominator is zero.
double * m_cumul
Histograms to hold the probability distribution and the cumulative distribution.
void ReadEfficiency(double efficiency, double err_low, double err_high)
Read efficiencies and upper/lower uncertainty (if numerator/denominator not applicable (e....
double GetSysUncert() const
Get absolute systematic uncertainty value of efficiency/weight.
const std::vector< int > & GetCoords() const
Returns the coordinates of the current entry in the original histogram.
unsigned int GetID() const
Returns the internal ID (used by APReweight/APReweight2D/APReweight3D/APReweightND).
APWeightEntry()
Default constructor.
double GetRandom()
Get random number from PDF.
double m_stat_uncert_high
Holds upper bound of asymmetric statistical uncertainty.
std::vector< int > m_coords
Holds the coordinates of the current entry in the original histogram.
double GetVariance() const
Get Variance of efficiency/weight (classical binomial/poisson model).
void _CreateHist()
Creates a TH1F instance from the arrays if necessary.
unsigned int GetValNumerator() const
Get value of original numerator.
double m_integral
Holds the integral of the probability distribution.
void _ComputeCum()
Calculates the cumulative function of the pdf if necessary.
double m_sys_uncert2
Holds absolute systematic uncertainty squared value of efficiency/weight.
TH1F * GetPDF()
Returns the calculated PDF.
unsigned int m_val_numerator
Holds the value of original numerator.
bool m_is_trig
Flag, set to true if weight entry is trigger based.
double GetExpectancy() const
Get Expectancy value of efficiency/weight.
double m_sys_uncert
Holds absolute systematic uncertainty value of efficiency/weight.
double m_stat_uncert_low
Holds lower bound of asymmetric statistical uncertainty.
unsigned int GetValDenominator() const
Get value of original denominator.
unsigned int m_val_denominator
Holds the value of original denominator.
bool IsNaN() const
Returns true if instance is NaN.
void SetSystUncert(double rel_uncert)
Set the relative (!) systematic uncertainty for the efficiency/weight.
TH1F * m_hist
Holds the TH1F instance from the arrays if computed.
double m_variance
Holds Variance of efficiency/weight (classical binomial/poisson model).
void SetCoordinates(const std::vector< int > &coords, const std::vector< int > &n_dim_origin)
std::vector< int > m_n_dim_origin
Holds the amount of dimensions and bins per axis in the original histogram.
double m_expectancy_val
Holds the Expectancy value of efficiency/weight.
unsigned int m_ID
Holds internal ID (used by APReweight/APReweight2D/APReweight3D/APReweightND).
bool IsTrig() const
Returns true if instance is trigger based.
Thread-local TRandom generator.
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")