Skip to content

HistStorage

Klaas Padeken edited this page Sep 11, 2017 · 1 revision

The HistStorage is a wrapper for things that you want to do to all the histograms from multiple files, like rebin, set the style, set axis-title, scale the histogram, merge a few backgrounds and so on.

There are two classes of interest here:

HistStorage
HistStorageContainer

While the first is the more basic the second is just a container, holding tree HistStorage objects (data, background and signal), for convenience.

Basic usage

To fill a HistStorage element you fist have to create it:

HistStorage(xs=1., lumi=1.,xstype="pythonConfig", path=None,isData=False,useRoot=False)

xs and xstype

The fist argument can be various types of cross section infos. The type of the xs info you specify with xstype.

There are at the moment the following options to specify the xs: * pythonConfig * music * music_scaled * BSM3G While the first tree expect a configobj with various names for crosssection, weight etc. the last one expects just a dict. The values of the dict have to be xs[_name]["xs"] and xs[_name]["eff"], where name is the name of the sample, you will provide.

lumi

This is the lumi. The unit you provide the cross sections in corresponds to the unit the lumi must be in. (use pb to make your life easier)

path

This must be the path that your files are in.

isData

bool True or False please.

useRoot

This will make the plot texts either compatible with maptplotlib or root (real tex or the pseudo tex with "#"

So when you have created your object

bghists=HistStorage(xs=sampleinfos,xstype="BSM3G",lumi=30000,path=".")

You can add files to it. The easiest way is to make a OrderedDict:

bglist=OrderedDict()
bglist['DY+Jets']=[
        'DYJetsToLL_M-50_HT-70To100',
        'DYJetsToLL_M-50_HT-600To800',
        .....
        ]
bghists.addFileList(bglist)

That way you can combine different samples. The name 'DYJetsToLL_M-50_HT-70To100' should be the root file in the path without ".root" at the end.

There are other ways to add files (look in the source code for details): * addAllFiles * addFile * addJoinList # this just is a ordered dict (same as addFileList)

Get the histogram

bghists.getHist("blaFolder/secondFolder/hist_mt")

This will store the hist internally, you can rebin it set stuff, and when you are finished you can get the histograms as a list:

allbg=bghists.getHistList()

Note you can do nice things like:

allbgAdded=sum(allbg)

The hist title will be the clean title that you choose earlier ('DY+Jets').