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.13 by peller, Thu Sep 20 14:14:53 2012 UTC vs.
Revision 1.18 by peller, Fri Oct 19 15:44:07 2012 UTC

# Line 17 | Line 17 | def getScale(job,path,config,rescale,sub
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 47 | Line 49 | def getHistoFromTree(job,path,config,opt
49      nBins=int(options[3])
50      xMin=float(options[4])
51      xMax=float(options[5])
52 +    #addOverFlow=eval(config.get('Plot_general','addOverFlow'))
53 +    addOverFlow = False
54 +
55 +    TrainFlag = eval(config.get('Analysis','TrainFlag'))
56 +    if TrainFlag: traincut = " & EventForTraining == 0"
57 +    if not TrainFlag: traincut=""
58  
59      if job.type != 'DATA':
60      
# Line 55 | Line 63 | def getHistoFromTree(job,path,config,opt
63          elif type(options[7])==list:
64              cutcut=config.get('Cuts',options[7][0])
65              cutcut=cutcut.replace(options[7][1],options[7][2])
66 <            #print cutcut
66 >            print cutcut
67          if subsample>-1:
68 <            treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample])        
68 >            treeCut='%s & %s%s'%(cutcut,job.subcuts[subsample],traincut)        
69          else:
70 <            treeCut='%s & EventForTraining == 0'%(cutcut)
70 >            treeCut='%s%s'%(cutcut,traincut)
71  
72      elif job.type == 'DATA':
73          cutcut=config.get('Cuts',options[8])
# Line 106 | Line 114 | def getHistoFromTree(job,path,config,opt
114          ScaleFactor = getScale(job,path,config,rescale,subsample)
115          if ScaleFactor != 0:
116              hTree.Scale(ScaleFactor)
117 +    
118 +    if addOverFlow:
119 +            print 'Adding overflow'
120 +            uFlow = hTree.GetBinContent(0)+hTree.GetBinContent(1)
121 +            oFlow = hTree.GetBinContent(hTree.GetNbinsX()+1)+hTree.GetBinContent(hTree.GetNbinsX())
122 +            uFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(0),2)+ROOT.TMath.Power(hTree.GetBinError(1),2))
123 +            oFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()),2)+ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()+1),2))
124 +            hTree.SetBinContent(1,uFlow)
125 +            hTree.SetBinContent(hTree.GetNbinsX(),oFlow)
126 +            hTree.SetBinError(1,uFlowErr)
127 +            hTree.SetBinError(hTree.GetNbinsX(),oFlowErr)
128 +              
129              
130      print '\t-->import %s\t Integral: %s'%(job.name,hTree.Integral())
131              
132      hTree.SetDirectory(0)
133      input.Close()  
134      
115              
116    
135      return hTree, group
136      
137  
# Line 140 | Line 158 | def orderandadd(histos,typs,setup):
158      histos=ordnung
159      typs=ordnungtyp
160  
161 +    print typs
162 +
163      for k in range(0,len(num)):
164          for m in range(0,num[k]):
165              if m > 0:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines