ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/gethistofromtree.py
(Generate patch)

Comparing UserCode/VHbb/python/gethistofromtree.py (file contents):
Revision 1.16 by peller, Tue Oct 9 21:17:34 2012 UTC vs.
Revision 1.21 by peller, Wed Dec 5 15:00:20 2012 UTC

# Line 11 | Line 11 | import sys
11  
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")
14 >    inputfile = TFile.Open(path+'/'+job.getpath())
15 >    CountWithPU = inputfile.Get("CountWithPU")
16 >    CountWithPU2011B = inputfile.Get("CountWithPU2011B")
17      #print lumi*xsecs[i]/hist.GetBinContent(1)
18      
19      if subsample>-1:
20 <        xsec=float(job.xsec[subsample])
20 >        if type(job.xsec[subsample]) == str: xsec=float(eval(job.xsec[subsample]))
21 >        else: xsec=float(job.xsec[subsample])
22          sf=float(job.sf[subsample])
23      else:
24 <        xsec=float(job.xsec)
24 >        if type(job.xsec) == str: xsec=float(eval(job.xsec))
25 >        else: xsec=float(job.xsec)
26          sf=float(job.sf)
27      
28      
# Line 29 | Line 31 | def getScale(job,path,config,rescale,sub
31          theScale = float(job.lumi)*xsec*sf/(0.46502*CountWithPU.GetBinContent(1)+0.53498*CountWithPU2011B.GetBinContent(1))*rescale/float(job.split)
32      elif anaTag == '8TeV':
33          theScale = float(job.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*rescale/float(job.split)
34 +    inputfile.Close()
35      return theScale
36  
37   def getHistoFromTree(job,path,config,options,rescale=1,subsample=-1,which_weightF='weightF'):
# Line 50 | Line 53 | def getHistoFromTree(job,path,config,opt
53      #addOverFlow=eval(config.get('Plot_general','addOverFlow'))
54      addOverFlow = False
55  
56 +    TrainFlag = eval(config.get('Analysis','TrainFlag'))
57 +    if TrainFlag: traincut = " & EventForTraining == 0"
58 +    if not TrainFlag: traincut=""
59 +
60      if job.type != 'DATA':
61      
62          if type(options[7])==str:
# Line 59 | Line 66 | def getHistoFromTree(job,path,config,opt
66              cutcut=cutcut.replace(options[7][1],options[7][2])
67              #print cutcut
68          if subsample>-1:
69 <            treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample])        
69 >            treeCut='%s & %s%s'%(cutcut,job.subcuts[subsample],traincut)        
70          else:
71 <            treeCut='%s & EventForTraining == 0'%(cutcut)
71 >            treeCut='%s%s'%(cutcut,traincut)
72  
73      elif job.type == 'DATA':
74          cutcut=config.get('Cuts',options[8])
# Line 141 | Line 148 | def orderandadd(histos,typs,setup):
148      num=[0]*len(setup)
149      for i in range(0,len(setup)):
150          for j in range(0,len(histos)):
151 <            if typs[j] in setup[i]:
151 >            if typs[j] == setup[i]:
152                  num[i]+=1
153                  ordnung.append(histos[j])
154                  ordnungtyp.append(typs[j])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines