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.4 by nmohr, Thu Jun 21 13:45:14 2012 UTC vs.
Revision 1.7 by peller, Thu Aug 2 16:03:52 2012 UTC

# Line 15 | Line 15 | config.read('./config')
15  
16   #get locations:
17   Wdir=config.get('Directories','Wdir')
18 + anaTag=config.get('Analysis','tag')
19  
20  
21  
22 <
22 < def getScale(job,rescale):
22 > def getScale(job,rescale,subsample=-1):
23      input = TFile.Open(job.getpath())
24      CountWithPU = input.Get("CountWithPU")
25      CountWithPU2011B = input.Get("CountWithPU2011B")
26      #print lumi*xsecs[i]/hist.GetBinContent(1)
27 <    return float(job.lumi)*float(job.xsec)*float(job.sf)/(CountWithPU.GetBinContent(1))*rescale/float(job.split)
28 <
27 >    
28 >    if subsample>-1:
29 >        xsec=float(job.xsec[subsample])
30 >        sf=float(job.sf[subsample])
31 >    else:
32 >        xsec=float(job.xsec)
33 >        sf=float(job.sf)
34 >    
35 >    
36 >    theScale = 1.
37 >    if anaTag == '7TeV':
38 >        theScale = float(job.lumi)*xsec*sf/(0.46502*CountWithPU.GetBinContent(1)+0.53498*CountWithPU2011B.GetBinContent(1))*rescale/float(job.split)
39 >    elif anaTag == '8TeV':
40 >        theScale = float(job.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*rescale/float(job.split)
41 >    return theScale
42  
43 < def getHistoFromTree(job,options,rescale=1):
43 > def getHistoFromTree(job,options,rescale=1,subsample=-1):
44      treeVar=options[0]
45 <    name=job.name
45 >    if subsample>-1:
46 >        name=job.subnames[subsample]
47 >        group=job.group[subsample]
48 >    else:
49 >        name=job.name
50 >        group=job.group
51 >
52      #title=job.plotname()
53      nBins=int(options[3])
54      xMin=float(options[4])
# Line 37 | Line 56 | def getHistoFromTree(job,options,rescale
56  
57      if job.type != 'DATA':
58          cutcut=config.get('Cuts',options[7])
59 <        treeCut='%s & EventForTraining == 0'%cutcut
59 >        if subsample>0:
60 >            treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample])        
61 >        else:
62 >            treeCut='%s & EventForTraining == 0'%(cutcut)
63  
64      elif job.type == 'DATA':
65 <        treeCut=config.get('Cuts',options[8])
65 >        cutcut=config.get('Cuts',options[8])
66 >        treeCut='%s & EventForTraining == 0'%(cutcut)
67 >
68  
69      input = TFile.Open(job.getpath(),'read')
70  
# Line 79 | Line 103 | def getHistoFromTree(job,options,rescale
103      #print job.name + ' Sumw2', hTree.GetEntries()
104  
105      if job.type != 'DATA':
106 <        ScaleFactor = getScale(job,rescale)
106 >        ScaleFactor = getScale(job,rescale,subsample)
107          if ScaleFactor != 0:
108              hTree.Scale(ScaleFactor)
109              
110      print '\t-->import %s\t Integral: %s'%(job.name,hTree.Integral())
111              
112      hTree.SetDirectory(0)
113 <    input.Close()            
114 <    return hTree, job.group
113 >    input.Close()  
114 >    
115 >              
116 >    
117 >    return hTree, group
118      
119  
120   ######################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines