def tth_hadronic_preselection(events, photons, electrons, muons, jets, options, debug): cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : tth_hadronic_preselection]") # Get number of electrons, muons selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_leptons = n_electrons + n_muons # Get number of jets selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, None, jets, options, debug)] n_jets = awkward.num(selected_jets) # Get number of b-jets selected_bjets = selected_jets[jet_selections.select_bjets( selected_jets, options, debug)] n_bjets = awkward.num(selected_bjets) lep_cut = n_leptons == 0 jet_cut = n_jets >= 3 bjet_cut = n_bjets >= 1 all_cuts = lep_cut & jet_cut & bjet_cut cut_diagnostics.add_cuts( [lep_cut, jet_cut, bjet_cut, all_cuts], ["N_leptons == 0", "N_jets >= 3", "N_bjets >= 1", "all"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_electrons = selected_electrons[all_cuts] selected_muons = selected_muons[all_cuts] selected_jets = selected_jets[all_cuts] # Calculate event-level variables selected_events = lepton_selections.set_electrons(selected_events, selected_electrons, debug) selected_events = lepton_selections.set_muons(selected_events, selected_muons, debug) selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) return selected_events
def tth_leptonic_preselection(events, photons, electrons, muons, jets, options, debug): """ Performs tth leptonic preselection, requiring >= 1 lepton and >= 1 jet Assumes diphoton preselection has already been applied. Also calculates relevant event-level variables. """ cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : tth_leptonic_preselection]") # Get number of electrons, muons selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_leptons = n_electrons + n_muons # Get number of jets selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, None, jets, options, debug)] n_jets = awkward.num(selected_jets) lep_cut = n_leptons >= 1 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"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_electrons = selected_electrons[all_cuts] selected_muons = selected_muons[all_cuts] selected_jets = selected_jets[all_cuts] # Calculate event-level variables selected_events = lepton_selections.set_electrons(selected_events, selected_electrons, debug) selected_events = lepton_selections.set_muons(selected_events, selected_muons, debug) selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) return selected_events
def trim_events(self, events_and_objects, data): selected_events = photon_selections.set_photons(events_and_objects["events"], events_and_objects["photons"], self.debug) if self.selections == "HHggTauTau_InclusivePresel" or self.selections == "ttH_LeptonicPresel": selected_events = lepton_selections.set_electrons(events_and_objects["events"], events_and_objects["electrons"], self.debug) selected_events = lepton_selections.set_muons(events_and_objects["events"], events_and_objects["muons"], self.debug) if self.selections == "HHggTauTau_InclusivePresel": selected_events = tau_selections.set_taus(events_and_objects["events"], events_and_objects["taus"], self.debug) if self.selections == "ttH_LeptonicPresel": selected_events = jet_selections.set_jets(events_and_objects["events"], events_and_objects["jets"], self.selection_options, self.debug) if data: branches = self.save_branches_data else: branches = self.save_branches trimmed_events = selected_events[branches] return trimmed_events
def ggbb_preselection(events, photons, electrons, muons, jets, fatjets, options, debug): cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : ggbb_preselection]") # Get number of electrons, muons selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_leptons = n_electrons + n_muons # Get number of jets selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, None, jets, options, debug)] n_jets = awkward.num(selected_jets) # Get number of b-jets selected_bjets = selected_jets[jet_selections.select_bjets( selected_jets, options, debug)] n_bjets = awkward.num(selected_bjets) # Get fat jets selected_fatjets = fatjets[jet_selections.select_fatjets( events, photons, fatjets, options, debug)] n_fatjets = awkward.num(selected_fatjets) lep_cut = n_leptons == 0 if options["boosted"]: jet_cut = n_bjets < 2 fatjet_cut = n_fatjets == 1 all_cuts = lep_cut & jet_cut & fatjet_cut cut_diagnostics.add_cuts( [lep_cut, jet_cut, fatjet_cut, all_cuts], ["N_leptons == 0", "N_b-jets < 2", "N_fatjets == 1", "all"]) else: jet_cut = n_bjets == 2 all_cuts = lep_cut & jet_cut cut_diagnostics.add_cuts([lep_cut, jet_cut, all_cuts], ["N_leptons == 0", "N_b-jets == 2", "all"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_jets = selected_jets[all_cuts] selected_fatjets = selected_fatjets[all_cuts] # Calculate event-level variables selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) selected_events = jet_selections.set_fatjets(selected_events, selected_fatjets, options, debug) return selected_events
def ggTauTau_inclusive_preselection(events, photons, electrons, muons, taus, jets, dR, genPart, Category_pairsLoose, options, debug): """ Performs inclusive ggTauTau preselection, requiring >=1 (leptons + tau_h). Assumes diphoton preselection has already been applied. Also calculates relevant event-level variables. """ cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : ggTauTau_inclusive_preselection]") # Get number of electrons, muons, taus selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] selected_taus = taus[tau_selections.select_taus(events, photons, selected_muons, selected_electrons, taus, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_taus = awkward.num(selected_taus) # Require >= 1 lep/tau n_leptons_and_taus = n_electrons + n_muons + n_taus # only events with hadronic taus (no leptonic taus!!!!!!!!!!) atleast_one_had_tau_cut = (n_taus >= 1) # Require OS leptons/taus for events with 2 leptons/taus sum_charge = awkward.sum(selected_electrons.charge, axis=1) + awkward.sum( selected_muons.charge, axis=1) + awkward.sum(selected_taus.charge, axis=1) charge_cut = sum_charge == 0 two_leptons = n_leptons_and_taus == 2 not_two_leptons = n_leptons_and_taus != 2 os_cut = ( two_leptons & charge_cut ) | not_two_leptons # only require 2 OS leptons if there are ==2 leptons in the event # Select jets (don't cut on jet quantities for selection, but they will be useful for BDT training) selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, selected_taus, jets, options, debug)] all_cuts = os_cut & atleast_one_had_tau_cut cut_diagnostics.add_cuts([atleast_one_had_tau_cut, os_cut, all_cuts], ["N_taus >= 1", "OS dileptons", "all"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_electrons = selected_electrons[all_cuts] selected_muons = selected_muons[all_cuts] selected_taus = selected_taus[all_cuts] selected_jets = selected_jets[all_cuts] dR = dR[all_cuts] # Calculate event-level variables selected_events = lepton_selections.set_electrons(selected_events, selected_electrons, debug) selected_events = lepton_selections.set_muons(selected_events, selected_muons, debug) selected_events = tau_selections.set_taus(selected_events, selected_taus, debug) selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) if genPart is not None: genPart = genPart[all_cuts] selected_events = gen_selections.set_genZ(selected_events, genPart, options, debug) else: selected_events["genZ_decayMode"] = awkward.from_numpy( numpy.ones(len(selected_events)) * -1) selected_events["tau_motherID"] = awkward.from_numpy( numpy.ones(len(selected_events)) * -1) selected_events = compound_selections.compound_selections( selected_events, options, debug) return selected_events
def ggTauTau_inclusive_preselection(events, photons, electrons, muons, taus, jets, options, debug): """ Performs inclusive ggTauTau preselection, requiring >=1 (leptons + tau_h). Assumes diphoton preselection has already been applied. Also calculates relevant event-level variables. """ cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : ggTauTau_inclusive_preselection]") # Get number of electrons, muons, taus selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] selected_taus = taus[tau_selections.select_taus(events, photons, selected_muons, selected_electrons, taus, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_taus = awkward.num(selected_taus) # Require >= 1 lep/tau n_leptons_and_taus = n_electrons + n_muons + n_taus lep_tau_cut = n_leptons_and_taus >= options["n_leptons_and_taus"] # Require OS leptons/taus for events with 2 leptons/taus sum_charge = awkward.sum(selected_electrons.charge, axis=1) + awkward.sum( selected_muons.charge, axis=1) + awkward.sum(selected_taus.charge, axis=1) charge_cut = sum_charge == 0 two_leptons = n_leptons_and_taus == 2 not_two_leptons = n_leptons_and_taus != 2 os_cut = ( two_leptons & charge_cut ) | not_two_leptons # only require 2 OS leptons if there are ==2 leptons in the event # Select jets (don't cut on jet quantities for selection, but they will be useful for BDT training) selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, selected_taus, jets, options, debug)] all_cuts = lep_tau_cut & os_cut cut_diagnostics.add_cuts( [lep_tau_cut, os_cut, all_cuts], ["N_leptons + N_taus >= 1", "OS dileptons", "all"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_electrons = selected_electrons[all_cuts] selected_muons = selected_muons[all_cuts] selected_taus = selected_taus[all_cuts] selected_jets = selected_jets[all_cuts] # Calculate event-level variables selected_events = lepton_selections.set_electrons(selected_events, selected_electrons, debug) selected_events = lepton_selections.set_muons(selected_events, selected_muons, debug) selected_events = tau_selections.set_taus(selected_events, selected_taus, debug) selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) # TODO: add calculation HH->ggTauTau specific variables (e.g. H->TauTau kinematics) here return selected_events
def ggbb_preselection(events, photons, electrons, muons, jets, fatjets, genparts, options, debug): cut_diagnostics = utils.CutDiagnostics( events=events, debug=debug, cut_set="[analysis_selections.py : ggbb_preselection]") # Get number of electrons, muons selected_electrons = electrons[lepton_selections.select_electrons( events, photons, electrons, options, debug)] selected_muons = muons[lepton_selections.select_muons( events, photons, muons, options, debug)] n_electrons = awkward.num(selected_electrons) n_muons = awkward.num(selected_muons) n_leptons = n_electrons + n_muons # Get number of jets selected_jets = jets[jet_selections.select_jets(events, photons, selected_electrons, selected_muons, None, jets, options, debug)] n_jets = awkward.num(selected_jets) # Get number of b-jets selected_bjets = selected_jets[jet_selections.select_bjets( selected_jets, options, debug)] n_bjets = awkward.num(selected_bjets) # Get fat jets selected_fatjets = fatjets[jet_selections.select_fatjets( events, photons, fatjets, options, debug)] n_fatjets = awkward.num(selected_fatjets) lep_cut = n_leptons == 0 if options["boosted"]: # jet_cut = n_bjets < 2 # This is not wanted fatjet_cut = n_fatjets >= 1 all_cuts = lep_cut & fatjet_cut cut_diagnostics.add_cuts([lep_cut, fatjet_cut, all_cuts], ["N_leptons == 0", "N_fatjets >= 1", "all"]) else: jet_cut = n_bjets == 2 all_cuts = lep_cut & jet_cut cut_diagnostics.add_cuts([lep_cut, jet_cut, all_cuts], ["N_leptons == 0", "N_b-jets == 2", "all"]) # Keep only selected events selected_events = events[all_cuts] selected_photons = photons[all_cuts] selected_jets = selected_jets[all_cuts] selected_bjets = selected_bjets[all_cuts] selected_fatjets = selected_fatjets[all_cuts] # # Lead FatJet pt cut fatjet_pt_cut = selected_fatjets.pt[:, 0] >= 350 # # Keep only selected events II # selected_events = selected_events[fatjet_pt_cut] # selected_photons = selected_photons[fatjet_pt_cut] # selected_jets = selected_jets[fatjet_pt_cut] # selected_bjets = selected_bjets[fatjet_pt_cut] # selected_fatjets = selected_fatjets[fatjet_pt_cut] # cut_diagnostics.add_cuts([fatjet_pt_cut], ["Lead FatJet pt > 350 GeV"]) # Filter mjj #TODO Fix the "nearest" function # mjj_cut = mjj_selections.mjj_filter(events,selected_fatjets,selected_jets,[120,130],debug) # selected_events = events[mjj_cut] # selected_photons = photons[mjj_cut] # selected_jets = selected_jets[mjj_cut] # selected_bjets = selected_fatjets[mjj_cut] # selected_fatjets = selected_fatjets[mjj_cut] # Calculate event-level variables if genparts is not None: selected_genparts = genparts[all_cuts] # selected_genparts = selected_genparts[mjj_cut] # selected_genparts = selected_genparts[fatjet_pt_cut] # selected_events = selected_events[gen_selections.filter_genHbb(selected_events,selected_genparts,options,debug)] selected_events = gen_selections.set_genInfo(selected_events, selected_genparts, options, debug) selected_events = jet_selections.set_fatjets(selected_events, selected_fatjets, selected_genparts, options, debug) else: selected_events = jet_selections.set_fatjets( selected_events, selected_fatjets, genparts, options, debug) #FIXME genparts is None here selected_events = jet_selections.set_jets(selected_events, selected_jets, options, debug) selected_events = helicity_selections.set_helicity(selected_events, selected_photons, selected_fatjets, selected_bjets, options, debug) return selected_events