|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #define APReweightND_cxx
12 #include "THnSparse.h"
20 m_denominator_hist(0),
38 std::vector<int> coords(m_n_dim);
39 for(
unsigned int i = 0;
i < m_n_dim; ++
i ) coords[
i] = 1;
40 bool checkComplete =
false;
43 std::cout <<
"WARNING in APReweightND::~APReweightND(THnSparse* denominator_in, THnSparse* numerator_in, bool isTrig) : Using histograms " <<
m_numerator_hist->GetName() <<
" and " <<
m_denominator_hist->GetName() <<
" the efficiency is larger than 1 for coordinates [ ";
for(
unsigned int j = 0; j < m_n_dim; ++j ) { std::cout << coords[j] <<
" "; } std::cout <<
" ]! This is inconsisten 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;
48 for(
unsigned int j = 0; j < m_n_dim; ++j ) {
49 if( coords[j] !=
m_numerator_hist->GetAxis(j)->GetNbins() ) checkComplete =
false;
51 if( checkComplete )
break;
53 int completeDimension = -1;
54 for(
unsigned int j = 0; j < m_n_dim; ++j ) {
56 bool isComplete =
true;
57 for(
int k = (
int)j-1;
k >= 0; --
k ) {
60 if( isComplete ) completeDimension = j;
64 if( completeDimension != -1 ) {
65 for(
int j = 0; j <= completeDimension; ++j ) coords[j] = 1;
66 coords[completeDimension+1] += 1;
78 if (err_high_in == 0) err_high_in = err_low_in;
82 m_n_dim = efficiency_in->GetNdimensions();
83 for (
unsigned int i = 0;
i < m_n_dim; ++
i)
m_axes.push_back( (TAxis*)efficiency_in->GetAxis(
i)->Clone(
"") );
87 vector<int> temp_vec_axes(m_n_dim,0);
88 for (
unsigned int j = 0; j < m_n_dim; ++j) temp_vec_axes[j] = efficiency_in->GetAxis(j)->GetNbins();
89 for (
int i = 0,
I = efficiency_in->GetNbins();
i <
I; ++
i) {
90 std::vector<int> coords (m_n_dim);
91 double efficiency = efficiency_in->GetBinContent(
i,coords.data() );
93 temp_entry->
ReadEfficiency(
efficiency,err_low_in->GetBinContent(err_low_in->GetBin(coords.data())),err_high_in->GetBinContent(err_high_in->GetBin(coords.data())));
95 temp_entry->
SetID(m_ID);
104 for (vector<TAxis*>::reverse_iterator
it=
m_axes.rbegin();
it !=
m_axes.rend(); ++
it) {
115 vector<int> temp_vec(&
bin[0],&
bin[m_n_dim]);
119 vector<int> temp_vec_axes(m_n_dim,0);
123 temp_weight->
SetID(m_ID);
127 return (*temp_it).second;
131 vector<int> temp_bin;
132 for (
unsigned int i = 0;
i < m_n_dim; ++
i) {
134 if (!
m_isQuiet) cout <<
"WARNING in APReweightND::GetBin: Value out of range! Dim: " <<
i <<
", value: " <<
value[
i] <<
", return value: " << (
m_axes[
i])->FindFixBin(
value[
i]) << endl;
154 unsigned int ret = 0;
155 for (
unsigned int i = 0;
i < m_n_dim; ++
i) ret += (
m_axes[
i])->GetNbins();
JetConstituentVector::iterator iterator
const THnSparse * GetDenominatorHist() const
Get original denominator histogram.
APWeightEntry * GetWeight(double value[])
Get Weight entry for a given n-tuple of values.
APWeightEntry * GetBinWeight(const int bin[])
Get Weight entry for a given n-tuple of bin numbers.
void SetCoordinates(const std::vector< int > &coords, const std::vector< int > &n_dim_origin)
APWeightEntry * m_empty_weight
Dummy weight (equals 0.) to return if value out of range is provided.
void SetSystUncert(double rel_uncert)
Set the global relative (!) systematic uncertainty of all efficiencies/weights.
double m_scale
Holds the scale factor that was calculated from sample sizes upon instantiation.
bool m_isQuiet
Flag to turn off messages.
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="")
void ReadEfficiency(double efficiency, double err_low, double err_high)
Read efficiencies and upper/lower uncertainty (if numerator/denominator not applicable (e....
bool m_isTrig
Flag to determine if the class holds trigger efficiencies or "simple" MC weights.
double GetSampleScale() const
Get scale factor that was calculated from sample sizes upon instantiation.
unsigned int NBins() const
Get amount of bins.
void ReadEfficiency(THnSparse *efficiency_in, THnSparse *err_low_in, THnSparse *err_high_in=0)
Read efficiencies and upper/lower uncertainty (if numerator/denominator not applicable (e....
void SetID(unsigned int id)
Set the internal ID (used by APReweight/APReweight2D/APReweight3D/APReweightND).
void SetSystUncert(double rel_uncert)
Set the relative (!) systematic uncertainty for the efficiency/weight.
virtual ~APReweightND()
Default destructor.
std::vector< TAxis * > m_axes
Holds all axes of the APReweightND instance (from input histograms).
APReweightND()
Default constructor.
double m_syst_uncert_global
Holds the global relative (!) systematic uncertainty of all efficiencies/weights.
const THnSparse * GetNumeratorHist() const
Get original numerator histogram.
void SetQuietMode(bool isQuiet=true)
Sets the flag to turn off messages.
std::map< std::vector< int >, APWeightEntry * > m_weights
Holds all weight entries.
THnSparse * m_numerator_hist
Holds the original numerator histogram.
ClassDef(APReweightND, 1) private THnSparse * m_denominator_hist
< Holds the amount of dimensions.