MakePlots

Introduction

Disclaimer: MakePlots is a small package to simplify working with root trees and creating histograms for a cut flow analysis. This package comes without any warranty. Any particles that may or may not be discovered using this package, fall to into the users responsibility.

Installation

localSetupROOT --rootVersion=5.30.04-i686-slc5-gcc4.3

svn co svn+ssh://svn.cern.ch/reps/atlasoff/PhysicsAnalysis/HiggsPhys/HSG5/Hbb/Edinburgh_H2bbAnalysis/MakePlots/trunk MakePlots
cd MakePlots

Compile

cd src
make
make pythonmodule
Or use one of the alternative makefiles (e.g. on MacOs X)
make -f Makefile.mac
Add the python directory to the PYTHONPATH
source ../scritps/setup.sh

Usage

Note: Please have a look inside and check section on configuration before trying one of these tools.

To run go into the script directory (also contains some config files)

cd ../scripts
./create_histos.py

or

./make_plots.py

Command line arguments

The script ./create_histos.py supports commandline arguments


[me@mycomputer]~/MakePlots/scripts% ./create_histos.py -h  
Usage: create_histos.py [options]

parse root tree, and create cut flow with histograms for each stage

Options:
  -h, --help            show this help message and exit
  -i INPUTFILES, --input=INPUTFILES
                        comma separated list of input files, e.g
                        aa.root,ab.root,ac.root
  -o OUTPUTFILE, --output=OUTPUTFILE
                        output filename, default: output.root
  -p PATH, --path=PATH  input path (will be prepend to input file)
  -t TREENAME, --tree=TREENAME
                        name of the input tree, default : OutputTree
</endverbatim>
 

---++Configuration for create_histos.py


Setup observable to create histos from
<verbatim>
class JetObservableList(PyObservableGroup):
    def __init__(self):
        PyObservableGroup.__init__(self,"JetObservableList")
        self.SetPath("jets")
        self.Add(Distribution(int)("njets",20,0,20))

        cut1=PyObservableGroup("jets1")
        cut1.SetCuts(MinCut(int)("njets",1))
        cut1.Add(Distribution(float,0)("jetPhi",100,0,3.1415))
        cut1.Add(Distribution(float,0)("jetEta",40,-5,5))
        self.Add(cut1)
        
        cut2=PyObservableGroup("jets2")
        cut2.SetCuts(MinCut(int)("njets",2))
        cut2.Add(Distribution(float,1)("jetPhi",100,0,3.1415))
        cut2.Add(Distribution(float,1)("jetEta",40,-5,5))
        cut1.Add(cut2)
    
class WHObservableList(PyObservableGroup):
    def __init__(self):
        PyObservableGroup.__init__(self,"WHObservableList")
        #self.SetPath("WHplots")
        self.Add(Distribution(float)("m_H",50,0,200))
        self.Add(Distribution(float)("pt_H",50,0,1000))
        self.Add(Distribution(float)("mt_W",50,0,200))
        self.Add(Distribution(float)("pt_W",50,0,1000))
        self.Add(Distribution(float)("EtMiss",50,0,200))
        self.Add(Distribution(float)("DeltaPhiWH",100,0.,3.1415))
        self.Add(Distribution(float)("WHDeltaPhi",100,0.,3.1415))
        self.Add(JetObservableList())
</verbatim>

Define your outflow
<verbatim>
class WHCutFlowConfig(CutFlowConfig):
    def __init__(self):
        CutFlowConfig.__init__(self)
        
        self.Add(initSel       = "passesTrigger==1&&passesPV==1&&passesHFOR==1&&passesMetCl==1")
        self.Add(objSel        = "njets>0&&nlep>0")

        self.Add(leptonVeto    = "passesLeptonVeto==1")
        self.Add(metCut        = "EtMiss>25.")
        self.Add(WmassCut      = "mt_W>40.")
        self.Add(HpT_Cut       = "pt_H>200.")

        higgsCandCut  = "NumberHiggsCandidates>0"
        self.Add(nFatJetsCut   = higgsCandCut+"&&nfatjets>0")

        self.Add(addfatjetVeto = "passesFatjetVeto==1")
        self.Add(bjetVeto      = "passesBjetVeto==1")

        self.Add(deltaPhiWHCut = "DeltaPhiWH>2.09")

        self.Add(WpT_Cut       = "pt_W>150.")

        self.Add(oneBTag       = "higgsJetSubjetFlavWeight[0]>.35||higgsJetSubjetFlavWeight[1]>.35")
        self.Add(twoBTag       = "higgsJetSubjetFlavWeight[0]>.35&&higgsJetSubjetFlavWeight[1]>.35")

</verbatim>

add add observable and outflow to your =CutFlowFactory=:
<verbatim>
    cutflow = CutFlowFactory()
    cutflow.SetObservable(WHObservableList)
    cutflow.SetCuts(WHCutFlowConfig)

    files=['mc11_7TeV.105200.T1_McAtNlo_Jimmy.merge.NTUP_HSG5WH.e835_s1272_s1274_r2920_r2900_p833_SplitPart_ab.root']
    cutflow.SetInputFiles(path='/Disk/speyside7/Grid/grid-files/Higgs/OutputFiles/Samples_01-03-2012/',files=files,treename="OutputTree")
    cutflow.SetOutput("output.root")

    cutflow.Initialize()
    cutflow.Execute()
    cutflow.Finalize()
</verbatim>

you will find the corresponding sections in the prepared =./create_histos.py=
after running
<verbatim>
./create_histos.py
</verbatim>
you will get an output root file containing the histograms filled for each step of the cut flow

Optionally you can use =./write_histos.py= to create png files, e.g. to put on a web page.

%ATTACHURL%/output-root.png


---+++Configuration for make_histos.py

*TODO*

---

-- Main.AndreasSchaelicke - 02-Mar-2012
Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng output-root.png r1 manage 45.3 K 2012-03-02 - 01:14 AndreasSchaelicke screenshot of TBrowser with output.root - illustration of cut flow
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2012-03-02 - AndreasSchaelicke
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback