DATA/MC Histogram Plotter Task for creating and plotting lists of stacked or overlayed MC histograms with DATA on top * The same binning for all histograms is required * Until now only 1d histograms are supported The plots are made from input files containing histograms for the various MC samples (signal + bckg) as well as DATA. Here, it is assumed that the directory and histogram structure is the same for each input file. The samples will be normalized w.r.t. the given luminosities The list of plots can be exported in two ways (combination possible): (1) All plots are stored in a single .root file. Here, the directory structure of the input files is preserved. (2) Export to various graphical formats like eps, ps, pdf, png or C macro. Since the number of plots is usually high, the directory structure of the input files is mapped onto the file system and the image files will be stored in their respective directories. In case of an already existing version of the directory tree a backup copy is created first under the name $ExportDir_backup where $ExportDir indicates the name of the export directory given by SetExportDir(). Samples can be combined in groups for better drawing. See the examples below. The way of drawing can be changed afterwards via HepDataMCPlot::SetGroupHistograms(). Legend: The default behaviour is not to draw a legend inside the plots since the number of samples is nornmally high and therefore the legend would fit badly into the pad. (However, this behaviour can be changed with the help of the SetLegend() member function, accessible alspo from the TBrowser) It is recommended to draw the legend in an additional pad. In case of an exported .root file this is easily possible by using the HepDataMCPlot::DrawLegendPad() function (can also be used from the TBrowser). In case of exported graphical files an additional file containing only the legend is created in toplevel export directory under the name Legend.eps etc. Example 1 (ungrouped histograms): { HepDataMCPlotter *pl = new HepDataMCPlotter("single-top", "Single-Top Analysis"); pl->SetExportDir("~/atlas/APlusPlus/libSingleTop/hist/tChannelAnalysis/test"); pl->SetLumiDATA(100.); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/tchannel_enu.root", "MC single-top t-channel e#nu", 120., kOrange); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/tchannel_munu.root", "MC single-top t-channel #mu#nu", 130., kRed); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/tchannel_taunu.root", "MC single-top t-channel #tau#nu", 110., kMagenta); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/schannel_enu.root", "MC single-top s-channel e#nu", 120., kBlue); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/schannel_muunu.root", "MC single-top s-channel #mu#nu", 120., kCyan); pl->AddMCSample("$LIBSINGLETOP/hist/tChannelAnalysis/Wtproduction.root", "MC single-top Wt production", 90., kGreen); gROOT->GetListOfBrowsables()->Add(pl); new TBrowser; } Example 2 (grouped histograms): { HepDataMCPlotter *pl_test = new HepDataMCPlotter("DATA-MC plotter", "Create all Data-MC plots"); pl_test->SetWorkingDir("$LIBSINGLETOP/hist/test/plots_datamc"); pl_test->SetLumiDATA(100.); // ttbar pl_test->AddMCFolder("ttbar", "ttbar lnln", kRed); (pl_test->AddMCSample("ttbar", "$LIBSINGLETOP/hist/test/ttbar_lnln_np0_hists.root", "MC ttbar, Np0", 160., kRed-4))->SetLumi(160.); (pl_test->AddMCSample("ttbar", "$LIBSINGLETOP/hist/test/ttbar_lnln_np1_hists.root", "MC ttbar, Np1", 180., kRed-7))->SetLumi(180.); (pl_test->AddMCSample("ttbar", "$LIBSINGLETOP/hist/test/ttbar_lnln_np2_hists.root", "MC ttbar, Np2", 150., kRed-9))->SetLumi(150.); // Z+jets pl_test->AddMCFolder("Zjets", "Z+jets", kBlue); (pl_test->AddMCSample("Zjets", "$LIBSINGLETOP/hist/test/zee_np0_hists.root", "MC Zee, Np0", 70., kBlue-4))->SetLumi(70.); (pl_test->AddMCSample("Zjets", "$LIBSINGLETOP/hist/test/zee_np1_hists.root", "MC Zee, Np1", 60., kBlue-7))->SetLumi(60.); (pl_test->AddMCSample("Zjets", "$LIBSINGLETOP/hist/test/zmumu_np0_hists.root", "MC Zmumu, Np0", 90., kBlue-9))->SetLumi(90.); (pl_test->AddMCSample("Zjets", "$LIBSINGLETOP/hist/test/zmumu_np1_hists.root", "MC Zmumu, Np1", 110., kBlue-10))->SetLumi(110.); (pl_test->AddMCSample("Zjets", "$LIBSINGLETOP/hist/test/zmumu_np2_hists.root", "MC Zmumu, Np2", 120., kBlue-8))->SetLumi(120.); } Author: Oliver Maria Kind <mailto: kind@mail.desy.de> Update: $Id: HepDataMCPlotter.cxx,v 1.32 2017/07/28 09:34:11 kaphle Exp $ Copyright: 2009 (C) Oliver Maria Kind
virtual | ~HepDataMCPlotter() |
virtual void | TTask::Abort()MENU |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TTask::Add(TTask* task) |
void | AddDataFile(const char* path, const char* label)MENU |
void | AddMCFolder(const char* name, const char* title, Color_t color) |
HepDataMCSample* | AddMCSample(const char* path, const char* label, Color_t color)MENU |
HepDataMCSample* | AddMCSample(const char* path, const char* label, Float_t xsec, Color_t color)MENU |
HepDataMCSample* | AddMCSample(const char* folder_name, const char* path, const char* label, Float_t xsec, Color_t color)MENU |
HepDataMCSample* | AddMCSample(HepDataMCFolder* folder, const char* path, const char* label, Float_t xsec, Color_t color) |
HepDataMCSample* | AddMCSample(const char* path, const char* label, Color_t color, Style_t line_style, Width_t line_width, Style_t fill_style) |
void | AddNtuplePlotCmd(const char* TreeName, const char* VarExp, const char* Selection, const char* PlotName, const char* PlotTitle, Int_t Nbins, Double_t Xlow, Double_t Xup, const char* XTitle, const char* YTitle) |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TTask::Browse(TBrowser* b) |
HepDataMCPlot* | BuildNtuplePlot(HepNtuplePlotCmd* cmd) const |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TTask::CleanTasks() |
virtual void | TTask::Clear(Option_t* option = "") |
virtual TObject* | TNamed::Clone(const char* newname = "") const |
virtual Int_t | TNamed::Compare(const TObject* obj) const |
virtual void | TTask::Continue()MENU |
virtual void | TNamed::Copy(TObject& named) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | Exec(Option_t* option = "") |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TTask::ExecuteTask(Option_t* option = "0")MENU |
virtual void | TTask::ExecuteTasks(Option_t* option) |
void | Export(HepDataMCPlot* Plot, TNamed* PlotName) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual void | TNamed::FillBuffer(char*& buffer) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
TString | GetAtlasLabelStatus() |
Int_t | TTask::GetBreakin() const |
Int_t | TTask::GetBreakout() const |
TString | GetCenterOfMassEnergyLabel() |
Bool_t | GetDrawCMSLumiAtlasLabel() |
Bool_t | GetDrawDataZeroEntryErrors() |
Bool_t | GetDrawLegend() |
Bool_t | GetDrawMCError() |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
Bool_t | GetExportC() |
Bool_t | GetExportEPS() |
Bool_t | GetExportPDF() |
Bool_t | GetExportPNG() |
Bool_t | GetExportPS() |
Bool_t | GetExportROOT() |
Bool_t | GetGroupHistograms() |
virtual const char* | TObject::GetIconName() const |
TList* | GetListOfPlots() |
TList* | TTask::GetListOfTasks() const |
Bool_t | GetLogyaxis() |
TString | GetLuminosityLabel() |
virtual const char* | TNamed::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual const char* | TNamed::GetTitle() const |
Bool_t | GetUnifyMCStack() |
virtual UInt_t | TObject::GetUniqueID() const |
Bool_t | GetUseAtlasStyle() |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TNamed::Hash() const |
HepDataMCPlotter(const HepDataMCPlotter&) | |
HepDataMCPlotter(const char* name, const char* title) | |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
void | InitInput() |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
Bool_t | TTask::IsActive() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TTask::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TNamed::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TTask::ls(Option_t* option = "*") constMENU |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
void | TObject::operator delete(void* ptr) |
void | TObject::operator delete(void* ptr, void* vp) |
void | TObject::operator delete[](void* ptr) |
void | TObject::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) |
HepDataMCPlotter& | operator=(const HepDataMCPlotter&) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TNamed::Print(Option_t* option = "") const |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TTask::SetActive(Bool_t active = kTRUE)TOGGLE |
void | SetAtlasLabelStatus(TString AtlasLabelStatus) |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
void | TTask::SetBreakin(Int_t breakin = 1)TOGGLE |
void | TTask::SetBreakout(Int_t breakout = 1)TOGGLE |
void | SetCenterOfMassEnergyLabel(TString CenterOfMassEnergy) |
void | SetDrawCMSLumiAtlasLabel(Bool_t DrawCMSLumiAtlasLabel = kTRUE) |
void | SetDrawDataZeroEntryErrors(Bool_t DrawDataZeroEntryErrors = kTRUE)TOGGLE |
void | SetDrawLegend(Bool_t DrawLegend)TOGGLE |
void | SetDrawMCError(Bool_t DrawMCError)TOGGLE |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
void | SetDrawSignalOverlay(Bool_t status) |
static void | TObject::SetDtorOnly(void* obj) |
void | SetExportC(Bool_t ExportC)TOGGLE |
void | SetExportDir(const char* dir) |
void | SetExportEPS(Bool_t ExportEPS)TOGGLE |
void | SetExportPDF(Bool_t ExportPDF)TOGGLE |
void | SetExportPNG(Bool_t ExportPNG)TOGGLE |
void | SetExportPS(Bool_t ExportPS)TOGGLE |
void | SetExportROOT(Bool_t ExportROOT)TOGGLE |
void | SetGroupHistograms(Bool_t GroupHistograms)TOGGLE |
void | SetLogyaxis(Bool_t Logyaxis)TOGGLE |
void | SetLumiDATA(Float_t lumi) |
void | SetLuminosityLabel(TString Luminosity) |
virtual void | TNamed::SetName(const char* name)MENU |
virtual void | TNamed::SetNameTitle(const char* name, const char* title) |
static void | TObject::SetObjectStat(Bool_t stat) |
void | SetScaleOverlay(Float_t scale) |
virtual void | TNamed::SetTitle(const char* title = "")MENU |
void | SetUnifyMCStack(Bool_t UnifyMCStack)TOGGLE |
virtual void | TObject::SetUniqueID(UInt_t uid) |
void | SetUseAtlasStyle(Bool_t UseAtlasStyle = kTRUE) |
void | SetUseOverflowUnderflow(Bool_t status) |
void | SetWorkingDir(const char* dir) |
virtual void | ShowMembers(TMemberInspector& insp) const |
virtual Int_t | TNamed::Sizeof() const |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | TObject::MakeZombie() |
void | AddHistMC(HepDataMCPlot* plot, TH1F* h, HepDataMCSample* mc_sample, HepDataMCFolder* folder = 0, Float_t LumiScale = 1.) const |
void | BuildListOfPlots() |
HepDataMCPlot* | BuildPlot(TNamed* PlotName) |
HepDataMCPlot* | CreatePlotFromHist(TH1F* h) const |
TH1F* | GetHistFromFile(TFile* f, TNamed* PlotName) |
TDirectory* | MkDirWithParents(TFile* f, const char* dir) |
void | Normalize(TH1F& h, HepDataMCSample* sample, Float_t LumiScale = 1.) const |
void | ReadHistogramsFromDir(TDirectory* dir) |
static TObject::(anonymous) | TObject::kBitMask | |
static TObject::EStatusBits | TObject::kCanDelete | |
static TObject::EStatusBits | TObject::kCannotPick | |
static TObject::EStatusBits | TObject::kHasUUID | |
static TObject::EStatusBits | TObject::kInvalidObject | |
static TObject::(anonymous) | TObject::kIsOnHeap | |
static TObject::EStatusBits | TObject::kIsReferenced | |
static TObject::EStatusBits | TObject::kMustCleanup | |
static TObject::EStatusBits | TObject::kNoContextMenu | |
static TObject::(anonymous) | TObject::kNotDeleted | |
static TObject::EStatusBits | TObject::kObjInCanvas | |
static TObject::(anonymous) | TObject::kOverwrite | |
static TObject::(anonymous) | TObject::kSingleKey | |
static TObject::(anonymous) | TObject::kWriteDelete | |
static TObject::(anonymous) | TObject::kZombie |
Bool_t | TTask::fActive | true if task is active |
Int_t | TTask::fBreakin | =1 if a break point set at task extry |
Int_t | TTask::fBreakout | =1 if a break point set at task exit |
Bool_t | TTask::fHasExecuted | True if task has executed |
TString | TNamed::fName | object identifier |
TString | TTask::fOption | Option specified in ExecuteTask |
TList* | TTask::fTasks | List of Tasks |
TString | TNamed::fTitle | object title |
static TTask* | TTask::fgBeginTask | pointer to task initiator |
static TTask* | TTask::fgBreakPoint | pointer to current break point |
TString | fAtlasLabelStatus | label in plot after "ATLAS" |
TString | fCenterOfMassEnergyLabel | Center of mass energy label |
Bool_t | fDrawCMSLumiAtlasLabel | Draw labels |
Bool_t | fDrawDataZeroEntryErrors | Draw the DATA error bars even for 0 data entry bins |
Bool_t | fDrawLegend | Draw a legend inside all plots |
Bool_t | fDrawMCError | Draw the total MC uncertainty on top |
Bool_t | fDrawSignalOverlay | 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 (default = false) |
Bool_t | fExportC | Export all plots to C files |
TString* | fExportDir | Working directory |
Bool_t | fExportEPS | Export all plots to EPS files |
Bool_t | fExportPDF | Export all plots to PDF files |
Bool_t | fExportPNG | Export all plots to PNG files |
Bool_t | fExportPS | Export all plots to PS files |
Bool_t | fExportROOT | Export all plots to a ROOT file |
Bool_t | fGroupHistograms | Group histograms when drawing and in the legend |
TList* | fListOfDataFileNames | List of data file names |
TList* | fListOfDataFiles | List of data files pointers |
TList* | fListOfInFiles | List of all input files |
TList* | fListOfPlots | List of DataMC plots |
Bool_t | fLogyaxis | Plot y axis in logarithmic scale |
Float_t | fLumiDATA | Integrated DATA luminosity (used for over-all normalisation) |
TString | fLuminosityLabel | Luminosity label |
TList* | fMCFolders | List of folders to group MC samples |
TList* | fMCSamples | List of MC samples (input filenames and drawing attributes) |
TList* | fMCSingleSamples | List of MC single samples, not belonging to folder (input filenames and drawing attributes) |
TList* | fNtuplePlotCmds | List of ntuple draw commands used by the plotter tasks |
TFile* | fOutputRootFile | Output file containing all plots |
Float_t | fScaleOverlay | Scale factor of the overlay histogram ( default = 1. ) |
Bool_t | fUnifyMCStack | Draw MC stack histograms as a single histogram |
Bool_t | fUseAtlasStyle | Use ATLAS style |
Bool_t | fUseOverflowUnderflow | Flag for plotter (default = false) |
Inheritance Chart: | |||||||||||||||||
|
Add file to the list of data files. The label is used for the legend
Add MC sample given by the path to its histogram file. The label will be used in the corresponding legend entry. The line and fill attributes are used for drawing the histograms in stacked and overlay mode, resp.
Same as above but line style and width, and fill style are set to the defaults given by the current style
Same as above but line style and width, and fill style are set to the defaults given by the current style
Add an MC sample given by the path to its histogram file to the given folder. The folder can be used to group histograms in order to make the plot and its legend better readable, in particluar when dealing with many samples. The given label will be used in the corresponding legend entry. The line and fill attributes are used for drawing the histograms in stacked and overlay mode, resp. The given x-section is used for the luminosity weighting when drawing the stack of all samples.
Add an MC sample given by the path to its histogram file to the given folder. The folder can be used to group histograms in order to make the plot and its legend better readable, in particluar when dealing with many samples. The given label will be used in the corresponding legend entry. The line and fill attributes are used for drawing the histograms in stacked and overlay mode, resp. The given x-section is used for the luminosity weighting when drawing the stack of all samples. Get folder
Open all input files for reading and add them to the list of input files. In case single HepDataMCPlots are being produced instead of using HepDataMCPlotter::Exec() this routine must be called first explicitly.
Execute task The plot building process is performed in two steps: First a list of plots is created by inspecting all keys in the input files. In the next step for each list entry a plot is created and all existing histograms are added. The directory structure is preserved. The two steps are needed because only one plot can be kept in memory at a time. Otherwise one would have to keep all plots in memory in parallel which would blow the available RAM.
Loop over all histograms in the DATA file (if exisiting) or the 1st MC file otherwise and create a list containg the names of all plots
Read all histograms from given directory and all its sub-directories
Create plot and use the given hisotgram for setting name, title and axis titles of the plot
Add MC histogram to given plot. The histogram ist normalized. In case of non-existing folder the zero pointer is used (default).
Export the given plot to the .root output file and to the file system in various graphical formats
Create the given directoy and all of its parents if necessary in the given file
Draw the Data error bars even for 0 data entry bins
Add folder for grouping histograms Line and fill style are set to the defaults given by the current style
Weight given histogram with the lumi of the given MC sample and normalize it to DATA luminosity. LumiScale is an additional factor which can be given to the MC lumi (default = 1)
Set 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
Set scale factor of the overlay histogram (see SetDrawSignalOverlay())