Example #1
0
cChain.Add(signal_loc +
           'monojet_VectorMonoW_Mphi-2000_Mchi-50_gSM-1p0_gDM-1p0_13TeV.root')
#cChain.Add(signal_loc + 'monojet_AxialMonoW_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')

plotter.AddTree(aFile.Get('events'))
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,
Example #2
0
#! /usr/bin/python

from ROOT import TFile
from CrombieTools.PlotTools.PlotHists import plotter
from CrombieTools.LoadConfig import cuts

from array import array

signalFile = TFile(
    '/afs/cern.ch/work/d/dabercro/public/Winter15/SkimOut_GluGlu/monojet_GluGlu_HToInvisible_M125_13TeV_powheg_pythia8.root'
)

plotter.SetDefaultTree(signalFile.events)

plotter.AddLegendEntry('Without Pileup Reweighting', 1)
plotter.AddLegendEntry('With Pileup Reweighting', 2)
plotter.AddLegendEntry('With Official Pileup Reweighting', 4)
plotter.SetEventsPer(1.0)
# plotter.SetDataIndex(0)
plotter.SetRatioIndex(2)
plotter.SetRatioMinMax(0, 3)

# plotter.SetPrintTests(True)
# plotter.SetNormalizedHists(True)


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,
Example #3
0
plotter.AddTreeWeight(zeeMCFile.events,
                      '(' + cuts.ZeeMJ + ')*mcFactors*XSecWeight')
plotter.AddTreeWeight(dataFile.events, cuts.ZeeMJ)
zPlots = plotter.MakeHists(len(xArray) - 1, array('d', xArray))

plotter.ResetTree()
plotter.ResetWeight()

plotter.AddTreeWeight(gammaMCFile.events,
                      '(' + cuts.gjetMJ + ')*mcFactors*XSecWeight')
plotter.AddTreeWeight(dataFile.events, cuts.gjetMJ)

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

plotter.AddLegendEntry('MC', 2)
plotter.AddLegendEntry('Data', 1)

plotter.SetDataIndex(1)
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)
    ##
Example #4
0
from CrombieTools import Nminus1Cut

from ROOT import TFile

#plotter.SetDebugLevel(3)

directory = '/data/t3home000/dabercro/hbb/compare'
files = [TFile(os.path.join(directory, f)) for f in ['2016.root', '2017.root', '2018.root']]

thecut = '(met_trigger && pfmet > 170 && met_filter == 1 && n_lep_presel == 0 && n_centerjet < 4 && min_dphi_metj_hard > 0.5 && dphi_met_dztrkmet < 0.5 && cmva_hbb_m_reg_old < 500 && cmva_daughter_max_pt > 60 && cmva_daughter_min_pt > 35 && cmva_jet2_cmva > -0.5884 && cmva_dphi_uh > 2.0 && cmva_hbb_pt_reg_old > 120)'
#thecut = '(met_trigger && pfmet > 170 && met_filter == 1 && n_lep_presel == 0 && n_centerjet >= 4 && min_dphi_metj_hard > 0.5 && dphi_met_dztrkmet < 0.5 && cmva_hbb_m_reg_old < 500 && cmva_daughter_max_pt > 60 && cmva_daughter_min_pt > 35 && cmva_jet2_cmva > -0.5884 && cmva_dphi_uh > 2.0 && cmva_hbb_pt_reg_old > 120)'

for f in files:
    plotter.AddTree(f.Get('events'))

plotter.AddLegendEntry('2016 Data', 1, 2, 1)
plotter.AddLegendEntry('2017 Data', 2, 2, 1)
plotter.AddLegendEntry('2018 Data', 3, 2, 1)

plotter.SetNormalizedHists(True)

for expr in [
    ('pfmet', 7, 150, 290),
    ('n_centerjet', 10, 0, 10),
    ('npv', 50, 0, 50),
    ('cmva_jet1_cmva', 42, -1.05, 1.05),
    ('cmva_jet2_cmva', 42, -1.05, 1.05),
    ('cmva_jet1_pt', 25, 0, 300),
    ('cmva_jet2_pt', 25, 0, 300),
    ('cmva_jet1_eta', 25, -2.5, 2.5),
    ('cmva_jet2_eta', 25, -2.5, 2.5),
Example #5
0
infile = TFile(
    '/data/t3home000/dabercro/hbb/180208/ZH_HToBB_ZToNuNu_M125_13TeV_powheg_pythia8.root'
)

plotter.SetDefaultCut(
    '%s * (%s)' %
    (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.')
Example #6
0
nlo_file = TFile(directory +
                 'WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8.root')
lo_file = TFile(directory +
                'WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8.root')
nlobinned_file = TFile(directory + 'WJetsToLNu_Pt.root')
lobinned_file = TFile(directory + 'WJetsToLNu_HT.root')

plotter.SetDefaultExpr('genboson_pt')
plotter.SetDefaultWeight('genboson * mc_weight * XSecWeight')

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))
Example #7
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 #8
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 #9
0
#inDir = '/Users/dabercro/GradSchool/Winter15/vbfFiles/'
#outDir = 'plots/160317/'

if __name__ == '__main__':
    from CrombieTools.PlotTools.PlotHists import plotter

    vbfFile = TFile(inDir + 'monojet_VBFSignal.root')
    zvvFile = TFile(inDir + 'monojet_ZJetsToNuNu.root')
    qcdFile = TFile(inDir + 'monojet_QCD.root')

    plotter.AddTree(vbfFile.events)
    plotter.AddTree(zvvFile.events)
    plotter.AddTree(qcdFile.events)

    plotter.AddLegendEntry('VBF', 1)
    plotter.AddLegendEntry('Zvv', 2)
    plotter.AddLegendEntry('QCD', 3)

    plotter.SetLumiLabel('2.30')
    plotter.SetIsCMSPrelim(True)
    plotter.SetLegendLocation(plotter.kUpper, plotter.kRight)
    plotter.SetEventsPer(1.0)
    plotter.SetNormalizedHists(True)

    def MakePlot(args):
        holding = list(args)
        expr = args[0]
        holding[0] = outDir + 'VBFStudy_' + expr
        plotter.SetDefaultWeight(
            Nminus1Cut(
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.")