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

Comparing UserCode/VHbb/python/myutils/HistoMaker.py (file contents):
Revision 1.10 by peller, Tue Feb 19 17:22:31 2013 UTC vs.
Revision 1.18 by nmohr, Sun Apr 7 09:30:04 2013 UTC

# Line 18 | Line 18 | class HistoMaker:
18          self.cuts = []
19          for options in optionsList:
20              self.cuts.append(options['cut'])
21 <        print self.cuts
21 >        #print self.cuts
22          #self.tc = TreeCache(self.cuts,samples,path)
23          self.tc = TreeCache(self.cuts,samples,path,config)
24          self._rebin = False
25          self.mybinning = None
26          self.GroupDict=GroupDict
27          self.calc_rebin_flag = False
28 +        VHbbNameSpace=config.get('VHbbNameSpace','library')
29 +        ROOT.gSystem.Load(VHbbNameSpace)
30  
31      def get_histos_from_tree(self,job):
32          if self.lumi == 0:
# Line 41 | Line 43 | class HistoMaker:
43          addOverFlow=eval(self.config.get('Plot_general','addOverFlow'))
44  
45          # get all Histos at once
46 +        CuttedTree = self.tc.get_tree(job,'1')
47          for options in self.optionsList:
48              name=job.name
49              if self.GroupDict is None:
# Line 57 | Line 60 | class HistoMaker:
60              xMax=float(options['xMax'])
61              weightF=options['weight']
62              treeCut='%s'%(options['cut'])
60            CuttedTree = self.tc.get_tree(job,treeCut)
63  
64              #options
65  
66              if job.type != 'DATA':
67                  if CuttedTree.GetEntries():
68                      if 'RTight' in treeVar or 'RMed' in treeVar:
69 <                        drawoption = '(%s)*(%s)'%(weightF,BDT_add_cut)
69 >                        drawoption = '(%s)*(%s & %s)'%(weightF,treeCut,BDT_add_cut)
70                      else:
71 <                        drawoption = '%s'%(weightF)
71 >                        drawoption = '(%s)*(%s)'%(weightF,treeCut)
72                      CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax), drawoption, "goff,e")
73                      full=True
74                  else:
75                      full=False
76              elif job.type == 'DATA':
77 <                if eval(options['blind']):
77 >                if options['blind']:
78                      if treeVar == 'H.mass':
79 <                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<90. || '+treeVar + '>150.' , "goff,e")
79 >                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),' (%(var)s <90. || %(var)s > 150.) & %(cut)s' %options, "goff,e")
80                      else:
81 <                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),treeVar+'<0', "goff,e")
81 >                        CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),'%(var)s < 0. & %(cut)s'%options, "goff,e")
82  
83                  else:
84 <                    CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),'1', "goff,e")
84 >                    CuttedTree.Draw('%s>>%s(%s,%s,%s)' %(treeVar,name,nBins,xMin,xMax),'%s' %treeCut, "goff,e")
85                  full = True
86              if full:
87                  hTree = ROOT.gDirectory.Get(name)
# Line 114 | Line 116 | class HistoMaker:
116                  gDict[group] = self.mybinning.rebin(hTree)
117                  del hTree
118              else:
119 <                print 'not rebinning %s'%job.name
119 >                #print 'not rebinning %s'%job.name
120                  gDict[group] = hTree
121              hTreeList.append(gDict)
122 <            CuttedTree.IsA().Destructor(CuttedTree)
123 <            del CuttedTree
122 >        CuttedTree.IsA().Destructor(CuttedTree)
123 >        del CuttedTree
124          return hTreeList
125        
126      @property
# Line 142 | Line 144 | class HistoMaker:
144          elif not self._rebin and not self.value:
145              return False
146  
147 <    def calc_rebin(self, bg_list, nBins_start=1000, tolerance=0.35):
147 >    def calc_rebin(self, bg_list, nBins_start=1000, tolerance=0.25):
148          self.calc_rebin_flag = True
149          self.norebin_nBins = copy(self.nBins)
150          self.rebin_nBins = nBins_start
# Line 173 | Line 175 | class HistoMaker:
175              if not TotR == 0 and not ErrorR == 0:
176                  rel=ErrorR/TotR
177                  #print rel
178 <        print 'upper bin is %s'%binR
178 >        #print 'upper bin is %s'%binR
179  
180          #---- from left
181          rel=1.0
# Line 186 | Line 188 | class HistoMaker:
188                  #print rel
189          #it's the lower edge
190          binL+=1
191 <        print 'lower bin is %s'%binL
191 >        #print 'lower bin is %s'%binL
192  
193          inbetween=binR-binL
194          stepsize=int(inbetween)/(int(self.norebin_nBins)-2)
195          modulo = int(inbetween)%(int(self.norebin_nBins)-2)
196  
197 <        print 'stepsize %s'% stepsize
197 >        #print 'stepsize %s'% stepsize
198          #print 'modulo %s'%modulo
199          binlist=[binL]
200          for i in range(0,int(self.norebin_nBins)-3):
# Line 200 | Line 202 | class HistoMaker:
202          binlist[-1]+=modulo
203          binlist.append(binR)
204          binlist.append(self.rebin_nBins+1)
205 <        print 'binning set to %s'%binlist
205 >        #print 'binning set to %s'%binlist
206          self.mybinning = Rebinner(int(self.norebin_nBins),array('d',[-1.0]+[totalBG.GetBinLowEdge(i) for i in binlist]),True)
207          self._rebin = True
208          print '\t > rebinning is set <\n'

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines