示例#1
0
def getStack(labels, var, binning, cut, options={}, qcdSample=None):

#      style_Data         = {'legendText':dataSample['name'],      'style':"e", 'lineThickness':0, 'errorBars':True, 'color':ROOT.kBlack, 'markerStyle':20, 'markerSize':1}
#  tyle_WJets        = {'legendText':'W + Jets',         'style':"l", 'lineThickness':0, 'errorBars':False, 'color':42, 'markerStyle':None, 'markerSize':None}
  style_TTJets       = {'legendText':'t#bar{t} + Jets',  'style':"f", 'linethickNess':0, 'errorBars':False, 'color':7, 'markerStyle':None, 'markerSize':None}
  style_DY           = {'legendText':'DY + Jets',  'style':"f", 'linethickNess':0, 'errorBars':False,       'color':8, 'markerStyle':None, 'markerSize':None}
#  style_TTX          = {'legendText':'t#bar{t} + W/Z/H',  'style':"l", 'linethickNess':0, 'errorBars':False, 'color':ROOT.kYellow+2, 'markerStyle':None, 'markerSize':None}
  style_diBoson         = {'legendText':'WW/WZ/ZZ',  'style':"l", 'linethickNess':2, 'errorBars':False, 'color':ROOT.kGreen-5, 'markerStyle':None, 'markerSize':None}
  style_QCD          = {'legendText':'QCD',  'style':"l", 'linethickNess':2, 'errorBars':False,             'color':46, 'markerStyle':None, 'markerSize':None}
  style_singleTop    = {'legendText':'single top',  'style':"l", 'linethickNess':2, 'errorBars':False,      'color':40, 'markerStyle':None, 'markerSize':None}
  
#      data               = plot(var, binning, cut, sample=dataSample,       style=style_Data, weightString="weight")
  MC_TTJets          = plot(var, binning, cut, sample=TTJets,       style=style_TTJets,    weightString="weight", weightFunc=puReweighting)
#  MC_WJetsToLNu      = plot(var, binning, cut, sample=WJetsToLNu,   style=style_WJets,     weightString="weight", weightFunc=puReweighting)
  MC_DY              = plot(var, binning, cut, sample=DY,           style=style_DY,        weightString="weight", weightFunc=puReweighting)
  MC_singleTop       = plot(var, binning, cut, sample=singleTop,    style=style_singleTop, weightString="weight", weightFunc=puReweighting)
  MC_QCD             = plot(var, binning, cut, sample=qcdSample,        style=style_QCD,       weightString="weight", weightFunc=puReweighting)
#  MC_TTX             = plot(var, binning, cut, sample=TTX,          style=style_TTX, weightString="weight", weightFunc=puReweighting)
#  MC_diBoson         = plot(var, binning, cut, sample=diBoson,     style=style_diBoson, weightString="weight", weightFunc=puReweighting)
  #FIXME triBoson
#      mcStack = [MC_TTJets, MC_DY,  MC_QCD, MC_singleTop, MC_WJetsToLNu, MC_diBoson, MC_TTX]
#  mcStack = [MC_TTJets, MC_DY,  MC_QCD, MC_singleTop, MC_WJetsToLNu]

  ewk = [MC_TTJets, MC_DY]
  qcd = [ MC_QCD] 
  MC_QCD.normalizeTo=ewk[0]

  plotLists = [ ewk, qcd]  #, MC_singleTop]
#      for s in mcStack:
#        s.sample['scale'] = lumiScaleFac*scaleFac


  for pL in plotLists:
    for p in pL:
      p.sample['small']=opts.small

  opt = {'small':opts.small, 'yHeadRoomFac':12, 'labels':labels, 'logX':False, 'logY':True, 'yRange':[0.11, "auto"], 'ratio':ratioOps, 'fileName':var['name']}
#  opt = {'small':small, 'yHeadRoomFac':12, 'labels':labels, 'logX':False, 'logY':True, 'yRange':[0.11, "auto"], 'ratio':None, 'fileName':var['name']}

  if opt.has_key('ratio') and opt['ratio']:
    opt['texLines'] = [{'pos':(0.15, 0.95),'text':'CMS Preliminary', 'options':{'size':0.052}},
#                           {'pos':(0.47, 0.95), 'text':'L='+str(dataSample['lumi'])+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac, 'options':{'size':0.052}}
    ]
    opt['legend'] = {'coordinates':[0.55,0.90 - (len(ewk)+len(qcd))*0.05,.98,.93],'boxed':True}
  else:
    opt['texLines'] = [{'pos':(0.16, 0.965), 'text':'CMS Preliminary',       'options':{'size':0.038}},
#                           {'pos':(0.47, 0.965),  'text':'L='+str(dataSample['lumi'])+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac,'options':{'size':0.038}}
    ]
    opt['legend'] = {'coordinates':[0.55,0.90 - (len(ewk)+len(qcd))*0.05,.98,.95],'boxed':True}

  opt.update(options)
  res = stack(plotLists, options = opt)
  res.usedBranches = cutBranches
  return res
