9 |
|
import sys |
10 |
|
|
11 |
|
|
12 |
< |
#load config |
13 |
< |
config = BetterConfigParser() |
14 |
< |
config.read('./config7TeV_ZZ') |
15 |
< |
|
16 |
< |
#get locations: |
17 |
< |
Wdir=config.get('Directories','Wdir') |
18 |
< |
anaTag=config.get('Analysis','tag') |
19 |
< |
|
20 |
< |
|
21 |
< |
|
22 |
< |
def getScale(job,rescale,subsample=-1): |
23 |
< |
input = TFile.Open(job.getpath()) |
12 |
> |
def getScale(job,path,config,rescale,subsample=-1): |
13 |
> |
anaTag=config.get('Analysis','tag') |
14 |
> |
input = TFile.Open(path+'/'+job.getpath()) |
15 |
|
CountWithPU = input.Get("CountWithPU") |
16 |
|
CountWithPU2011B = input.Get("CountWithPU2011B") |
17 |
|
#print lumi*xsecs[i]/hist.GetBinContent(1) |
31 |
|
theScale = float(job.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*rescale/float(job.split) |
32 |
|
return theScale |
33 |
|
|
34 |
< |
def getHistoFromTree(job,options,rescale=1,subsample=-1): |
34 |
> |
def getHistoFromTree(job,path,config,options,rescale=1,subsample=-1,which_weightF='weightF'): |
35 |
|
|
36 |
|
#print job.getpath() |
37 |
|
#print options |
49 |
|
xMax=float(options[5]) |
50 |
|
|
51 |
|
if job.type != 'DATA': |
52 |
< |
cutcut=config.get('Cuts',options[7]) |
52 |
> |
|
53 |
> |
if type(options[7])==str: |
54 |
> |
cutcut=config.get('Cuts',options[7]) |
55 |
> |
elif type(options[7])==list: |
56 |
> |
cutcut=config.get('Cuts',options[7][0]) |
57 |
> |
cutcut=cutcut.replace(options[7][1],options[7][2]) |
58 |
> |
print cutcut |
59 |
|
if subsample>-1: |
60 |
|
treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample]) |
61 |
|
else: |
66 |
|
treeCut='%s'%(cutcut) |
67 |
|
|
68 |
|
|
69 |
< |
input = TFile.Open(job.getpath(),'read') |
69 |
> |
input = TFile.Open(path+'/'+job.getpath(),'read') |
70 |
|
|
71 |
|
Tree = input.Get(job.tree) |
72 |
|
#Tree=tmpTree.CloneTree() |
73 |
|
#Tree.SetDirectory(0) |
74 |
|
|
75 |
|
#Tree=tmpTree.Clone() |
76 |
< |
weightF=config.get('Weights','weightF') |
76 |
> |
weightF=config.get('Weights',which_weightF) |
77 |
|
#hTree = ROOT.TH1F('%s'%name,'%s'%title,nBins,xMin,xMax) |
78 |
|
#hTree.SetDirectory(0) |
79 |
|
#hTree.Sumw2() |
103 |
|
#print job.name + ' Sumw2', hTree.GetEntries() |
104 |
|
|
105 |
|
if job.type != 'DATA': |
106 |
< |
ScaleFactor = getScale(job,rescale,subsample) |
106 |
> |
ScaleFactor = getScale(job,path,config,rescale,subsample) |
107 |
|
if ScaleFactor != 0: |
108 |
|
hTree.Scale(ScaleFactor) |
109 |
|
|