Skip to content

Commit

Permalink
Add tools for running ttH leptonic preselection
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-may committed Feb 5, 2021
1 parent 5922ed5 commit a96044c
Show file tree
Hide file tree
Showing 8 changed files with 875 additions and 17 deletions.
544 changes: 544 additions & 0 deletions Preselection/data/samples_and_scale1fb_ttH.json

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions Preselection/data/samples_ttH.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
{
"Data" : {
"resonant" : false,
"fpo" : 10,
"process_id" : 0,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016B-2____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016B____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016C____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016D____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016E____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016F____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016G____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2016H____v4/"],
"metadata" : {}
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2017B____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2017C____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2017D____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2017E____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/DoubleEG_Run2017F____v4/"],
"metadata" : {}
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/EGamma_Run2018A____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/EGamma_Run2018B____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/EGamma_Run2018C____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/EGamma_Run2018D____v4/"],
"metadata" : {}
}
},
"ZGamma" : {
"resonant" : false,
"fpo" : 1,
"process_id" : 2,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ZGTo2LG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8_16____v4/"],
"metadata" : { "xs" : 55.6 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_17____v4/"],
"metadata" : { "xs" : 55.6 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_18_2____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_18_3____v4/", "/hadoop/cms/store/user/legianni/ProjectMetis/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_18____v4/"],
"metadata" : { "xs" : 55.6 }
}
},
"DiPhoton" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 3,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_16____v4"],
"metadata" : { "xs" : 84.4 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_17____v4/"],
"metadata" : { "xs" : 84.4 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_18____v4/"],
"metadata" : { "xs" : 84.4 }
}
},
"WGamma" : {
"resonant" : false,
"fpo" : 1,
"process_id" : 4,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/WGToLNuG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8_16_2____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/WGToLNuG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8_16_3____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/WGToLNuG_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8_16____v4"],
"metadata" : { "xs" : 191.4 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_17____v4"],
"metadata" : { "xs" : 191.4 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8_18____v4"],
"metadata" : { "xs" : 191.4 }
}
},
"TTbar" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 5,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTJets_TuneCUETP8M2T4_13TeV-amcatnloFXFX-pythia8_16____v4"],
"metadata" : { "xs" : 831.76 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_17____v4"],
"metadata" : { "xs" : 831.76 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_18____v4"],
"metadata" : { "xs" : 831.76 }
}
},
"TTGamma" : {
"resonant" : false,
"fpo" : 1,
"process_id" : 6,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGJets_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/TTGJets_TuneCUETP8M1_13TeV-amcatnloFXFX-madspin-pythia8_16_2____v4"],
"metadata" : { "xs" : 3.819 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_17____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_17_2____v4"],
"metadata" : { "xs" : 4.078 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_18____v4"],
"metadata" : { "xs" : 4.078 }
}
},
"TTGG" : {
"resonant" : false,
"fpo" : 1,
"process_id" : 7,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGG_0Jets_TuneCUETP8M1_13TeV_amcatnlo_madspin_pythia8_16____v4"],
"metadata" : { "xs" : 0.01731 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_17____v4"],
"metadata" : { "xs" : 0.01687 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_18____v4"],
"metadata" : { "xs" : 0.01687 }
}
},
"GJets_HT40To100" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 8,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-40To100_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-40To100_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16_2____v4"],
"metadata" : { "xs" : 23100.0 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_17____v4"],
"metadata" : { "xs" : 23100.0 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_18____v4"],
"metadata" : { "xs" : 23100.0 }
}
},
"GJets_HT-100To200" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 8,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-100To200_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-100To200_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16_2____v4"],
"metadata" : { "xs" : 8631.0 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-100To200_TuneCP5_13TeV-madgraphMLM-pythia8_17____v4"],
"metadata" : { "xs" : 8631.0 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-100To200_TuneCP5_13TeV-madgraphMLM-pythia8_18____v4"],
"metadata" : { "xs" : 8631.0 }
}
},
"GJets_HT-200To400" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 8,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-200To400_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-200To400_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16_2____v4"],
"metadata" : { "xs" : 2280.0 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-200To400_TuneCP5_13TeV-madgraphMLM-pythia8_17____v4"],
"metadata" : { "xs" : 2280.0 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-200To400_TuneCP5_13TeV-madgraphMLM-pythia8_18____v4"],
"metadata" : { "xs" : 2280.0 }
}
},
"GJets_HT-400To600" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 8,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-400To600_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-400To600_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16_2____v4"],
"metadata" : { "xs" : 273.0 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-400To600_TuneCP5_13TeV-madgraphMLM-pythia8_17____v4"],
"metadata" : { "xs" : 273.0 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-400To600_TuneCP5_13TeV-madgraphMLM-pythia8_18____v4"],
"metadata" : { "xs" : 273.0 }
}
},
"GJets_HT-600ToInf" : {
"resonant" : false,
"fpo" : 5,
"process_id" : 8,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16____v4", "/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-600ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8_16_2____v4"],
"metadata" : { "xs" : 94.5 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_17____v4"],
"metadata" : { "xs" : 94.5 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_18____v4"],
"metadata" : { "xs" : 94.5 }
}
},
"VH" : {
"resonant" : true,
"fpo" : 1,
"process_id" : 9,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_16____v4"],
"metadata" : { "xs" : 0.00512 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_17____v4"],
"metadata" : { "xs" : 0.00512 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_18____v4"],
"metadata" : { "xs" : 0.00512 }
}
},
"ttH" : {
"resonant" : true,
"fpo" : 1,
"process_id" : -1,
"2016" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_17____v4/"],
"metadata" : { "xs" : 0.001151117 }
},
"2017" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_17____v4/"],
"metadata" : { "xs" : 0.001151117 }
},
"2018" : {
"paths" : ["/hadoop/cms/store/user/legianni/ProjectMetis/ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_18____v4/"],
"metadata" : { "xs" : 0.001151117 }
}
}
}
42 changes: 42 additions & 0 deletions Preselection/data/ttH_Leptonic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"branches" : [
"Photon_pt", "Photon_eta", "Photon_phi", "Photon_mass", "Photon_pixelSeed", "Photon_mvaID", "Photon_electronVeto",
"Muon_pt", "Muon_eta", "Muon_phi", "Muon_mass", "Muon_charge", "Muon_pfRelIso03_all", "Muon_dxy", "Muon_dz",
"Electron_pt", "Electron_eta", "Electron_phi", "Electron_mass", "Electron_charge", "Electron_mvaFall17V2Iso_WP90", "Electron_mvaFall17V2noIso_WP90", "Electron_pfRelIso03_all", "Electron_dxy", "Electron_dz",
"Jet_pt", "Jet_eta", "Jet_phi", "Jet_mass", "Jet_btagDeepFlavB", "Jet_jetId",
"ggMass", "nJet", "MET_pt", "genWeight", "tautauMassAll_SVFit"
],
"save_branches" : [
"ggMass", "nJet", "MET_pt",
"lead_pho_ptmgg", "sublead_pho_ptmgg", "lead_pho_eta", "sublead_pho_eta", "lead_pho_idmva", "sublead_pho_idmva",
"ele1_pt", "ele1_eta", "ele2_pt", "ele2_eta",
"muon1_pt", "muon1_eta", "muon2_pt", "muon2_eta",
"n_electrons", "n_muons"
],
"selection_options" : {
"photons" : {
"idmva_cut" : -0.7
},
"electrons" : {
"pt" : 10.0,
"eta" : 2.4,
"ip_xy" : 0.045,
"ip_z" : 0.2,
"dR_pho" : 0.2
},
"muons" : {
"pt" : 5.0,
"eta" : 2.4,
"ip_xy" : 0.045,
"ip_z" : 0.2,
"rel_iso" : 0.3,
"dR_pho" : 0.2
},
"jets": {
"pt" : 25.0,
"eta" : 2.4,
"dR_pho" : 0.4,
"dR_lep" : 0.4
}
}
}
10 changes: 7 additions & 3 deletions Preselection/helpers/loop_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import selections.analysis_selections as analysis_selections
import selections.lepton_selections as lepton_selections
import selections.tau_selections as tau_selections
import selections.jet_selections as jet_selections

class LoopHelper():
"""
Expand Down Expand Up @@ -234,14 +235,17 @@ def select_events(self, events, metadata):
events = analysis_selections.tth_leptonic_preselection(events, options, self.debug)
events.Electron = events.Electron[lepton_selections.select_electrons(events, events.Photon, options, self.debug)]
events.Muon = events.Muon[lepton_selections.select_muons(events, events.Photon, options, self.debug)]
events.Jet = events.Jet[jet_selections.select_jets(events, events.Photon, events.Electron, events.Muon, None, options, self.debug)]

return events

def trim_events(self, events, data):
events = photon_selections.set_photons(events, self.debug)
events = lepton_selections.set_electrons(events, self.debug)
events = lepton_selections.set_muons(events, self.debug)
events = tau_selections.set_taus(events, self.debug)
if self.selections == "HHggTauTau_InclusivePresel" or self.selections == "ttH_LeptonicPresel":
events = lepton_selections.set_electrons(events, self.debug)
events = lepton_selections.set_muons(events, self.debug)
if self.selections == "HHggTauTau_InclusivePresel":
events = tau_selections.set_taus(events, self.debug)
if data:
branches = self.save_branches_data
else:
Expand Down
24 changes: 15 additions & 9 deletions Preselection/selections/analysis_selections.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import selections.lepton_selections as lepton_selections
import selections.tau_selections as tau_selections
import selections.photon_selections as photon_selections
import selections.jet_selections as jet_selections

def ggTauTau_inclusive_preselection(events, options, debug):
cut_diagnostics = utils.CutDiagnostics(events = events, debug = debug, cut_set = "[analysis_selections.py : ggTauTau_inclusive_preselection]")
Expand Down Expand Up @@ -42,18 +43,23 @@ def tth_leptonic_preselection(events, options, debug):
cut_diagnostics = utils.CutDiagnostics(events = events, debug = debug, cut_set = "[analysis_selections.py : tth_leptonic_preselection]")

# Get number of electrons, muons
n_electrons = awkward.num(events.Electron[lepton_selections.select_electrons(events, debug)])
n_muons = awkward.num(events.Muon[lepton_selections.select_muons(events, debug)])

electron_selection = lepton_selections.select_electrons(events, events.Photon, options, debug)
muon_selection = lepton_selections.select_muons(events, events.Photon, options, debug)

n_electrons = awkward.num(events.Electron[electron_selection])
n_muons = awkward.num(events.Muon[muon_selection])
n_leptons = n_electrons + n_muons


# Get number of jets
#TODO

jet_selection = jet_selections.select_jets(events, events.Photon, events.Electron[electron_selection], events.Muon[muon_selection], None, options, debug)
n_jets = awkward.num(events.Jet[jet_selection])

lep_cut = n_leptons >= 1

events = events[lep_cut]
cut_diagnostics.add_cut(len(events), cut_name = "leptons >= 1 cut")
jet_cut = n_jets >= 1

all_cuts = lep_cut & jet_cut
cut_diagnostics.add_cuts([lep_cut, jet_cut, all_cuts], ["N_leptons >= 1", "N_jets >= 1", "all"])

events = events[all_cuts]

return events
27 changes: 27 additions & 0 deletions Preselection/selections/jet_selections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import awkward
import numpy
import numba

import selections.selection_utils as utils
import selections.object_selections as object_selections

def select_jets(events, photons, electrons, muons, taus, options, debug):
cut_diagnostics = utils.ObjectCutDiagnostics(objects = events.Jet, cut_set = "[jet_selections.py : select_jets]", debug = debug)

pt_cut = events.Jet.pt > options["jets"]["pt"]
eta_cut = abs(events.Jet.eta) < options["jets"]["eta"]

dR_pho_cut = object_selections.select_deltaR(events, events.Jet, photons, options["jets"]["dR_pho"], debug)
dR_ele_cut = object_selections.select_deltaR(events, events.Jet, electrons, options["jets"]["dR_lep"], debug)
dR_muon_cut = object_selections.select_deltaR(events, events.Jet, muons, options["jets"]["dR_lep"], debug)

if taus is not None:
dR_tau_cut = object_selections.select_deltaR(events, events.Jet, taus, options["jets"]["dR_tau"], debug)
else:
dR_tau_cut = object_selections.select_deltaR(events, events.Jet, photons, 0.0, debug) # dummy cut of all True

jet_cut = pt_cut & eta_cut & dR_pho_cut & dR_ele_cut & dR_muon_cut & dR_tau_cut

cut_diagnostics.add_cuts([pt_cut, eta_cut, dR_pho_cut, dR_ele_cut, dR_muon_cut, dR_tau_cut, jet_cut], ["pt > 25", "|eta| < 2.4", "dR_photons", "dR_electrons", "dR_muons", "dR_taus", "all"])

return jet_cut
2 changes: 0 additions & 2 deletions Preselection/selections/lepton_selections.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import selections.selection_utils as utils
import selections.object_selections as object_selections

DR_LEP_PHO = 0.2

def select_electrons(events, photons, options, debug):
cut_diagnostics = utils.ObjectCutDiagnostics(objects = events.Electron, cut_set = "[lepton_selections.py : select_electrons]", debug = debug)

Expand Down
Loading

0 comments on commit a96044c

Please sign in to comment.