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

Comparing UserCode/VHbb/python/HistoMaker.py (file contents):
Revision 1.7 by peller, Thu Oct 11 13:40:18 2012 UTC vs.
Revision 1.10 by peller, Tue Oct 23 16:39:55 2012 UTC

# Line 18 | Line 18 | class HistoMaker:
18          self.region = region
19          self.lumi=0.
20  
21 <    def getScale(self,job,subsample=-1):
21 >    def getScale(self,job,subsample=-1,MC_rescale_factor=1):
22          anaTag=self.config.get('Analysis','tag')
23          input = TFile.Open(self.path+'/'+job.getpath())
24          CountWithPU = input.Get("CountWithPU")
# Line 32 | Line 32 | class HistoMaker:
32              sf=float(job.sf)
33          theScale = 1.
34          if anaTag == '7TeV':
35 <            theScale = float(self.lumi)*xsec*sf/(0.46502*CountWithPU.GetBinContent(1)+0.53498*CountWithPU2011B.GetBinContent(1))*self.rescale/float(job.split)
35 >            theScale = float(self.lumi)*xsec*sf/(0.46502*CountWithPU.GetBinContent(1)+0.53498*CountWithPU2011B.GetBinContent(1))*MC_rescale_factor/float(job.split)
36          elif anaTag == '8TeV':
37 <            theScale = float(self.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*self.rescale/float(job.split)
37 >            theScale = float(self.lumi)*xsec*sf/(CountWithPU.GetBinContent(1))*MC_rescale_factor/float(job.split)
38          return theScale
39  
40  
# Line 46 | Line 46 | class HistoMaker:
46  
47          #get the conversion rate in case of BDT plots
48          TrainFlag = eval(self.config.get('Analysis','TrainFlag'))
49        if TrainFlag:
50            MC_rescale_factor=2.
51            print 'I RESCALE BY 2.0'
52        else: MC_rescale_factor = 1.
53
49          BDT_add_cut='EventForTraining == 0'
50  
51  
# Line 82 | Line 77 | class HistoMaker:
77          Tree = input.Get(job.tree)
78          output.cd()
79          CuttedTree=Tree.CopyTree(treeCut)
80 <    
80 >        input.Close()
81 >        del input
82          # get all Histos at once
83          weightF=self.config.get('Weights',self.which_weightF)
84          for options in self.optionsList:
# Line 103 | Line 99 | class HistoMaker:
99              if job.type != 'DATA':
100                  if CuttedTree.GetEntries():
101                      
102 <                    if 'BDT' in treeVar: drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
102 >                    if 'RTight' in treeVar or 'RMed' in treeVar: drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
103                      else: drawoption = '%s'%(weightF)
104                      output.cd()
105                      CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax), drawoption, "goff,e")
# Line 114 | Line 110 | class HistoMaker:
110                  if options[11] == 'blind':
111                      output.cd()
112                      if treeVar == 'H.mass':
113 <                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<80. || '+treeVar + '>150.' , "goff,e")
113 >                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<90. || '+treeVar + '>150.' , "goff,e")
114                      else:
115                          CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<0', "goff,e")
116  
# Line 129 | Line 125 | class HistoMaker:
125                  hTree = ROOT.TH1F('%s'%name,'%s'%name,nBins,xMin,xMax)
126                  hTree.Sumw2()
127              if job.type != 'DATA':
128 <                if 'BDT' in treeVar: ScaleFactor = self.getScale(job,subsample,MC_rescale_factor)
128 >                if 'RTight' in treeVar or 'RMed' in treeVar:
129 >                    if TrainFlag:
130 >                        MC_rescale_factor=2.
131 >                        print 'I RESCALE BY 2.0'
132 >                    else: MC_rescale_factor = 1.
133 >                    ScaleFactor = self.getScale(job,subsample,MC_rescale_factor)
134                  else: ScaleFactor = self.getScale(job,subsample)
135                  if ScaleFactor != 0:
136                      hTree.Scale(ScaleFactor)
# Line 144 | Line 145 | class HistoMaker:
145                  hTree.SetBinError(1,uFlowErr)
146                  hTree.SetBinError(hTree.GetNbinsX(),oFlowErr)
147              hTree.SetDirectory(0)
147            input.Close()
148              hTreeList.append(hTree)
149              groupList.append(group)
150 <            
150 >        
151 >        output.Close()
152 >        del output
153          return hTreeList, groupList
154          
155  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines