def KMuMuData(process, cuts): from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionSkimmer import collectionSkimmer from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionEmbeder import collectionEmbeder from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.branchCreator import branchCreator BSkim = collectionSkimmer( input="BToKMuMu", output="SkimBToKMuMu", # importedVariables = ["Muon_pt","Muon_pt","ProbeTracks_pt",""], # importIds = ["l1Idx","l2Idx","kIdx"], # varnames = ["l1pt","l2pt","kpt"], selector=cuts, branches=[ "fit_pt", "fit_mass", "mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "l1Idx", "l2Idx", "kIdx", "fit_eta", "mll_fullfit" ], exclTriggerMuonId="TriggerMuon_trgMuonIndex", #selTriggerMuonId = "TriggerMuon_trgMuonIndex", flat=False) process.append(BSkim) Mu1 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKMuMu", inputBranches=["pt", "eta", "phi", "softId", "vz", "pfRelIso03_all"], embededBranches=[ "mu1Pt", "mu1Eta", "mu1Phi", "mu1SoftId", "mu1Vz", "mu1iso" ], embededCollIdx="l1Idx") process.append(Mu1) Mu2 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKMuMu", inputBranches=["pt", "eta", "phi", "softId", "vz", "pfRelIso03_all"], embededBranches=[ "mu2Pt", "mu2Eta", "mu2Phi", "mu2SoftId", "mu2Vz", "mu2iso" ], embededCollIdx="l2Idx") process.append(Mu2) K = collectionEmbeder(inputColl="ProbeTracks", embededColl="SkimBToKMuMu", inputBranches=["pt", "eta", "phi", "vz"], embededBranches=["kPt", "kEta", "kPhi", "kVz"], embededCollIdx="kIdx") process.append(K) CreateVars = branchCreator( collection="SkimBToKMuMu", inputBranches=[["l_xy", "l_xy_unc"], ["mu1Vz", "mu2Vz"], ["kVz", "mu1Vz", "mu2Vz"], ["mu1Eta", "mu1Phi", "mu2Eta", "mu2Phi"], [ "kEta", "kPhi", "mu1Eta", "mu1Phi", "mu2Eta", "mu2Phi" ]], operation=[ "{0}/{1}", "abs({0}-{1})", "min(abs({0}-{1}),abs({0}-{2}))", "deltaR({0},{1},{2},{3})", "min( deltaR({0},{1},{2},{3}),deltaR({0},{1},{3},{4}))" ], createdBranches=["l_xy_sig", "mu1mu2Dz", "muKDz", "mu1mu2Dr", "muKDr"]) process.append(CreateVars) return process
def KshortMuMuData(process, cuts): from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionSkimmer import collectionSkimmer from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionEmbeder import collectionEmbeder BSkim = collectionSkimmer( input="BToKshortMuMu", output="SkimBToKshortMuMu", importedVariables=["Kshort_svprob"], importIds=["kshort_idx"], varnames=["kshort_prob"], selector=cuts, branches=[ #B vars "fit_pt", "fit_mass", "fit_eta", "fit_phi", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", # lep "mll_fullfit", "lep1pt_fullfit", "lep1eta_fullfit", "lep2pt_fullfit", "lep2eta_fullfit", "l1_idx", "l2_idx", # kshort "ptkshort_fullfit", "etakshort_fullfit", "mkshort_fullfit", "kshort_idx", "kshort_prob" ], # triggerMuonId = "TriggerMuon_trgMuonIndex", flat=False) process.append(BSkim) Mu1 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKshortMuMu", inputBranches=["softMvaId", "softId", "triggerIdLoose"], embededBranches=["lep1softMvaId", "lep1softId", "lep1trigger"], embededCollIdx="l1_idx") Mu2 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKshortMuMu", inputBranches=["softMvaId", "softId", "triggerIdLoose"], embededBranches=["lep2softMvaId", "lep2softId", "lep2trigger"], embededCollIdx="l2_idx") Kshort = collectionEmbeder(inputColl="Kshort", embededColl="SkimBToKshortMuMu", inputBranches=["trk1_pt", "trk2_pt"], embededBranches=["trk1pt", "trk2pt"], embededCollIdx="kshort_idx") process.append(Mu1) process.append(Mu2) process.append(Kshort) return process
def KEEData_Bpt(process, cuts, usePF, useLowPtE): from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionSkimmer import collectionSkimmer from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionEmbeder import collectionEmbeder from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionCleaner import collectionCleaner from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.branchCreator import branchCreator cuts2 = cuts if usePF and not useLowPtE: cuts2 = cuts and (lambda l: l.e1isPF == 1 and l.e2isPF == 1) elif not usePF and useLowPtE: cuts2 = cuts and (lambda l: l.e1isPF == 0 and l.e2isPF == 0) BSkim_Bpt = collectionSkimmer( input="BToKEE", output="SkimPtBToKEE", importedVariables=["Electron_isPF", "Electron_isPF"], importIds=["l1Idx", "l2Idx"], varnames=["e1isPF", "e2isPF"], # selector = cuts2, sortOutput=True, sortkey=lambda x: x.fit_pt, # variable to sort branches=[ "fit_pt", "fit_mass", "mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "l1Idx", "l2Idx", "kIdx", "fit_eta", "mll_fullfit" ], flat=False) process.append(BSkim_Bpt) BSkim_svProb = collectionSkimmer( input="BToKEE", output="SkimProbBToKEE", importedVariables=["Electron_isPF", "Electron_isPF"], importIds=["l1Idx", "l2Idx"], varnames=["e1isPF", "e2isPF"], #selector = cuts2, sortOutput=True, sortkey=lambda x: x.svprob, # variable to sort branches=[ "fit_pt", "fit_mass", "mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "l1Idx", "l2Idx", "kIdx", "fit_eta", "mll_fullfit" ], flat=False) process.append(BSkim_svProb) BSkim = collectionCleaner(FirstColl="SkimPtBToKEE", SecondColl="SkimProbBToKEE", output="SkimBToKEE", branches=[ "fit_pt", "fit_mass", "mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "l1Idx", "l2Idx", "kIdx", "fit_eta", "mll_fullfit" ], flat=False) process.append(BSkim) El1 = collectionEmbeder(inputColl="Electron", embededColl="SkimBToKEE", inputBranches=[ "mvaId", "isPF", "pt", "eta", "phi", "fBrem", "hoe", "vz" ], embededBranches=[ "e1mvaId", "e1isPF", "e1Pt", "e1Eta", "e1Phi", "e1fBrem", "e1hoe", "e1Vz" ], embededCollIdx="l1Idx") process.append(El1) El2 = collectionEmbeder(inputColl="Electron", embededColl="SkimBToKEE", inputBranches=[ "mvaId", "isPF", "pt", "eta", "phi", "fBrem", "hoe", "vz" ], embededBranches=[ "e2mvaId", "e2isPF", "e2Pt", "e2Eta", "e2Phi", "e2fBrem", "e2hoe", "e2Vz" ], embededCollIdx="l2Idx") process.append(El2) K = collectionEmbeder(inputColl="ProbeTracks", embededColl="SkimBToKEE", inputBranches=["pt", "eta", "phi", "vz"], embededBranches=["kPt", "kEta", "kPhi", "kVz"], embededCollIdx="kIdx") process.append(K) El1 = collectionEmbeder(inputColl="Electron", embededColl="SkimProbBToKEE", inputBranches=[ "mvaId", "isPF", "pt", "eta", "phi", "fBrem", "hoe", "vz" ], embededBranches=[ "e1mvaId", "e1isPF", "e1Pt", "e1Eta", "e1Phi", "e1fBrem", "e1hoe", "e1Vz" ], embededCollIdx="l1Idx") process.append(El1) El2 = collectionEmbeder(inputColl="Electron", embededColl="SkimProbBToKEE", inputBranches=[ "mvaId", "isPF", "pt", "eta", "phi", "fBrem", "hoe", "vz" ], embededBranches=[ "e2mvaId", "e2isPF", "e2Pt", "e2Eta", "e2Phi", "e2fBrem", "e2hoe", "e2Vz" ], embededCollIdx="l2Idx") process.append(El2) K = collectionEmbeder(inputColl="ProbeTracks", embededColl="SkimProbBToKEE", inputBranches=["pt", "eta", "phi", "vz"], embededBranches=["kPt", "kEta", "kPhi", "kVz"], embededCollIdx="kIdx") process.append(K) CreateVars = branchCreator( collection="SkimBToKEE", inputBranches=[["l_xy", "l_xy_unc"], ["e1Vz", "e2Vz"], ["kVz", "e1Vz", "e2Vz"], ["e1Eta", "e1Phi", "e2Eta", "e2Phi"], ["kEta", "kPhi", "e1Eta", "e1Phi", "e2Eta", "e2Phi"]], operation=[ "{0}/{1}", "abs({0}-{1})", "min(abs({0}-{1}),abs({0}-{2}))", "deltaR({0},{1},{2},{3})", "min( deltaR({0},{1},{2},{3}),deltaR({0},{1},{3},{4}))" ], createdBranches=["l_xy_sig", "e1e2Dz", "eKDz", "e1e2Dr", "eKDr"]) process.append(CreateVars) # CreateVars_c2 = branchCreator( # collection="SkimProbBToKEE", # inputBranches=[["l_xy","l_xy_unc"],["e1Vz","e2Vz"],["kVz","e1Vz","e2Vz"],["e1Eta","e1Phi","e2Eta","e2Phi"],["kEta","kPhi","e1Eta","e1Phi","e2Eta","e2Phi"]], # operation=["{0}/{1}","abs({0}-{1})","min(abs({0}-{1}),abs({0}-{2}))","deltaR({0},{1},{2},{3})","min( deltaR({0},{1},{2},{3}),deltaR({0},{1},{3},{4}))"], # createdBranches=["l_xy_sig","e1e2Dz","eKDz","e1e2Dr","eKDr"] # ) # process.append(CreateVars_c2) return process
def KEEData(process, Bcuts, use_PF=False, use_1LowPt_1PF=False): from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionSkimmer import collectionSkimmer from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionEmbeder import collectionEmbeder from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.branchCreator import branchCreator BKLLSelection = lambda l: l.fit_pt > Bcuts["Pt"] and l.fit_cos2D > Bcuts[ "Cos2D"] and l.svprob > Bcuts["Prob"] and l.l_xy_unc > 0 and ( l.l_xy) / l.l_xy_unc > Bcuts["LxySign"] and l.mll_fullfit > Bcuts[ "Mllmin"] and l.fit_mass > Bcuts[ "MinMass"] and l.fit_mass < Bcuts[ "MaxMass"] and l.mll_fullfit < Bcuts["Mllmax"] if use_PF and not use_1LowPt_1PF: BKLLSelection = lambda l: l.fit_pt > Bcuts[ "Pt" ] and l.fit_cos2D > Bcuts["Cos2D"] and l.svprob > Bcuts[ "Prob" ] and l.l_xy_unc > 0 and (l.l_xy) / l.l_xy_unc > Bcuts[ "LxySign" ] and l.mll_fullfit > Bcuts["Mllmin"] and l.fit_mass > Bcuts[ "MinMass" ] and l.fit_mass < Bcuts["MaxMass"] and l.mll_fullfit < Bcuts[ "Mllmax" ] and l.l1isPF == 1 and l.l2isPF == 1 and l.l1PFId > -30.5 and l.l2PFId > -50.0 elif use_1LowPt_1PF and not use_PF: BKLLSelection = lambda l: l.fit_pt > Bcuts[ "Pt"] and l.fit_cos2D > Bcuts["Cos2D"] and l.svprob > Bcuts[ "Prob"] and l.l_xy_unc > 0 and (l.l_xy) / l.l_xy_unc > Bcuts[ "LxySign" ] and l.mll_fullfit > Bcuts["Mllmin"] and l.fit_mass > Bcuts[ "MinMass" ] and l.fit_mass < Bcuts["MaxMass"] and l.mll_fullfit < Bcuts[ "Mllmax"] and ( (l.l1isPF == 1 and l.l2isPF == 0 and l.l2isPFoverlap == 0 and l.l1PFId > -1.25 and l.l2LowPtId > -1.5) or (l.l1isPF == 0 and l.l2isPF == 1 and l.l1isPFoverlap == 0 and l.l2PFId > -1.25 and l.l1LowPtId > -1.5)) else: BKLLSelection = lambda l: l.fit_pt > Bcuts[ "Pt"] and l.fit_cos2D > Bcuts["Cos2D"] and l.svprob > Bcuts[ "Prob"] and l.l_xy_unc > 0 and (l.l_xy) / l.l_xy_unc > Bcuts[ "LxySign"] and l.mll_fullfit > Bcuts[ "Mllmin"] and l.fit_mass > Bcuts[ "MinMass"] and l.fit_mass < Bcuts[ "MaxMass"] and l.mll_fullfit < Bcuts["Mllmax"] BSkim = collectionSkimmer( input="BToKEE", output="SkimBToKEE", importedVariables=[ "Electron_isPF", "Electron_isPF", "Electron_isPFoverlap", "Electron_isPFoverlap", "Electron_pfmvaId", "Electron_pfmvaId", "Electron_mvaId", "Electron_mvaId" ], importIds=[ "l1Idx", "l2Idx", "l1Idx", "l2Idx", "l1Idx", "l2Idx", "l1Idx", "l2Idx" ], varnames=[ "l1isPF", "l2isPF", "l1isPFoverlap", "l2isPFoverlap", "l1PFId", "l2PFId", "l1LowPtId", "l2LowPtId" ], selector=BKLLSelection, branches=[ "fit_pt", "fit_eta", "fit_phi", "fit_mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "fit_massErr", "b_iso04", "mll_fullfit", "vtx_x", "vtx_y", "vtx_z", "l1Idx", "l2Idx", "kIdx", "fit_k_pt", "fit_k_eta", "fit_k_phi", "k_iso04", "fit_l1_pt", "fit_l1_eta", "fit_l1_phi", "l1_iso04", "fit_l2_pt", "fit_l2_eta", "fit_l2_phi", "l2_iso04", "l1isPF", "l2isPF", "l1PFId", "l2PFId", "l1LowPtId", "l2LowPtId" ], flat=False) process.append(BSkim) El1 = collectionEmbeder( inputColl="Electron", embededColl="SkimBToKEE", inputBranches=["pt", "eta", "phi", "vx", "vy", "vz"], embededBranches=["l1Pt", "l1Eta", "l1Phi", "l1Vx", "l1Vy", "l1Vz"], embededCollIdx="l1Idx") process.append(El1) El2 = collectionEmbeder( inputColl="Electron", embededColl="SkimBToKEE", inputBranches=["pt", "eta", "phi", "vx", "vy", "vz"], embededBranches=["l2Pt", "l2Eta", "l2Phi", "l2Vx", "l2Vy", "l2Vz"], embededCollIdx="l2Idx") process.append(El2) K = collectionEmbeder(inputColl="ProbeTracks", embededColl="SkimBToKEE", inputBranches=["vx", "vy", "vz"], embededBranches=["kVx", "kVz", "kVz"], embededCollIdx="kIdx") process.append(K) # in case of inf in L_xy/unc produces -99 CreateVars = branchCreator( collection="SkimBToKEE", inputBranches=[["l_xy", "l_xy_unc"], ["l1Vz", "l2Vz"], ["kVz", "l1Vz", "l2Vz"], [ "fit_l1_eta", "fit_l1_phi", "fit_l2_eta", "fit_l2_phi" ], [ "fit_k_eta", "fit_k_phi", "fit_l1_eta", "fit_l1_phi", "fit_l2_eta", "fit_l2_phi" ]], operation=[ "{0}/{1}", "abs({0}-{1})", "min(abs({0}-{1}),abs({0}-{2}))", "deltaR({0},{1},{2},{3})", "min( deltaR({0},{1},{2},{3}),deltaR({0},{1},{3},{4}))" ], createdBranches=["l_xy_sig", "l1l2Dz", "lKDz", "l1l2Dr", "lKDr"], ) process.append(CreateVars) from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.functionWrapper import functionWrapper TagVars = functionWrapper( functionName="TagVars", collections=["ProbeTracks", "TriggerMuon", "SkimBToKEE"], createdBranches=[ "SkimBToKEE_TagMuEtRatio", "SkimBToKEE_TagMuDphi", "SkimBToKEE_TagMu4Prod" ], nCol="nSkimBToKEE") process.append(TagVars) ClosestTrkVars = functionWrapper( functionName="ClosestTrkVars", collections=["ProbeTracks", "SkimBToKEE", "Electron"], createdBranches=[ "SkimBToKEE_l1_trk_mass", "SkimBToKEE_l2_trk_mass", "SkimBToKEE_trk_minxy1", "SkimBToKEE_trk_minxy2", "SkimBToKEE_trk_minxy3", "SkimBToKEE_trk_mean" ], nCol="nSkimBToKEE") process.append(ClosestTrkVars) return process
def KMuMuData(process, Bcuts): from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionSkimmer import collectionSkimmer from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.collectionEmbeder import collectionEmbeder from PhysicsTools.NanoAODTools.postprocessing.modules.bpark.branchCreator import branchCreator BKLLSelection = lambda l: l.fit_pt > Bcuts["Pt"] and l.fit_cos2D > Bcuts[ "Cos2D"] and l.svprob > Bcuts["Prob"] and l.l_xy_unc > 0 and ( l.l_xy) / l.l_xy_unc > Bcuts["LxySign"] and l.mll_fullfit > Bcuts[ "Mllmin"] and l.fit_mass > Bcuts[ "MinMass"] and l.fit_mass < Bcuts[ "MaxMass"] and l.mll_fullfit < Bcuts["Mllmax"] BSkim = collectionSkimmer(input="BToKMuMu", output="SkimBToKMuMu", selector=BKLLSelection, branches=[ "fit_pt", "fit_mass", "mass", "l_xy", "l_xy_unc", "fit_cos2D", "svprob", "l1Idx", "l2Idx", "kIdx", "fit_eta", "mll_fullfit", "fit_l1_pt", "fit_l1_eta", "fit_l1_phi", "fit_l2_pt", "fit_l2_eta", "fit_l2_phi", "fit_k_pt", "fit_k_eta", "fit_k_phi" ], TriggerMuonId="Muon_isTriggering", selectTagMuons=False, flat=False) process.append(BSkim) Mu1 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKMuMu", inputBranches=["softId", "vz", "pfRelIso03_all", "isTriggering"], embededBranches=["l1_softId", "l1_vz", "l1_iso", "l1_isTrg"], embededCollIdx="l1Idx") process.append(Mu1) Mu2 = collectionEmbeder( inputColl="Muon", embededColl="SkimBToKMuMu", inputBranches=["softId", "vz", "pfRelIso03_all", "isTriggering"], embededBranches=["l2_softId", "l2_vz", "l2_iso", "l2_isTrg"], embededCollIdx="l2Idx") process.append(Mu2) K = collectionEmbeder(inputColl="ProbeTracks", embededColl="SkimBToKMuMu", inputBranches=["vz"], embededBranches=["k_vz"], embededCollIdx="kIdx") process.append(K) # in case of inf in L_xy/unc produces -99 CreateVars = branchCreator( collection="SkimBToKMuMu", inputBranches=[["l_xy", "l_xy_unc"], ["l1_vz", "l2_vz"], ["k_vz", "l1_vz", "l2_vz"], [ "fit_l1_eta", "fit_l1_phi", "fit_l2_eta", "fit_l2_phi" ], [ "fit_k_eta", "fit_k_phi", "fit_l1_eta", "fit_l1_phi", "fit_l2_eta", "fit_l2_phi" ]], operation=[ "{0}/{1}", "abs({0}-{1})", "min(abs({0}-{1}),abs({0}-{2}))", "deltaR({0},{1},{2},{3})", "min( deltaR({0},{1},{2},{3}),deltaR({0},{1},{3},{4}))" ], createdBranches=["l_xy_sig", "l1l2_dz", "lk_dz", "l1l2_dr", "lk_dr"], ) process.append(CreateVars) return process