Crombie Tools
|
#include <Hist.h>
Public Member Functions | |
Hist (const std::string label="", unsigned nbins=0, double min=0, double max=0, bool w2=true, double total_events=0) | |
Constructor of custom Hist class. More... | |
void | add (const Hist &other) |
const Hist & | fetch_unc (const std::string &key, const std::string &direction) const |
Get the uncertainty histogram, either up or down. Helpful for dumping datacards. More... | |
void | fill (double val, double weight=1.0) |
Fills this histogram with some value and weight. More... | |
Hist & | get_env_hist (const std::string &sys) |
Create and return a histogram inside an envelope. More... | |
std::pair< unsigned, unsigned > | get_maxbin_outof () const |
Get the maximum bin and the total number of bins. More... | |
Hist & | get_unc_hist (const std::string &sys) |
Get a reference to a histogram representing an uncertainty. More... | |
double | max_w_unc () const |
Get the maximum value including uncertainties (for plotting) More... | |
double | min_w_unc (const bool includezeros=true) const |
Get the minimum value including uncertainties, but not less than 0.0 (for plotting) More... | |
Hist | ratio (const Hist &other) const |
Returns a Hist that is a ratio between this and another Hist. More... | |
TH1D * | roothist (bool allunc=true) const |
Returns a pointer to a histogram that is owned by global list. More... | |
void | scale (const double scale) |
Scale this histogram by a direct scale factor. More... | |
void | scale (const double lumi, const double xs) |
Scale this histogram to a luminosity and cross section. More... | |
void | set_total (double newtotal) |
Sets the value of the total number of events, throws exception if total is already set. More... | |
Types::map< TH1D * > | unchists () const |
Get all of the uncertainty histograms. More... | |
Private Types | |
using | Envelope = std::tuple< Hist, Hist, std::list< Hist >> |
Private Member Functions | |
template<typename F > | |
void | doall (const F &func) |
Apply some function to this histogram and all its uncertainties. More... | |
void | doscale (const double scale) |
Scales histogram without scaling uncertainties. More... | |
void | doscale (const double lumi, const double xs) |
Scales histogram without scaling uncertainties. More... | |
double | get_unc (unsigned bin, bool allunc=true) const |
Find the full uncertainty from uncs hists and sumw2. More... | |
void | set_env_min_max () const |
Sets the min and max histograms for each envelope. More... | |
Private Attributes | |
std::vector< double > | contents {} |
Types::map< Envelope > | envs |
Envelope information. More... | |
bool | envs_set {false} |
Determine whether envelope minmax has been set or not. More... | |
std::string | label {} |
double | max {} |
double | min {} |
unsigned | nbins {} |
std::vector< double > | sumw2 {} |
double | total {} |
Stores the total weights of files filling this. More... | |
Types::map< Hist > | uncs |
Store of alternate histograms for uncertainties. More... | |
|
private |
|
inline |
Constructor of custom Hist class.
label | Is the label to go on the x-axis |
nbins | The number of bins to show in the plot. There is also one overflow and one underflow bin stored internally. |
min | The minimum value shown on the x-axis |
max | The maximum value on the x-axis |
w2 | If true, store the squared sum of weights, otherwise don't bother |
total_events | Is the total weight of events in the file(s) filling this histogram |
Definition at line 34 of file Hist.h.
References add(), contents, fetch_unc(), fill(), get_env_hist(), get_maxbin_outof(), get_unc_hist(), label, max, max_w_unc(), min, min_w_unc(), nbins, ratio(), roothist(), scale(), set_total(), sumw2, total, and unchists().
Referenced by set_env_min_max().
void crombie::Hist::Hist::add | ( | const Hist & | other | ) |
Definition at line 149 of file Hist.h.
References contents, Debug::Debug(), crombie::Misc::env(), envs, envs_set, nbins, sumw2, total, and uncs.
Referenced by crombie::Plotter::Plot::draw(), and Hist().
|
private |
Apply some function to this histogram and all its uncertainties.
Definition at line 217 of file Hist.h.
References crombie::Misc::env(), envs, envs_set, set_env_min_max(), and uncs.
Referenced by scale().
|
private |
|
private |
Scales histogram without scaling uncertainties.
Definition at line 211 of file Hist.h.
References Debug::Debug(), doscale(), and total.
const Hist & crombie::Hist::Hist::fetch_unc | ( | const std::string & | key, |
const std::string & | direction | ||
) | const |
void crombie::Hist::Hist::fill | ( | double | val, |
double | weight = 1.0 |
||
) |
Hist & crombie::Hist::Hist::get_env_hist | ( | const std::string & | sys | ) |
std::pair< unsigned, unsigned > crombie::Hist::Hist::get_maxbin_outof | ( | ) | const |
|
private |
Find the full uncertainty from uncs hists and sumw2.
Definition at line 324 of file Hist.h.
References contents, crombie::Misc::env(), envs, set_env_min_max(), sumw2, and uncs.
Referenced by max_w_unc(), min_w_unc(), and roothist().
Hist & crombie::Hist::Hist::get_unc_hist | ( | const std::string & | sys | ) |
double crombie::Hist::Hist::max_w_unc | ( | ) | const |
double crombie::Hist::Hist::min_w_unc | ( | const bool | includezeros = true | ) | const |
TH1D * crombie::Hist::Hist::roothist | ( | bool | allunc = true | ) | const |
Returns a pointer to a histogram that is owned by global list.
This list will handle the deletion when the program is done running. Not thread-safe.
allunc | If this is false, only the stat uncertainties will be included in the histogram. |
Definition at line 244 of file Hist.h.
References contents, Debug::Debug(), get_unc(), label, max, min, nbins, and backupslides::title.
Referenced by Hist().
void crombie::Hist::Hist::scale | ( | const double | scale | ) |
void crombie::Hist::Hist::scale | ( | const double | lumi, |
const double | xs | ||
) |
Scale this histogram to a luminosity and cross section.
The result will be invalid if this scale function is called after any other call to Hist::scale.
Definition at line 239 of file Hist.h.
References doall().
|
private |
void crombie::Hist::Hist::set_total | ( | double | newtotal | ) |
Types::map< TH1D * > crombie::Hist::Hist::unchists | ( | ) | const |
Get all of the uncertainty histograms.
The keys are the name of the uncertainty including "Up" or "Down" at the end.
Definition at line 383 of file Hist.h.
References crombie_completion::dir, crombie::Misc::env(), envs, and uncs.
Referenced by Hist().
|
private |
Definition at line 98 of file Hist.h.
Referenced by add(), doscale(), fill(), get_maxbin_outof(), get_unc(), Hist(), max_w_unc(), min_w_unc(), ratio(), roothist(), and set_env_min_max().
|
mutableprivate |
Envelope information.
Definition at line 112 of file Hist.h.
Referenced by add(), doall(), fetch_unc(), get_env_hist(), get_unc(), set_env_min_max(), and unchists().
|
mutableprivate |
Determine whether envelope minmax has been set or not.
Definition at line 113 of file Hist.h.
Referenced by add(), doall(), and set_env_min_max().
|
private |
Definition at line 93 of file Hist.h.
Referenced by get_env_hist(), get_unc_hist(), Hist(), roothist(), and set_env_min_max().
|
private |
Definition at line 96 of file Hist.h.
Referenced by fill(), get_env_hist(), get_maxbin_outof(), get_unc_hist(), Hist(), ratio(), roothist(), and set_env_min_max().
|
private |
Definition at line 95 of file Hist.h.
Referenced by fill(), get_env_hist(), get_unc_hist(), Hist(), ratio(), roothist(), and set_env_min_max().
|
private |
Definition at line 94 of file Hist.h.
Referenced by add(), fill(), get_env_hist(), get_maxbin_outof(), get_unc_hist(), Hist(), max_w_unc(), min_w_unc(), ratio(), roothist(), and set_env_min_max().
|
private |
|
private |
|
private |
Store of alternate histograms for uncertainties.
Definition at line 106 of file Hist.h.
Referenced by add(), doall(), fetch_unc(), get_unc(), get_unc_hist(), and unchists().