示例#2
0
    def getStack(labels, var, binning, cut, options={}):

      style_Data         = {'legendText':dataSample['name'],      'style':"e", 'lineThickness':0, 'errorBars':True, 'color':ROOT.kBlack, 'markerStyle':20, 'markerSize':1}
      style_WJets        = {'legendText':'W + Jets',         'style':"f", 'lineThickness':0, 'errorBars':False, 'color':42, 'markerStyle':None, 'markerSize':None}
      style_TTJets       = {'legendText':'t#bar{t} + Jets',  'style':"f", 'linethickNess':0, 'errorBars':False, 'color':7, 'markerStyle':None, 'markerSize':None}
      style_DY           = {'legendText':'DY + Jets',  'style':"f", 'linethickNess':0, 'errorBars':False,       'color':8, 'markerStyle':None, 'markerSize':None}
      style_TTX          = {'legendText':'t#bar{t} + W/Z/H',  'style':"f", 'linethickNess':0, 'errorBars':False, 'color':ROOT.kYellow+2, 'markerStyle':None, 'markerSize':None}
      style_diBoson         = {'legendText':'WW/WZ/ZZ',  'style':"f", 'linethickNess':0, 'errorBars':False, 'color':ROOT.kGreen-5, 'markerStyle':None, 'markerSize':None}
      style_QCD          = {'legendText':'QCD',  'style':"f", 'linethickNess':0, 'errorBars':False,             'color':46, 'markerStyle':None, 'markerSize':None}
      style_singleTop    = {'legendText':'single top',  'style':"f", 'linethickNess':0, 'errorBars':False,      'color':40, 'markerStyle':None, 'markerSize':None}
      
      data               = plot(var, binning, cut, sample=dataSample,       style=style_Data)
      MC_TTJets          = plot(var, binning, cut, sample=TTJets,       style=style_TTJets,    weightString=weightMC, weightFunc=wf)
      MC_WJetsToLNu      = plot(var, binning, cut, sample=WJetsToLNu,   style=style_WJets,     weightString=weightMC, weightFunc=wf)
      MC_DY              = plot(var, binning, cut, sample=DY_HT_LO,           style=style_DY,  weightString=weightMC, weightFunc=wf)
      MC_singleTop       = plot(var, binning, cut, sample=singleTop,    style=style_singleTop, weightString=weightMC, weightFunc=wf)
      MC_QCD             = plot(var, binning, cut, sample=QCDSample,        style=style_QCD,   weightString=weightMC, weightFunc=wf)
      MC_TTX             = plot(var, binning, cut, sample=TTX,          style=style_TTX,       weightString=weightMC, weightFunc=wf)
      MC_diBoson         = plot(var, binning, cut, sample=diBoson,     style=style_diBoson,    weightString=weightMC, weightFunc=wf)
      #FIXME triBoson
      mcStack = [MC_TTJets, MC_DY,  MC_QCD, MC_singleTop, MC_WJetsToLNu, MC_diBoson, MC_TTX]
      for s in mcStack:
    #    print s,s.sample
        s.sample['scale'] = lumiScaleFac*scaleFac if opts.scaleToData else lumiScaleFac

      plotLists = [mcStack, [data]]
#      plotLists = [mcStack]

      for pL in plotLists:
        for p in pL:
          p.sample['small']=opts.small

      opt = {'small':opts.small, 'yHeadRoomFac':12, 'labels':labels, 'logX':False, 'logY':True, 'yRange':[0.11, "auto"], 'ratio':ratioOps, 'fileName':var['name']}
    #  opt = {'small':small, 'yHeadRoomFac':12, 'labels':labels, 'logX':False, 'logY':True, 'yRange':[0.11, "auto"], 'ratio':None, 'fileName':var['name']}

      if opt.has_key('ratio') and opt['ratio']:
        opt['texLines'] = [{'pos':(0.15, 0.95),'text':'CMS Preliminary', 'options':{'size':0.052}},\
                           {'pos':(0.47, 0.95), 'text':'L='+str(int(dataSample['lumi']/1)*1)+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac, 'options':{'size':0.052}}]
        opt['legend'] = {'coordinates':[0.55,0.90 - len(mcStack)*0.05,.98,.93],'boxed':True}
      else:
        opt['texLines'] = [{'pos':(0.16, 0.965), 'text':'CMS Preliminary',       'options':{'size':0.038}},\
                           {'pos':(0.47, 0.965),  'text':'L='+str(int(dataSample['lumi']/1)*1)+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac,'options':{'size':0.038}}]
        opt['legend'] = {'coordinates':[0.55,0.90 - len(mcStack)*0.05,.98,.95],'boxed':True}

      opt.update(options)
      res = stack(plotLists, options = opt)
      res.usedBranches = cutBranches
      return res
