HighLAND
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DrawingToolsBase Class Reference

#include <DrawingToolsBase.hxx>

Inheritance diagram for DrawingToolsBase:
DrawingTools DrawingToolsNueCC

Public Member Functions

 DrawingToolsBase (const std::string &file="", Int_t T2KstyleIndex=1)
 
TH1_h * AddErrorsInQuadrature (TH1_h *h1, TH1_h *h2, const std::string &opt="")
 
std::string GetSameRootOption (const std::string &root_opt)
 extract the same or sames option from the full root option
 
std::string GetNoSameRootOption (const std::string &root_opt)
 remove same and sames options from the root option
 
void Reset ()
 reset all saved histograms
 
double GetEntries (TTree *tree, const std::string &cut)
 Get number (sum of weights) of events (i.e. bunches) passing "cut".
 
double GetEntries (TTree *tree, const std::string &cut, const std::string &var, const std::string &opt="", int toy_ref=-1)
 Get number (sum of weights) for variable var pasing "cut" (useful for vector variables, which number can be different than number of events/bunches)
 
void ScaleHisto (TH1 *h, double scale, bool scale_errors=true)
 Scale an histogram and its errors(when requested)
 
double * GetVariableBins (int nx, double xmin, double xmax, double *)
 Get a vector with variable binning.
 
std::string GetSameLevel (const std::string &root_opt)
 Get the superposition level.
 
std::string GetUniqueName (const std::string &name)
 
void CreateLegend (const std::string &uopt="")
 create the legend
 
void PrintEventNumbers (TTree *tree, const std::string &cut, const std::string &file="", int toy_ref=-1)
 Print the event number of a specific selection.
 
std::string FormatCut (const std::string &cut)
 Give the appropriate format to any cut.
 
std::string AddRangeCut (const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &cut, const std::string &uopt)
 Add cut on range shown on plot.
 
