A++ » INC » HepTemplateFitter

class HepTemplateFitter: public TTask


    This Tool provides the functionality to define templates whose
    weighted sum is then fitted to a reference. The fractions of
    the individual samples as well es the fitted templates themselves
    are returned to the user.

    In order to use the tool you have to write a task file in the
    fashion described below. If you have experience with the
    HepDataMCPlotter you should not have any problems.

    The example is taken from a flavor ratio analysis in the
    semileptonic ttbar channel



    {
    // Define a new task
    TTask *ttbar = new TTask("ttbar", "TTbar Analysis");

    // Initialize HepTemplatefitter with name and title. The Name
    // sets the name of the .root file that will be written.
    HepTemplateFitter *pl_ttbar = new HepTemplateFitter("Template Fitter", "Template plots");

    // AddMCSample adds samples to the list from which the templates will be
    // generated.
    // Parameter 1 is the pathname of the sample
    // Parameter 2 is the title of the MCSample
    // Parameter 3 is the cross section of the sample since it is possible
    // to generate templates from multiple files.
    pl_ttbar->AddMCSample("templatetest.root", "MC t#bar{t} Np0 qq", 1.0);

    // AddDatasample adds samples to the list from which the reference histogram
    // will be generated. Since one may want to do template fits in MC also
    // it is implemented similiar to AddMCSample
    pl_ttbar->AddDataSample("FRTest.root", "MC t#bar{t} Np0 qq", 1.0);

    // This generates the templates out of the MCSample files.
    // Parameter 1 is the name of the histogram from which the template is derived
    // Parameter 2 is the title of the parameter (for legends)
    // Parameter 3 is the color of the template
    pl_ttbar->GenerateTemplate("h_Masstemplate_uds", "light", kOrange);
    pl_ttbar->GenerateTemplate("h_Masstemplate_c", "charm", kRed);
    pl_ttbar->GenerateTemplate("h_Masstemplate_b", "bottom", kBlue);
    pl_ttbar->GenerateTemplate("h_Masstemplate_x", "unknown", kGreen);

    // Sets the reference. The parameter is the name of the histogram
    // from which the reference is generated.
    pl_ttbar->GenerateReference("h_jets_mass_all");

    // Add the Fitter to the task
    ttbar->Add(pl_ttbar);

    // Open browser
    gROOT->GetListOfTasks()->Add(ttbar);
    gROOT->GetListOfBrowsables()->Add(ttbar);
    new TBrowser;
    }



    Now execute the task and you will get the results of the fit.


 Author: Felix Thomas <mailto: Felix.Thomas@mailbox-tu-dresden.de>
 Update: $$
 Copyright: 2010 (C) Felix Thomas

Function Members (Methods)

public:
virtual~HepTemplateFitter()
virtual voidTTask::Abort()MENU
voidTObject::AbstractMethod(const char* method) const
virtual voidTTask::Add(TTask* task)
HepDataMCSample*AddDataSample(const char* path, const char* label)MENU
HepDataMCSample*AddDataSample(const char* path, const char* label, Float_t xsec)MENU
HepDataMCSample*AddMCSample(const char* path, const char* label, Float_t xsec)MENU
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTTask::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTTask::CleanTasks()
virtual voidTTask::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTTask::Continue()MENU
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 voidExec(Option_t* option = "")
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 voidTTask::ExecuteTask(Option_t* option = "0")MENU
virtual voidTTask::ExecuteTasks(Option_t* option)
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
voidGenerateReference(char* histname)
voidGenerateTemplate(char* histname, char* templatename, Color_t color)
voidGenerateTemplate(char* histname, char* templatename, Double_t low, Double_t high, Color_t color)
Int_tTTask::GetBreakin() const
Int_tTTask::GetBreakout() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Bool_tGetExportROOT()
virtual const char*TObject::GetIconName() const
TList*TTask::GetListOfTasks() 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
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
HepTemplateFitter(const HepTemplateFitter&)
HepTemplateFitter(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
Bool_tTTask::IsActive() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTTask::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTTask::ls(Option_t* option = "*") constMENU
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)
HepTemplateFitter&operator=(const HepTemplateFitter&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
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 = "")
voidTTask::SetActive(Bool_t active = kTRUE)TOGGLE
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidTTask::SetBreakin(Int_t breakin = 1)TOGGLE
voidTTask::SetBreakout(Int_t breakout = 1)TOGGLE
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetExportDir(const char* dir)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetWorkingDir(const char* dir)
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:
HepDataMCSample*AddDataSample(const char* path, const char* label, Color_t color, Style_t line_style, Width_t line_width, Style_t fill_style)
HepDataMCSample*AddMCSample(const char* path, const char* label, Color_t color, Style_t line_style, Width_t line_width, Style_t fill_style)
THStack*BuildStackPlot()
HepTemplate*BuildTemplate(char* histname, char* templatename, Color_t color)
voidFillTemplates()

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:
Bool_tTTask::fActivetrue if task is active
Int_tTTask::fBreakin=1 if a break point set at task extry
Int_tTTask::fBreakout=1 if a break point set at task exit
Bool_tTTask::fHasExecutedTrue if task has executed
TStringTNamed::fNameobject identifier
TStringTTask::fOptionOption specified in ExecuteTask
TList*TTask::fTasksList of Tasks
TStringTNamed::fTitleobject title
static TTask*TTask::fgBeginTaskpointer to task initiator
static TTask*TTask::fgBreakPointpointer to current break point
private:
TList*fDataSamplesList of data samples (might be also MC)
TString*fExportDirWorking directory
Bool_tfExportROOTExport all plots to a ROOT file ?
TFractionFitter*fFitter
TList*fMCSamplesList of MC samples
TFile*fOutputRootFileOutput file containing all plots
TH1F*fReferenceHistogram to which the templates are fitted
TList*fTemplatesList with templates

Class Charts

Inheritance Chart:
TObject
TNamed
TTask
HepTemplateFitter

Function documentation

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

~HepTemplateFitter()
 Default destructor

HepDataMCSample* AddMCSample(const char* path, const char* label, Color_t color, Style_t line_style, Width_t line_width, Style_t fill_style)
 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.

HepDataMCSample* AddMCSample(const char* path, const char* label, Float_t xsec)
 Same as above but line style and width, and fill style are set
 to the defaults given by the current style

HepDataMCSample* AddDataSample(const char* path, const char* label, Color_t color, Style_t line_style, Width_t line_width, Style_t fill_style)
 Add Data 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.

HepDataMCSample* AddDataSample(const char* path, const char* label)
 Same as above but line style and width, and fill style are set
 to the defaults given by the current style

HepDataMCSample* AddDataSample(const char* path, const char* label, Float_t xsec)
 Same as above but line style and width, and fill style are set
 to the defaults given by the current style

void Exec(Option_t* option = "")
 Execute task

void FillTemplates()
 Fit Histograms and fit results are migrated to the
 HepTemplate-class objects

THStack* BuildStackPlot()
 Generation of stacked plot that shows the individual
 contributions of the templates to the fit

void GenerateTemplate(char* histname, char* templatename, Color_t color)
void GenerateTemplate(char* histname, char* templatename, Double_t low, Double_t high, Color_t color)
HepTemplate* BuildTemplate(char* histname, char* templatename, Color_t color)
void GenerateReference(char* histname)
HepTemplateFitter(const char* name, const char* title)
void SetWorkingDir(const char* dir)
{ SetExportDir(dir); }
void SetExportDir(const char* dir)
Bool_t GetExportROOT()
{ return fExportROOT; }