Skip to content

Commit

Permalink
add modes in triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrommyd committed Sep 15, 2024
1 parent d67ad24 commit e21f44e
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 50 deletions.
170 changes: 139 additions & 31 deletions src/egamma_tnp/triggers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from egamma_tnp import ElectronTagNProbeFromMiniNTuples, ElectronTagNProbeFromNanoAOD
from egamma_tnp import ElectronTagNProbeFromMiniNTuples, ElectronTagNProbeFromNanoAOD, ElectronTagNProbeFromNanoNTuples


class ElePt_WPTight_Gsf:
Expand All @@ -12,8 +12,9 @@ class ElePt_WPTight_Gsf:
The fileset to calculate the trigger efficiencies for.
trigger_pt : int or float
The Pt threshold of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode: str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 30.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -41,7 +42,7 @@ def __new__(
fileset,
trigger_pt,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=30,
probes_pt_cut=27,
use_sc_eta=False,
Expand All @@ -51,7 +52,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltEle{trigger_pt}WPTightGsf"],
Expand All @@ -66,7 +67,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt}_WPTight_Gsf"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt}_WPTight_Gsf"],
Expand All @@ -84,6 +100,8 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance

Expand All @@ -97,8 +115,9 @@ class ElePt_CaloIdVT_GsfTrkIdT:
The fileset to calculate the trigger efficiencies for.
trigger_pt : int or float
The Pt threshold of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode : str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 30.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -126,7 +145,7 @@ def __new__(
fileset,
trigger_pt,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=30,
probes_pt_cut=112,
use_sc_eta=False,
Expand All @@ -136,7 +155,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltEle{trigger_pt}CaloIdVTGsfTrkIdTGsf"],
Expand All @@ -151,7 +170,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt}_CaloIdVT_GsfTrkIdT"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt}_CaloIdVT_GsfTrkIdT"],
Expand All @@ -169,6 +203,8 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance

Expand All @@ -184,8 +220,9 @@ class ElePt1_ElePt2_CaloIdL_TrackIdL_IsoVL_Leg1:
The Pt threshold of the high-Pt leg of the trigger.
trigger_pt2 : int or float
The Pt threshold of the low-Pt leg of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode: str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 30.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -214,7 +251,7 @@ def __new__(
trigger_pt1,
trigger_pt2,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=30,
probes_pt_cut=20,
use_sc_eta=False,
Expand All @@ -224,7 +261,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltEle{trigger_pt1}Ele{trigger_pt2}CaloIdLTrackIdLIsoVLLeg1L1match"],
Expand All @@ -239,7 +276,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt1}_Ele{trigger_pt2}_CaloIdL_TrackIdL_IsoVL_Leg1"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt1}_Ele{trigger_pt2}_CaloIdL_TrackIdL_IsoVL_Leg1"],
Expand All @@ -257,6 +309,8 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance

Expand All @@ -272,8 +326,9 @@ class ElePt1_ElePt2_CaloIdL_TrackIdL_IsoVL_Leg2:
The Pt threshold of the high-Pt leg of the trigger.
trigger_pt2 : int or float
The Pt threshold of the low-Pt leg of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode: str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 30.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -302,7 +357,7 @@ def __new__(
trigger_pt1,
trigger_pt2,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=30,
probes_pt_cut=9,
use_sc_eta=False,
Expand All @@ -312,7 +367,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltEle{trigger_pt1}Ele{trigger_pt2}CaloIdLTrackIdLIsoVLLeg2"],
Expand All @@ -327,7 +382,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt1}_Ele{trigger_pt2}_CaloIdL_TrackIdL_IsoVL_Leg2"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_Ele{trigger_pt1}_Ele{trigger_pt2}_CaloIdL_TrackIdL_IsoVL_Leg2"],
Expand All @@ -345,6 +415,8 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance

Expand All @@ -358,8 +430,9 @@ class DoubleElePt_CaloIdL_MW_SeededLeg:
The fileset to calculate the trigger efficiencies for.
trigger_pt : int or float
The Pt threshold of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode: str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 35.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -387,7 +460,7 @@ def __new__(
fileset,
trigger_pt,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=35,
probes_pt_cut=30,
use_sc_eta=False,
Expand All @@ -397,7 +470,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltDoubleEle{trigger_pt}CaloIdLMWSeedLegL1match"],
Expand All @@ -412,7 +485,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_DoubleEle{trigger_pt}_CaloIdL_MW_SeededLeg"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_DoubleEle{trigger_pt}_CaloIdL_MW_SeededLeg"],
Expand All @@ -430,6 +518,8 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance

Expand All @@ -443,8 +533,9 @@ class DoubleElePt_CaloIdL_MW_UnseededLeg:
The fileset to calculate the trigger efficiencies for.
trigger_pt : int or float
The Pt threshold of the trigger.
from_ntuples : bool, optional
Whether the fileset is E/Gamma NTuples or NanoAOD. The default is False.
mode : str, optional
Can be `"from_nanoaod"`, `"from_mini_ntuples"` or `"from_nano_ntuples"`. The default is `"from_nanoaod"`.
The default is `"from_nanoaod"`.
tags_pt_cut: int or float, optional
The Pt cut to apply to the tag electrons. The default is 35.
probes_pt_cut: int or float, optional
Expand Down Expand Up @@ -472,7 +563,7 @@ def __new__(
fileset,
trigger_pt,
*,
from_ntuples=False,
mode="from_nanoaod",
tags_pt_cut=35,
probes_pt_cut=30,
use_sc_eta=False,
Expand All @@ -482,7 +573,7 @@ def __new__(
extra_filter=None,
extra_filter_args=None,
):
if from_ntuples:
if mode == "from_mini_ntuples":
instance = ElectronTagNProbeFromMiniNTuples(
fileset=fileset,
filters=[f"passHltDoubleEle{trigger_pt}CaloIdLMWUnsLeg"],
Expand All @@ -497,7 +588,22 @@ def __new__(
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
else:
elif mode == "from_nano_ntuples":
instance = ElectronTagNProbeFromNanoNTuples(
fileset=fileset,
filters=[f"HLT_DoubleEle{trigger_pt}_CaloIdL_MW_UnseededLeg"],
tags_pt_cut=tags_pt_cut,
probes_pt_cut=probes_pt_cut,
tags_abseta_cut=2.5,
cutbased_id="cutBased >= 4",
extra_filter=extra_filter,
extra_filter_args=extra_filter_args,
use_sc_eta=use_sc_eta,
use_sc_phi=use_sc_phi,
avoid_ecal_transition_tags=avoid_ecal_transition_tags,
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
)
elif mode == "from_nanoaod":
instance = ElectronTagNProbeFromNanoAOD(
fileset=fileset,
filters=[f"HLT_DoubleEle{trigger_pt}_CaloIdL_MW_UnseededLeg"],
Expand All @@ -515,5 +621,7 @@ def __new__(
avoid_ecal_transition_probes=avoid_ecal_transition_probes,
require_event_to_pass_hlt_filter=True,
)
else:
raise ValueError(f"Invalid mode: {mode}")

return instance
Loading

0 comments on commit e21f44e

Please sign in to comment.