TH1 * Draw (TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 1D histos
 
TH1 * Draw (TTree *tree, const std::string &var, int nbins, double xmin, double xmax, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
TH1 * Draw (TTree *tree, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 2D histos
 
TH1 * Draw (TTree *tree, const std::string &var, int nx, double xmin, double xmax, int ny, double ymin, double ymax, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
void Draw (TTree *tree, const std::string &var, int nx, double xmin, double xmax, int ny, double ymin, double ymax, const std::string &idVar, std::vector< int > idSel, std::vector< std::string > idName, std::vector< int > idColor, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1., bool scale_errors=true)
 
void Draw (TTree *tree_mc, TTree *tree_data, const std::string &var, int nx, double xmin, double xmax, int ny, double ymin, double ymax, const std::string &idVar, std::vector< int > idSel, std::vector< std::string > idName, std::vector< int > idColor, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1., bool scale_errors=true)
 
void Draw (TTree *tree, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &idvar, std::vector< int > idSel, std::vector< std::string > idName, std::vector< int > idColor, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
void Draw (TTree *tree_mc, TTree *tree_data, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &idvar, std::vector< int > idSel, std::vector< std::string > idName, std::vector< int > idColor, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
double GetEff (TTree *tree, const std::string &var, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="")
 
double GetEff (TTree *tree, const std::string &var, double xmin, double xmax, double &errlow, double &errhigh, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="")
 
void DrawRatio (TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawRatio (TTree *tree, const std::string &var, int nx, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawEff (TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawEff (TTree *tree, const std::string &var, int nx, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawDoubleEff (TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 ratio between two Efficiencies
 
void DrawDoubleEff (TTree *tree1, TTree *tree2, const std::string &var, int nx, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawSignificance (TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &cut1, const std::string &cut2, double norm=1, double rel_syst=0, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 1D significance
 
void DrawSignificance (TTree *tree, const std::string &var, int nbins, double xmin, double xmax, const std::string &cut1, const std::string &cut2, double norm=1, double rel_syst=0, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawGraph (TGraphAsymmErrors *eff, int nbins, double *xbins, const std::string &uroot_opt, const std::string &uopt, const std::string &leg, double ymax=1.05)
 [DrawingToolsBase_eff_ratio]
 
void DumpGraph (TGraphAsymmErrors *graph, int nbins, const std::string &uopt)
 
TH1_h * GetEventsVSCut (TTree *tree, const std::string &var, const std::string &cut_norm, int isel, int branch, int &first_cut, int &last_cut, const std::string &root_opt="", const std::string &opt="")
 Get a TH1 containing the number of events passing the selection as a function of the cut.
 
void DrawEventsVSCut (TTree *tree, const std::string &cut_norm="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawEventsVSCut (TTree *tree, int branch, const std::string &cut_norm="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the number of events passing the selection as a function of the cut, for a given branch.
 
void DrawEventsVSCut (TTree *tree, int isel, int branch, const std::string &cut_norm="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the number of events passing the selection as a function of the cut, for a given selection and branch.
 
void DrawRatioVSCut (TTree *tree1, TTree *tree2, const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1.)
 Draw the ratio between two trees as a function of the cut.
 
void DrawRatioVSCut (TTree *tree1, TTree *tree2, int branch, const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1.)
 Draw the ratio between two trees as a function of the cut for a given branch.
 
void DrawRatioVSCut (TTree *tree1, TTree *tree2, int isel, int branch, const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1.)
 Draw the ratio between two trees as a function of the cut for a given selection and branch.
 
void DrawEffVSCut (TTree *tree, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection efficiency as a function of the cut. Must use the truth tree as input.
 
void DrawEffVSCut (TTree *tree, int branch, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection efficiency as a function of the cut for a given branch. Must use the truth tree as input.
 
void DrawEffVSCut (TTree *tree, int isel, int branch, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection efficiency as a function of the cut for a given selection and branch. Must use the truth tree as input.
 
void DrawPurVSCut (TTree *tree, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection purity as a function of the cut. Must use the default tree as input.
 
void DrawPurVSCut (TTree *tree, int branch, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection purity as a function of the cut for a given branch. Must use the default tree as input.
 
void DrawPurVSCut (TTree *tree, int isel, int branch, const std::string &signal="", const std::string &precut="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the selection purity as a function of the cut for a given selection and branch. Must use the default tree as input.
 
void DrawRatioVSCut (TH1_h *h1, TH1_h *h2, int isel, int branch, int first_cut, const std::string &root_opt, const std::string &opt, const std::string &leg)
 [DrawingToolsBaseVsCutsMethods] More...
 
void DrawToys (TTree *tree, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 
void DrawToysRatio (TTree *tree1, TTree *tree2, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 
void DrawToysRatioTwoCuts (TTree *tree1, TTree *tree2, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 
void DrawToysBase (TH1_h &result, TH1_h &entries, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 [DrawingToolsBaseDrawToyMethods] More...
 
void DrawVariations (const std::string &name, Int_t ipar=-1, int nx=100, double xmin=-5, double xmax=5, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
 Draw the variations for systematic parameter ipar.
 
void Draw (TTree *tree1, TTree *tree2, const std::string &var, int nx, double xmin, double xmax, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=false)
 1D comparison More...
 
void Draw (TTree *tree1, TTree *tree2, const std::string &var, int nbins, double *xbins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=false)
 
void Draw (TTree *tree1, TTree *tree2, const std::string &var, int nx, double xmin, double xmax, int ny, double ymin, double ymax, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=false)
 2D comparison
 
void Draw (TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=false)
 
void DrawRatio (TTree *tree1, TTree *tree2, const std::string &var, int nx, double xmin, double xmax, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 Ratio between the two data samples with the same cut.
 
void DrawRatio (TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 
void DrawRatioTwoCuts (TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &cut1="", const std::string &cut2="", const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1, bool scale_errors=false)
 
void DrawRatioTwoCuts (TTree *tree1, TTree *tree2, const std::string &var, int nx, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 Ratio between the two data samples with different cuts.
 
virtual void DrawRatioTwoCuts (TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)
 
void DrawRatio (TH1_h *ratio, const std::string &root_opt, const std::string &uopt, const std::string &leg)
 just Draw the ratio histogram
 
void Project (HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm2=1, bool scale_errors=true)
 
void ProjectNew (HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &categ="all", const std::string &cut1="", const std::string &cut2="", const std::string &root_opt="", const std::string &opt="", double norm2=1, bool scale_errors=true)
 
void DumpHisto (TH1 *histo, const std::string &uopt)
 dump histo contents
 
void DumpHistoInfo (TH1 *histo, const std::string &uopt)
 Dump integral, underflow and overflow.
 
void DrawHisto (TH1 *h, int lc, int lw, int fc, int fs, const std::string &root_opt="", const std::string &opt="", const std::string &leg_opt="", int mode=0)
 
void DrawHisto (TH1 *h, int lw, int fc, int fs, const std::string &root_opt="", const std::string &opt="", const std::string &leg_opt="", int mode=0)
 
void DrawHisto (TH2 *h, int lc, int lw, int fc, int fs, const std::string &root_opt="", const std::string &opt="", const std::string &leg_opt="", int mode=0)
 
void DrawHisto (TH3F *h, int lc, int lw, int fc, int fs, const std::string &opt="")
 
void DrawHistoStack (HistoStack *hs, const std::string &categ, const std::string &root_opt, const std::string &opt, const std::string &leg_opt="", int mode=2)
 
void DrawHistoStack (HistoStack *hs, const std::string &categ, const std::string &root_opt, const std::string &opt, int lc, int lw, int fc, int fs, const std::string &leg_opt="", int mode=2)
 
void DrawHistoStacks (HistoStack *hs1, HistoStack *hs2, const std::string &categ, const std::string &root_opt, const std::string &opt, double norm)
 
void DrawRatioHistoStacks (HistoStack *hs1, HistoStack *hs2, const std::string &root_opt, const std::string &opt, double norm, const std::string &leg="")
 
void Project (HistoStack *hs, const std::string &sample_name, TTree *tree, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
void Project (HistoStack *hs, TTree *tree, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &idVar, std::vector< int > idSel, std::vector< std::string > idName, std::vector< int > idColor, const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
 
TH1_h * GetHisto (TTree *tree, const std::string &name, const std::string &var, int nx, double *xbins, const std::string &cut, const std::string &root_opt, const std::string &opt, double scale, bool scale_errors=true, int toy_ref=-1)
 
virtual TH2_h * GetHisto (TTree *tree, const std::string &name, const std::string &var, int nx, double *xbins, int ny, double *ybins, const std::string &cut, const std::string &root_opt, const std::string &opt, double scale, bool scale_errors=true, int toy_ref=-1)
 
virtual TH1_h * GetHisto (HistoStack *hs, TTree *tree, const std::string &name, const std::string &var, int nx, double *xbins, const std::string &cut, const std::string &root_opt, const std::string &opt, TH1_h *&hsyst, double scale, bool scale_errors=true, int toy_ref=-1)
 
TH1_h * GetHisto (HistoStack *hs, TTree *tree, const std::string &name, const std::string &var, int nx, double *xbins, const std::string &cut, const std::string &root_opt, const std::string &opt, double scale, bool scale_errors=true, int toy_ref=-1)
 
TH1_h * GetRatioHisto (HistoStack *hs1, HistoStack *hs2, const std::string &opt)
 
virtual TH1_h * GetRatioHisto (TTree *tree1, TTree *tree2, const std::string &name, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &root_opt, const std::string &opt, double norm, double scale, bool scale_errors=true, int toy_ref=-1)
 
virtual void FillHistoErrors (HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &name, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &opt, double norm, TH1_h *hstat, TH1_h *&hsyst)
 
virtual void FillHistoErrors (HistoStack *hs1, HistoStack *hs2, TH1_h *histo, const std::string uopt)
 
virtual void UpdateSystInfo (HistoStack *hs1, HistoStack *hs2, TTree *tree1, TTree *tree2, const std::string &var, int nx, double *xbins, const std::string &cut1, const std::string &cut2, const std::string &opt, double norm)
 fill/update systematics information (fill appopriate histograms) for the stacks
 
virtual void FillGraphErrors (HistoStack *hs1, HistoStack *hs2, TGraphAsymmErrors *graph, const std::string uopt)
 
void DumpLegendPos ()
 Dump position and size of the legend/small legend.
 
void DumpSmallLegendPos ()
 
void SetLegendEntryHeight (double h)
 [DrawingToolsCommandLineOptions] More...
 
void SetLegendParam (double a, double b, double c, double d)
 Set position and size of the legend.
 
void SetLegendPos (double x=-999, double y=-999)
 
void SetLegendPos (std::string pos)
 
void SetLegendSize (double w=-999, double h=-999)
 Set legend/small legend size, width and height (if -999 keep same value)
 
void SetSmallLegendSize (double w=-999, double h=-999)
 
double GetLegendX ()
 Get position/size of the legend/small legend.
 
double GetLegendY ()
 
double GetLegendW ()
 
double GetLegendH ()
 
double GetSmallLegendX ()
 
double GetSmallLegendY ()
 
double GetSmallLegendW ()
 
double GetSmallLegendH ()
 
void SetOptStat (int opt)
 Set the stat option (by int or string)
 
void SetOptStat (Option_t *stat)
 
double GetStatW ()
 Set/Get the stat box size.
 
double GetStatH ()
 
void SetStatSize (double w=-999, double h=-999)
 
double GetStatX ()
 Set/Get the stat box position (if -999 keep same value)
 
double GetStatY ()
 
void SetStatPos (double x=-999, double y=-999)
 
void SetStackFillStyle (int FillStyle)
 Change the fill style.
 
void SetDifferentStackFillStyles (bool diff=true)
 Make each histogram in the stack have a different fill style.
 
void SetMarkerStyle (int style)
 change the marker style
 
void SetMarkerSize (double size)
 change the marker size
 
void SetFillStyle (int style)
 Set the fill style of the current histogram..
 
void SetLineWidth (int width)
 Set the line width of the current histogram..
 
void SetLineColor (int color)
 Set the line color of the current histogram..
 
void SetLineColor (EColor kColor)
 
void SetFillColor (int color)
 Set the line color of the current histogram..
 
void SetFillColor (EColor kColor)
 
void SetMCErrorColor (EColor kColor)
 Set the color for the MC error bars.
 
void SetMCErrorColor (int color)
 
void SetMCStatErrorColor (EColor kColor)
 
void SetMCStatErrorColor (int color)
 
void SetAutoColors (int colors[], int ncolors)
 Set the auto colors when superimposing histograms.
 
void SetAutoMarkers (int markers[], int nmarkers)
 Set the auto Markers when superimposing histograms.
 
const std::string & GetEffDivideParams ()
 Setter and Getter for params controlling the efficiency calculation.
 
void SetEffDivideParams (const std::string &params)
 
void SetDefaultEffDivideParams ()
 Setter of default params.
 
void SetTitleX (const std::string &titleX)
 Set the title in X.
 
void SetTitleY (const std::string &titleY)
 Set the title in Y.
 
void SetTitle (const std::string &title)
 Set the title that appears at the top of the plot.
 
void SetDataLabel (const std::string &label, Color_t color=kBlack)
 
void SetAllMCLabel (const std::string &label, Color_t color=kBlack)
 
void SetAllMCStatLabel (const std::string &label)
 
void SetAllMCSystLabel (const std::string &label)
 
void SetMinY (double minY=0)
 
void SetMaxY (double maxY=0)
 
void SetRangeY (double minY=0, double maxY=0)
 
void SetLogY (bool logY=true)
 Set the current histogram to be drawn with a logarithmic Y axis.
 
void SetLogZ (bool logZ=true)
 Set the current 2D histogram to be drawn with a logarithmic Z axis (works only for category "all").
 
void SetRelativeMaxY (double maxY)
 Set the maximum value in Y relative to the bin with maximum content.
 
std::string GetErrorStyle (const std::string &opt)
 Gets the root error style from the user option.
 
void SetDraw2p2h (bool draw=true)
 switch on/off 2p2h type for reaction histos
 
void DrawCutLineVertical (double xval, bool addarrow=false, std::string arrowdir="l", double arrowpos=0.5)
 [DrawingToolsCommandLineOptions] More...
 
void DrawCutLineHorizontal (double yval, bool addarrow=false, std::string arrowdir="u", double arrowpos=0.5)
 
void DrawCutLine (double xmin, double ymin, double xmax, double ymax)
 
void DrawCutRegion (double xmin, double ymin, double xmax, double ymax, std::string opt="tblr")
 
void DrawCutArrow (double xmin, double ymin, double xmax, double ymax)
 
void SetCutLineColor (int col)
 Set the color of lines drawn with the DrawCut* functions.
 
void SetCutLineColor (EColor kCol)
 
void SetCutLineWidth (int width)
 Set the width of lines drawn with the DrawCut* functions.
 
CorrectionManagercorr ()
 [DrawingToolsBaseDrawCutLineMethods] More...
 
SystematicManagersyst ()
 
SelectionManagersel ()
 
ConfigurationManagerconf ()
 
CategoryManagercat ()
 
DocStringManagerdoc ()
 
Headerheader ()
 
SystematicsToolssyst_tools ()
 an access to tools instance
 
ConfigTreeToolsconfig_tools ()
 
void DumpVariationSystematics ()
 Print out the Standard Systematics for a given configuration.
 
void DumpWeightSystematics ()
 Print out the Weight Systematics for a given configuration.
 
void DumpSystematics ()
 Print out all Systematics for a given configuration.
 
void DumpCorrections (const std::string &file="")
 Print out the Corrections.
 
void ReadCorrections (const std::string &file)
 Read the list of Corrections.
 
void ReadSystematics (const std::string &file)
 
void DumpConfigurations (const std::string &file="")
 Print out the Configurations.
 
void DumpConfiguration (const std::string &name)
 Print out the Configuration.
 
void ReadConfigurations (const std::string &file)
 Read the list of Configurations.
 
void DumpSoftwareVersions (const std::string &file="")
 —— Package versions -------—— More...
 
void DumpOriginalSoftwareVersion (const std::string &file="", bool all=true)
 Dumps on the screen the software version of the original file (i.e. output of recon)
 
void DumpFileInfo (const std::string &file="")
 ---— Package versions ----------—
 
void ReadCategories (const std::string &file)
 
void DumpCategories ()
 
void DumpCategories (const std::string &file)
 
void DumpCategory (std::string category)
 
void ChangeCategory (const std::string &categ_name, int ntypes, std::string *names, int *codes, int *colors)
 [DrawingToolsBase_categ] More...
 
bool HasCategory (const std::string &categ_name)
 Check whether a category has been defined.
 
void ReadSelections (const std::string &file)
 Read the list of Selections.
 
void DumpSelections (const std::string &file="")
 
void DumpBranches (Int_t sel_index=0)
 Dump the list of branches in the selection provided selection index.
 
void DumpBranches (const std::string &sel_name)
 Dump the list of branches in the selection provided selection name.
 
void DumpCuts (int branch=-1)
 [DrawingToolsBase_DumpSelections] More...
 
void DumpSteps (int branch=-1)
 
void DumpCuts (const std::string &sel_name, int branch=-1)
 
void DumpSteps (const std::string &sel_name, int branch=-1)
 
void DumpCuts (Int_t sel_index, int branch)
 
void DumpSteps (Int_t sel_index, int branch)
 
std::vector< std::string > GetCutNames (const std::string &sel_name, int branch=0)
 [DrawingToolsBase_DumpSteps] More...
 
std::vector< std::string > GetStepNames (const std::string &sel_name, int branch=0)
 Get a vector of steps names for a given branch (in order) in a selection with a given name.
 
std::vector< std::string > GetCutNames (Int_t sel_index, int branch)
 Get a vector of cut names for a given branch (in order) in a selection with a given index.
 
std::vector< std::string > GetStepNames (Int_t sel_index, int branch)
 Get a vector of steps names for a given branch (in order) in a selection with a given index.
 
void ExplainOption (std::string name)
 
void ListOptions ()
 List all drawing options.
 
void ExplainVar (std::string name, std::string tree_name="default")
 [DrawingToolsBase_ops] More...
 
void ListVars (std::string tree_name="default")
 List all the variables stored in a tree. If no tree name is provided the "default" tree is used.
 
void ReadDocStrings (const std::string &file)
 [DrawingToolsBase_vars] More...
 
void DumpPOT (TTree *tree)
 
void DumpPOT (const std::string &file)
 Dump the POT information for this sample, provided an input file name.
 
void ReadConfig (const std::string &file)
 [DrawingToolsBase_POT] More...
 
void ReadOther (const std::string &file)
 Read any other variables in the config tree.
 
void ReadOther (TTree *chain)
 
void PrintPurities (TTree *tree, const std::string &categ, const std::string &cut, double events_ratio=1)
 
std::vector< TGraph *> GetGraphs ()
 Get all the graphs that have been drawn. Useful if you want to save them to file.
 
TGraph * GetLastGraph ()
 Get the last graph that was drawn. Useful if you want to modify its appearance.
 
std::vector< TH1 *> GetHistos ()
 
TLegend * GetLastLegend ()
 Get the last legend that was drawn. Useful if you want to modify its appearance.
 
void ChangeLegendEntry (Int_t index, const std::string &new_label="", const std::string &new_opt="")
 Change the label or drawing style of a entry in the legend provided the entry number.
 
void DeleteLegendEntry (Int_t index)
 Delete a given Legent entry provided its index.
 
std::vector< TH1 *> Get2DHistos ()
 
TH1 * GetLastHisto ()
 Get all the last Histo that was drawn. Useful if you want to modify its appearance.
 
TH1 * GetLastStackTotal (int nexttolast=0)
 
HistoStackGetLastStack (int nexttolast=0)
 Get the most recently-drawn stacked histogram. Useful to access its histograms.
 
void StartDocument (const std::string &title, bool pdf=true, bool web=false, const std::string &pdffile="plots.pdf", const std::string &webpath="plots")
 
void AddDocumentPage (const std::string &name)
 
void FinishDocument ()
 
int MakeDirectory (const std::string &path, mode_t mode)
 Make a directory on the filesystem.
 
std::string ConvertCutForTruthTree (const std::string cut, bool replace_selmu=true)
 
double GetChi2 (const TH1 *h1, const TH1 *h2)
 
int GetNDOF (const TH1 *h1, const TH1 *h2)
 
double GetPvalue (double chi2, int ndof)
 
double GetPvalue (const TH1 *h1, const TH1 *h2)
 

Protected Member Functions

int GetFillStyle (int i)
 

Protected Attributes

int _unique
 Counter for ensuring all histograms get a unique name.
 
bool _drawleg
 
std::vector< TLegend * > _legends
 
double _legendParam [4]
 
double _legendSize [2]
 
double _legendPos [2]
 
double _legendSmallSize [2]
 
double _statPos [2]
 
std::string _legendPosS
 
int _stat_option
 
int _stack_fill_style
 
bool _different_fill_styles
 
int _marker_style
 
int _fill_style
 
int _fill_color
 
int _line_width
 
int _line_color
 
int _mcerror_color
 
int _mcstaterror_color
 
double _marker_size
 
int _cut_line_col
 
int _cut_line_width
 
std::string _titleX
 
std::string _titleY
 
std::string _title
 
Color_t _data_color
 
Color_t _allmc_color
 
std::string _data_label
 
std::string _allmc_label
 
std::string _allmcstat_label
 
std::string _allmcsyst_label
 
double _minY
 
double _maxY
 
double _relativeMaxY
 
bool _logY
 
bool _logZ
 
std::string _eff_params
 parameter to control options for TGraphAsymmErrors::Divide() method, the one used to get the efficiencies
 
bool _draw_2p2h
 
TFile * _file
 
int _same_level
 
int _same_level_tot
 
int _auto_colors [NMAXAUTOCOLORS]
 
int _auto_markers [NMAXAUTOCOLORS]
 
std::vector< TH1 *> _saved_histos
 
std::vector< TH2 *> _saved_histos2D
 
std::vector< HistoStack *> _saved_histoStacks
 
std::vector< TGraph *> _saved_graphs
 
std::vector< TLine *> _cut_lines
 
TPad * _MainPad
 
TPad * _RatioPad
 
TCanvas * _pdfcanvas
 
TPad * _bodypad
 
TPad * _headpad
 
std::string _pdfpath
 
std::string _webpath
 
std::string _webheader
 
std::string _webbody
 
std::string _config_file
 
DocStringManager _docStrings
 
CategoryManager _categories
 
ConfigurationManager _configurations
 
CorrectionManager _corrections
 
SystematicManager _systematics
 
SelectionManager _selections
 
SystematicsTools _syst_tools
 
ConfigTreeTools _configTree_tools
 
Header _header
 
Int_t _minAccumLevelToSave
 

Detailed Description

This is the base class for the DrawingTools, and uses a single TTree to as input, rather than a DataSample object. It handles color code drawing and variable binning.

Users generally shouldn't instantiate this class directly, but use the DrawingTools class instead. See the DrawingTools class documentation for more details.

TODO: This class must be properly documented.

Definition at line 62 of file DrawingToolsBase.hxx.

Member Function Documentation

§ AddDocumentPage()

void DrawingToolsBase::AddDocumentPage ( const std::string &  name)

Add a page to the PDF document and/or webpage that was opened with StartDocument(). "name" will appear on web pages to give context to what each plot is. If StartDocument() createdg a canvas for you, "name" will also appear in the header section of the PDF page.

Definition at line 3590 of file DrawingToolsBase.cxx.

3590  {
3591 //*********************************************************
3592  if (_webpath != "") {
3593  TString safename = name;
3594  safename = safename.ReplaceAll(" ", "_");
3595  gPad->SaveAs((_webpath + "/" + safename.Data() + ".png").c_str());
3596  _webheader += std::string("<li><a href=\"#") + safename.Data() + "\">" + name + "</a></li>\n";
3597  _webbody += std::string("<p><a name=\"") + safename.Data() + "\"></a>" + name + "</p>\n";
3598  _webbody += std::string("<p><img src=\"") + safename.Data() + ".png\" alt=\"" + name + "\"/></p>\n";
3599  }
3600 
3601  if (_pdfpath != "") {
3602  TVirtualPad* currpad = gPad;
3603 
3604  if (currpad && currpad == _bodypad) {
3605  _headpad->Clear();
3606  _headpad->cd();
3607  TLatex l;
3608  l.SetTextSize(0.5);
3609  l.SetTextAlign(22);
3610  l.DrawLatex(0.5, 0.5, name.c_str());
3611 
3612  _pdfcanvas->cd();
3613  _pdfcanvas->Draw();
3614  _pdfcanvas->Print(_pdfpath.c_str());
3615 
3616  currpad->cd();
3617  } else {
3618  currpad->Print(_pdfpath.c_str());
3619  }
3620  }
3621 }

§ ChangeCategory()

void DrawingToolsBase::ChangeCategory ( const std::string &  categ_name,
int  ntypes,
std::string *  names,
int *  codes,
int *  colors 
)

[DrawingToolsBase_categ]

Update or add a category.

  • categ_name is the name this category will have. This must be a variable that is stored in the output file, such as "particle" (you can of course save your own variables).
  • ntypes is the number of options your category will have.
  • names is an array of length ntypes of the name of each option.
  • codes is an array of length ntypes of the value stored in the output file for this option.
  • colors is an array of length ntypes of the colour to plot each option with.

Definition at line 3304 of file DrawingToolsBase.cxx.

3304  {
3305 //********************************************************************
3306 
3307  // Read the categories from the config tree
3308  ReadCategories(_config_file);
3309 
3310  bool multi = false;
3311  bool noWarning = false;
3312 
3313  // don't add automatic categories
3314  bool addNOTRUTH=false;
3315  bool addSAND=false;
3316 
3317 
3318  cat().AddCategory(categ_name, ntypes, names, codes, colors, multi, noWarning, addNOTRUTH, addSAND);
3319 }
void AddCategory(const std::string &name, int ntypes, std::string *names, int *codes, int *colors, bool multi=false, bool noWarning=false, bool addNOTRUTH=true, bool addSAND=true)
void ReadCategories(const std::string &file)

§ corr()

CorrectionManager& DrawingToolsBase::corr ( )
inline

[DrawingToolsBaseDrawCutLineMethods]

Provide easy access to the managers.

Definition at line 613 of file DrawingToolsBase.hxx.

613 {return _corrections;}

§ Draw()

void DrawingToolsBase::Draw ( TTree *  tree1,
TTree *  tree2,
const std::string &  var,
int  nx,
double  xmin,
double  xmax,
const std::string &  categ = "all",
const std::string &  cut = "",
const std::string &  root_opt = "",
const std::string &  opt = "",
double  norm = 1,
bool  scale_errors = false 
)

1D comparison


----—— comparisons between two data samples (two trees) -----------——

Definition at line 1241 of file DrawingToolsBase.cxx.

1242  {
1243 //**************************************************
1244 
1245  // 1D comparison between two data samples with different normalisation. Uniform binning
1246  double xbins[NMAXBINS];
1247  Draw(tree1,tree2,var,nx,GetVariableBins(nx,xmin,xmax,xbins),categ,cut,root_opt,opt,norm,scale_errors);
1248 }
TH1 * Draw(TTree *tree, const std::string &var, int nbins, double *xbins, const std::string &categ="all", const std::string &cut="", const std::string &root_opt="", const std::string &opt="", double norm=1, bool scale_errors=true)
1D histos
double * GetVariableBins(int nx, double xmin, double xmax, double *)
Get a vector with variable binning.

§ DrawCutArrow()

void DrawingToolsBase::DrawCutArrow ( double  xmin,
double  ymin,
double  xmax,
double  ymax 
)

Draw an arrow between two points. If a legend had already been created by the DrawingTools, and drawn on the current pad, it is re-drawn. This means that the line does not cover it up.

Definition at line 3457 of file DrawingToolsBase.cxx.

3457  {
3458 //*********************************************************
3459  TArrow* arr = new TArrow(xmin, ymin, xmax, ymax, 0.02, "|>");
3460  arr->SetLineColor(_cut_line_col);
3461  arr->SetFillColor(_cut_line_col);
3462  arr->SetLineWidth(_cut_line_width);
3463  _cut_lines.push_back(arr);
3464  arr->Draw();
3465 
3466  if (_drawleg && _legends.size() > 0 && gPad->FindObject(_legends.back())) {
3467  _legends.back()->Draw();
3468  }
3469 }

§ DrawCutLine()

void DrawingToolsBase::DrawCutLine ( double  xmin,
double  ymin,
double  xmax,
double  ymax 
)

Draw an abritary line between two points. If a legend had already been created by the DrawingTools, and drawn on the current pad, it is re-drawn. This means that the line does not cover it up.

Definition at line 3442 of file DrawingToolsBase.cxx.

3442  {
3443 //*********************************************************
3444  TLine* l = new TLine(xmin, ymin, xmax, ymax);
3445 
3446  l->SetLineColor(_cut_line_col);
3447  l->SetLineWidth(_cut_line_width);
3448  _cut_lines.push_back(l);
3449  l->Draw();
3450 
3451  if (_drawleg && _legends.size() > 0 && gPad->FindObject(_legends.back())) {
3452  _legends.back()->Draw();
3453  }
3454 }

§ DrawCutLineHorizontal()

void DrawingToolsBase::DrawCutLineHorizontal ( double  yval,
bool  addarrow = false,
std::string  arrowdir = "u",
double  arrowpos = 0.5 
)

Draw a horizontal line at the specified Y value, spanning the currently-drawn histogram. See note in DrawCutLine() about legends being re-drawn when calling this function. If addarrow is set to true, then an arrow indicating the direction of the cut is drawn. arrowdir respects the following options: u : Draw the arrow pointing upwards (default) d : Draw the arrow pointing downwards arrowpos specifies the fractional length along the cut line to draw the arrow at, measuring from the left end of the line. Defaults to half way along.

Definition at line 3420 of file DrawingToolsBase.cxx.

3420  {
3421 //*********************************************************
3422  double xmin = gPad->PadtoX(gPad->GetUxmin());
3423  double xmax = gPad->PadtoX(gPad->GetUxmax());
3424  DrawCutLine(xmin, yval, xmax, yval);
3425 
3426  if (addarrow) {
3427  std::string uarrowdir = drawUtils::ToUpper(arrowdir);
3428  double deltay = yval-gPad->PadtoY( gPad->YtoPad(yval)-(gPad->GetUymax()-gPad->GetUymin())/20.);
3429 
3430  if (uarrowdir.find("D") != std::string::npos) {
3431  deltay *= -1;
3432  }
3433 
3434  // It needs this to work in LogX scale
3435  double xarr = gPad->PadtoX((gPad->GetUxmax()-gPad->GetUxmin())*arrowpos+gPad->GetUxmin());
3436  double yarrmax = yval + deltay;
3437  DrawCutArrow(xarr, yval, xarr, yarrmax);
3438  }
3439 }
void DrawCutArrow(double xmin, double ymin, double xmax, double ymax)
void DrawCutLine(double xmin, double ymin, double xmax, double ymax)
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9

§ DrawCutLineVertical()

void DrawingToolsBase::DrawCutLineVertical ( double  xval,
bool  addarrow = false,
std::string  arrowdir = "l",
double  arrowpos = 0.5 
)

[DrawingToolsCommandLineOptions]

[DrawingToolsBaseDrawCutLineMethods] Draw a vertical line at the specified X value, spanning the currently-drawn histogram. See note in DrawCutLine() about legends being re-drawn when calling this function. If addarrow is set to true, then an arrow indicating the direction of the cut is drawn. arrowdir respects the following options: l : Draw the arrow pointing to the left r : Draw the arrow pointing to the right (default) arrowpos specifies the fractional length along the cut line to draw the arrow at, measuring from the bottom of the line. Defaults to half way along.

Definition at line 3397 of file DrawingToolsBase.cxx.

3397  {
3398 //*********************************************************
3399 
3400  double ymin = gPad->PadtoY(gPad->GetUymin());
3401  double ymax = gPad->PadtoY(gPad->GetUymax());
3402  DrawCutLine(xval, ymin, xval, ymax);
3403 
3404  if (addarrow) {
3405  std::string uarrowdir = drawUtils::ToUpper(arrowopt);
3406  double deltax = xval-gPad->PadtoX( gPad->XtoPad(xval)-(gPad->GetUxmax()-gPad->GetUxmin())/20.);
3407 
3408  if (uarrowdir.find("L") != std::string::npos) {
3409  deltax *= -1;
3410  }
3411 
3412  // It needs this to work in LogY scale
3413  double yarr = gPad->PadtoY((gPad->GetUymax()-gPad->GetUymin())*arrowpos+gPad->GetUymin());
3414  double xarrmax = xval + deltax;
3415  DrawCutArrow(xval, yarr, xarrmax, yarr);
3416  }
3417 }
void DrawCutArrow(double xmin, double ymin, double xmax, double ymax)
void DrawCutLine(double xmin, double ymin, double xmax, double ymax)
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9

§ DrawCutRegion()

void DrawingToolsBase::DrawCutRegion ( double  xmin,
double  ymin,
double  xmax,
double  ymax,
std::string  opt = "tblr" 
)

Draw a box defined by the minimum and maximum points. The opt parameter specifies, among other things, which sides of the box to draw: t : draw the (t)op of the box b : draw the (b)ottom of the box l : draw the (l)eft of the box r : draw the (r)ight of the box nochop : Don't constrain the sides of the box to stay within the current axes.

See note in DrawCutLine() about legends being re-drawn when calling this function.

Definition at line 3472 of file DrawingToolsBase.cxx.

3472  {
3473 //*********************************************************
3474  std::string uopt = drawUtils::ToUpper(opt);
3475 
3476  if (!drawUtils::CheckOption(uopt,"NOCHOP")) {
3477  xmin = std::max(xmin, gPad->PadtoX(gPad->GetUxmin()));
3478  xmax = std::min(xmax, gPad->PadtoY(gPad->GetUxmax()));
3479  ymin = std::max(ymin, gPad->PadtoX(gPad->GetUymin()));
3480  ymax = std::min(ymax, gPad->PadtoY(gPad->GetUymax()));
3481  }
3482 
3483  if (uopt.find("T")!=std::string::npos) {
3484  DrawCutLine(xmin, ymax, xmax, ymax);
3485  }
3486  if (uopt.find("B")!=std::string::npos) {
3487  DrawCutLine(xmin, ymin, xmax, ymin);
3488  }
3489  if (uopt.find("L")!=std::string::npos) {
3490  DrawCutLine(xmin, ymin, xmin, ymax);
3491  }
3492  if (uopt.find("R")!=std::string::npos) {
3493  DrawCutLine(xmax, ymin, xmax, ymax);
3494  }
3495 }
void DrawCutLine(double xmin, double ymin, double xmax, double ymax)
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9
bool CheckOption(const std::string &uopt, const std::string &this_opt)
Check if specific option exists, and if so if it appears in option field.

§ DrawEventsVSCut()

void DrawingToolsBase::DrawEventsVSCut ( TTree *  tree,
const std::string &  cut_norm = "",
int  first_cut = -1,
int  last_cut = -1,
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "" 
)

[DrawingToolsBaseVsCutsMethods] Draw the number of events passing the selection as a function of the cut

Definition at line 1427 of file DrawingToolsBase.cxx.

1428  {
1429 //**************************************************
1430 
1431  DrawEventsVSCut(tree,0,cut_norm,first_cut,last_cut,root_opt,opt,leg);
1432 }
void DrawEventsVSCut(TTree *tree, const std::string &cut_norm="", int first_cut=-1, int last_cut=-1, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")

§ DrawRatio()

void DrawingToolsBase::DrawRatio ( TTree *  tree,
const std::string &  var,
int  nbins,
double *  xbins,
const std::string &  cut1,
const std::string &  cut2,
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "" 
)

[DrawingToolsBase_eff_ratio] 1D Ratio between two independent cuts (the denominator cut is cut2, the numerator cut is cut1)

Definition at line 1232 of file DrawingToolsBase.cxx.

1233  {
1234 //*********************************************************
1235 
1236  // Ratio between two histograms with independent cuts
1237  DrawRatioTwoCuts(tree, tree, var, nx, xbins, cut1, cut2, root_opt, opt, leg, 1.);
1238 }

§ DrawRatioVSCut()

void DrawingToolsBase::DrawRatioVSCut ( TH1_h *  h1,
TH1_h *  h2,
int  isel,
int  branch,
int  first_cut,
const std::string &  root_opt,
const std::string &  opt,
const std::string &  leg 
)

[DrawingToolsBaseVsCutsMethods]

Draw the ratio between two samples as a function of the cut

Definition at line 1702 of file DrawingToolsBase.cxx.

1703  {
1704 //**************************************************
1705 
1706  // TODO: The entire method must be simplified using DrawHisto and DrawGraph
1707 
1708  // Read the steps from the config tree
1709  // ReadSteps(_config_file);
1710 
1711  // Check if selection exists
1712  if (!sel().GetSelection(isel,true)) return;
1713 
1714  std::string uopt = drawUtils::ToUpper(opt);
1715  std::string uroot_opt = drawUtils::ToUpper(root_opt);
1716 
1717  // Check that all user options are valid
1718  if (!drawUtils::ContainValidOptions(uopt)) return;
1719 
1720  TH1_h* hratio = new TH1_h(GetUniqueName("ratio").c_str(),"",h1->GetNbinsX(),h1->GetXaxis()->GetXmin(),h1->GetXaxis()->GetXmax());
1721  _saved_histos.push_back(hratio);
1722 
1723  hratio->Divide(h1,h2);
1724 
1725  Int_t cut_offset = 1;
1726  // First bin corresponds to no cut
1727  hratio->GetXaxis()->SetBinLabel(1, "NO CUT");
1728 
1729  std::vector<StepBase*> cuts = sel().GetSelection(isel)->GetCutsInBranch(branch);
1730  // Start from second bin since first corresponds to no cut
1731  for (int i=cut_offset;i<hratio->GetNbinsX();i++ ){
1732  int icut = i-cut_offset;
1733  hratio->GetXaxis()->SetBinLabel(i+1, cuts[icut]->Title().c_str());
1734  }
1735 
1736  // No stats box
1737  gStyle->SetOptStat(0);
1738 
1739  // Histogram attributes
1740  hratio->SetTitle(_title.c_str());
1741  hratio->GetXaxis()->SetTitle("");
1742  hratio->GetYaxis()->SetTitle(_titleY.c_str());
1743  hratio->GetYaxis()->SetNdivisions(520);
1744 
1745  // Efficiency ratio
1746  if (drawUtils::CheckInternalOption(uopt,"EFF")){
1747 
1748  hratio->GetYaxis()->SetRangeUser(0,1.1);
1749 
1750  // Set the proper range depending on the first_cut
1751  hratio->GetXaxis()->SetRange(first_cut+cut_offset+1,hratio->GetNbinsX());
1752 
1753  if (uroot_opt.find("SAME")!=std::string::npos)
1754  hratio->Draw("PHIST same");
1755  else
1756  hratio->Draw("PHIST");
1757 
1758  // compute the efficiency
1759  // TGraphAsymmErrors* eff = new TGraphAsymmErrors(h1);
1760  TGraphAsymmErrors* eff = new TGraphAsymmErrors(h1->GetNbinsX());
1761  eff->SetName(GetUniqueName("eff").c_str());
1762  _saved_graphs.push_back(eff);
1763  eff->Divide(h1, h2, (_eff_params + " v").c_str()); //the options are explicitely provided by SetEffDivideParams(const std::string&), root_opt not used to avoid possible confusions
1764 
1765  eff->SetLineColor(_auto_colors[_same_level]);
1766  eff->SetMarkerColor(_auto_colors[_same_level]);
1767  eff->SetMarkerStyle(21);
1768 
1769  // eff->GetXaxis()->SetRange(first_cut+cut_offset+1,hratio->GetNbinsX());
1770  eff->GetXaxis()->SetLimits(first_cut+cut_offset+1,hratio->GetNbinsX());
1771 
1772  for (int i=0; i<h1->GetNbinsX();i++){
1773  eff->SetPointEXhigh(i,0);
1774  eff->SetPointEXlow(i,0);
1775  }
1776 
1777  // Draw the efficiency histogram (TODO: use DrawGraph)
1778  eff->Draw(("PL "+root_opt).c_str());
1779 
1780  // Add an entry to the legend if requested
1781  if (!drawUtils::CheckOption(uopt,"NOLEG") && leg!=""){
1782  drawUtils::AddLegendEntry(_legends.back(), eff, leg, "LE1P");
1783  }
1784  }
1785  // Normal ratio
1786  else{
1787  hratio->SetLineColor(_auto_colors[_same_level]);
1788  hratio->SetMarkerColor(_auto_colors[_same_level]);
1789  hratio->SetMarkerStyle(21);
1790 
1791  // Set the proper range depending on the first_cut
1792  hratio->GetXaxis()->SetRange(first_cut+cut_offset+1,hratio->GetNbinsX());
1793 
1794  // Draw the ratio histogram
1795  hratio->Draw(("PL "+uroot_opt).c_str());
1796 
1797  // Add an entry to the legend if requested
1798  if (!drawUtils::CheckOption(uopt,"NOLEG") && leg!=""){
1799  drawUtils::AddLegendEntry(_legends.back(), hratio, leg, "LE1P");
1800  }
1801 
1802  // Print numbers on the screen
1803  char out1[256];
1804  char out2[256];
1805  for (int i=0;i<hratio->GetNbinsX();i++ ){
1806  int icut = i-1;
1807  std::string cut_name="";
1808  if (icut==-1)
1809  cut_name = "NO CUT";
1810  else
1811  cut_name = cuts[icut]->Title();
1812  sprintf(out1,"%3s: %-25s %-10s", "#", "cut", "ratio");
1813  sprintf(out2,"%3d: %-25s %-10.2f", icut, cut_name.c_str(), hratio->GetBinContent(i+1));
1814  if (i==0) std::cout << out1 << std::endl;
1815  std::cout << out2 << std::endl;
1816  }
1817  }
1818 
1819  // Draw the legend if requestet
1820  if (!drawUtils::CheckOption(uopt,"NOLEG") && leg!="")
1821  _legends.back()->Draw();
1822 
1823  if (!drawUtils::CheckOption(uopt,"NODRAW"))
1824  gPad->Update();
1825 }
void AddLegendEntry(TLegend *leg, TObject *ht, const std::string &type, const std::string &opt)
Add an entry to the Legend and resize it.
std::string _eff_params
parameter to control options for TGraphAsymmErrors::Divide() method, the one used to get the efficien...
std::vector< StepBase * > GetCutsInBranch(const std::string &branch) const
Get all cuts in a given branch provided the branch alias.
bool ContainValidOptions(const std::string &uopt)
Check if the input string contails only valid options.
std::string GetUniqueName(const std::string &name)
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9
bool CheckInternalOption(const std::string &uopt, const std::string &this_opt)
Check if specific option appears in option field (don&#39;t check if it exists: Added with AddOption) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...
bool CheckOption(const std::string &uopt, const std::string &this_opt)
Check if specific option exists, and if so if it appears in option field.

§ DrawToys()

void DrawingToolsBase::DrawToys ( TTree *  tree,
const std::string &  cut = "",
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "" 
)

[DrawingToolsBaseDrawToyMethods] This method draws the distribution of the number of selected events for all toys (one entry per toy in the histogram), provided a cut This is useful to check that the systematic error bars correspond to the RMS of this distribution

Definition at line 1828 of file DrawingToolsBase.cxx.

1828  {
1829 //*********************************************************
1830 
1831  // Draw the distribution of entries for all toy experiments
1832  // The rms of this distribution is the systematic error
1833 
1834  std::string uopt = drawUtils::ToUpper(opt);
1835 
1836 
1837  // Check that all user options are valid
1838  if (!drawUtils::ContainValidOptions(uopt)) return;
1839 
1840  int ntoys = drawUtils::GetNToys(tree);
1841 
1842  TH1_h h1("h1","h1",ntoys,0,ntoys);
1843  TH1_h hw("hw","hw",ntoys,0,ntoys);
1844 
1845  // Apply event weights
1846  std::string cutp = weightTools::ApplyWeights(tree,FormatCut(cut),(uopt+" NOTOYW").c_str());
1847 
1848  // Project with no toy experiment weights
1849  tree->Project("h1","toy_index",cutp.c_str());
1850 
1851  std::string cut2=cut;
1852  if (cut2=="") cut2="1==1";
1853 
1854  // Project the toy experiment PDF weights
1855  if (drawUtils::TreeHasVar(tree,"toy_weight"))
1856  tree->Project("hw","toy_index",("("+cutp+")*toy_weight").c_str());
1857  else
1858  hw = h1;
1859 
1860  // compute the average toy exp weight
1861  TH1_h hwa(hw);
1862  hwa.Divide(&hw,&h1);
1863 
1864  DrawToysBase(h1,hwa,root_opt,uopt,leg);
1865 }
std::string FormatCut(const std::string &cut)
Give the appropriate format to any cut.
bool TreeHasVar(TTree *tree, const std::string &var)
Check wether the tree has a given variable.
bool ContainValidOptions(const std::string &uopt)
Check if the input string contails only valid options.
void DrawToysBase(TH1_h &result, TH1_h &entries, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
[DrawingToolsBaseDrawToyMethods]
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9
int GetNToys(TTree *tree)
get the number of weights in the tree

§ DrawToysBase()

void DrawingToolsBase::DrawToysBase ( TH1_h &  result,
TH1_h &  entries,
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "" 
)

[DrawingToolsBaseDrawToyMethods]

Basic method used by the ones above

Definition at line 1947 of file DrawingToolsBase.cxx.

1947  {
1948 //*********************************************************
1949 
1950  // Draw the distribution of entries for all toy experiments
1951 
1952  std::string slevel = GetSameLevel(root_opt);
1953  std::string uopt = drawUtils::ToUpper(opt);
1954  if (slevel=="0" && leg!="")
1955  CreateLegend();
1956 
1957  // Stat option (entries, MEAN, RMS, and integral)
1958  int statTemp = _stat_option;
1959  SetOptStat(1001110);
1960  gStyle->SetOptStat(1001110);
1961 
1962  const int NTOYS = result.GetNbinsX();
1963 
1964  double nentries[NMAXTOYS];
1965  double avg_weight[NMAXTOYS];
1966  double sum_weights=0;
1967  double avg_nentries=0;
1968  double hmin = 1e10;
1969  double hmax = -1;
1970 
1971  // Get the entries
1972  for (int itoy=0;itoy<NTOYS;itoy++){
1973  nentries[itoy]=result.GetBinContent(itoy+1);
1974  // Get the average weight for each toy experiment
1975  if (nentries[itoy]>0)
1976  avg_weight[itoy] = weights.GetBinContent(itoy+1);
1977  else
1978  avg_weight[itoy] = 0;
1979  std::cout << "toy_index = "<< itoy << "\t --> #entries = " << nentries[itoy] << "\t w=" << avg_weight[itoy] << std::endl;
1980 
1981  if (nentries[itoy]>hmax) hmax = nentries[itoy];
1982  if (nentries[itoy]<hmin) hmin = nentries[itoy];
1983 
1984  // compute the total weight and average entries (justfor debugging)
1985  sum_weights += avg_weight[itoy];
1986  avg_nentries += nentries[itoy]*avg_weight[itoy];
1987  }
1988 
1989  std::cout << "avg[#entries] = sum[entries*avg_weight]/sum[avg_weight] = "<< avg_nentries/sum_weights
1990  << ", sum[avg_weights] = " << sum_weights
1991  << ", sum[entries*avg_weight] = " << avg_nentries << std::endl;
1992 
1993  // Create an histogram and fill the distribution
1994  TH1_h* hentries = new TH1_h(GetUniqueName("hentries").c_str(),leg.c_str(),1000,hmin-(hmax-hmin)/10.,hmax+(hmax-hmin)/10.);
1995  _saved_histos.push_back(hentries);
1996 
1997  double rms=0;
1998  double rms2=0;
1999  for (int itoy=0;itoy<NTOYS;itoy++){
2000  // hentries->Fill(nentries[itoy],avg_weight[itoy]);
2001  hentries->Fill(nentries[itoy],1./NTOYS);
2002 
2003  // this is just for debugging. rms should coincide with the rms given by root
2004  rms += pow(nentries[itoy]-avg_nentries/sum_weights,2)*avg_weight[itoy]/sum_weights;
2005 
2006  // this is the rms when the weights are not properly normilized to 1
2007  rms2 += pow(nentries[itoy]-avg_nentries,2)*avg_weight[itoy];
2008  }
2009 
2010  std::cout << "rms = "<< sqrt(rms) << ", rms' = " << sqrt(rms2) << std::endl;
2011 
2012  // Draw the entries histogram
2013  DrawHisto(hentries, _line_width, _line_color, _fill_style, root_opt, uopt, "LE1P");
2014 
2015  // Draw the legend
2016  if (!drawUtils::CheckOption(uopt,"NOLEG") && leg!="")
2017  _legends.back()->Draw();
2018 
2019  if (!drawUtils::CheckOption(uopt,"NODRAW"))
2020  gPad->Update();
2021 
2022  // go back to previous stat option
2023  SetOptStat(statTemp);
2024 }
std::string GetSameLevel(const std::string &root_opt)
Get the superposition level.
void CreateLegend(const std::string &uopt="")
create the legend
std::string GetUniqueName(const std::string &name)
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9
void SetOptStat(int opt)
Set the stat option (by int or string)
bool CheckOption(const std::string &uopt, const std::string &this_opt)
Check if specific option exists, and if so if it appears in option field.

§ DrawToysRatio()

void DrawingToolsBase::DrawToysRatio ( TTree *  tree1,
TTree *  tree2,
const std::string &  cut = "",
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "",
double  norm = 1 
)

This method draws the distribution of the ratio of number of selected events between two samples for all toys (one entry per toy in the histogram), provided a cut (the same for numerator and denominator)

Definition at line 1869 of file DrawingToolsBase.cxx.

1870  {
1871 //*********************************************************
1872 
1873  // Draw the distribution of ratios for all toy experiments
1874  // The rms of this distribution is the systematic error
1875  // Use same cut for both data samples
1876 
1877  DrawToysRatioTwoCuts(tree1,tree2,cut,cut,root_opt,opt,leg,norm);
1878 }
void DrawToysRatioTwoCuts(TTree *tree1, TTree *tree2, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="", const std::string &leg="", double norm=1)

§ DrawToysRatioTwoCuts()

void DrawingToolsBase::DrawToysRatioTwoCuts ( TTree *  tree1,
TTree *  tree2,
const std::string &  cut1,
const std::string &  cut2,
const std::string &  root_opt = "",
const std::string &  opt = "",
const std::string &  leg = "",
double  norm = 1 
)

This method draws the distribution of the ratio of number of selected events between two samples for all toys (one entry per toy in the histogram), provided two cuts, one for the numerator and another for the denominator

Definition at line 1881 of file DrawingToolsBase.cxx.

1882  {
1883 //*********************************************************
1884 
1885  // Draw the distribution of ratios for all toy experiments
1886  // The rms of this distribution is the systematic error
1887  // Use different cuts for both data samples
1888 
1889  int NTOYS1 = drawUtils::GetNToys(tree1);
1890  int NTOYS2 = drawUtils::GetNToys(tree2);
1891 
1892  // The number of toy experiments must be the same
1893  if (NTOYS1!=NTOYS2) return;
1894 
1895  std::string uopt = drawUtils::ToUpper(opt);
1896 
1897  // Check that all user options are valid
1898  if (!drawUtils::ContainValidOptions(uopt)) return;
1899 
1900 
1901  // Apply event weights
1902  std::string cut1p = weightTools::ApplyWeights(tree1,FormatCut(cut1),(uopt+" NOTOYW").c_str());
1903  std::string cut2p = weightTools::ApplyWeights(tree2,FormatCut(cut2),(uopt+" NOTOYW").c_str());
1904 
1905  // Project the first sample
1906  TH1_h h1("en1","en2",NTOYS1,0,NTOYS1);
1907  tree1->Project("en1","toy_index",cut1p.c_str());
1908 
1909  // Project the second sample
1910  TH1_h h2("en2","en2",NTOYS1,0,NTOYS1);
1911  tree2->Project("en2","toy_index",cut2p.c_str());
1912 
1913  // compute the ratio
1914  TH1_h ratio(h1);
1915  ratio.SetName("ratio");
1916  ScaleHisto(&h2,norm);
1917  ratio.Divide(&h1,&h2);
1918 
1919  // Project the weights for the first sample
1920  TH1_h hw1("hw1","hw1",NTOYS1,0,NTOYS1);
1921  if (drawUtils::TreeHasVar(tree1,"toy_weight"))
1922  tree1->Project("hw1","toy_index",("("+cut1p+")*toy_weight").c_str());
1923  else
1924  hw1 = h1;
1925 
1926  // Project the weights for the first sample
1927  TH1_h hw2("hw2","hw2",NTOYS1,0,NTOYS1);
1928  if (drawUtils::TreeHasVar(tree2,"toy_weight"))
1929  tree2->Project("hw2","toy_index",("("+cut2p+")*toy_weight").c_str());
1930  else
1931  hw2 = h2;
1932 
1933 
1934  // compute the average weights for sample 1
1935  TH1_h hwa1(hw1);
1936  hwa1.Divide(&hw1,&h1);
1937 
1938  // compute the average weights for sample 2
1939  TH1_h hwa2(hw2);
1940  hwa2.Divide(&hw2,&h2);
1941 
1942 
1943  DrawToysBase(ratio,hwa2,root_opt,uopt,leg);
1944 }
std::string FormatCut(const std::string &cut)
Give the appropriate format to any cut.
bool TreeHasVar(TTree *tree, const std::string &var)
Check wether the tree has a given variable.
bool ContainValidOptions(const std::string &uopt)
Check if the input string contails only valid options.
void ScaleHisto(TH1 *h, double scale, bool scale_errors=true)
Scale an histogram and its errors(when requested)
void DrawToysBase(TH1_h &result, TH1_h &entries, const std::string &root_opt="", const std::string &opt="", const std::string &leg="")
[DrawingToolsBaseDrawToyMethods]
std::string ToUpper(const std::string &str)
Definition: DrawingUtils.cxx:9
int GetNToys(TTree *tree)
get the number of weights in the tree

§ DumpCategories() [1/2]

void DrawingToolsBase::DumpCategories ( )
inline

[DrawingToolsBase_categ] Print out the list of categories which can be used when plotting stacked histograms

Definition at line 709 of file DrawingToolsBase.hxx.

709 {cat().DumpCategories();}
void DumpCategories()
Dump the map of track categories.

§ DumpCategories() [2/2]

void DrawingToolsBase::DumpCategories ( const std::string &  file)
inline

Print out the list of categories stored in the given file which can be used when plotting stacked histograms

Definition at line 713 of file DrawingToolsBase.hxx.

713 {ReadCategories(file);cat().DumpCategories();if (_config_file!="") ReadCategories(_config_file);}
void DumpCategories()
Dump the map of track categories.
void ReadCategories(const std::string &file)

§ DumpCategory()

void DrawingToolsBase::DumpCategory ( std::string  category)
inline

Print the options saved for the given category, including the name of each category, the value stored in the output file for that category, and the colour used to plot the category.

Definition at line 717 of file DrawingToolsBase.hxx.

717 {cat().DumpCategory(category);}
void DumpCategory(const std::string &categ)
Dump the options stored for the given category.

§ DumpCuts() [1/3]

void DrawingToolsBase::DumpCuts ( int  branch = -1)

[DrawingToolsBase_DumpSelections]

[DrawingToolsBase_DumpSteps] Print to screen the details of cuts for a given branch or selection. Specifying a branch of -1 (the default) will print details for all branches. When there are multiple selections the input index is for the selection

Definition at line 4154 of file DrawingToolsBase.cxx.

4154  {
4155 //********************************************************************
4156  if (sel().GetNEnabledSelections()>1){
4157  if (sel().GetSelection(branch)) sel().GetSelection(branch)->DumpCuts();
4158  }
4159  else
4160  sel().GetSelection(0)->DumpCuts(branch);
4161 }
void DumpCuts(Int_t branch=-1) const
Print out the index, name and title of each cut for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ DumpCuts() [2/3]

void DrawingToolsBase::DumpCuts ( const std::string &  sel_name,
int  branch = -1 
)

Print to screen the details of cuts for a given branch and selection (name). Specifying a branch of -1 (the default) will print details for all branches.

Definition at line 4174 of file DrawingToolsBase.cxx.

4174  {
4175 //********************************************************************
4176  if (sel().GetSelection(sel_name)) sel().GetSelection(sel_name)->DumpCuts(branch);
4177 }
void DumpCuts(Int_t branch=-1) const
Print out the index, name and title of each cut for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ DumpCuts() [3/3]

void DrawingToolsBase::DumpCuts ( Int_t  sel_index,
int  branch 
)

Print to screen the details of cuts for a given branch and selection (index). Specifying a branch of -1 (the default) will print details for all branches.

Definition at line 4186 of file DrawingToolsBase.cxx.

4186  {
4187 //********************************************************************
4188  if (sel().GetSelection(sel_index)) sel().GetSelection(sel_index)->DumpCuts(branch);
4189 }
void DumpCuts(Int_t branch=-1) const
Print out the index, name and title of each cut for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ DumpPOT()

void DrawingToolsBase::DumpPOT ( TTree *  tree)

[DrawingToolsBase_POT] Dump the POT information for this sample, provided the header tree

Definition at line 4198 of file DrawingToolsBase.cxx.

4198  {
4199 //********************************************************************
4200  header().ReadHeader(tree);
4201  header().DumpPOT();
4202 }
void ReadHeader(const std::string &file)
Read the "header" tree from the given file, but reset POT counting first.
Definition: Header.cxx:141
void DumpPOT()
Print the POT information.
Definition: Header.cxx:226

§ DumpSelections()

void DrawingToolsBase::DumpSelections ( const std::string &  file = "")

[DrawingToolsBase_DumpSelections] Dump the list of Selections

Definition at line 4134 of file DrawingToolsBase.cxx.

4134  {
4135 //********************************************************************
4136  if (file!="") sel().ReadSelections(file);
4137  sel().DumpSelections();
4138  if (_config_file!="") ReadSelections(_config_file);
4139 }
void DumpSelections()
Print out the index, name and title of each selection for a given branch (no argument for all branche...
void ReadSelections(const std::string &file)
Read the list of Selections.
void ReadSelections(const std::string &file)

§ DumpSoftwareVersions()

void DrawingToolsBase::DumpSoftwareVersions ( const std::string &  file = "")

—— Package versions -------——

Dumps on the screen the highland/psyche software versions used to produce this file

Definition at line 3814 of file DrawingToolsBase.cxx.

3814  {
3815 //*********************************************************
3816 
3817  // Use the file used to create the DrawingTools if no file is specified
3818  std::string file2 = file;
3819  if (file=="") file2 = _config_file;
3820 
3821  if (file2!="") ND::versioning().ReadVersions(file2);
3822  ND::versioning().DumpVersions();
3823  DumpOriginalSoftwareVersion(file2, false);
3824 }
void ReadVersions(const std::string &file)
Read package names and versions use to produce this file.
void DumpOriginalSoftwareVersion(const std::string &file="", bool all=true)
Dumps on the screen the software version of the original file (i.e. output of recon) ...
void DumpVersions()
dump package names and versions

§ DumpSteps() [1/3]

void DrawingToolsBase::DumpSteps ( int  branch = -1)

Print to screen the details of steps for a given branch or selection. Specifying a branch of -1 (the default) will print details for all branches. When there are multiple selections the input index is for the selection

Definition at line 4164 of file DrawingToolsBase.cxx.

4164  {
4165 //********************************************************************
4166  if (sel().GetNEnabledSelections()>1){
4167  if (sel().GetSelection(branch,true)) sel().GetSelection(branch)->DumpSteps();
4168  }
4169  else
4170  sel().GetSelection(0)->DumpSteps(branch);
4171 }
void DumpSteps(const std::string &branch="", bool onlycuts=false) const
Print out the index, name and title of each step for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ DumpSteps() [2/3]

void DrawingToolsBase::DumpSteps ( const std::string &  sel_name,
int  branch = -1 
)

Print to screen the details of steps for a given branch and selection (name). Specifying a branch of -1 (the default) will print details for all branches.

Definition at line 4180 of file DrawingToolsBase.cxx.

4180  {
4181 //********************************************************************
4182  if (sel().GetSelection(sel_name)) sel().GetSelection(sel_name)->DumpSteps(branch);
4183 }
void DumpSteps(const std::string &branch="", bool onlycuts=false) const
Print out the index, name and title of each step for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ DumpSteps() [3/3]

void DrawingToolsBase::DumpSteps ( Int_t  sel_index,
int  branch 
)

Print to screen the details of steps for a given branch and selection (index). Specifying a branch of -1 (the default) will print details for all branches.

Definition at line 4192 of file DrawingToolsBase.cxx.

4192  {
4193 //********************************************************************
4194  if (sel().GetSelection(sel_index)) sel().GetSelection(sel_index)->DumpSteps(branch);
4195 }
void DumpSteps(const std::string &branch="", bool onlycuts=false) const
Print out the index, name and title of each step for a given branch (no argument for all branches) ...
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ ExplainOption()

void DrawingToolsBase::ExplainOption ( std::string  name)
inline

[DrawingToolsBase_ops] Explain the user drawing options

Definition at line 809 of file DrawingToolsBase.hxx.

void ExplainOption(OptionEnum opt)
Explain a given option given as enum.

§ ExplainVar()

void DrawingToolsBase::ExplainVar ( std::string  name,
std::string  tree_name = "default" 
)
inline

[DrawingToolsBase_ops]

[DrawingToolsBase_vars] Explain the meaning of a variable stored in a tree. If no tree name is provided the "default" tree is used

Definition at line 817 of file DrawingToolsBase.hxx.

817 {doc().ExplainVar(name, tree_name);}
void ExplainVar(const std::string &name, const std::string &tree_name)
Print the details of the specified variable in the given tree.

§ FinishDocument()

void DrawingToolsBase::FinishDocument ( )

Close the PDF document / webpage that was opened with StartDocument. Note that you MUST call this function or your PDF document will be corrupt / the webpage will be empty.

Definition at line 3624 of file DrawingToolsBase.cxx.

3624  {
3625 //*********************************************************
3626  if (_webpath != "") {
3627  _webbody += "</body></html>\n";
3628  std::ofstream outfile;
3629  outfile.open((_webpath+"/index.html").c_str());
3630  outfile << _webheader << _webbody;
3631  outfile.close();
3632  }
3633  if (_pdfpath != "") {
3634  gPad->Print((_pdfpath+"]").c_str());
3635  }
3636 }

§ Get2DHistos()

std::vector< TH1* > DrawingToolsBase::Get2DHistos ( )
inline

Get all the 1D histos that have been drawn. Useful if you want to save them to file. NOTE! The "same" plot may appear multiple times due to the way the comparison histograms are drawn.

Definition at line 876 of file DrawingToolsBase.hxx.

876 { return _saved_histos; }

§ GetChi2()

double DrawingToolsBase::GetChi2 ( const TH1 *  h1,
const TH1 *  h2 
)

Compute the Chi2 without normalizing by area (as Chi2Test of root does) h1/h2 should be already normalized by POT, with errors properly propagated: just get them from your DATA-mc plot with GetLastStackTotal(0) and GetLastStackTotal(1)

Definition at line 4076 of file DrawingToolsBase.cxx.

4076  {
4077  //********************************************************************
4078 
4079  if (h1->GetXaxis()->GetNbins() != h2->GetXaxis()->GetNbins())
4080  std::cout << "WARNING: the two histograms have different number of bins!" << std::endl;
4081 
4082  TH1* h1temp = (TH1*)h1->Clone();
4083  TH1* h2temp = (TH1*)h2->Clone();
4084 
4085  // Refill to avoid dealing with normalizing factors
4086  h1temp->Reset();
4087  h2temp->Reset();
4088  for (int i=1; i<=h1temp->GetXaxis()->GetNbins(); i++) {
4089  h1temp->SetBinContent(i,h1->GetBinContent(i));
4090  h2temp->SetBinContent(i,h2->GetBinContent(i));
4091  h1temp->SetBinError(i,h1->GetBinError(i));
4092  h2temp->SetBinError(i,h2->GetBinError(i));
4093  }
4094 
4095  double chi2=0;
4096  int ndof=0;
4097  for (int i=1; i<=h1temp->GetXaxis()->GetNbins(); i++) {
4098  if (h1temp->GetBinContent(i)==0 && h2temp->GetBinContent(i)==0) continue;
4099  ndof++;
4100  double diff = h1temp->GetBinContent(i) - h2temp->GetBinContent(i);
4101  double err1 = h1temp->GetBinError(i);
4102  double err2 = h2temp->GetBinError(i);
4103  double errsq = pow(err1,2) + pow(err2,2);
4104  if (errsq == 0 || errsq != errsq) {
4105  if (diff != 0)
4106  std::cout << "ERROR errsq = 0! \n";
4107  else {
4108  std::cout << "WARNING diff=0 and errsq= 0 (set to 1) \n";
4109  errsq=1;
4110  diff=1;
4111  }
4112  }
4113  chi2 += pow(diff,2) / errsq;
4114  }
4115  ndof--;
4116 /*
4117  double chi2test;
4118  int ndoftest;
4119  int igood;
4120  double pvalue = h2temp->Chi2TestX(h1temp,chi2test,ndoftest,igood,"WW");
4121 
4122  cout << "my chi2/ndof (pvalue) = " << chi2 << " / " << ndof
4123  << " (" << TMath::Prob(chi2,ndof) << ")" << endl;
4124  cout << "my Chi2TestX (pvalue) = " << chi2test << " / " << ndoftest
4125  << " (" << TMath::Prob(chi2test,ndoftest) << ")" << endl;
4126 */
4127  delete h1temp;
4128  delete h2temp;
4129 
4130  return chi2;
4131 }

§ GetCutNames()

std::vector<std::string> DrawingToolsBase::GetCutNames ( const std::string &  sel_name,
int  branch = 0 
)
inline

[DrawingToolsBase_DumpSteps]

Get a vector of cut names for a given branch (in order) in a selection with a given name

Definition at line 782 of file DrawingToolsBase.hxx.

782  {
783  if (sel().GetSelection(sel_name)) return sel().GetSelection(sel_name)->GetCutNames(branch);
784  return std::vector<std::string>();
785  }
std::vector< std::string > GetCutNames(Int_t ibranch=0) const
Return all the names of the cuts, in the order they were added.
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...

§ GetEff() [1/2]

double DrawingToolsBase::GetEff ( TTree *  tree,
const std::string &  var,
double  xmin,
double  xmax,
const std::string &  cut1,
const std::string &  cut2,
const std::string &  root_opt = "",
const std::string &  opt = "" 
)

Get the efficiency (BayesDivide ratio) of two histograms in which the numerator (cut1+cut2) is a subset of the denominator (cut2). Integrate over "var" between xmin and xmax. This is useful for doing quick optimisation studies, where one can loop over several cut options to see the effect they have.

Definition at line 855 of file DrawingToolsBase.cxx.

856  {
857 //*********************************************************
858  double errhigh = 0.;
859  double errlow = 0.;
860  return GetEff(tree, var, xmin, xmax, errlow, errhigh, cut1, cut2, root_opt, opt);
861 }
double GetEff(TTree *tree, const std::string &var, double xmin, double xmax, const std::string &cut1, const std::string &cut2, const std::string &root_opt="", const std::string &opt="")

§ GetEff() [2/2]

double DrawingToolsBase::GetEff ( TTree *  tree,
const std::string &  var,
double  xmin,
double  xmax,
double &  errlow,
double &  errhigh,
const std::string &  cut1,
const std::string &  cut2,
const std::string &  root_opt = "",
const std::string &  opt = "" 
)

See other GetEff() interface for documentation. In this interface, errlow and errhigh will be filled with the upper and lower errors on the efficiency.

Definition at line 864 of file DrawingToolsBase.cxx.

865  {
866 //*********************************************************
867 
868  errlow = 0;
869  errhigh = 0;
870  // std::string slevel = GetSameLevel(root_opt);
871  int nbins = 1;
872  double xbins[2] = {xmin, xmax};
873 
874  // Histogram for cut1+cut2 (numerator)
875  TH1_h* h1 = GetHisto(tree, "eff1",var,nbins,xbins,(cut1+" && "+cut2), root_opt, opt,1);
876  h1->Sumw2();
877  // Histogram for cut2 (denominator)
878  TH1_h* h2 = GetHisto(tree, "eff2",var,nbins,xbins,cut2, root_opt, opt,1);
879  h2->Sumw2();
880 
881  // compute the efficiency
882  TGraphAsymmErrors* eff = new TGraphAsymmErrors(h1);
883  _saved_graphs.push_back(eff);
884  eff->Divide(h1, h2, _eff_params.c_str()); //the options are explicitely provided by SetEffDivideParams(const std::string&), root_opt not used to avoid possible confusions
885 
886  if (eff->GetN() != 1) {
887  std::cout << "Error computing efficiency" << std::endl;
888  return 0;
889  }
890 
891  errlow = eff->GetEYlow()[0];
892  errhigh = eff->GetEYhigh()[0];
893 
894  return eff->GetY()[0];
895 }
std::string _eff_params
parameter to control options for TGraphAsymmErrors::Divide() method, the one used to get the efficien...

§ GetFillStyle()

int DrawingToolsBase::GetFillStyle ( int  i)
protected

Get the fill style to apply to the i'th histogram in a stack. Depends on whether SetDifferentStackFillStyles() has been called.

Definition at line 2627 of file DrawingToolsBase.cxx.

2627  {
2628 //*********************************************************
2629 
2630  if (_different_fill_styles && i < NAUTOCOLORS) {
2631  return auto_styles[i];
2632  } else {
2633  return _stack_fill_style;
2634  }
2635 }

§ GetHistos()

std::vector< TH1* > DrawingToolsBase::GetHistos ( )
inline

Get all the 1D histos that have been drawn. Useful if you want to save them to file. NOTE! The "same" plot may appear multiple times due to the way the comparison histograms are drawn.

Definition at line 862 of file DrawingToolsBase.hxx.

862 { return _saved_histos; }

§ GetLastStackTotal()

TH1* DrawingToolsBase::GetLastStackTotal ( int  nexttolast = 0)
inline

Get the total from the most recently-drawn stacked histogram. Useful if you want to save it to file.

Definition at line 887 of file DrawingToolsBase.hxx.

887  {
888  std::cout << "If it crashes you should maybe use GetLastHisto instead.\n";
889  if ( ! _saved_histoStacks.back()) {
890  std::cout << "No histoStacks found. You can try GetLastHisto\n"; return NULL; }
891  if (nexttolast>0){
892  if ((int)_saved_histoStacks.size() <= nexttolast) {
893  return NULL;
894  } else {
895  HistoStack* s = _saved_histoStacks[(int)_saved_histoStacks.size() - nexttolast - 1];
896  return s->GetTotal1D();
897  }
898  }
899  else{
900  HistoStack* s = _saved_histoStacks.back();
901  return s->GetTotal1D();
902  }
903  }
TH1_h * GetTotal1D()
Return the total 1D histo.
Definition: HistoStack.hxx:67

§ GetUniqueName()

std::string DrawingToolsBase::GetUniqueName ( const std::string &  name)

Get a unique name for a histogram, to avoid name clashes when drawing on multiple canvases.

Definition at line 2668 of file DrawingToolsBase.cxx.

2668  {
2669 //*********************************************************
2670  std::stringstream unique;
2671  unique << _unique++;
2672  TString name2 = name;
2673  name2 = name2.ReplaceAll("(","_");
2674  name2 = name2.ReplaceAll(")","_");
2675  return std::string(name2.Data()) + "_" + unique.str();
2676 }
int _unique
Counter for ensuring all histograms get a unique name.

§ PrintPurities()

void DrawingToolsBase::PrintPurities ( TTree *  tree,
const std::string &  categ,
const std::string &  cut,
double  events_ratio = 1 
)

Print on the screen the purities for the different categories defined by "categ" and with cuts "cut". The expected number of events are also printed, after scaling by events_ratio.

Definition at line 3215 of file DrawingToolsBase.cxx.

3215  {
3216 //*********************************************************
3217 
3218  // Read the categories from the config tree
3219  ReadCategories(_config_file);
3220 
3221  if (!cat().HasCategory(categ) || categ =="all" ) {
3222  std::cout << " ------------------------------------------ " << std::endl;
3223  std::cout << " Invalid category " << categ << std::endl;
3224  std::cout << " ------------------------------------------ " << std::endl;
3225  return;
3226  }
3227 
3228  int i=0;
3229 
3230  TH1_h *ht = new TH1_h("temp"," ",10,0.,10.);
3231 
3232  std::string cut1 = FormatCut(cut);
3233  if (tree->FindLeaf("toy_ref"))
3234  cut1 = cut1 + " && toy_index == toy_ref";
3235 
3236  // std::string cut1w = "("+cut1+")"+w;
3237  std::string cut1w = weightTools::ApplyWeights(tree,cut,"");
3238 
3239  tree->Project("temp","1.",cut1w.c_str());
3240 
3241  double TotalEntries = ht->GetSumOfWeights();
3242  delete ht;
3243 
3244 
3245  std::cout << " --------------------------------------------------------" << std::endl;
3246  std::cout << " Purities: " << std::endl;
3247  std::cout << " Category: " << categ << std::endl;
3248  std::cout << " Cut: " << cut << std::endl;
3249  std::cout << " Events: " << std::setprecision(8) << TotalEntries << std::endl;
3250  std::cout << " --------------------------------------------------------" << std::endl;
3251 
3252  // define stuff to print % on the legend
3253  std::ostringstream percstr, str_tmp;
3254  const int ntypes = (const int)cat().GetCategoryTypes(categ).size();
3255  std::string* cattypes = new std::string[ntypes]; // to initialize with const dimension
3256  int* catcodes = new int[ntypes]; // to initialize with const dimension
3257  int* catcolors = new int[ntypes]; // to initialize with const dimension
3258  int itype=0;
3259 
3260  std::vector<TrackTypeDefinition>::iterator it;
3261  for (it=cat().GetCategoryTypes(categ).begin();it!=cat().GetCategoryTypes(categ).end();it++, i++){
3262  std::string type = it->_name;
3263  std::string code = drawUtils::GetString(it->_code);
3264 
3265  std::string cut2 = cut1+"&&"+categ+"=="+code;
3266 
3267  cut2 = weightTools::ApplyWeights(tree,cut2,"");
3268  // cut2 = "("+cut2+")"+w;
3269 
3270  TH1_h *ht1 = new TH1_h("temp1"," ",10,0.,10.);
3271 
3272  tree->Project("temp1","1.",cut2.c_str());
3273 
3274  double caseEntries = ht1->GetSumOfWeights();
3275  double frac = caseEntries/TotalEntries;
3276  double nev1 = caseEntries * events_ratio;
3277  delete ht1;
3278 
3279  std::cout << std::setprecision(8) << std::setw(25) << type << std::setw(12) << frac*100. << " % (" << nev1 << " events)" << std::endl;
3280 
3281  // create categ_temp to print % on the legend
3282  percstr.str(std::string()); // to clear it
3283  percstr << std::setprecision(2) << std::fixed << frac*100.; // round to 2 decimal
3284  str_tmp.str(std::string()); // to clear it
3285  str_tmp << it->_name << std::setw(8) << percstr.str() << " %"; // tab
3286  cattypes[itype] = str_tmp.str();
3287  catcodes[itype] = it->_code;
3288  catcolors[itype] = it->_color;
3289  itype++;
3290  }
3291 
3292  // create categories with % in the name
3293  bool multi = cat().GetCategory(categ).IsMultiType();
3294  bool noWarning = true, addNOTRUTH = false, addSAND = false;
3295  cat().AddCategory(categ+"_withPurities",itype,cattypes,catcodes,catcolors,multi,noWarning,addNOTRUTH,addSAND);
3296 
3297  std::cout << " --------------------------------------------------------" << std::endl;
3298  std::cout << std::endl;
3299 
3300  return;
3301 }
bool IsMultiType()
Is this a multi-type category ? (Can several types coexist?)
void AddCategory(const std::string &name, int ntypes, std::string *names, int *codes, int *colors, bool multi=false, bool noWarning=false, bool addNOTRUTH=true, bool addSAND=true)
std::string FormatCut(const std::string &cut)
Give the appropriate format to any cut.
TrackCategoryDefinition & GetCategory(const std::string &categ)
Get a specific category.
std::string GetString(int code)
convert integer to string
std::vector< TrackTypeDefinition > & GetCategoryTypes(const std::string &categ)
Get the vector of track types in a given category.
void ReadCategories(const std::string &file)
bool HasCategory(const std::string &categ_name)
Check whether a category has been defined.

§ ReadCategories()

void DrawingToolsBase::ReadCategories ( const std::string &  file)
inline

Read the list of categories stored in the given file which can be used when plotting stacked histograms

Definition at line 705 of file DrawingToolsBase.hxx.

705 {cat().ReadCategories(file);}
void ReadCategories(const std::string &file)
Build the categories from a root file.

§ ReadConfig()

void DrawingToolsBase::ReadConfig ( const std::string &  file)

[DrawingToolsBase_POT]

Read config tree

Definition at line 248 of file DrawingToolsBase.cxx.

248  {
249 //********************************************************************
250 
251  _config_file = file;
252 
253  ReadCategories(file);
254  ReadSelections(file);
255  ReadDocStrings(file);
256  ReadCorrections(file);
257  ReadSystematics(file);
258  ReadConfigurations(file);
259  ReadOther(file);
260  ND::versioning().ReadVersions(file);
261 
262  _configTree_tools.Initialize(file);
263 
264 }
void ReadVersions(const std::string &file)
Read package names and versions use to produce this file.
void ReadCorrections(const std::string &file)
Read the list of Corrections.
void ReadSelections(const std::string &file)
Read the list of Selections.
void ReadConfigurations(const std::string &file)
Read the list of Configurations.
void ReadOther(const std::string &file)
Read any other variables in the config tree.
void ReadDocStrings(const std::string &file)
[DrawingToolsBase_vars]
void ReadCategories(const std::string &file)

§ ReadDocStrings()

void DrawingToolsBase::ReadDocStrings ( const std::string &  file)
inline

[DrawingToolsBase_vars]

Read the details of docstrings from a given file. The details will have been read automatically if you passed the path to a valid highland file in the DrawingTools or DrawingToolsBase constructor.

Definition at line 825 of file DrawingToolsBase.hxx.

825  {
826  // ReadManager(file,"DocMan", &_docStrings);
827  doc().ReadDocStrings(file);
828  }
void ReadDocStrings(const std::string &file)

§ SetAllMCLabel()

void DrawingToolsBase::SetAllMCLabel ( const std::string &  label,
Color_t  color = kBlack 
)
inline

Set the label for the mc when drawing comparison plots. Defaults to "MC all". Setting it to "" (empty string) will disable adding it to the legend.

Definition at line 519 of file DrawingToolsBase.hxx.

519 {_allmc_label = label; _allmc_color = color;}

§ SetAllMCStatLabel()

void DrawingToolsBase::SetAllMCStatLabel ( const std::string &  label)
inline

Set the label for the mc with only statistical errors when drawing comparison plots. Defaults to "MC all (stat)". Setting it to "" (empty string) will disable adding it to the legend.

Definition at line 523 of file DrawingToolsBase.hxx.

523 {_allmcstat_label=label;}

§ SetAllMCSystLabel()

void DrawingToolsBase::SetAllMCSystLabel ( const std::string &  label)
inline

Set the label for the mc with only systematic errors when drawing comparison plots. Defaults to "MC all (syst)". Setting it to "" (empty string) will disable adding it to the legend.

Definition at line 527 of file DrawingToolsBase.hxx.

527 {_allmcstat_label=label;}

§ SetDataLabel()

void DrawingToolsBase::SetDataLabel ( const std::string &  label,
Color_t  color = kBlack 
)
inline

Set the label for the data when drawing comparison plots. Defaults to "Data". Setting it to "" (empty string) will disable adding it to the legend.

Definition at line 515 of file DrawingToolsBase.hxx.

515 {_data_label = label; _data_color = color;}

§ SetLegendEntryHeight()

void DrawingToolsBase::SetLegendEntryHeight ( double  h)
inline

[DrawingToolsCommandLineOptions]

Set the height (in normalized coordinates: NDC) of each legend entry

Definition at line 420 of file DrawingToolsBase.hxx.

420 {drawUtils::legendEntryHeight=h;}

§ SetLegendPos()

void DrawingToolsBase::SetLegendPos ( double  x = -999,
double  y = -999 
)

Set legend/small legend position by double (-999 keep current value) or by string ("l"=left, "r"=right , "c"=center, "t"=top, "b"=bottom)

Definition at line 282 of file DrawingToolsBase.cxx.

282  {
283 //*********************************************************
284 
285  _legendPosS = "";
286  if (posX != -999) _legendPos[0] = posX;
287  if (posY != -999) _legendPos[1] = posY;
288  SetLegendParam(_legendPos[0],_legendPos[1],_legendPos[0]+_legendSize[0], _legendPos[1]+_legendSize[1]);
289 }
void SetLegendParam(double a, double b, double c, double d)
Set position and size of the legend.

§ SetMaxY()

void DrawingToolsBase::SetMaxY ( double  maxY = 0)
inline

Set the maximum of the Y-axis. By default the maximum is set automatically by the DrawingTools. Call SetMaxY() to revert to the default behaviour.

Definition at line 535 of file DrawingToolsBase.hxx.

535 {_maxY = maxY;}

§ SetMinY()

void DrawingToolsBase::SetMinY ( double  minY = 0)

Set the minimum of the Y-axis. By default the minimum is set to 0. Call SetMinY() to revert to the default behaviour.

Definition at line 3498 of file DrawingToolsBase.cxx.

3498  {
3499 //*********************************************************
3500 
3501  if (minY<=0 && _logY) {
3502  std::cout << "Cannot set minimum <= 0 in logY scale! Call SetLogY(false) before calling SetMinY()!" << std::endl;
3503  return;
3504  }
3505  _minY = minY;
3506 }

§ SetRangeY()

void DrawingToolsBase::SetRangeY ( double  minY = 0,
double  maxY = 0 
)
inline

Set the minimum and maximum of the Y-axis. See the documentation of SetMinY and SetMaxY for the default behaviour. Call SetRangeY() to revert to the default behaviour.

Definition at line 539 of file DrawingToolsBase.hxx.

539 {SetMinY(minY); SetMaxY(maxY);}
void SetMinY(double minY=0)
void SetMaxY(double maxY=0)

§ StartDocument()

void DrawingToolsBase::StartDocument ( const std::string &  title,
bool  pdf = true,
bool  web = false,
const std::string &  pdffile = "plots.pdf",
const std::string &  webpath = "plots" 
)

Start the creation of a PDF document and/or webpage which will contain the plots you make. This makes it particularly easy to share many plots. pdffile is the path to the PDF FILE that will be created webpath is the path to the DIRECTORY in which the webpage and images will be placed.

There are two possible use cases for these functions: draw.StartDocument(...); // Will create a canvas for you draw.Draw(...); // Will draw on the right canvas draw.AddDocumentPage(...); // Will save the current page ... draw.FinishDocument(); // Finish and close

OR

TCanvas canvas(...); // Create your own canvas draw.StartDocument(...); // Won't create a canvas for you draw.Draw(...); // Will draw on your canvas draw.AddDocumentPage(...); // Will save the current page ... draw.FinishDocument(); // Finish and close

In the first case, a canvas was automatically created. This canvas is split into two sections - a header and a body. The header will be populated with the "name" you provide in AddDocumentPage. This makes it easier to understand what each plot is. In the second case, it is assumed you know what you want, so we don't create this header section.

Definition at line 3548 of file DrawingToolsBase.cxx.

3548  {
3549 //*********************************************************
3550  if (_pdfcanvas) {
3551  delete _pdfcanvas;
3552  }
3553  _pdfpath = "";
3554  _webpath = "";
3555  _webheader = "";
3556  _webbody = "";
3557 
3558  if (web) {
3559  _webpath = webpath;
3560  MakeDirectory(_webpath, 0755);
3561  _webheader += "<html><head><title>" + title + "</title></head><body>\n";
3562  _webheader += "<h2>" + title + "</h2>\n<ol>\n";
3563  _webbody += "</ol>\n";
3564  }
3565  if (pdf) {
3566  _pdfpath = pdffile;
3567 
3568  if (!gPad) {
3569  // User hadn't set up a canvas - create one for them.
3570  // We split it into 2 sections, so we can save useful info
3571  // in the small top "header" bit.
3572  _pdfcanvas = new TCanvas("pdfcanvas", "pdfcanvas", 800, 630);
3573  _headpad = new TPad("header", "header", 0, 0.95, 1, 1, 0);
3574  _headpad->SetNumber(1);
3575  _headpad->Draw();
3576  _bodypad = new TPad("body", "body", 0, 0, 1, 0.95, 0);
3577  _bodypad->SetNumber(2);
3578  _bodypad->Draw();
3579  _pdfcanvas->Draw();
3580  _bodypad->cd();
3581  }
3582 
3583  std::cout << _pdfpath << std::endl;
3584 
3585  gPad->Print((_pdfpath+"[").c_str());
3586  }
3587 }
int MakeDirectory(const std::string &path, mode_t mode)
Make a directory on the filesystem.

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