示例#3
0
        def getStack(labels, var, binning, cut, options={}):

            style_Data = {
                'legendText': dataSample['name'],
                'style': "e",
                'lineThickness': 0,
                'errorBars': True,
                'color': ROOT.kBlack,
                'markerStyle': 20,
                'markerSize': 1
            }
            style_WJets = {
                'legendText': 'W + Jets',
                'style': "f",
                'lineThickness': 0,
                'errorBars': False,
                'color': 42,
                'markerStyle': None,
                'markerSize': None
            }
            style_TTJets = {
                'legendText': 't#bar{t} + Jets',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': 7,
                'markerStyle': None,
                'markerSize': None
            }
            style_DY = {
                'legendText': 'DY + Jets',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': 8,
                'markerStyle': None,
                'markerSize': None
            }
            style_TTX = {
                'legendText': 't#bar{t} + W/Z/H',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': ROOT.kYellow + 2,
                'markerStyle': None,
                'markerSize': None
            }
            style_diBoson = {
                'legendText': 'WW/WZ/ZZ',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': ROOT.kGreen - 5,
                'markerStyle': None,
                'markerSize': None
            }
            style_QCD = {
                'legendText': 'QCD',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': 46,
                'markerStyle': None,
                'markerSize': None
            }
            style_singleTop = {
                'legendText': 'single top',
                'style': "f",
                'linethickNess': 0,
                'errorBars': False,
                'color': 40,
                'markerStyle': None,
                'markerSize': None
            }

            data = plot(var, binning, cut, sample=dataSample, style=style_Data)
            MC_TTJets = plot(var,
                             binning,
                             cut,
                             sample=TTJets,
                             style=style_TTJets,
                             weightString=weightMC,
                             weightFunc=wf)
            MC_WJetsToLNu = plot(var,
                                 binning,
                                 cut,
                                 sample=WJetsToLNu,
                                 style=style_WJets,
                                 weightString=weightMC,
                                 weightFunc=wf)
            MC_DY = plot(var,
                         binning,
                         cut,
                         sample=DY_HT_LO,
                         style=style_DY,
                         weightString=weightMC,
                         weightFunc=wf)
            MC_singleTop = plot(var,
                                binning,
                                cut,
                                sample=singleTop,
                                style=style_singleTop,
                                weightString=weightMC,
                                weightFunc=wf)
            MC_QCD = plot(var,
                          binning,
                          cut,
                          sample=QCDSample,
                          style=style_QCD,
                          weightString=weightMC,
                          weightFunc=wf)
            MC_TTX = plot(var,
                          binning,
                          cut,
                          sample=TTX,
                          style=style_TTX,
                          weightString=weightMC,
                          weightFunc=wf)
            MC_diBoson = plot(var,
                              binning,
                              cut,
                              sample=diBoson,
                              style=style_diBoson,
                              weightString=weightMC,
                              weightFunc=wf)
            #FIXME triBoson
            mcStack = [
                MC_TTJets, MC_DY, MC_QCD, MC_singleTop, MC_WJetsToLNu,
                MC_diBoson, MC_TTX
            ]
            for s in mcStack:
                #    print s,s.sample
                s.sample[
                    'scale'] = lumiScaleFac * scaleFac if opts.scaleToData else lumiScaleFac

            plotLists = [mcStack, [data]]
            #      plotLists = [mcStack]

            for pL in plotLists:
                for p in pL:
                    p.sample['small'] = opts.small

            opt = {
                'small': opts.small,
                'yHeadRoomFac': 12,
                'labels': labels,
                'logX': False,
                'logY': True,
                'yRange': [0.11, "auto"],
                'ratio': ratioOps,
                'fileName': var['name']
            }
            #  opt = {'small':small, 'yHeadRoomFac':12, 'labels':labels, 'logX':False, 'logY':True, 'yRange':[0.11, "auto"], 'ratio':None, 'fileName':var['name']}

            if opt.has_key('ratio') and opt['ratio']:
                opt['texLines'] = [{'pos':(0.15, 0.95),'text':'CMS Preliminary', 'options':{'size':0.052}},\
                                   {'pos':(0.47, 0.95), 'text':'L='+str(int(dataSample['lumi']/1)*1)+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac, 'options':{'size':0.052}}]
                opt['legend'] = {
                    'coordinates':
                    [0.55, 0.90 - len(mcStack) * 0.05, .98, .93],
                    'boxed': True
                }
            else:
                opt['texLines'] = [{'pos':(0.16, 0.965), 'text':'CMS Preliminary',       'options':{'size':0.038}},\
                                   {'pos':(0.47, 0.965),  'text':'L='+str(int(dataSample['lumi']/1)*1)+' pb{}^{-1} (13 TeV) Scale %3.2f'%scaleFac,'options':{'size':0.038}}]
                opt['legend'] = {
                    'coordinates':
                    [0.55, 0.90 - len(mcStack) * 0.05, .98, .95],
                    'boxed': True
                }

            opt.update(options)
            res = stack(plotLists, options=opt)
            res.usedBranches = cutBranches
            return res