A++ » INC » AtlHistogramTool

class AtlHistogramTool: public AtlAnalysisTool



Histogram tool

The tool allows to book and fill many histograms inside an analysis in a transparent and efficient way.

For each tool a folder with the name of the tool is created inside the output file of the analysis job. The histograms can also be managed in subfolders simply by prepending the path in the hisotgram name (see the example below). The subfolders are created automatically if they do not exist.

Example:

MyAnalysis.h:
 private:
   AtlHistogramTool *fHistograms1;   // List 1
   AtlHistogramTool *fHistograms2;   // List 2
   ...
 
MyAnalysis::BookHistograms():
 // Pre-tagged histograms
 fHistograms1 = new AtlHistogramTool("PreTag",
                                     "Pre-tagged histograms");
 AddTool(fHistograms1)
 // Leading lepton Pt
 fHistograms1->Add("leptons/h_lep1_Pt", "Leading Lepton Pt", 40, 0., 200.,
                   "Leading lepton p_{T} [GeV]", "Events");
 // Leading lepton eta
 fHistograms1->Add("leptons/h_lep1_Eta", "Leading Lepton Eta",
                   50, -2.5, 2.5, "Leading lepton #eta", "Events");
 // Leading electron Pt
 fHistograms1->Add("leptons/el/h_el1_Pt", "Leading Electron Pt", 40, 0., 200.,
                   "Leading electron p_{T} [GeV]", "Events");
 ...
 // b-tagged histograms
 fHistograms2 = new AtlHistogramTool("bTag",
                                     "b-tagged histograms");
 AddTool(fHistograms2)
 // Leading jet Pt
 fHistograms2->Add("jets/h_jet1_Pt", "Leading Jet Pt",
                   40, 0., 200., "Leading jet p_{T} [GeV]", "Events");
    
 // Leading jet eta
 fHistograms2->Add("jets/h_jet1_Eta", "Leading Jet Eta",
                   100, -5., 5., "Leading jet #eta", "Events");
 ...
 
MyAnalysis::ProcessCut():
 fHistograms1->Fill("leptons/h_lep1_Pt",  lep1->Pt(), w1);
 fHistograms1->Fill("leptons/h_lep1_Eta", lep1->Eta(), w1);
 fHistograms1->Fill("leptons/el/h_el1_Pt",  el1->Pt(), w1);
 ...
 // Perform b-tagging
 ...
 fHistograms1->Fill("jets/h_jet1_Pt",  jet1->Pt(), w2);
 fHistograms1->Fill("jets/h_jet1_Eta", jet1->Eta(), w2);
 ...
 


 Author: Oliver Maria Kind <mailto: kind@physik.hu-berlin.de>
 Update: $Id: AtlHistogramTool.cxx,v 1.5 2017/01/22 12:16:58 kind Exp $
 Copyright: 2015 (C) Oliver Maria Kind

Function Members (Methods)

