예제 #1
0
def makeMTPlotWithUncertainties(c,  binning, cut, weight, doPDF = doPDF):
  hMT = getCutPlotFromChain(c, 'mT', binning, cut, weight, binningIsExplicit=True, addOverFlowBin='upper')
  hPDF = None
  if doPDF:
    cPDF = ROOT.TChain('Events')
    cPDF.Add('/data/schoef/convertedTuples_v22/copy/WJetsHT150PDF/histo_WJetsHT150PDF*.root')
    hPDF = getPDFRelUncertaintyPlot(cPDF, 'mT', binning, cut, weight)
    del cPDF
#    hErrPDF = hMT.Clone()
#    for b in range(1,1+hMT.GetNbinsX()):
##      hErrPDF.SetBinContent(b,0)
#      hErrPDF.SetBinContent(b, hPDF.GetBinContent(b)*hMT.GetBinContent(b))

  cJESPlus = ROOT.TChain('Events')
  cJESPlus.Add('/data/schoef/convertedTuples_v22/copy_JESup/WJetsHT150v2/histo_WJetsHT150v2*.root')
  cJESMinus = ROOT.TChain('Events')
  cJESMinus.Add('/data/schoef/convertedTuples_v22/copy_JESdown/WJetsHT150v2/histo_WJetsHT150v2*.root')
  hErrJES = getJESRelUncertaintyPlot([cJESPlus, cJESMinus], hMT, 'mT', binning, cut, weight)
  del cJESPlus, cJESMinus

  cJERCentral = ROOT.TChain('Events')
  cJERCentral.Add('/data/schoef/convertedTuples_v22/copy_JERcentral/WJetsHT150v2/histo_WJetsHT150v2*.root')
  cJERPlus = ROOT.TChain('Events')
  cJERPlus.Add('/data/schoef/convertedTuples_v22/copy_JERup/WJetsHT150v2/histo_WJetsHT150v2*.root')
  cJERMinus = ROOT.TChain('Events')
  cJERMinus.Add('/data/schoef/convertedTuples_v22/copy_JERdown/WJetsHT150v2/histo_WJetsHT150v2*.root')
  hErrJER = getJERRelUncertaintyPlot([cJERCentral, cJERPlus, cJERMinus], 'mT', binning, cut, weight)
  del cJERPlus, cJERMinus, cJERCentral

  return {'hist':hMT, 'unc':{'pdf':hPDF, 'jes':hErrJES, 'jer':hErrJER}}
예제 #2
0
def  getJESRelUncertaintyPlot(chains, hRef, var, binning, cut, weight):
  hPlus = getCutPlotFromChain(chains[0], 'mT', binning, cut, weight, binningIsExplicit=True, addOverFlowBin='upper')
  hMinus = getCutPlotFromChain(chains[1], 'mT', binning, cut, weight, binningIsExplicit=True, addOverFlowBin='upper')
  res = hPlus.Clone()
  res.Reset()
  hPlus.Scale(hRef.GetBinContent(1)/hPlus.GetBinContent(1))
  hMinus.Scale(hRef.GetBinContent(1)/hMinus.GetBinContent(1))
  for b in range(1,1+res.GetNbinsX()):
    ref=hRef  .GetBinContent(b)
    p  =hPlus .GetBinContent(b)
    m  =hMinus.GetBinContent(b)
    if ref>0:
      relErr = 1./ref * max(abs(p-ref),abs(m-ref))
    else:
      relErr=0.
#    print b, relErr
    res.SetBinContent(b, relErr)
  del hPlus, hMinus
  return res 
예제 #3
0
cRest=ROOT.TChain('Events')
for s in['WW','ZZ','WZ','singleTop','DY','QCD20to600','QCD600to1000','QCD1000']:
  cRest.Add('/data/schoef/convertedTuples_v22/copy/'+s+'/histo_'+s+'*.root')

cData=ROOT.TChain('Events')
cData.Add('/data/schoef/convertedTuples_v22/copy/data/histo_data*.root')


metb=[150,350]
htb=[400,750]
njetb=[2,3]
lpdg=''
mTCut='mT>20&&mT<120'

template_WJets_PosPdg=getCutPlotFromChain(cWJets,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'pos',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
template_WJets_NegPdg=getCutPlotFromChain(cWJets,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'neg',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
template_TTJets=getCutPlotFromChain(cTTJets,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
template_Rest_PosPdg=getCutPlotFromChain(cRest,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'pos',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
template_Rest_NegPdg=getCutPlotFromChain(cRest,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'neg',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')

print "Nominal yields TT:",template_TTJets.Integral(),'WJets_PosPdg',template_WJets_PosPdg.Integral(),'WJets_NegPdg',template_WJets_NegPdg.Integral()
print "Nominal yields:",'Rest_PosPdg',template_Rest_PosPdg.Integral(),'Rest_NegPdg',template_Rest_NegPdg.Integral()

#template_WJets_PosPdg.Scale(1./template_WJets_PosPdg.GetBinContent(1))
#template_WJets_NegPdg.Scale(1./template_WJets_NegPdg.GetBinContent(1))
#template_TTJets.Scale(1./template_TTJets.GetBinContent(1))

hData_PosPdg=getCutPlotFromChain(cData,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'pos',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
hData_NegPdg=getCutPlotFromChain(cData,'nbtags',[0,1,2,3],mTCut+'&&'+nameAndCut(metb,htb,njetb,'neg',btagRequirement='None')[1],'weight',binningIsExplicit=True,addOverFlowBin='upper')
예제 #4
0
cWJets.Add('/data/schoef/convertedTuples_v22/copy/WJetsHT150v2/histo_WJetsHT150v2*.root')
cAllMC.Add('/data/schoef/convertedTuples_v22/copy/WJetsHT150v2/histo_WJetsHT150v2*.root')

cRest = ROOT.TChain('Events')
for s in['WW','ZZ','WZ','TTJetsPowHeg','singleTop','DY','QCD20to600','QCD600to1000','QCD1000']:
  cRest.Add('/data/schoef/convertedTuples_v22/copy/'+s+'/histo_'+s+'*.root')
  cAllMC.Add('/data/schoef/convertedTuples_v22/copy/'+s+'/histo_'+s+'*.root')

cData = ROOT.TChain('Events')
cData.Add('/data/schoef/convertedTuples_v22/copy/data/histo_data*.root')

for postFix, binning in [['_binningCoarse', binningCoarse], ['_binningFine', binningFine] ]:
  for plotName, cut, addData in plots:
    print "At", plotName, cut,'addData', addData
    mTRes = makeMTPlotWithUncertainties(cWJets, binning, cut, 'weight', doPDF = doPDF)
    hRest = getCutPlotFromChain(cRest, 'mT', binning, cut, 'weight', binningIsExplicit=True, addOverFlowBin='upper')
    mTRes['hist'].Add(hRest)
    if addData:
      hData = getCutPlotFromChain(cData, 'mT', binning, cut, 'weight', binningIsExplicit=True, addOverFlowBin='upper')
      scaleF = hData.GetBinContent(1)/mTRes['hist'].GetBinContent(1)
      mTRes['hist'].Scale(scaleF)
      hRest.Scale(scaleF)
      for k in mTRes['unc'].keys():
        if mTRes['unc'][k]:
          mTRes['unc'][k].Scale(scaleF)
    topPadDrawObjs=[]
    bottomPadDrawObjs=[]
    for b in range(1, 1+mTRes['hist'].GetNbinsX()):
      binWidth = mTRes['hist'].GetBinWidth(b)
      xLow = mTRes['hist'].GetBinLowEdge(b)
      xHigh = xLow + binWidth 
예제 #5
0
    cRest.Add('/data/schoef/convertedTuples_v22/copy/' + s + '/histo_' + s +
              '*.root')

cData = ROOT.TChain('Events')
cData.Add('/data/schoef/convertedTuples_v22/copy/data/histo_data*.root')

metb = [150, 350]
htb = [400, 750]
njetb = [2, 3]
lpdg = ''
mTCut = 'mT>20&&mT<120'

template_WJets_PosPdg = getCutPlotFromChain(
    cWJets,
    'nbtags', [0, 1, 2, 3],
    mTCut + '&&' +
    nameAndCut(metb, htb, njetb, 'pos', btagRequirement='None')[1],
    'weight',
    binningIsExplicit=True,
    addOverFlowBin='upper')
template_WJets_NegPdg = getCutPlotFromChain(
    cWJets,
    'nbtags', [0, 1, 2, 3],
    mTCut + '&&' +
    nameAndCut(metb, htb, njetb, 'neg', btagRequirement='None')[1],
    'weight',
    binningIsExplicit=True,
    addOverFlowBin='upper')
template_TTJets = getCutPlotFromChain(
    cTTJets,
    'nbtags', [0, 1, 2, 3],
    mTCut + '&&' + nameAndCut(metb, htb, njetb, '', btagRequirement='None')[1],