Example #1
0
def plotPU(category):

    MJArray = [
        200., 230., 260.0, 290.0, 320.0, 350.0, 390.0, 430.0, 470.0, 510.0,
        550.0, 590.0, 640.0, 690.0, 740.0, 790.0, 840.0, 900.0, 960.0, 1020.0,
        1090.0, 1160.0, 1250.0
    ]
    MVArray = [250, 300, 350, 400, 500, 600, 1000]

    theArray = MJArray
    if category == 'monoV':
        theArray = MVArray

    plotter.ResetWeight()
    plotter.AddWeight(cuts.cut(category, 'signal') + '* (mcWeight)')
    plotter.AddWeight(cuts.cut(category, 'signal') + '* (mcWeight * puWeight)')
    plotter.AddWeight(
        cuts.cut(category, 'signal') + '* (mcWeight * puWeightOff)')

    plotter.SetDefaultExpr('met')
    plotter.MakeCanvas('~/www/plots/160314/' + category,
                       len(theArray) - 1, array('d', theArray), 'MET [GeV]',
                       'Events/GeV', True)
    plotter.SetDefaultExpr('npv')
    plotter.MakeCanvas('~/www/plots/160314/NPV_' + category, 30, 0, 30, 'NPV',
                       'Events', False)
Example #2
0
 def MakePlot(args):
     holding = list(args)
     expr = args[0]
     holding[0] = outDir + 'VBFStudy_' + expr
     plotter.SetDefaultWeight(
         Nminus1Cut(
             cuts.cut('monoJet_inc', 'signal') + '*(' + cuts.METTrigger +
             ' * mcWeight * XSecWeight * puWeight * zkfactor * ewk_z)',
             expr))
     plotter.SetDefaultExpr(expr)
     plotter.MakeCanvas(*holding)
Example #3
0
plotter.AddTree(cChain)

plotter.SetRatioIndex(0)

#plotter.SetNormalizedHists(True)

plotter.AddWeight('(fatjet1Pt > 0) * mcWeight * 2.450')
plotter.AddWeight('(fatjet1Pt > 0) * mcWeight * 2.058')

plotter.AddLegendEntry('Axial 2000 #rightarrow 50 80X', 1, 2, 1)
plotter.AddLegendEntry('Axial 2000 #rightarrow 50 74X', 2, 2, 2)

plotter.SetLegendLocation(plotter.kUpper, plotter.kRight, 0.4, 0.3)

plotter.SetDefaultExpr('fatjet1Pt')
plotter.MakeCanvas('~/www/plots/160728/compare_releases_pT', 30, 250, 1000,
                   "p_{T} [GeV]", "A.U.")
plotter.SetDefaultExpr('fatjet1PrunedM')
plotter.MakeCanvas('~/www/plots/160728/compare_releases_masspruned', 20, 0,
                   200, "m_{pruned} [GeV]", "A.U.")
plotter.SetDefaultExpr('fatjet1Mass')
plotter.MakeCanvas('~/www/plots/160728/compare_releases_mass', 25, 0, 250,
                   "m_{raw} [GeV]", "A.U.")
plotter.SetDefaultExpr('met')
plotter.MakeCanvas('~/www/plots/160728/compare_releases_met', 30, 250, 1000,
                   "E_{T}^{miss} [GeV]", "A.U.")
plotter.SetLegendLocation(plotter.kUpper, plotter.kLeft, 0.4, 0.3)
plotter.SetDefaultExpr('fatjet1tau21')
plotter.MakeCanvas('~/www/plots/160728/compare_releases_tau21', 24, -0.2, 1.0,
                   "#tau_{2}/#tau_{1}", "A.U.")
Example #4
0
    ('cmva_jet1_nhf', 25, 0, 1.0),
    ('cmva_jet1_chf', 25, 0, 1.0),
    ('cmva_jet1_efrac', 25, 0, 1.0),
    ('cmva_jet1_hfrac', 25, 0, 1.0),
    ('cmva_jet2_nef', 25, 0, 1.0),
    ('cmva_jet2_cef', 25, 0, 1.0),
    ('cmva_jet2_nhf', 25, 0, 1.0),
    ('cmva_jet2_chf', 25, 0, 1.0),
    ('cmva_jet2_efrac', 25, 0, 1.0),
    ('cmva_jet2_hfrac', 25, 0, 1.0),
    ('jet_pt', 50, 0, 300),
    ('jet_eta', 25, -5.0, 5.0),
    ('n_bcmva_loose', 10, 0, 10),
    ]:
    plotter.ResetWeight()
    plotter.ResetExpr()

#    for weight in ['/ 35.9', '* pu_2017to2016_v2 / 41.3']:
#        plotter.AddWeight(Nminus1Cut(thecut, expr[0]) + weight)
#    plotter.AddWeight(Nminus1Cut(thecut + '* pu_2018to2016_v2 / 12.3', expr[0]).replace('cmva_', ''))
    plotter.AddWeight(Nminus1Cut(thecut + '/ 35.9', expr[0]))
    plotter.AddWeight(Nminus1Cut(thecut + '/ 41.3', expr[0]))
    plotter.AddWeight(Nminus1Cut(thecut + '/ 12.3', expr[0]).replace('cmva_', ''))

    plotter.AddExpr(expr[0])
    plotter.AddExpr(expr[0])
    plotter.AddExpr(expr[0].replace('cmva_', '').replace('bloose', 'bcmva_loose'))

    plotter.MakeCanvas(AddOutDir(expr[0]), expr[1], expr[2], expr[3], expr[0], 'Events/fb')
    plotter.MakeCanvas(AddOutDir('log_' + expr[0]), expr[1], expr[2], expr[3], expr[0], 'Events/fb', True)
Example #5
0
plotter.SetRatioIndex(0)

ratio = GetRatioToLines(zPlots, gammaPlots)

for iBin in range(len(xArray)):
    if iBin == 0:
        continue
    sumw2 = math.pow(ratio[0].GetBinError(iBin), 2)
    for uncert in uncertainties:
        sumw2 += math.pow(
            ratio[0].GetBinContent(iBin) * (uncert.GetBinContent(iBin) - 1), 2)
    ##
    ratio[0].SetBinError(iBin, math.sqrt(sumw2))
##

plotter.MakeCanvas(outDir + 'Zgamma_ratio_ZeeMJ_met', ratio, '|U| [GeV]',
                   'Yield Ratio (Zee/#gamma)')

plotter.SetDefaultExpr('photonPt')
gammaPlots = plotter.MakeHists(len(xArray) - 1, array('d', xArray))

plotter.ResetTree()
plotter.ResetWeight()

plotter.SetDefaultExpr('dilep_pt')
plotter.AddTreeWeight(zeeMCFile.events,
                      '(' + cuts.ZeeMJ + ')*mcFactors*XSecWeight')
plotter.AddTreeWeight(dataFile.events, cuts.ZeeMJ)
zPlots = plotter.MakeHists(len(xArray) - 1, array('d', xArray))

ratio = GetRatioToLines(zPlots, gammaPlots)
Example #6
0
plotter.AddTree(nlo_file.Get('events'))
plotter.AddTree(nlobinned_file.Get('events'))
plotter.AddTree(lo_file.Get('events'))
plotter.AddTree(lobinned_file.Get('events'))

plotter.AddLegendEntry('NLO', 1, 2, 1)
plotter.AddLegendEntry('NLO binned', 3, 2, 1)
plotter.AddLegendEntry('LO', 2, 2, 1)
plotter.AddLegendEntry('LO binned', 4, 2, 1)

plotter.SetMakeRatio(True)
plotter.SetRatioIndex(3)

plotter.SetEventsPer(1)

plotter.SetRatioMinMax(0.5, 2.0)

binning = [40, 50, 75, 100, 125, 150, 200, 250, 300, 400, 500, 700, 1000]

hists = plotter.MakeHists(len(binning) - 1, array('d', binning))

out = TFile('wjets_kfactors.root', 'RECREATE')

for name, hist in zip(['NLO', 'NLO_binned', 'LO', 'LO_binned'], hists):
    out.WriteTObject(hist, name)

plotter.MakeCanvas(AddOutDir('wjets_1'), hists, 'Boson p_{T}',
                   'Events/GeV/fb^{-1}', True)

out.Close()
Example #7
0
    (cuts.cut('ZvvHbb', 'signal'), cuts.dataMCCuts('signal', False)))
plotter.SetDefaultTree(infile.Get('events'))

plotter.AddExpr('cmva_hbb_m')
plotter.AddExpr('cmva_hbb_m_reg_old')
plotter.AddExpr('cmva_hbb_m_reg')

plotter.SetNormalizedHists(True)

plotter.AddLegendEntry('No Regression', 1, 2, 1)
plotter.AddLegendEntry('Old Regression', 2, 2, 1)
plotter.AddLegendEntry('New Regression', 3, 2, 1)

plotter.SetDebugLevel(2)

plotter.MakeCanvas(AddOutDir('regression'), 50, 50, 200, 'Dijet Mass', 'A.U.')

plotter.SetDebugLevel(1)

plotter.AddExpr('cmva_gen_withnu_dijet_m')
plotter.AddLegendEntry('Dijet Gen Mass', 1, 1, 2)

plotter.MakeCanvas(AddOutDir('regression_withgen'), 50, 50, 200, 'Dijet Mass',
                   'A.U.')

plotter.ResetExpr()
plotter.ResetLegend()

plotter.AddExpr('1.0 - cmva_jet1_gen_withnu_pt/cmva_jet1_pt')
plotter.AddExpr('cmva_jet1_pt_ratio - cmva_jet1_gen_withnu_pt/cmva_jet1_pt')
plotter.AddExpr(
Example #8
0
           'monojet_VectorMonoW_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')
cChain.Add(signal_loc +
           'monojet_VectorMonoZ_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')

dFile = TFile(directory +
              'wscale_TTJets_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8.root')

plotter.AddTree(aChain)
plotter.AddTree(bChain)
plotter.AddTree(cChain)
plotter.AddTree(dFile.Get('events'))

plotter.SetNormalizedHists(True)

plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjet1Pt')
plotter.AddExpr('fatjetPt')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('mcWeight')
plotter.AddWeight('(' + cuts.cut('semilep', 'full') + ')*(mcWeight)')

plotter.AddLegendEntry('VH Signal', 1, 2, 1)
plotter.AddLegendEntry('m_{#phi} = 500 GeV Signal', 2, 2, 2)
plotter.AddLegendEntry('m_{#phi} = 2000 GeV Signal', 3, 2, 3)
plotter.AddLegendEntry('W in tt', 4, 2, 4)

plotter.MakeCanvas('~/www/plots/160707/WPt_comparison', 17, 275, 700,
                   "p_{T} [GeV]", "A.U.")
Example #9
0
#!/usr/bin/env python

from CrombieTools.PlotTools.PlotHists import plotter

from ROOT import TFile

theFile = TFile('signalTest.root')

plotter.SetDefaultTree(theFile.Get('events'))
plotter.SetDefaultExpr('fatjetPrunedML2L3')

weight = 'fatjetPt > 250 && n_looselep == 0 && n_loosepho == 0 && n_bjetsLoose == 0 && met > 250'

plotter.AddWeight(weight)
plotter.AddWeight(weight + ' && fatjetDRWq2 > 0 && fatjetDRWq1 > 0.8')
plotter.AddWeight(weight + ' && fatjetDRWq2 > 0.8 && fatjetDRWq1 > 0.8')

plotter.AddLegendEntry('All',1)
plotter.AddLegendEntry('Part of W',2)
plotter.AddLegendEntry('Not Matching W',4)

plotter.MakeCanvas("plots/fatjetPrunedMx",25,0,150,"m_{pruned} [GeV]","A.U.")
Example #10
0
#! /usr/bin/env python

from CrombieTools.PlotTools.PlotHists import plotter
from CrombieTools.PlotTools import AddOutDir
from CrombieTools.LoadConfig import cuts

from ROOT import TFile

infile = TFile('TMVAReg_0_new.root')

plotter.SetDefaultCut('genPt > 5')

plotter.AddTreeExpr(infile.Get('TestTree'), '1.0 - target')
plotter.AddTreeExpr(infile.Get('TrainTree'), 'oldReg - target')
plotter.AddTreeExpr(infile.Get('TrainTree'), 'BDTG - target')
plotter.AddTreeExpr(infile.Get('TestTree'), 'BDTG - target')

plotter.SetNormalizedHists(True)

plotter.AddLegendEntry('No Regression', 1, 2, 2)
plotter.AddLegendEntry('Old Regression', 1, 2, 1)
plotter.AddLegendEntry('New (Training)', 2, 2, 2)
plotter.AddLegendEntry('New (Test)', 4, 2, 3)

plotter.MakeCanvas(AddOutDir('tmva'), 20, -1, 1, "Regression - Truth",
                   "Normalized")
Example #11
0
#!/usr/bin/env python

from CrombieTools.PlotTools.PlotHists import plotter

from ROOT import TFile

directory = '/Users/dabercro/GradSchool/Summer16/Skim_160622/'
theFile = TFile(directory + 'wscale_TTJets_SingleLeptFromT.root')

plotter.SetDefaultExpr('topPtReweighting')
plotter.SetDefaultTree(theFile.Get('events'))

plotter.AddWeight(
    'fatjetPt > 250 && thirdFatMass < 50 && n_tightlep == 1 && n_looselep == 1 && n_bjetsLoose > 0 && fatjetDRLooseB > 0.8 && fatjetDRLooseB < 1.2 && fatjetDPhiLep1 > 2.0 && ((n_jetsNotFat == 3 && fatjet2Pt < 0) || (n_jetsNotFat == 2)) && n_tightlep == 1 && n_looselep == 1 && fatjet1DRGenW < 0.2'
)
plotter.AddWeight(
    'fatjetPt > 250 && thirdFatMass < 50 && n_tightlep == 1 && n_looselep == 1 && n_bjetsLoose > 0 && fatjetDRLooseB > 0.8 && fatjetDRLooseB < 1.2 && fatjetDPhiLep1 > 2.0 && n_tightlep == 1 && n_looselep == 1 && fatjet1DRGenW < 0.2'
)

plotter.AddLegendEntry('With n_{jets} cut', 1)
plotter.AddLegendEntry('Without that cut', 2)

plotter.SetRatioIndex(1)

plotter.MakeCanvas("topPtWeight", 50, 0.75, 1.2, "top p_{T} reweighting",
                   "A.U.")