def plotFatjetMatching(cont, sel, sub1, sub2): plots = [] plots.append( Plot.make1D(f"fatjet{sub1}{sub2}_sub1_dE", op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E()), sel, EquidistantBinning(1000, -1000., 1000.), xTitle=f"subJet1 {sub1} E - gen {sub1} E")) plots.append( Plot.make2D( f"fatjet{sub1}{sub2}_sub1_TF", [ op.map(cont, lambda m: m[0].p4.E()), op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E()) ], sel, [ EquidistantBinning(3000, 0., 3000.), EquidistantBinning(8000, -1000., 1000.) ], xTitle="E^{{parton}}({sub1})", yTitle=f"#Delta E = E^{{reco}}({sub1})-E^{{parton}}({sub1})")) plots.append( Plot.make1D(f"fatjet{sub1}{sub2}_sub2_dE", op.map(cont, lambda m: m[2].subJet2.p4.E() - m[1].p4.E()), sel, EquidistantBinning(1000, -1000., 1000.), xTitle=f"subJet2 {sub2} E - gen {sub2} E")) plots.append( Plot.make2D( f"fatjet{sub1}{sub2}_sub2_TF", [ op.map(cont, lambda m: m[1].p4.E()), op.map(cont, lambda m: m[2].subJet1.p4.E() - m[1].p4.E()) ], sel, [ EquidistantBinning(3000, 0., 3000.), EquidistantBinning(8000, -1000., 1000.) ], xTitle="E^{{parton}}({sub2})", yTitle=f"#Delta E = E^{{reco}}({sub2})-E^{{parton}}({sub2})")) plots.append( Plot.make2D(f"fatjet{sub1}{sub2}_dE2D", [ op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E()), op.map(cont, lambda m: m[2].subJet2.p4.E() - m[1].p4.E()) ], sel, [ EquidistantBinning(1000, -1000., 1000.), EquidistantBinning(1000, -1000., 1000.) ], xTitle=f"subJet1 {sub1} E - gen {sub1} E", yTitle=f"subJet2 {sub2} E - gen {sub2} E")) return plots
def plotMatching(contName, cont, sel, partName): plots = [] # plots.append(Plot.make1D(contName+"_deltaR", # op.map(cont,lambda m : op.deltaR(m[0].p4,m[1].p4)), # sel, # EquidistantBinning(1000,0.,0.2), # xTitle="#Delta R(%s_{gen},%s_{reco})"%(partName,partName))) # plots.append(Plot.make1D(contName+"_deltaPtRel", # op.map(cont,lambda m : (m[1].pt-m[0].pt)/(m[0].pt+m[1].pt)), # sel, # EquidistantBinning(1000,-1.,1.), # xTitle="P_{T}(%s_{reco})-P_{T}(%s_{gen})/P_{T}(%s_{reco})+P_{T}(%s_{gen})"%(partName,partName,partName,partName))) # plots.append(Plot.make2D(contName+"_Pt2D", # [op.map(cont,lambda m : m[0].pt),op.map(cont,lambda m : m[1].pt)], # sel, # [EquidistantBinning(1000,0,1000),EquidistantBinning(1000,0,1000)], # xTitle="P_{T}(gen)", # yTitle="P_{T}(reco)")) plots.append( Plot.make2D(contName + "_TF", (op.map(cont, lambda m: m[0].p4.E()), op.map(cont, lambda m: m[1].p4.E() - m[0].p4.E())), sel, [ EquidistantBinning(3000, 0., 3000.), EquidistantBinning(8000, -1000., 1000.) ], xTitle="E^{parton}(e^{-})", yTitle="#Delta E = E^{reco}(%s)-E^{parton}(%s)" % (partName, partName))) return plots
def MakeEllipsesPLots(self, sel, bjets, lepton, wp, uname, suffix): plots = [] binScaling = 1 for key in sel.keys(): tagger = key.replace(wp, "") bjets_ = safeget(bjets, tagger, wp) plots.append( Plot.make1D( "jj_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format( suffix, uname, key), op.invariant_mass(bjets_[0].p4, bjets_[1].p4), sel.get(key), EqB(60 // binScaling, 0., 1000.), title="invariant mass of two b-tagged jets wrt {0} Discriminator" .format(suffix, key), xTitle="mjj {0} {1} [GeV]".format(suffix, key), plotopts=utils.getOpts(uname, **{"log-y": False}))) plots.append( Plot.make1D( "lljj_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format( suffix, uname, key), (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 + bjets_[1].p4).M(), sel.get(key), EqB(60 // binScaling, 0., 1000.), title= "invariant mass of 2 leptons two b-tagged jets wrt {0} Discriminator" .format(suffix, key), xTitle="mlljj {0} {1} [GeV]".format(suffix, key), plotopts=utils.getOpts(uname, **{"log-y": False}))) plots.append( Plot.make2D( "Mjj_vs_Mlljj_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format( suffix, uname, key), (op.invariant_mass(bjets_[0].p4, bjets_[1].p4), (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 + bjets_[1].p4).M()), sel.get(key), (EqB(60 // binScaling, 0., 1000.), EqB(60 // binScaling, 0., 1000.)), title="mlljj vs mjj invariant mass {0} wrt {1} Discriminator". format(suffix, key), plotopts=utils.getOpts(uname, **{"log-y": False}))) plots.append( Plot.make1D( "ll_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format( suffix, uname, key), op.invariant_mass(lepton[0].p4, lepton[1].p4), sel.get(key), EqB(60 // binScaling, 70., 110.), title=" dilepton invariant mass {0} wrt {1} Discriminator". format(suffix, key), xTitle="mll {0} {1} [GeV]".format(suffix, key), plotopts=utils.getOpts(uname))) return plots
def fatjetPlots(sel, fatjets, name): plots = [] # plots.append(Plot.make2D(name+'_Pt2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet1.pt),op.map(fatjets, lambda fatjet : fatjet.subJet2.pt)], # sel, # [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)], # xTitle = "subjet 1 P_{T}", # yTitle = "subjet 2 P_{T}")) plots.append( Plot.make2D(name + '_E2D', [ op.map(fatjets, lambda fatjet: fatjet.subJet1.p4.E()), op.map(fatjets, lambda fatjet: fatjet.subJet2.p4.E()) ], sel, [ EquidistantBinning(1000, 0., 1000.), EquidistantBinning(1000, 0., 1000.) ], xTitle="subjet 1 E", yTitle="subjet 2 E")) # plots.append(Plot.make2D(name+'_partonflavour2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet1.partonFlavour),op.map(fatjets, lambda fatjet : fatjet.subJet2.partonFlavour)], # sel, # [EquidistantBinning(7,0.,6.),EquidistantBinning(7,0.,6.)], # xTitle = "subjet 1 P_{T}", # yTitle = "subjet 2 P_{T}")) # plots.append(Plot.make2D(name+'_subjet1VSFatjet_E2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.E()),op.map(fatjets, lambda fatjet : fatjet.p4.E())], # sel, # [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)], # xTitle = "subjet 1 E", # yTitle = "fatjet E")) # plots.append(Plot.make2D(name+'_subjet2VSFatjet_E2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.E()),op.map(fatjets, lambda fatjet : fatjet.p4.E())], # sel, # [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)], # xTitle = "subjet 2 E", # yTitle = "fatjet E")) # # plots.append(Plot.make2D(name+'_Eta2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.eta()),op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.eta())], # sel, # [EquidistantBinning(500,-2.5,2.5),EquidistantBinning(500,-2.5,2.5)], # xTitle = "subjet 1 #eta", # yTitle = "subjet 2 #eta")) # plots.append(Plot.make2D(name+'_Phi2D', # [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.phi()),op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.phi())], # sel, # [EquidistantBinning(320,-3.2,3.2),EquidistantBinning(320,-3.2,3.2)], # xTitle = "subjet 1 #phi", # yTitle = "subjet 2 #phi")) return plots
def makeControlPlotsForFinalSel(self, sel, bjets, dilepton, uname): plots = [] binScaling = 1 for key in sel.keys(): tagger = key.replace(wp, "") bjets_ = safeget(bjets, tagger, wp) plots.append( Plot.make1D("{0}_TwoBtaggedJets_pT_{1}".format(uname, key), (bjets_[0].p4 + bjets_[1].p4).Pt(), sel.get(key), EqB(60, 170., 800.), title="di-bjet P_{T} [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_mlljj_btagged_{1}".format(uname, key), (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 + bjets_[1].p4).M(), sel.get(key), EqB(60, 170., 1000.), title="mlljj [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_mjj_btagged_{1}".format(uname, key), op.invariant_mass(bjets_[0].p4 + bjets_[1].p4), sel.get(key), EqB(60, 170., 800.), title="mjj [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make2D("{0}_mlljjvsmjj_btagged_{1}".format(uname, key), (op.invariant_mass(bjets_[0].p4 + bjets_[1].p4), (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 + bjets_[1].p4).M()), sel.get(key), (EqB(60, 170., 1000.), EqB(60, 170., 1000.)), title="mlljj vs mjj invariant mass [GeV]", plotopts=utils.getOpts(uname))) return plots
def definePlots(self, t, noSel, sample=None, sampleCfg=None): if 'type' not in sampleCfg.keys() or sampleCfg["type"] != "signal": raise RuntimeError("Sample needs to be HH signal LO GGF sample") era = sampleCfg.get("era") if sampleCfg else None # Select gen level Higgs # genh = op.select( t.GenPart, lambda g: op.AND(g.pdgId == 25, g.statusFlags & (0x1 << 13))) HH_p4 = genh[0].p4 + genh[1].p4 cm = HH_p4.BoostToCM() boosted_h = op.extMethod("ROOT::Math::VectorUtil::boost", returnType=genh[0].p4._typeName)(genh[0].p4, cm) mHH = op.invariant_mass(genh[0].p4, genh[1].p4) cosHH = op.abs(boosted_h.Pz() / boosted_h.P()) # Apply reweighting # benchmarks = [ 'BenchmarkSM', 'Benchmark1', 'Benchmark2', 'Benchmark3', 'Benchmark4', 'Benchmark5', 'Benchmark6', 'Benchmark7', 'Benchmark8', 'Benchmark8a', 'Benchmark9', 'Benchmark10', 'Benchmark11', 'Benchmark12', 'BenchmarkcHHH0', 'BenchmarkcHHH1', 'BenchmarkcHHH2p45', 'BenchmarkcHHH5', 'Benchmarkcluster1', 'Benchmarkcluster2', 'Benchmarkcluster3', 'Benchmarkcluster4', 'Benchmarkcluster5', 'Benchmarkcluster6', 'Benchmarkcluster7', ] selections = {'': noSel} reweights = {} if self.args.reweighting: for benchmark in benchmarks: json_file = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'data', 'ScaleFactors_GGF_LO', '{}_to_{}_{}.json'.format(sample, benchmark, era)) if os.path.exists(json_file): print("Found file {}".format(json_file)) reweightLO = get_scalefactor("lepton", json_file, paramDefs={ 'Eta': lambda x: mHH, 'Pt': lambda x: cosHH }) selections[benchmark] = SelectionWithDataDriven.create( parent=noSel, name='noSel' + benchmark, ddSuffix=benchmark, cut=op.c_bool(True), ddCut=op.c_bool(True), weight=op.c_float(1.), ddWeight=reweightLO(op.c_float(1.)), enable=True) reweights[benchmark] = reweightLO(op.c_float(1.)) else: print("Could not find file {}".format(json_file)) # Plots # plots = [] for name, reweight in reweights.items(): plots.append( Plot.make1D("weight_{}".format(name), reweight, noSel, EquidistantBinning(100, 0, 5.), xTitle='weight')) for selName, sel in selections.items(): plots.append( Plot.make2D( f"mHHvsCosThetaStar{selName}", [mHH, cosHH], sel, [ VariableBinning([ 250., 270., 290., 310., 330., 350., 370., 390., 410., 430., 450., 470., 490., 510., 530., 550., 570., 590., 610., 630., 650., 670., 700., 750., 800., 850., 900., 950., 1000., 1100., 1200., 1300., 1400., 1500., 1750., 2000., 5000. ]), VariableBinning([0.0, 0.4, 0.6, 0.8, 1.0]) ], xTitle='m_{HH}', yTitle='cos(#theta^{*})')) plots.append( Plot.make1D(f"mHH{selName}", mHH, sel, VariableBinning([ 250., 270., 290., 310., 330., 350., 370., 390., 410., 430., 450., 470., 490., 510., 530., 550., 570., 590., 610., 630., 650., 670., 700., 750., 800., 850., 900., 950., 1000., 1100., 1200., 1300., 1400., 1500., 1750., 2000., 5000. ]), xTitle='m_{HH}')) plots.append( Plot.make1D(f"cosThetaStar{selName}", cosHH, sel, VariableBinning([0.0, 0.4, 0.6, 0.8, 1.0]), xTitle='cos(#theta^{*})')) return plots
def makeControlPlotsForBasicSel(self, sel, jets, dilepton, uname): binScaling = 1 plots = [] plots.append( Plot.make1D("{0}_leadJetPT".format(uname), jets[0].pt, sel, EqB(60, 0., 450.), title="P_{T} (leading Jet) [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_subleadJetPT".format(uname), jets[1].pt, sel, EqB(60, 0., 450.), title="P_{T} (sub-leading Jet) [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_leadJetETA".format(uname), jets[0].eta, sel, EqB(10, -2.4, 2.4), title="Eta (leading Jet)", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_subleadJetETA".format(uname), jets[1].eta, sel, EqB(10, -2.4, 2.4), title="Eta (sub-leading Jet)", plotopts=utils.getOpts(uname))) for i in range(2): plots.append( Plot.make1D(f"{uname}_jet{i+1}_phi", jets[i].phi, sel, EqB(50 // binScaling, -3.1416, 3.1416), title=f"{utils.getCounter(i+1)} jet phi", plotopts=utils.getOpts(uname, **{"log-y": False}))) plots.append( Plot.make1D("{0}_jjpT".format(uname), (jets[0].p4 + jets[1].p4).pt, sel, EqB(100, 0., 450.), title="dijet P_{T} [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_jjPhi".format(uname), (jets[0].p4 + jets[1].p4).phi, sel, EqB(50 // binScaling, -3.1416, 3.1416), title="dijet phi", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_jjEta".format(uname), (jets[0].p4 + jets[1].p4).eta, sel, EqB(50 // binScaling, -2.4, 2.4), title="dijet eta", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_mjj".format(uname), op.invariant_mass(jets[0].p4, jets[1].p4), sel, EqB(100, 0., 800.), title="mjj [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make1D("{0}_mlljj".format(uname), (dilepton[0].p4 + dilepton[1].p4 + jets[0].p4 + jets[1].p4).M(), sel, EqB(100, 0., 1000.), title="mlljj [GeV]", plotopts=utils.getOpts(uname))) plots.append( Plot.make2D( "{0}_mlljjvsmjj".format(uname), (op.invariant_mass(jets[0].p4, jets[1].p4), (dilepton[0].p4 + dilepton[1].p4 + jets[0].p4 + jets[1].p4).M()), sel, (EqB(1000, 0., 1000.), EqB(1000, 0., 1000.)), title="mlljj vs mjj invariant mass [Gev]", plotopts=utils.getOpts(uname))) return plots
def plotMatching(contName, list_cont, list_sel, partName): plots = [] dr_plots = [] dr2_plots = [] ptrel_plots = [] TF_plots = [] for idx, (cont, sel) in enumerate(zip(list_cont, list_sel)): dr_plots.append( Plot.make1D(contName + str(idx) + "_deltaR", op.map(cont, lambda m: op.deltaR(m[0].p4, m[1].p4)), sel, EquidistantBinning(100, 0., 0.2), xTitle="#Delta R(%s_{gen},%s_{reco})" % (partName, partName))) dr2_plots.append( Plot.make1D(contName + str(idx) + "_deltaR2", op.map( cont, lambda m: op.pow(op.deltaR(m[0].p4, m[1].p4), 2)), sel, EquidistantBinning(100, 0., 0.04), xTitle="#Delta R^{2}(%s_{gen},%s_{reco})" % (partName, partName))) ptrel_plots.append( Plot.make1D( contName + str(idx) + "_deltaPtRel", op.map(cont, lambda m: (m[1].pt - m[0].pt) / m[1].pt), sel, EquidistantBinning(100, -2., 2.), xTitle="P_{T}(%s_{reco})-P_{T}(%s_{gen})/P_{T}(%s_{reco})" % (partName, partName, partName))) TF_plots.append( Plot.make2D(contName + str(idx) + "_TF", (op.map(cont, lambda m: m[0].p4.E()), op.map(cont, lambda m: m[1].p4.E() - m[0].p4.E())), sel, [ EquidistantBinning(100, 0., 500.), EquidistantBinning(400, -200., 200.) ], xTitle="E^{parton}(e^{-})", yTitle="#Delta E = E^{reco}(%s)-E^{parton}(%s)" % (partName, partName))) plots.append( SummedPlot(contName + "_deltaR", dr_plots, xTitle="#Delta R(%s_{gen},%s_{reco})" % (partName, partName))) plots.append( SummedPlot(contName + "_deltaR2", dr2_plots, xTitle="#Delta R^{2}(%s_{gen},%s_{reco})" % (partName, partName))) plots.append( SummedPlot(contName + "_deltaPtRel", ptrel_plots, xTitle="P_{T}(%s_{reco})-P_{T}(%s_{gen}/P_{T}(%s_{reco})" % (partName, partName, partName))) plots.append( SummedPlot(contName + "_TF", TF_plots, xTitle="#Delta E = E^{reco}(%s)-E^{patron}(%s)" % (partName, partName))) return plots