public:
virtual~AtlHistogramTool()
voidTObject::AbstractMethod(const char* method) const
TH1D*Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, const char* xtitle, const char* ytitle)
TH2D*Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, const Double_t* ybins, const char* xtitle, const char* ytitle, const char* ztitle)
TH2D*Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char* xtitle, const char* ytitle, const char* ztitle)
virtual Bool_tAtlAnalysisTool::AnalyzeEvent()
virtual voidTObject::AppendPad(Option_t* option = "")
AtlHistogramTool(const AtlHistogramTool&)
AtlHistogramTool(const char* name, const char* title)
virtual voidBookHistograms()
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidAtlAnalysisTool::Clear()
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
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)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
voidFill(const char* hname, Double_t x, Double_t w)
voidFill(const char* hname, Double_t x, Double_t y, Double_t w)
voidFill(const char* path, const char* hname, Double_t x, Double_t w)
voidFill(const char* path, const char* hname, Double_t x, Double_t y, Double_t w)
virtual voidTNamed::FillBuffer(char*& buffer)
virtual voidFillHistograms()
virtual voidAtlAnalysisTool::FillHistogramsNoEvtSel()
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
const char*AtlAnalysisTool::GetOutputDir() const
Float_tAtlAnalysisTool::GetPreTagEvtWeight() const
static const char*AtlAnalysisTool::GetProcessModeName(AtlAnalysisTool::EProcessMode mode)
Float_tAtlAnalysisTool::GetTagEvtWeight() const
virtual const char*TNamed::GetTitle() const
AtlAnalysisTool*AtlAnalysisTool::GetTool(const char* ClassName, const char* ToolName = "", Bool_t force = kFALSE) const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
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 voidAtlAnalysisTool::Init()
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tAtlAnalysisTool::IsIndividual() const
Bool_tAtlAnalysisTool::IsMainAnalysis() const
Bool_tAtlAnalysisTool::IsObjectsDefinition() const
Bool_tAtlAnalysisTool::IsOff() const
Bool_tTObject::IsOnHeap() const
Bool_tAtlAnalysisTool::IsPostAnalysis() const
Bool_tAtlAnalysisTool::IsPreAnalysis() const
Bool_tAtlAnalysisTool::IsScaleFactor() const
virtual Bool_tTNamed::IsSortable() const
Bool_tAtlAnalysisTool::IsSystematics() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tAtlAnalysisTool::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)
AtlHistogramTool&operator=(const AtlHistogramTool&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint() const
Bool_tAtlAnalysisTool::Process()
virtual Int_tTObject::Read(const char* name)
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 = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidSetBranchStatus()
virtual voidAtlAnalysisTool::SetCutDefaults()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidAtlAnalysisTool::SetEvent(AtlEvent* evt)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
voidAtlAnalysisTool::SetOutputDir(const char* dir)
voidAtlAnalysisTool::SetOutputFile(TFile* f)
voidAtlAnalysisTool::SetParent(AtlSelector* parent)
virtual voidTNamed::SetTitle(const char* title = "")MENU
voidAtlAnalysisTool::SetTree(TTree* t)
virtual voidTObject::SetUniqueID(UInt_t uid)
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
virtual voidAtlAnalysisTool::Terminate()
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:
TDirectory*MkDirWithParents(const char* dir)

Data Members

public:
TStringAtlAnalysisTool::fOutputDirDirectory in root output file, where histogram dir is created
AtlAnalysisTool::EProcessModeAtlAnalysisTool::fProcessModeDefines when exactly the tool is run (see AtlAnalysisTool class description for details)
Int_tAtlAnalysisTool::fVerbosityLevelIndicates the degree of verbosity of tool (0 = no info/debug output, 1 = info, 2 = info+debug)
static TObject::(anonymous)TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kIndividual
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::(anonymous)TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kMainAnalysis
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::(anonymous)TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kObjectsDefinition
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kOff
static TObject::(anonymous)TObject::kOverwrite
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kPostAnalysis
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kPreAnalysis
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kScaleFactor
static TObject::(anonymous)TObject::kSingleKey
static AtlAnalysisTool::EProcessModeAtlAnalysisTool::kSystematics
static TObject::(anonymous)TObject::kWriteDelete
static TObject::(anonymous)TObject::kZombie
protected:
AtlEvent*AtlAnalysisTool::fEventPointer to current event
TStringTNamed::fNameobject identifier
TString*AtlAnalysisTool::fOptionOption string
TFile*AtlAnalysisTool::fOutputFileOutput file
AtlSelector*AtlAnalysisTool::fParentPointer to parent selector
TStringTNamed::fTitleobject title
TTree*AtlAnalysisTool::fTreeEvent tree
private:
THashList*fHistogramsList of histograms
TDirectory*fParentDirTop-level folder

Class Charts

Inheritance Chart:
TObject
TNamed
AtlAnalysisTool
AtlHistogramTool

Function documentation

AtlHistogramTool(const char* name, const char* title)
 Default constructor

~AtlHistogramTool()
 Default destructor

TH1D* Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, const char* xtitle, const char* ytitle)
 Add TH1D histogram

 The histogram name can contain a path of subdirectories. These
 directories are created automatically if they do not exist. All
 path names are relative to the parent folder of the tool.

 Store current dirctory
TH2D* Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char* xtitle, const char* ytitle, const char* ztitle)
 Add TH2D histogram

 The histogram name can contain a path of subdirectories. These
 directories are created automatically if they do not exist. All
 path names are relative to the parent folder of the tool.

 Store current dirctory
TH2D* Add(const char* hname, const char* title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, const Double_t* ybins, const char* xtitle, const char* ytitle, const char* ztitle)
 Add TH2D histogram

 The histogram name can contain a path of subdirectories. These
 directories are created automatically if they do not exist. All
 path names are relative to the parent folder of the tool.

 Store current dirctory
void Fill(const char* hname, Double_t x, Double_t w)
 Fill given histogram with value x and weight w

 The histogram name needs to contain the full path of the
 histogram as given when booking the histogram using the Add()
 member function.

void Fill(const char* hname, Double_t x, Double_t y, Double_t w)
 Fill given histogram with values x,y and weight w

 The histogram name needs to contain the full path of the
 histogram as given when booking the histogram using the Add()
 member function.

TDirectory* MkDirWithParents(const char* dir)
 Create the given directoy and all of its parents if necessary
 in the top-level directory

void Print() const
 Print tool configuration

AtlHistogramTool(const char* name, const char* title)
void Fill(const char* hname, Double_t x, Double_t w)
void Fill(const char* hname, Double_t x, Double_t y, Double_t w)
void SetBranchStatus()
{;}
void BookHistograms()
{;}
void FillHistograms()
{;}