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.9 by nmohr, Mon Sep 17 18:23:58 2012 UTC vs.
Revision 1.15 by nmohr, Thu Oct 4 13:02:23 2012 UTC

# Line 9 | Line 9 | from BetterConfigParser import BetterCon
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,path,rescale,subsample=-1):
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")
# Line 40 | Line 31 | def getScale(job,path,rescale,subsample=
31          theScale = float(job.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*rescale/float(job.split)
32      return theScale
33  
34 < def getHistoFromTree(job,path,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
# Line 56 | Line 47 | def getHistoFromTree(job,path,options,re
47      nBins=int(options[3])
48      xMin=float(options[4])
49      xMax=float(options[5])
50 +    addOverFlow=eval(config.get('Plot_general','addOverFlow'))
51  
52      if job.type != 'DATA':
53 <        cutcut=config.get('Cuts',options[7])
53 >    
54 >        if type(options[7])==str:
55 >            cutcut=config.get('Cuts',options[7])
56 >        elif type(options[7])==list:
57 >            cutcut=config.get('Cuts',options[7][0])
58 >            cutcut=cutcut.replace(options[7][1],options[7][2])
59 >            #print cutcut
60          if subsample>-1:
61              treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample])        
62          else:
# Line 76 | Line 74 | def getHistoFromTree(job,path,options,re
74      #Tree.SetDirectory(0)
75      
76      #Tree=tmpTree.Clone()
77 <    weightF=config.get('Weights','weightF')
77 >    weightF=config.get('Weights',which_weightF)
78      #hTree = ROOT.TH1F('%s'%name,'%s'%title,nBins,xMin,xMax)
79      #hTree.SetDirectory(0)
80      #hTree.Sumw2()
# Line 106 | Line 104 | def getHistoFromTree(job,path,options,re
104      #print job.name + ' Sumw2', hTree.GetEntries()
105  
106      if job.type != 'DATA':
107 <        ScaleFactor = getScale(job,path,rescale,subsample)
107 >        ScaleFactor = getScale(job,path,config,rescale,subsample)
108          if ScaleFactor != 0:
109              hTree.Scale(ScaleFactor)
110 +    
111 +    if addOverFlow:
112 +            print 'Adding overflow'
113 +            uFlow = hTree.GetBinContent(0)+hTree.GetBinContent(1)
114 +            oFlow = hTree.GetBinContent(hTree.GetNbinsX()+1)+hTree.GetBinContent(hTree.GetNbinsX())
115 +            uFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(0),2)+ROOT.TMath.Power(hTree.GetBinError(1),2))
116 +            oFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()),2)+ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()+1),2))
117 +            hTree.SetBinContent(1,uFlow)
118 +            hTree.SetBinContent(hTree.GetNbinsX(),oFlow)
119 +            hTree.SetBinError(1,uFlowErr)
120 +            hTree.SetBinError(hTree.GetNbinsX(),oFlowErr)
121 +              
122              
123      print '\t-->import %s\t Integral: %s'%(job.name,hTree.Integral())
124              
125      hTree.SetDirectory(0)
126      input.Close()  
127      
118              
119    
128      return hTree, group
129      
130  
# Line 143 | Line 151 | def orderandadd(histos,typs,setup):
151      histos=ordnung
152      typs=ordnungtyp
153  
154 +    print typs
155 +
156      for k in range(0,len(num)):
157          for m in range(0,num[k]):
158              if m > 0:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines