A++ » INC » HepDataMCPlot

class HepDataMCPlot: public TNamed


 Plot overlayed or stacked MC histograms with DATA on top

 * The same binning for all histograms is required
 * Until now only 1d histograms are supported

 For drawing the histograms in grouped/ungrouped mode use
 SetGroupHistograms(). All MC stack histograms can be unified into a
 single-coloured histogram by SetUnifyMCStack().

 The total statistical uncertainty of the MC can be shown by using
 SetDrawMCError(). The errors are displayed as a rectangular hatched
 area on top of each bin.

 Usually the error per bin for the DATA histogram as well as for the
 total MC stack is computed as sqrt(sum of squares of weight) for
 each bin, which is ROOT's standard error handling for
 histograms. For verly low entry numbers inside a bin such kind of
 errors are not valid any more since the error function becomes more
 and more poissonic and the entry number is bound to be larger equal
 than zero which results in asymmetric error bars and in non-zero
 errors for bins without any entry. To obtain a better description,
 for entry numbers less then 33 the upper and lower confidence
 limits are estimated for a confidence level of 68% by the method of
 Feldman and Cousins (see the class TFeldmanCousins or the
 Statistics Review of the Particle Data Group). This method provides
 a smooth transition from the symmetric gaussian errors for large
 entry numbers to the completely asymmetric errors for zero-entry
 bins. This gives a realistic description of the uncertainties,
 however it slows down the speed of drawing the histograms. The
 limitt of 33 entries was chosen to have a fair trade-off between a
 good description and the time needed for drawing.


 Fitter:
 The plot gives the possibility to fit the MC distributions to the
 data distribution. This is done using the TFractionFitter class
 contained in ROOT.
 Starting from your plot object HepDataMCPlot *pl, the fit can be easily
 performed. First start with:
 pl->PrepareFit();
 This creates the needed HepTemplate objects. Folders are treated as one
 template per default. If you want to have all samples as single templates,
 use pl->PrepareFit(kTRUE);
 If you want you can specify start values for the template fractions
 pl->SetTemplateStartValue(template_name,initValue,initErr);
 and/or bounds:
 pl->SetTemplateBounds(template_name,low,up);
 The functions pl->ListFolders() and pl->ListSingleSamples() list all
 folders and single samples contained in the plot. Their names are used
 for the naming of the template objects.
 The fit is started by:
 pl->Fit();
 The function returns the value 0, if the fit converged.
 You can list all obtained fractions by
 pl->ListTemplateFractions();
 or get a fraction of a specific template:
 pl->GetTemplateFitFraction(template_name);
 Note that the fit uses only non-empty histograms. Templates for empty
 histograms are not created.
 Finally you can plot the data together with the fitted MC as stacked
 histogram by:
 pl->DrawFit();

 Author: Oliver Maria Kind <mailto: kind@mail.desy.de>
 Update: $Id: HepDataMCPlot.cxx,v 1.73 2017/05/12 13:38:47 kaphle Exp $
 Copyright: 2009 (C) Oliver Maria Kind

Function Members (Methods)

public:
virtual~HepDataMCPlot()
voidTObject::AbstractMethod(const char* method) const
voidAddHistMC(TH1F* h, HepDataMCSample* sample)
voidAddHistMC(TH1F* h, HepDataMCFolder* folder, HepDataMCSample* sample)
voidAddMCFolder(HepDataMCFolder* folder)
voidAddMCSingleSample(HepDataMCSample* sample)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidBrowse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
voidComputeNormUncertainty(Int_t bin, Double_t& up, Double_t& lo)
voidComputeStatisticalUncertainty(TH1F* h, Int_t bin, Double_t& up, Double_t& lo)
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
virtual voidDraw(Option_t* option = "")
voidDrawATLASLabel(Double_t x, Double_t y, TString text, Color_t color = 1)
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidDrawFit(Option_t* option = "")
voidDrawLegend()
voidDrawLegendPad()MENU
voidDrawTextLatex(Double_t x, Double_t y, Color_t color, TString text, Double_t tsize = 0.040000000000000001)
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
voidExportTemplates(TFile* f, const char* suffix)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
Int_tFit()
voidFixTemplateFraction(const char* template_name, Bool_t fix = kTRUE)
TStringGetAtlasLabelStatus()
TCanvas*GetCanvas() const
TStringGetCenterOfEnergyLabel()
TStringGetCentreOfEnergyLabel()
Bool_tGetDrawCMSLumiAtlasLabel()
Bool_tGetDrawData()
Bool_tGetDrawDataMCRatio()
Bool_tGetDrawDataZeroEntryErrors()
Bool_tGetDrawMCError()
Bool_tGetDrawNormError()
virtual Option_t*TObject::GetDrawOption() const
Bool_tGetDrawSignalOverlay() const
Bool_tGetDrawSignificance()
static Long_tTObject::GetDtorOnly()
Bool_tGetGroupHistograms() const
TH1F*GetHistDATA() const
TH1*GetHistogramMainPad()
TH1*GetHistogramRatioPad1()
TH1*GetHistogramRatioPad2()
virtual const char*TObject::GetIconName() const
TLegend*GetLegend()
TLegend*GetLegendLarge()
TList*GetListOfMCTemplates(const char* suffix)
Float_tGetLumiDATA()
TStringGetLuminosityLabel()
TPad*GetMainPad()
TGraphAsymmErrors*GetMCErrors()
THStack*GetMCFittedHistStack()
TList*GetMCFolders() const
THStack*GetMCHistStack() const
TList*GetMCSingleSamples()
virtual const char*TNamed::GetName() const
Int_tGetNFitTemplates()
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
static TStringGetPathInsideFile(TDirectory* dir)
TPad*GetRatioPad1()
TPad*GetRatioPad2()
HepTemplate*GetTemplate(const char* title)
Float_tGetTemplateCutEfficiency(const char* template_name)
Double_tGetTemplateFitFraction(const char* template_name)
Double_tGetTemplateFitFractionError(const char* template_name)
virtual const char*TNamed::GetTitle() const
Bool_tGetUnifyMCStack() const
virtual UInt_tTObject::GetUniqueID() const
Bool_tGetUseAtlasStyle()
Bool_tGetUseOverflowUnderflow()
const char*GetXTitle()
const char*GetYTitle()
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
HepDataMCPlot()
HepDataMCPlot(const HepDataMCPlot&)
HepDataMCPlot(const char* name, const char* title)
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tIsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
voidListFolders()
voidListSingleSamples()
voidListTemplateFractions()
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
HepDataMCPlot&operator=(const HepDataMCPlot&)
voidOptimizeBinning(Double_t zs = 15, Double_t zb = 15, Bool_t DrawStack = kFALSE)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
voidPrepareFit(Bool_t single_samples = kFALSE, Bool_t prepare_effs = kFALSE)
virtual voidPrint(Option_t* option = "") constMENU
voidPrintBinStatistics(Option_t* option = "")
virtual Int_tTObject::Read(const char* name)
voidRebin(Int_t ngroup)MENU
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidScaleMCFolder(Float_t scale, const char* mc_folder)
voidScaleMCStack(Float_t scale)MENU
voidSetAtlasLabelPos(Float_t x, Float_t y)
voidSetAtlasLabelStatus(TString AtlasLabelStatus)
voidSetAtlasStyle()
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetCenterOfMassEnergyLabel(TString CMSEnergy)
voidSetCentreOfMassEnergyLabel(TString CMSEnergy)
voidSetCMSEnergyLabelPos(Float_t x, Float_t y)
voidSetDataMCRatioCenterOne(Bool_t DataMCRatioCenter = kTRUE)TOGGLE
voidSetDrawCMSLumiAtlasLabel(Bool_t DrawCMSLumiAtlasLabel = kTRUE)
voidSetDrawData(Bool_t DrawData)TOGGLE
voidSetDrawDataErrorX(Bool_t DrawErrorX)
voidSetDrawDataMCRatio(Bool_t DrawDataMCRatio = kTRUE)TOGGLE
voidSetDrawDataZeroEntries(Bool_t flag = kTRUE)TOGGLE
voidSetDrawDataZeroEntryErrors(Bool_t DrawDataZeroEntryErrors = kTRUE)TOGGLE
voidSetDrawMCError(Bool_t DrawMCError)TOGGLE
voidSetDrawMCError(Bool_t DrawMCError, Bool_t DoRedraw)
voidSetDrawNormError(Bool_t DrawMCError)TOGGLE
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
voidSetDrawSignalOverlay(Bool_t DrawSignalOverlay)TOGGLE
voidSetDrawSignificance(Bool_t DrawSignificance = kTRUE)TOGGLE
static voidTObject::SetDtorOnly(void* obj)
voidSetGroupHistograms(Bool_t GroupHistograms)TOGGLE
voidSetHistDATA(TH1F* h, const char* label, Float_t lumiData)
voidSetLegendPos(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
voidSetLumiDATA(Float_t lumiData)
voidSetLuminosityLabel(TString Luminosity)
voidSetLuminosityLabelPos(Float_t x, Float_t y)
voidSetMCErrors(TGraphAsymmErrors* ErrorGraph)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
voidSetNdivisionsX(Int_t n = 510, Bool_t optim = kTRUE)MENU
voidSetNdivisionsY(Int_t n = 510, Bool_t optim = kTRUE)MENU
static voidTObject::SetObjectStat(Bool_t stat)
voidSetRatioHeight(Float_t ratio)
voidSetScaleOverlay(Float_t ScaleOverlay)MENU
voidSetTemplateBounds(const char* template_name, Double_t Lower, Double_t Upper)
voidSetTemplateStartValue(const char* template_name, Double_t frac, Double_t frac_err)
virtual voidTNamed::SetTitle(const char* title = "")MENU
voidSetUnifyMCStack(Bool_t UnifyMCStack)TOGGLE
voidSetUnifyMCStack(Bool_t UnifyMCStack, Bool_t DoRedraw)
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetUseAtlasStyle(Bool_t UseAtlasStyle = kTRUE)
voidSetUseOverflowUnderflow(Bool_t UseOverflowUnderflow = kTRUE)TOGGLE
voidSetXRange(Double_t xmin, Double_t xmax)MENU
voidSetXTitle(const char* title)MENU
voidSetYRange(Double_t ymin, Double_t ymax)
voidSetYRangeRatio(Double_t ymin, Double_t ymax, Int_t ratio)MENU
voidSetYTitle(const char* title)MENU
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
voidAddOverflowUnderflowBins(TH1* hist)
TH1F*CompareHistograms(TH1* hObs = 0, TH1* hExp = 0, bool neglectUncertainty = false, bool variableBinning = false, TH1* hPull = 0)
voidDrawDataMCRatio()
voidDrawNoStack(Option_t* option = "")
voidDrawSignificance()
voidDrawStack(Option_t* option = "")
Double_tpja_normal_quantile(double p)
Double_tpValuePoisson(unsigned int nObs, double nExp)
Double_tpValuePoissonError(unsigned int nObs, double E = 1, double V = 1)
Double_tpValueToSignificance(double p, bool excess = true)
voidSetColorsNoStack()
voidSetColorsStack()
TGraphAsymmErrors*SetErrors(TH1F* FromHist, Bool_t IsData, Option_t* option = "")
voidSetupAxis()
voidSetupPad()
voidSetXRange(TPad* pad, Double_t xmin, Double_t xmax)
voidSetYRange(TPad* pad, Double_t ymin, Double_t ymax)

Data Members

public:
static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::(anonymous)TObject::kOverwrite
static TObject::(anonymous)TObject::kSingleKey
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
protected:
TStringTNamed::fNameobject identifier
TStringTNamed::fTitleobject title
private:
Float_tfAddRangeExtra space added when setting axis limit (default: 1.1)
Float_tfAtlasLabelPosXX position of the Atlas label
Float_tfAtlasLabelPosYY position of the Atlas label
TStringfAtlasLabelStatusStatus label (example: "work in progress")
Float_tfCMSEnergyLabelPosXX position of the cms energy label
Float_tfCMSEnergyLabelPosYY position of the cms energy label
TCanvas*fCanvas! Pointer to the canvas (if plot is drawn in a canvas)
TStringfCenterOfMassEnergyLabelCharacter string which denotes the centre of mass energy (example: "13")
Bool_tfDataMCRatioCenterOneSwitch for drawing data/mc ratio centered at one
Bool_tfDrawCMSLumiAtlasLabelDraw Labels,if kTRUE
Bool_tfDrawDataDraw DATA histogram (default=on)
Bool_tfDrawDataErrorX! Draw x-errors for data histogram (default=on)
Bool_tfDrawDataMCRatioSwitch for drawing data/mc ratio
Bool_tfDrawDataZeroEntries! Draw markers for bins with no data
Bool_tfDrawDataZeroEntryErrorsDraw the Data error bars even for 0 data entry bins
Bool_tfDrawMCErrorDraw the total MC uncertainty on top
Bool_tfDrawNormErrorInclude the normalization error when computing the total uncertainty
Bool_tfDrawSignalOverlayFlag for drawing the signal MC (assumed to be the least entry in the MC histogram stack) as overlay instead as part of the stack
Bool_tfDrawSignificanceSwitch for drawing significance plot
Bool_tfFirstDraw! Drawing the first time ?
Bool_tfFirstLegend! Drawing the legend the first time ?
TFractionFitter*fFitter! TFractionFitter instance.
TGraphAsymmErrors*fGraphDATA! Graph for drawing data
Bool_tfGroupHistogramsGroup histograms when drawing and in the legend
TH1F*fHistDATAPointer to DATA histograms for fast access
TH1F*fHistMCTop! Pointer to top-most MC histogram of the stack
TH1*fHistogramLastInStack! Pointer to the last histogram inside the MC stack (supposed to be tha MC signal)
TH1*fHistogramMainPad! Pointer to the histogram used for drawing the axis of the stacked plot
TH1*fHistogramRatioPad1! Pointer to the histogram used for drawing the axis the first ratio plot
TH1*fHistogramRatioPad2! Pointer to the histogram used for drawing the axis second ratio plot
TLegend*fLegendLegend
TLegend*fLegendLargeLarge legend
Float_tfLumiDATALuminosity of data sample
TStringfLuminosityLabelstring which denotes the luminosity (example: "4.7 pb^{-1}")
Float_tfLuminosityLabelPosXX position of the luminosity label
Float_tfLuminosityLabelPosYY position of the luminosity label
TGraphAsymmErrors*fMCErrorsGraph for drawing the MC error band
TList*fMCFitTemplatesList of MC templates given to the fitter
THStack*fMCFittedHistStackMC HStack object for fitted MC histograms
TList*fMCFoldersList of folders to group MC samples
THStack*fMCHistStackMC HStack object
TList*fMCSingleSamplesList of single MC samples, not belonging to folder
TPad*fMainPad! Pointer to the pad of the stacked plot
Int_tfN_MCHistogramsNo. of MC histograms (used for histogram id)
Float_tfRatioHeightHeight of Ratio plots w.r.t stack plot ([0,1], default: 0.4)
TLine*fRatioLine! Line for Ratio plots indicating 0 or 1
TPad*fRatioPad1! Pointer to the pad of the first ratio plot
TPad*fRatioPad2! Pointer to the pad of the second ratio plot
Float_tfScaleOverlayScale factor of the overlay histogram
Bool_tfUnifyMCStackDraw MC stack histograms as one
Bool_tfUseAtlasStyleUse ATLAS style if it is true
Bool_tfUseOverflowUnderflowAdd overflow in last bin and underflow in first bin
Bool_tfUseShortCMSLumiLabel! Use short label for CMS + Lumi
TString*fXTitleTitle of x-axis
Bool_tfYRangeUserFlag if user defined y range should be used
Double_tfYRangeUserMaxY-axis limit (max)
Double_tfYRangeUserMinY-axis limit (min)
TString*fYTitleTitle of y-axis
static const Double_tfgFeldmanCousinsCL! Confidence level for error calculation
static const Int_tfgFeldmanCousinsMaxEntries! Separates Feldman-Cousins error
static const Color_tfgUnifyColor! Color used for unify the MC stack

Class Charts

Inheritance Chart:
TObject
TNamed
HepDataMCPlot

Function documentation

HepDataMCPlot()
 Default constructor

HepDataMCPlot(const char* name, const char* title)
 Normal constructor

~HepDataMCPlot()
 Default destructor

void SetHistDATA(TH1F* h, const char* label, Float_t lumiData)
 Set DATA histogram

void AddHistMC(TH1F* h, HepDataMCSample* sample)
 Add MC histogram to stack

void AddHistMC(TH1F* h, HepDataMCFolder* folder, HepDataMCSample* sample)
 Add grouped MC histogram to stack

 Grouped legend ?
void Draw(Option_t* option = "")
 Draw this object
 - by default, two pads are drawn, one for the stack and one for
   the significance. Best results are obtained if drawn in a
   Canvas of specified height and width (with default config)

               width      height
   No ratio:    700         500
    1 ratio:    700         633
    2 ratio:    700         765


 Options available:
   "NOSTACK" - Overlay MC histograms rather than stack them
   "NOLEG"   - Do not draw a legend
   "NORM"    - Normalize the plots to Integral of 1 in case of "nostack" option. Use the option like hist->Draw("nostack,norm").
   !!!ATTENTION!!! The histograms are scaled after the option "norm". You have to close root and restart it to get again the unnormalized plots

TString GetPathInsideFile(TDirectory* dir)
 Strip filesystem path from the full path of the given directory

void SetXTitle(const char* title)
 Set title of x-axis

void SetYTitle(const char* title)
 Set title of y-axis

void SetXRange(Double_t xmin, Double_t xmax)
 Set range of x-axis

void SetXRange(TPad* pad, Double_t xmin, Double_t xmax)
 Set range of x-axis

void SetYRange(Double_t ymin, Double_t ymax)
 Set range of y-axis

 Needs to be called before plot is drawn!

void SetYRangeRatio(Double_t ymin, Double_t ymax, Int_t ratio)
 Set range of y-axis of ratio plot

 Needs to be called before plot is drawn!

void SetNdivisionsX(Int_t n = 510, Bool_t optim = kTRUE)
 Set no. of X axis divisions

void SetNdivisionsY(Int_t n = 510, Bool_t optim = kTRUE)
 Set no. of Y axis divisions

void Browse(TBrowser* b)
 Browse plotter in TBrowser

void DrawLegend()
 Draw legend

 In case of gswitched on grouping of histograms only the group
 entries but not the entries inside the groupe will be displayed

void DrawLegendPad()
 Draw enlarged legend clone into the current pad.
 The pad is cleaned before

void SetGroupHistograms(Bool_t GroupHistograms)
 Switch grouping of histograms on or off

Int_t DistancetoPrimitive(Int_t px, Int_t py)
 Compute distance from point px,py

void SetUnifyMCStack(Bool_t UnifyMCStack)
 Draw all histograms of the MC stack

void SetUnifyMCStack(Bool_t UnifyMCStack, Bool_t DoRedraw)
 Draw all histograms of the MC stack

void SetDrawData(Bool_t DrawData)
 Draw DATA histogram

void SetDrawDataMCRatio(Bool_t DrawDataMCRatio = kTRUE)
 Draw DATA MC ratio

void SetDrawSignificance(Bool_t DrawSignificance = kTRUE)
 Draw Significance

void SetDataMCRatioCenterOne(Bool_t DataMCRatioCenter = kTRUE)
 Draw Significance

void SetDrawMCError(Bool_t DrawMCError)
 Draw MC error band

void SetDrawNormError(Bool_t DrawMCError)
 Include normalisation uncertainties in error band

void SetDrawDataZeroEntryErrors(Bool_t DrawDataZeroEntryErrors = kTRUE)
 Draw the Data error bars even for 0 data entry bins

void SetDrawDataZeroEntries(Bool_t flag = kTRUE)
 Draw the marker for bins with no data

void SetDrawMCError(Bool_t DrawMCError, Bool_t DoRedraw)
 Draw MC error band

void SetUseOverflowUnderflow(Bool_t UseOverflowUnderflow = kTRUE)
 Add overflow to last bin and underflow to first bin

TGraphAsymmErrors* SetErrors(TH1F* FromHist, Bool_t IsData, Option_t* option = "")
 Internal helper function.

 Creates the graph for drawing (asymmetric) errors. For large
 entries numbers the errors are taken from the given histogram
 (as well as the xy-positions). For low numbers (<33) the errors
 are estimated by the FeldmanCousins method.

void ComputeStatisticalUncertainty(TH1F* h, Int_t bin, Double_t& up, Double_t& lo)
 Computes upper and lower errors for given number of events in
 bin of histogram h.
 For low numbers (<33) the errors
 are estimated by the FeldmanCousins method.

void ComputeNormUncertainty(Int_t bin, Double_t& up, Double_t& lo)
 Compute the normalization uncertainty per bin

 For each grouped template an uncertainty must be provided

void PrepareFit(Bool_t single_samples = kFALSE, Bool_t prepare_effs = kFALSE)
 Prepares fit using TFractionFitter

 HepTemplate objects are created from the list of MC samples.
 Per default, sample groups are treated as one template.
 Set single_samples to TRUE, if you want to fit each single
 sample.
 If prepare_effs is set to TRUE, cut efficiencies are calculated
 and assigned to the template objects. For that, it is assumed
 that the number of entries in the fit histogram is equal to the
 number of events after all cuts applied. The denominator for the
 efficiencies is taken from the event info histogram. In case of
 folders a weighted sum is calculated. The efficiencies are probably
 needed to calculate cross sections from the fit results.

Int_t Fit()
 Perform the fit

 Create TFractionFitter instance. Start values and constraints
 given to template objects are set and the fit is started.
 Returns the return value from TFractionFitter.

void DrawFit(Option_t* option = "")
 Draw fitted MC histogram stack together with data

void ListFolders()
void ListSingleSamples()
void ListTemplateFractions()
Double_t GetTemplateFitFraction(const char* template_name)
 Get template fraction for specific template

Double_t GetTemplateFitFractionError(const char* template_name)
 Get template fraction error for specific template

Float_t GetTemplateCutEfficiency(const char* template_name)
 Get template cut efficiency for specific template

void SetTemplateBounds(const char* template_name, Double_t Lower, Double_t Upper)
void SetTemplateStartValue(const char* template_name, Double_t frac, Double_t frac_err)
void FixTemplateFraction(const char* template_name, Bool_t fix = kTRUE)
void Rebin(Int_t ngroup)
 Performs a rebinning of the stacked plot.
 Rebinning is applied to all histograms
 (data and MC).

void ScaleMCStack(Float_t scale)
 Scales the complete MC hist stack by the given scale

void ScaleMCFolder(Float_t scale, const char* mc_folder)
 Scales only a group of histograms by the given scale

void DrawATLASLabel(Double_t x, Double_t y, TString text, Color_t color = 1)
 Draw ATLAS + label

 Functions taken from official ATLAS style

 Adjust position in case user adds more space to the right margin
 x += 0.05 - gStyle->GetPadRightMargin();
void DrawTextLatex(Double_t x, Double_t y, Color_t color, TString text, Double_t tsize = 0.040000000000000001)
 Draw latex text on given position

 Functions taken from official ATLAS style

void SetAtlasStyle()
 set current style to ATLASstyle

void Print(Option_t* option = "") const
 Print event yield table

 Options available:
   "SPLIT" - Print table for all samples. If this option is
             not given, only the grouped sample will be
             listed (default).

void AddOverflowUnderflowBins(TH1* hist)
 Add overflow/underflow bin to first/last bin

void DrawNoStack(Option_t* option = "")

 Draw MC histograms in overlay mode

void SetColorsNoStack()
 Setup color scheme for non-stacked mode

void ExportTemplates(TFile* f, const char* suffix)
 Saves group-histograms and single sample histograms in a
 given file.

 The name of the histograms consists of the folder/sample name
 and a suffix, e.g. "ttbar_jesup"

TList* GetListOfMCTemplates(const char* suffix)
 Saves group-histograms and single sample histograms and
 returns a list of histograms

 The name of the histograms consists of the folder/sample name
 and a suffix, e.g. "ttbar_jesup"

void PrintBinStatistics(Option_t* option = "")
 Print S/B and S/sqrt(B) for all bins

void DrawStack(Option_t* option = "")

 Draw MC histograms in stacked mode


 In case of stacked histogram mode draw the histograms in
 filled mode with their fill color. Use the histogram line
 colour of the current style for drawing the histogram
 outline
void SetColorsStack()
 Setup colour scheme for stacked mode

 In case of grouped drawing mode set the line and fill
 attributes of the grouped histograms first. The histograms
 within one group get all the same colour for filling and the
 histogram line so that they appear as a single histogram
void SetupPad()
 Setup Pads for drawing the stack and ratio-plots

void DrawDataMCRatio()
 Draw Data/MC ratio

 The data/mc ratio is plotted with dotted markers and their
 uncertainty corresponds to the relative uncertainty from data.
 Furthermore the uncertainty on the prediction (i.e. MC/MC) is
 shown as shaded uncertainty band.

void SetupAxis()
 Setup axis labels and axis range

 Title size needs to be rescaled when using ratio plots. Size
 depends whether axis is redrawn in the ratio pad or main pad.

void DrawSignificance()
 Draw Significance

TH1F* CompareHistograms(TH1* hObs = 0, TH1* hExp = 0, bool neglectUncertainty = false, bool variableBinning = false, TH1* hPull = 0)
 Given two ROOT histograms (with the same binning!) containing the
 observed and expected counts, create and return a histogram showing
 the significance of their bin-to-bin discrepancies.

 If the histogram representing the expectation (second input
 parameter) has non-zero bin "errors", these are considered the
 standard deviations representing the full uncertainty and the
 significance is computed accordingly, unless this is disabled (third
 parameter).

 The last input pointer is the pull histogram, which is filled with
 all z-values, without discarding the bins for which the p-value is
 larger than 0.5: in case of ideal match, the pulls follow a standard
 normal distribution.  A typical binnin for the pulls is from -5 to
 +5 with 20 bins.



 Code from
 "Plotting the Differences Between Data and Expectation"
 by Georgios Choudalakis and Diego Casadei
 Eur. Phys. J. Plus 127 (2012) 25
 http://dx.doi.org/10.1140/epjp/i2012-12025-y
 (http://arxiv.org/abs/1111.2062)


 This code is covered by the GNU General Public License:
 http://www.gnu.org/licenses/gpl.html

 Diego Casadei <casadei@cern.ch> 7 Dec 2011

Double_t pja_normal_quantile(double p)

 Normal quantile computed following Peter John Acklam's
 pseudo-code algorithm for rational approximation
 (pjacklam@online.no)
 http://home.online.no/~pjacklam/notes/invnorm

 The algorithm below assumes p is the input and x is the output.

  Coefficients in rational approximations.
  a(1) <- -3.969683028665376e+01
  a(2) <-  2.209460984245205e+02
  a(3) <- -2.759285104469687e+02
  a(4) <-  1.383577518672690e+02
  a(5) <- -3.066479806614716e+01
  a(6) <-  2.506628277459239e+00

  b(1) <- -5.447609879822406e+01
  b(2) <-  1.615858368580409e+02
  b(3) <- -1.556989798598866e+02
  b(4) <-  6.680131188771972e+01
  b(5) <- -1.328068155288572e+01

  c(1) <- -7.784894002430293e-03
  c(2) <- -3.223964580411365e-01
  c(3) <- -2.400758277161838e+00
  c(4) <- -2.549732539343734e+00
  c(5) <-  4.374664141464968e+00
  c(6) <-  2.938163982698783e+00

  d(1) <-  7.784695709041462e-03
  d(2) <-  3.224671290700398e-01
  d(3) <-  2.445134137142996e+00
  d(4) <-  3.754408661907416e+00

  Define break-points.

  p_low  <- 0.02425
  p_high <- 1 - p_low

  Rational approximation for lower region.

  if 0 < p < p_low
     q <- sqrt(-2*log(p))
x <- (((((c(1)*q+c(2))*q+c(3))*q+c(4))*q+c(5))*q+c(6))
           ((((d(1)*q+d(2))*q+d(3))*q+d(4))*q+1)
  endif

  Rational approximation for central region.

  if p_low <= p <= p_high
     q <- p - 0.5
     r <- q*q
x <- (((((a(1)*r+a(2))*r+a(3))*r+a(4))*r+a(5))*r+a(6))*q
          (((((b(1)*r+b(2))*r+b(3))*r+b(4))*r+b(5))*r+1)
  endif

  Rational approximation for upper region.

  if p_high < p < 1
     q <- sqrt(-2*log(1-p))
x <- -(((((c(1)*q+c(2))*q+c(3))*q+c(4))*q+c(5))*q+c(6))
            ((((d(1)*q+d(2))*q+d(3))*q+d(4))*q+1)
  endif

 The absolute value of the relative error (x_approx - x)/x is
 <= 1.15e-9 for all input values p which can be represented in
 IEEE double precision arithmetic.




 Code from
 "Plotting the Differences Between Data and Expectation"
 by Georgios Choudalakis and Diego Casadei
 Eur. Phys. J. Plus 127 (2012) 25
 http://dx.doi.org/10.1140/epjp/i2012-12025-y
 (http://arxiv.org/abs/1111.2062)


 This code is covered by the GNU General Public License:
 http://www.gnu.org/licenses/gpl.html


Double_t pValuePoisson(unsigned int nObs, double nExp)
 p-value for Poisson distribution, no uncertainty on the parameter


 Diego Casadei <casadei@cern.ch>   Oct 2011
 Last update: 4 Nov 2011 (using incomplete Gamma from ROOT)


 Consider Poi(k|nExp) and compute the p-value which corresponds to
 the observation of nObs counts.

 When nObs > nExp there is an excess of observed events and

   p-value = P(n>=nObs|nExp) = \sum_{n=nObs}^{\infty} Poi(n|nExp)
           = 1 - \sum_{n=0}^{nObs-1} Poi(n|nExp)
           = 1 - e^{-nExp} \sum_{n=0}^{nObs-1} nExp^n / n!

 Otherwise (nObs <= nExp) there is a deficit and

   p-value = P(n<=nObs|nExp) = \sum_{n=0}^{nObs} Poi(n|nExp)
           = e^{-nExp} \sum_{n=0}^{nObs} nExp^n / n!



 Code from
 "Plotting the Differences Between Data and Expectation"
 by Georgios Choudalakis and Diego Casadei
 Eur. Phys. J. Plus 127 (2012) 25
 http://dx.doi.org/10.1140/epjp/i2012-12025-y
 (http://arxiv.org/abs/1111.2062)


 This code is covered by the GNU General Public License:
 http://www.gnu.org/licenses/gpl.html

Double_t pValuePoissonError(unsigned int nObs, double E = 1, double V = 1)
  p-value for Poisson distribution when there is uncertainty on the
 parameter



 Diego Casadei <casadei@cern.ch>  6 Nov 2011
 Last update: 3 Mar 2012 (logarithms used only for big numbers)



 Consider Poi(k|nExp) and compute the p-value which corresponds to
 the observation of nObs counts, in the case of uncertain nExp whose
 variance is provided.

 The prior for nExp is a Gamma density which matches the expectation
 and variance provided as input.  The marginal model is provided by
 the Poisson-Gamma mixture, which is used to compute the p-value.

 Gamma density: the parameters are
  * a = shape param  [dimensionless]
  * b = rate param   [dimension: inverse of x]

   nExp ~ Ga(x|a,b) = [b^a/Gamma(a)] x^{a-1} exp(-bx)

 One has E[x] = a/b and V[x] = a/b^2 hence
  * b = E/V
  * a = E*b

 The integral of Poi(n|x) Ga(x|a,b) over x gives the (marginal)
 probability of observing n counts as

               b^a [Gamma(n+a) / Gamma(a)]
   P(n|a,b) = -----------------------------
                      n! (1+b)^{n+a}

 When nObs > nExp there is an excess of observed events and

   p-value = P(n>=nObs) = \sum_{n=nObs}^{\infty} P(n)
           = 1 - \sum_{n=0}^{nObs-1} P(n)

 Otherwise (nObs <= nExp) there is a deficit and

   p-value = P(n<=nObs) = \sum_{n=0}^{nObs} P(n)

 To compute the sum, we use the following recurrent relation:

   P(n=0) = [b/(1+b)]^a
   P(n=1) = [b/(1+b)]^a a/(1+b) = P(n=0) a/(1+b)
   P(n=2) = [b/(1+b)]^a a/(1+b) (a+1)/[2(1+b)] = P(n=1) (a+1)/[2(1+b)]
   ...        ...
   P(n=k) = P(n=k-1) (a+k-1) / [k(1+b)]

 and to avoid rounding errors, we work with logarithms.


 Code from
 "Plotting the Differences Between Data and Expectation"
 by Georgios Choudalakis and Diego Casadei
 Eur. Phys. J. Plus 127 (2012) 25
 http://dx.doi.org/10.1140/epjp/i2012-12025-y
 (http://arxiv.org/abs/1111.2062)


 This code is covered by the GNU General Public License:
 http://www.gnu.org/licenses/gpl.html

Double_t pValueToSignificance(double p, bool excess = true)
 Convert a p-value into a right-tail normal significance, i.e. into
 the number of Gaussian standard deviations which correspond to it.

 Code from
 "Plotting the Differences Between Data and Expectation"
 by Georgios Choudalakis and Diego Casadei
 Eur. Phys. J. Plus 127 (2012) 25
 http://dx.doi.org/10.1140/epjp/i2012-12025-y
 (http://arxiv.org/abs/1111.2062)


 This code is covered by the GNU General Public License:
 http://www.gnu.org/licenses/gpl.html

void OptimizeBinning(Double_t zs = 15, Double_t zb = 15, Bool_t DrawStack = kFALSE)
 Optimize binning for given HepDataMCPlot
 (this plot should have many bin (~100 - ~1000)

 To optimize the binning, the quantity Z_ij


Z(i,j) = z_{S}*#frac{n_{S}(i,j)}{N_S} + z_{B}*#frac{n_{B}(i,j)}{N_B}

 with


n_{S(B)}(i,j) = #text{Number of signal (bkg) events with indices between i and j}

 is computed. z_{S} and z_{B} are parameters for adjusting the number of bins.

 The binning is determined in a iterative procedure. Starting with
 i = j = k, #text{with} k_{last bin} , then
  1) Compute Z(i,j)
  2) Check if Z(i,j) > 1 && #sqrt{n_B(i,j)} < 0.1
  2.a) Condition is true  -> Merge all bins from i to j
                             Set j = i-1 and go back to 1)
  2.b) Condition is false -> Reduce i by one and go back to 1).

  Repeat this until i == 1.

void SetScaleOverlay(Float_t ScaleOverlay)
 Scale factor of the overlay histogram (see
 SetDrawSignalOverlay())

void SetDrawSignalOverlay(Bool_t DrawSignalOverlay)
 Flag for drawing the signal MC (assumed to be the least entry
 in the MC histogram stack) as overlay instead as part of the
 stack

HepDataMCPlot()
Bool_t IsFolder() const
{ return kFALSE; }
void SetYRange(Double_t ymin, Double_t ymax)
Bool_t GetGroupHistograms() const
{ return fGroupHistograms; }
Bool_t GetUnifyMCStack() const
{ return fUnifyMCStack; }
Bool_t GetDrawMCError()
{ return fDrawMCError; }
Bool_t GetDrawNormError()
{ return fDrawNormError; }
Bool_t GetDrawData()
{ return fDrawData; }
Bool_t GetUseOverflowUnderflow()
Bool_t GetDrawDataZeroEntryErrors()
Bool_t GetDrawDataMCRatio()
Bool_t GetDrawSignificance()
void AddMCFolder(HepDataMCFolder* folder)
 Add MC folder for grouping histograms
void AddMCSingleSample(HepDataMCSample* sample)
 Add MC single sample
void SetMCErrors(TGraphAsymmErrors* ErrorGraph)
void SetLumiDATA(Float_t lumiData)
TList* GetMCFolders() const
{ return fMCFolders; }
TList* GetMCSingleSamples()
{ return fMCSingleSamples; }
TH1F* GetHistDATA() const
{ return fHistDATA; }
Float_t GetLumiDATA()
{ return fLumiDATA; }
THStack* GetMCHistStack() const
{ return fMCHistStack; }
TLegend* GetLegend()
{ return fLegend; }
TLegend* GetLegendLarge()
{ return fLegendLarge; }
const char* GetXTitle()
{ return fXTitle->Data(); }
const char* GetYTitle()
{ return fYTitle->Data(); }
TGraphAsymmErrors* GetMCErrors()
{ return fMCErrors; }
HepTemplate* GetTemplate(const char* title)
THStack* GetMCFittedHistStack()
{ return fMCFittedHistStack; }
Int_t GetNFitTemplates()
void SetUseAtlasStyle(Bool_t UseAtlasStyle = kTRUE)
function to design plot in ATLAS style
Bool_t GetUseAtlasStyle()
{ return fUseAtlasStyle;}
void SetDrawCMSLumiAtlasLabel(Bool_t DrawCMSLumiAtlasLabel = kTRUE)
Bool_t GetDrawCMSLumiAtlasLabel()
void SetAtlasLabelStatus(TString AtlasLabelStatus)
TString GetAtlasLabelStatus()
void SetCentreOfMassEnergyLabel(TString CMSEnergy)
void SetCenterOfMassEnergyLabel(TString CMSEnergy)
TString GetCentreOfEnergyLabel()
TString GetCenterOfEnergyLabel()
void SetLuminosityLabel(TString Luminosity)
TString GetLuminosityLabel()
{ return fLuminosityLabel;}
void SetDrawDataErrorX(Bool_t DrawErrorX)
void SetAtlasLabelPos(Float_t x, Float_t y)
void SetLuminosityLabelPos(Float_t x, Float_t y)
void SetCMSEnergyLabelPos(Float_t x, Float_t y)
void SetLegendPos(Float_t x1, Float_t y1, Float_t x2, Float_t y2)
void SetRatioHeight(Float_t ratio)
{ fRatioHeight = ratio; }
TCanvas * GetCanvas() const
{ return fCanvas; }
TPad* GetRatioPad1()
{ return fRatioPad1; }
TPad* GetRatioPad2()
{ return fRatioPad2; }
TPad* GetMainPad()
{ return fMainPad; }
TH1* GetHistogramMainPad()
{ return fHistogramMainPad; }
TH1* GetHistogramRatioPad1()
TH1* GetHistogramRatioPad2()
Bool_t GetDrawSignalOverlay() const
 Flag for drawing the signal MC (assumed to be the least
 entry in the MC histogram stack) as overlay instead as part of the
 stack