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.11 by nmohr, Thu Nov 22 14:13:41 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 >        input.Close()
39          return theScale
40  
41  
# Line 46 | Line 47 | class HistoMaker:
47  
48          #get the conversion rate in case of BDT plots
49          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
50          BDT_add_cut='EventForTraining == 0'
51  
52  
# Line 82 | Line 78 | class HistoMaker:
78          Tree = input.Get(job.tree)
79          output.cd()
80          CuttedTree=Tree.CopyTree(treeCut)
81 <    
81 >        input.Close()
82 >        del input
83          # get all Histos at once
84          weightF=self.config.get('Weights',self.which_weightF)
85          for options in self.optionsList:
# Line 103 | Line 100 | class HistoMaker:
100              if job.type != 'DATA':
101                  if CuttedTree.GetEntries():
102                      
103 <                    if 'BDT' in treeVar: drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
103 >                    if 'RTight' in treeVar or 'RMed' in treeVar: drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
104                      else: drawoption = '%s'%(weightF)
105                      output.cd()
106                      CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax), drawoption, "goff,e")
# Line 114 | Line 111 | class HistoMaker:
111                  if options[11] == 'blind':
112                      output.cd()
113                      if treeVar == 'H.mass':
114 <                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<80. || '+treeVar + '>150.' , "goff,e")
114 >                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<90. || '+treeVar + '>150.' , "goff,e")
115                      else:
116                          CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<0', "goff,e")
117  
# Line 129 | Line 126 | class HistoMaker:
126                  hTree = ROOT.TH1F('%s'%name,'%s'%name,nBins,xMin,xMax)
127                  hTree.Sumw2()
128              if job.type != 'DATA':
129 <                if 'BDT' in treeVar: ScaleFactor = self.getScale(job,subsample,MC_rescale_factor)
129 >                if 'RTight' in treeVar or 'RMed' in treeVar:
130 >                    if TrainFlag:
131 >                        MC_rescale_factor=2.
132 >                        print 'I RESCALE BY 2.0'
133 >                    else: MC_rescale_factor = 1.
134 >                    ScaleFactor = self.getScale(job,subsample,MC_rescale_factor)
135                  else: ScaleFactor = self.getScale(job,subsample)
136                  if ScaleFactor != 0:
137                      hTree.Scale(ScaleFactor)
# Line 144 | Line 146 | class HistoMaker:
146                  hTree.SetBinError(1,uFlowErr)
147                  hTree.SetBinError(hTree.GetNbinsX(),oFlowErr)
148              hTree.SetDirectory(0)
147            input.Close()
149              hTreeList.append(hTree)
150              groupList.append(group)
151 <            
151 >        
152 >        output.Close()
153 >        del output
154          return hTreeList, groupList
155          
156  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines