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.3 by peller, Tue Oct 2 13:19:45 2012 UTC vs.
Revision 1.5 by peller, Fri Oct 5 11:58:18 2012 UTC

# Line 44 | Line 44 | class HistoMaker:
44          hTreeList=[]
45          groupList=[]
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 +
54 +        BDT_add_cut='EventForTraining == 0'
55 +
56  
57          plot_path = self.config.get('Directories','plotpath')
58 +        addOverFlow=eval(self.config.get('Plot_general','addOverFlow'))
59  
60          # define treeCut
61          if job.type != 'DATA':
# Line 57 | Line 67 | class HistoMaker:
67                  cutcut=cutcut.replace(self.region[1],self.region[2])
68                  #print cutcut
69              if subsample>-1:
70 <                treeCut='%s & %s & EventForTraining == 0'%(cutcut,job.subcuts[subsample])        
70 >                treeCut='%s & %s'%(cutcut,job.subcuts[subsample])        
71              else:
72 <                treeCut='%s & EventForTraining == 0'%(cutcut)
72 >                treeCut='%s'%(cutcut)
73          elif job.type == 'DATA':
74              cutcut=self.config.get('Cuts',self.region)
75              treeCut='%s'%(cutcut)
# Line 86 | Line 96 | class HistoMaker:
96              xMin=float(options[4])
97              xMax=float(options[5])
98  
99 +            #options
100 +
101              if job.type != 'DATA':
102                  if CuttedTree.GetEntries():
103 +                    
104 +                    if 'BDT' in treeVar: drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
105 +                    else: drawoption = '%s'%(weightF)
106                      output.cd()
107 <                    CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax), weightF, "goff,e")
107 >                    CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax), drawoption, "goff,e")
108                      full=True
109                  else:
110                      full=False
# Line 108 | Line 123 | class HistoMaker:
123                  hTree = ROOT.TH1F('%s'%name,'%s'%name,nBins,xMin,xMax)
124                  hTree.Sumw2()
125              if job.type != 'DATA':
126 <                ScaleFactor = self.getScale(job,subsample)
126 >                if 'BDT' in treeVar: ScaleFactor = self.getScale(job,subsample,MC_rescale_factor)
127 >                else: ScaleFactor = self.getScale(job,subsample)
128                  if ScaleFactor != 0:
129                      hTree.Scale(ScaleFactor)
130              #print '\t-->import %s\t Integral: %s'%(job.name,hTree.Integral())
131 +            if addOverFlow:
132 +                uFlow = hTree.GetBinContent(0)+hTree.GetBinContent(1)
133 +                oFlow = hTree.GetBinContent(hTree.GetNbinsX()+1)+hTree.GetBinContent(hTree.GetNbinsX())
134 +                uFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(0),2)+ROOT.TMath.Power(hTree.GetBinError(1),2))
135 +                oFlowErr = ROOT.TMath.Sqrt(ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()),2)+ROOT.TMath.Power(hTree.GetBinError(hTree.GetNbinsX()+1),2))
136 +                hTree.SetBinContent(1,uFlow)
137 +                hTree.SetBinContent(hTree.GetNbinsX(),oFlow)
138 +                hTree.SetBinError(1,uFlowErr)
139 +                hTree.SetBinError(hTree.GetNbinsX(),oFlowErr)
140              hTree.SetDirectory(0)
141              input.Close()
142              hTreeList.append(hTree)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines