Crombie Tools
crombie::Hist::Hist Class Reference

#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 Histfetch_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...
 
Histget_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...
 
Histget_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< Envelopeenvs
 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< Histuncs
 Store of alternate histograms for uncertainties. More...
 

Detailed Description

Definition at line 22 of file Hist.h.

Member Typedef Documentation

§ Envelope

using crombie::Hist::Hist::Envelope = std::tuple<Hist, Hist, std::list<Hist>>
private

Definition at line 111 of file Hist.h.

Constructor & Destructor Documentation

§ Hist()

crombie::Hist::Hist::Hist ( const std::string  label = "",
unsigned  nbins = 0,
double  min = 0,
double  max = 0,
bool  w2 = true,
double  total_events = 0 
)
inline

Constructor of custom Hist class.

Parameters
labelIs the label to go on the x-axis
nbinsThe number of bins to show in the plot. There is also one overflow and one underflow bin stored internally.
minThe minimum value shown on the x-axis
maxThe maximum value on the x-axis
w2If true, store the squared sum of weights, otherwise don't bother
total_eventsIs 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().

Member Function Documentation

§ add()

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().

§ doall()

template<typename F >
void crombie::Hist::Hist::doall ( const F &  func)
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().

§ doscale() [1/2]

void crombie::Hist::Hist::doscale ( const double  scale)
private

Scales histogram without scaling uncertainties.

Definition at line 201 of file Hist.h.

References contents, Debug::Debug(), scale(), and sumw2.

Referenced by doscale().

§ doscale() [2/2]

void crombie::Hist::Hist::doscale ( const double  lumi,
const double  xs 
)
private

Scales histogram without scaling uncertainties.

Definition at line 211 of file Hist.h.

References Debug::Debug(), doscale(), and total.

§ fetch_unc()

const Hist & crombie::Hist::Hist::fetch_unc ( const std::string &  key,
const std::string &  direction 
) const

Get the uncertainty histogram, either up or down. Helpful for dumping datacards.

Definition at line 368 of file Hist.h.

References envs, set_env_min_max(), and uncs.

Referenced by Hist().

§ fill()

void crombie::Hist::Hist::fill ( double  val,
double  weight = 1.0 
)

Fills this histogram with some value and weight.

Definition at line 124 of file Hist.h.

References contents, max, min, nbins, and sumw2.

Referenced by Hist().

§ get_env_hist()

Hist & crombie::Hist::Hist::get_env_hist ( const std::string &  sys)

Create and return a histogram inside an envelope.

Definition at line 142 of file Hist.h.

References envs, label, max, min, and nbins.

Referenced by Hist().

§ get_maxbin_outof()

std::pair< unsigned, unsigned > crombie::Hist::Hist::get_maxbin_outof ( ) const

Get the maximum bin and the total number of bins.

Does not include overflow bins.

Definition at line 259 of file Hist.h.

References contents, max, and nbins.

Referenced by crombie::Plotter::Plot::add(), and Hist().

§ get_unc()

double crombie::Hist::Hist::get_unc ( unsigned  bin,
bool  allunc = true 
) 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().

§ get_unc_hist()

Hist & crombie::Hist::Hist::get_unc_hist ( const std::string &  sys)

Get a reference to a histogram representing an uncertainty.

Definition at line 136 of file Hist.h.

References label, max, min, nbins, and uncs.

Referenced by Hist().

§ max_w_unc()

double crombie::Hist::Hist::max_w_unc ( ) const

Get the maximum value including uncertainties (for plotting)

Definition at line 272 of file Hist.h.

References contents, get_unc(), and nbins.

Referenced by Hist().

§ min_w_unc()

double crombie::Hist::Hist::min_w_unc ( const bool  includezeros = true) const

Get the minimum value including uncertainties, but not less than 0.0 (for plotting)

Definition at line 280 of file Hist.h.

References contents, get_unc(), and nbins.

Referenced by Hist().

§ ratio()

Hist crombie::Hist::Hist::ratio ( const Hist other) const

Returns a Hist that is a ratio between this and another Hist.

Definition at line 290 of file Hist.h.

References contents, Debug::Debug(), max, min, and nbins.

Referenced by Hist().

§ roothist()

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.

Parameters
alluncIf 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().

§ scale() [1/2]

void crombie::Hist::Hist::scale ( const double  scale)

Scale this histogram by a direct scale factor.

Definition at line 234 of file Hist.h.

References doall().

Referenced by doscale(), and Hist().

§ scale() [2/2]

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().

§ set_env_min_max()

void crombie::Hist::Hist::set_env_min_max ( ) const
private

Sets the min and max histograms for each envelope.

Definition at line 343 of file Hist.h.

References contents, crombie::Misc::env(), envs, envs_set, Hist(), label, max, min, and nbins.

Referenced by doall(), fetch_unc(), and get_unc().

§ set_total()

void crombie::Hist::Hist::set_total ( double  newtotal)

Sets the value of the total number of events, throws exception if total is already set.

Definition at line 317 of file Hist.h.

References total.

Referenced by Hist().

§ unchists()

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().

Member Data Documentation

§ contents

std::vector<double> crombie::Hist::Hist::contents {}
private

§ envs

Types::map<Envelope> crombie::Hist::Hist::envs
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().

§ envs_set

bool crombie::Hist::Hist::envs_set {false}
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().

§ label

std::string crombie::Hist::Hist::label {}
private

Definition at line 93 of file Hist.h.

Referenced by get_env_hist(), get_unc_hist(), Hist(), roothist(), and set_env_min_max().

§ max

double crombie::Hist::Hist::max {}
private

§ min

double crombie::Hist::Hist::min {}
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().

§ nbins

unsigned crombie::Hist::Hist::nbins {}
private

§ sumw2

std::vector<double> crombie::Hist::Hist::sumw2 {}
private

Definition at line 99 of file Hist.h.

Referenced by add(), doscale(), fill(), get_unc(), and Hist().

§ total

double crombie::Hist::Hist::total {}
private

Stores the total weights of files filling this.

Definition at line 101 of file Hist.h.

Referenced by add(), doscale(), Hist(), and set_total().

§ uncs

Types::map<Hist> crombie::Hist::Hist::uncs
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().


The documentation for this class was generated from the following file: