ATLAS Offline Software
Loading...
Searching...
No Matches
python.EventSelectionConfig.EventSelectionConfig Class Reference
Inheritance diagram for python.EventSelectionConfig.EventSelectionConfig:
Collaboration diagram for python.EventSelectionConfig.EventSelectionConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeAlgs (self, config)
 interpret (self, text, cfg)
 raise_misconfig (self, text, keyword)
 raise_missinginput (self, collection)
 check_float (self, test, requirePositive=True)
 check_int (self, test, requirePositive=True)
 check_string (self, test)
 check_sign (self, test)
 check_btagging (self, test)
 check_ghosts (self, test)
 getCutflow (self)
 setDecorationName (self, algorithm, config, decoration)
 checkDecorationName (self, decoration)
 extendObjectSelection (self, config, container, oldSelection, newSelection)
 add_IMPORT (self, text, config)
 add_NBJET_selector (self, text, config)
 add_SUMNELNMU_selector (self, text, config)
 add_SUMNLEPTONS_selector (self, text, config)
 add_NLJETMASS_selector (self, text, config)
 add_NLJETMASSWINDOW_selector (self, text, config)
 add_NJETGHOST_selector (self, text, config)
 add_NLJETGHOST_selector (self, text, config)
 add_NOBJ_selector (self, text, config)
 add_MET_selector (self, text, config)
 add_MWT_selector (self, text, config)
 add_METMWT_selector (self, text, config)
 add_MLL_selector (self, text, config)
 add_MLLWINDOW_selector (self, text, config)
 add_MLL_OSSF_selector (self, text, config)
 add_EVENTFLAG (self, text, config)
 add_GLOBALTRIGMATCH (self, text, config)
 add_RUNNUMBER (self, text, config)
 add_EXPR_selector (self, text, config)
 add_SAVE (self, text, config)

Public Attributes

int step = 0
str currentDecoration = ''
list cutflow = []
 selectionName
 debugMode
 jets
 muons
 electrons
 taus
 met
 btagDecoration

Protected Member Functions

 _build_dispatch (self)
 _check_args (self, items, keyword, validCounts)
 _maybe_dressed (self, alg, *specs)
 _val_sign_count (self, items, config, alg, container)
 _route_lepton (self, alg, config, spec, reco, truth)
 _add_nobject (self, text, config, *, attr, tag)
 _add_charge (self, text, config, *, osMode, tag)
 _expr_tokenize (self, text)
 _expr_peek (self)
 _expr_advance (self)
 _expr_expect (self, kind)
 _expr_parse (self, tokens)
 _expr_parse_funcall (self)
 _expr_parse_operand (self)
 _expr_parse_sign (self)
 _expr_parse_value (self)
 _expr_validate (self, variable, separator, operands)
 _emit_save (self, config)

Protected Attributes

 _dispatch = self._build_dispatch()
 _exprTokens = tokens
int _exprPos = 0

Static Protected Attributes

dict _NOBJECT
dict _EXPR_COLL
dict _EXPR_VARS
 _EXPR_TOKEN_RE = re.compile(, re.VERBOSE)

Detailed Description

ConfigBlock for interpreting text-based event selections

Definition at line 59 of file EventSelectionConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.EventSelectionConfig.EventSelectionConfig.__init__ ( self)

Definition at line 73 of file EventSelectionConfig.py.

73 def __init__(self):
74 super(EventSelectionConfig, self).__init__()
75 self.setBlockName('EventSelection')
76 self.addOption('selectionName', '', type=str,
77 noneAction='error',
78 info="the name of the event selection, used to uniquely identify "
79 "the `EventSelectionConfig` block.")
80 self.addOption('electrons', "", type=str,
81 info="the input electron container, with a possible selection, in "
82 "the format `container` or `container.selection`.")
83 self.addOption('muons', "", type=str,
84 info="the input muon container, with a possible selection, in the "
85 "format `container` or `container.selection`.")
86 self.addOption('jets', "", type=str,
87 info="the input jet container, with a possible selection, in the "
88 "format `container` or `container.selection`.")
89 self.addOption('largeRjets', "", type=str,
90 info="the large-R jet container, with a possible selection, in "
91 "the format `container` or `container.selection`.")
92 self.addOption('photons', "", type=str,
93 info="the input photon container, with a possible selection, in "
94 "the format `container` or `container.selection`.")
95 self.addOption('taus', "", type=str,
96 info="the input tau-jet container, with a possible selection, in "
97 "the format `container` or `container.selection`.")
98 self.addOption('met', "", type=str,
99 info="the input MET container.")
100 self.addOption('metTerm', "Final", type=str,
101 info="the MET term to use when computing MET-based quantities.")
102 self.addOption('btagDecoration', "", type=str,
103 info="the b-tagging decoration to use when defining b-jets.")
104 self.addOption('preselection', "", type=str,
105 info="the event-wise selection flag to start this event selection "
106 "from.")
107 self.addOption('selectionCuts', "", type=str,
108 noneAction='error',
109 info="a single string listing one selection cut per line. "
110 "See [available keywords](https://topcptoolkit.docs.cern.ch/latest/settings/eventselection/#available-keywords).")
111 self.addOption('debugMode', False, type=bool,
112 info="whether to create an output branch for every single line "
113 "of the selection cuts. Setting it to `False` only saves the"
114 " final decision.")
115 self.addOption('useDressedProperties', True, type=bool,
116 info="whether to use dressed truth electron and truth muon "
117 "kinematics rather than simple 4-vector kinematics.")
118 self.step = 0
119 self.currentDecoration = ''
120 self.cutflow = []
121 self._dispatch = self._build_dispatch()
122

Member Function Documentation

◆ _add_charge()

python.EventSelectionConfig.EventSelectionConfig._add_charge ( self,
text,
config,
* ,
osMode,
tag )
protected
Builder shared by OS and SS: same algorithm, opposite charge mode.

Definition at line 668 of file EventSelectionConfig.py.

668 def _add_charge(self, text, config, *, osMode, tag):
669 """Builder shared by OS and SS: same algorithm, opposite charge mode."""
670 items = text.split()
671 if not items or len(items) > 4:
672 self.raise_misconfig(text, "number of arguments")
673 if not self.electrons and not self.muons and not self.taus:
674 self.raise_missinginput("electrons or muons or taus")
675 thisalg = f'{self.selectionName}_{tag}_{self.step}'
676 alg = config.createAlgorithm('CP::ChargeSelectorAlg', thisalg)
677 allLeptons = (len(items) == 1)
678 if self.electrons and (allLeptons or "el" in items):
679 self._route_lepton(alg, config, self.electrons,
680 ('electrons', 'electronSelection'),
681 ('truthElectrons', 'truthElectronSelection'))
682 if self.muons and (allLeptons or "mu" in items):
683 self._route_lepton(alg, config, self.muons,
684 ('muons', 'muonSelection'),
685 ('truthMuons', 'truthMuonSelection'))
686 if self.taus and (allLeptons or "tau" in items):
687 self._route_lepton(alg, config, self.taus,
688 ('taus', 'tauSelection'),
689 ('truthTaus', 'truthTauSelection'))
690 alg.OS = osMode
691 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
692 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
693 return
694

◆ _add_nobject()

python.EventSelectionConfig.EventSelectionConfig._add_nobject ( self,
text,
config,
* ,
attr,
tag )
protected
Generic builder for the N-object pT selectors (EL_N, MU_N, JET_N,
PH_N, TAU_N, LJET_N): identical except for the source container, which
is always required since the cut acts on it.

Definition at line 345 of file EventSelectionConfig.py.

345 def _add_nobject(self, text, config, *, attr, tag):
346 """Generic builder for the N-object pT selectors (EL_N, MU_N, JET_N,
347 PH_N, TAU_N, LJET_N): identical except for the source container, which
348 is always required since the cut acts on it."""
349 items = text.split()
350 spec = getattr(self, attr)
351 if not spec:
352 self.raise_missinginput(attr)
353 if len(items) not in (4, 5):
354 self.raise_misconfig(text, "number of arguments")
355 thisalg = f'{self.selectionName}_{tag}_{self.step}'
356 alg = config.createAlgorithm('CP::NObjectPtSelectorAlg', thisalg)
357 alg.particles, alg.objectSelection = config.readNameAndSelection(spec)
358 if attr in ("electrons", "muons"):
359 self._maybe_dressed(alg, spec)
360 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
361 alg.minPt, alg.sign, alg.count = self._val_sign_count(
362 items, config, alg, spec.split(".")[0])
363 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
364

◆ _build_dispatch()

python.EventSelectionConfig.EventSelectionConfig._build_dispatch ( self)
protected
Map each keyword to its handler. Dispatch is an exact lookup on the
first token, which removes the ordering fragility of token-membership.

Definition at line 127 of file EventSelectionConfig.py.

127 def _build_dispatch(self):
128 """Map each keyword to its handler. Dispatch is an exact lookup on the
129 first token, which removes the ordering fragility of token-membership."""
130 d = {
131 "JET_N_BTAG": self.add_NBJET_selector,
132 "JET_N_GHOST": self.add_NJETGHOST_selector,
133 "LJET_N_GHOST": self.add_NLJETGHOST_selector,
134 "LJETMASS_N": self.add_NLJETMASS_selector,
135 "LJETMASSWINDOW_N": self.add_NLJETMASSWINDOW_selector,
136 "OBJ_N": self.add_NOBJ_selector,
137 "SUM_EL_N_MU_N": self.add_SUMNELNMU_selector,
138 "SUM_EL_N_MU_N_TAU_N": self.add_SUMNLEPTONS_selector,
139 "MET": self.add_MET_selector,
140 "MWT": self.add_MWT_selector,
141 "MET+MWT": self.add_METMWT_selector,
142 "MLL": self.add_MLL_selector,
143 "MLLWINDOW": self.add_MLLWINDOW_selector,
144 "MLL_OSSF": self.add_MLL_OSSF_selector,
145 "OS": partial(self._add_charge, osMode=True, tag="OS"),
146 "SS": partial(self._add_charge, osMode=False, tag="SS"),
147 "SAVE": self.add_SAVE,
148 "IMPORT": self.add_IMPORT,
149 "EVENTFLAG": self.add_EVENTFLAG,
150 "GLOBALTRIGMATCH": self.add_GLOBALTRIGMATCH,
151 "RUN_NUMBER": self.add_RUNNUMBER,
152 "EXPR": self.add_EXPR_selector,
153 }
154 for kw, (attr, tag) in self._NOBJECT.items():
155 d[kw] = partial(self._add_nobject, attr=attr, tag=tag)
156 return d
157

◆ _check_args()

python.EventSelectionConfig.EventSelectionConfig._check_args ( self,
items,
keyword,
validCounts )
protected
Validate the leading keyword and the number of arguments.

Definition at line 201 of file EventSelectionConfig.py.

201 def _check_args(self, items, keyword, validCounts):
202 """Validate the leading keyword and the number of arguments."""
203 if items[0] != keyword:
204 self.raise_misconfig(' '.join(items), keyword)
205 if len(items) not in validCounts:
206 self.raise_misconfig(' '.join(items), "number of arguments")
207

◆ _emit_save()

python.EventSelectionConfig.EventSelectionConfig._emit_save ( self,
config )
protected
Create the SaveFilterAlg that turns the accumulated event selection
into a named, persisted selection (and ntuple branch). Called once per
block, automatically at the end of makeAlgs.

Definition at line 959 of file EventSelectionConfig.py.

959 def _emit_save(self, config):
960 """Create the SaveFilterAlg that turns the accumulated event selection
961 into a named, persisted selection (and ntuple branch). Called once per
962 block, automatically at the end of makeAlgs."""
963 thisalg = f'{self.selectionName}_SAVE'
964 alg = config.createAlgorithm('CP::SaveFilterAlg', thisalg)
965 alg.FilterDescription = f'events passing < {self.selectionName} >'
966 alg.eventDecisionOutputDecoration = f'ignore_{self.selectionName}_%SYS%'
967 alg.selection = self.checkDecorationName(self.currentDecoration)
968 alg.noFilter = True
969 alg.selectionName = f'pass_{self.selectionName}_%SYS%,as_char' # this one is used as a selection
970 alg.decorationName = f'ntuplepass_{self.selectionName}_%SYS%' # this one is saved to file
971 config.addOutputVar('EventInfo', f'ntuplepass_{self.selectionName}_%SYS%', f'pass_{self.selectionName}')
972 return
973
974
975@groupBlocks

◆ _expr_advance()

python.EventSelectionConfig.EventSelectionConfig._expr_advance ( self)
protected

Definition at line 802 of file EventSelectionConfig.py.

802 def _expr_advance(self):
803 tok = self._exprTokens[self._exprPos]
804 self._exprPos += 1
805 return tok
806

◆ _expr_expect()

python.EventSelectionConfig.EventSelectionConfig._expr_expect ( self,
kind )
protected

Definition at line 807 of file EventSelectionConfig.py.

807 def _expr_expect(self, kind):
808 tok = self._expr_advance()
809 if tok[0] != kind:
810 raise InconsistentSettingsError(
811 f"[EventSelectionConfig] EXPR: expected {kind}, got '{tok[1]}'")
812 return tok
813

◆ _expr_parse()

python.EventSelectionConfig.EventSelectionConfig._expr_parse ( self,
tokens )
protected

Definition at line 814 of file EventSelectionConfig.py.

814 def _expr_parse(self, tokens):
815 self._exprTokens = tokens
816 self._exprPos = 0
817 variable, separator, operands = self._expr_parse_funcall()
818 sign = self._expr_parse_sign()
819 refValue = self._expr_parse_value()
820 self._expr_expect("END")
821 return variable, separator, operands, sign, refValue
822

◆ _expr_parse_funcall()

python.EventSelectionConfig.EventSelectionConfig._expr_parse_funcall ( self)
protected

Definition at line 823 of file EventSelectionConfig.py.

823 def _expr_parse_funcall(self):
824 variable = self._expr_expect("ID")[1]
825 self._expr_expect("LP")
826 operands = [self._expr_parse_operand()]
827 separator = None
828 while self._expr_peek()[0] in ("COMMA", "PLUS"):
829 sep = "," if self._expr_advance()[0] == "COMMA" else "+"
830 if separator is None:
831 separator = sep
832 elif sep != separator:
833 raise InconsistentSettingsError(
834 "[EventSelectionConfig] EXPR: cannot mix ',' and '+' separators")
835 operands.append(self._expr_parse_operand())
836 self._expr_expect("RP")
837 return variable, separator, operands
838

◆ _expr_parse_operand()

python.EventSelectionConfig.EventSelectionConfig._expr_parse_operand ( self)
protected

Definition at line 839 of file EventSelectionConfig.py.

839 def _expr_parse_operand(self):
840 coll = self._expr_expect("ID")[1]
841 index = None
842 if self._expr_peek()[0] == "LB":
843 self._expr_advance()
844 index = int(self._expr_expect("NUM")[1])
845 self._expr_expect("RB")
846 return (coll, index)
847

◆ _expr_parse_sign()

python.EventSelectionConfig.EventSelectionConfig._expr_parse_sign ( self)
protected

Definition at line 848 of file EventSelectionConfig.py.

848 def _expr_parse_sign(self):
849 tok = self._expr_advance()
850 if tok[0] not in ("LT", "GT", "EQ", "GE", "LE"):
851 raise InconsistentSettingsError(
852 f"[EventSelectionConfig] EXPR: expected a comparison operator, got '{tok[1]}'")
853 return tok[0]
854

◆ _expr_parse_value()

python.EventSelectionConfig.EventSelectionConfig._expr_parse_value ( self)
protected

Definition at line 855 of file EventSelectionConfig.py.

855 def _expr_parse_value(self):
856 negative = False
857 if self._expr_peek()[0] == "MINUS":
858 self._expr_advance()
859 negative = True
860 value = float(self._expr_expect("NUM")[1])
861 return -value if negative else value
862

◆ _expr_peek()

python.EventSelectionConfig.EventSelectionConfig._expr_peek ( self)
protected

Definition at line 799 of file EventSelectionConfig.py.

799 def _expr_peek(self):
800 return self._exprTokens[self._exprPos]
801

◆ _expr_tokenize()

python.EventSelectionConfig.EventSelectionConfig._expr_tokenize ( self,
text )
protected

Definition at line 785 of file EventSelectionConfig.py.

785 def _expr_tokenize(self, text):
786 tokens, pos = [], 0
787 while pos < len(text):
788 m = self._EXPR_TOKEN_RE.match(text, pos)
789 if not m:
790 raise InconsistentSettingsError(
791 f"[EventSelectionConfig] EXPR: cannot parse near '{text[pos:]}'")
792 pos = m.end()
793 if m.lastgroup != "WS":
794 tokens.append((m.lastgroup, m.group()))
795 tokens.append(("END", ""))
796 return tokens
797
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359

◆ _expr_validate()

python.EventSelectionConfig.EventSelectionConfig._expr_validate ( self,
variable,
separator,
operands )
protected

Definition at line 863 of file EventSelectionConfig.py.

863 def _expr_validate(self, variable, separator, operands):
864 if variable not in self._EXPR_VARS:
865 raise UnavailableFeatureError(
866 f"[EventSelectionConfig] EXPR: variable '{variable}' is not available. "
867 "Please request it from the EventSelectionAlgorithms developers.")
868 minN, maxN, sep, _needsEta, metOk = self._EXPR_VARS[variable]
869 n = len(operands)
870 if n < minN or (maxN is not None and n > maxN):
871 expected = f"{minN}" if maxN == minN else (f"{minN}+" if maxN is None else f"{minN}-{maxN}")
872 raise InconsistentSettingsError(
873 f"[EventSelectionConfig] EXPR: '{variable}' takes {expected} operand(s), got {n}")
874 if n > 1 and separator != sep:
875 want = {",": "','", "+": "'+'"}.get(sep, str(sep))
876 raise InconsistentSettingsError(
877 f"[EventSelectionConfig] EXPR: '{variable}' operands must be separated by {want}")
878 for coll, index in operands:
879 if coll not in self._EXPR_COLL:
880 raise UnavailableFeatureError(
881 f"[EventSelectionConfig] EXPR: collection '{coll}' is not available. "
882 "Please request it from the EventSelectionAlgorithms developers.")
883 _opt, _btag, isMET = self._EXPR_COLL[coll]
884 if isMET:
885 if not metOk:
886 raise InconsistentSettingsError(
887 f"[EventSelectionConfig] EXPR: 'met' is not valid for '{variable}'")
888 if index is not None:
889 raise InconsistentSettingsError(
890 "[EventSelectionConfig] EXPR: 'met' cannot be indexed")
891 if separator == "+":
892 raise InconsistentSettingsError(
893 "[EventSelectionConfig] EXPR: 'met' cannot be combined in a sum")
894 elif index is None:
895 raise InconsistentSettingsError(
896 f"[EventSelectionConfig] EXPR: '{coll}' must be indexed, e.g. {coll}[0]")
897
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

◆ _maybe_dressed()

python.EventSelectionConfig.EventSelectionConfig._maybe_dressed ( self,
alg,
* specs )
protected
Enable dressed kinematics when any of the given electron/muon
containers is a truth container. Dressed kinematics only exist for
truth electrons and muons, so only those specs should be passed here.

Definition at line 310 of file EventSelectionConfig.py.

310 def _maybe_dressed(self, alg, *specs):
311 """Enable dressed kinematics when any of the given electron/muon
312 containers is a truth container. Dressed kinematics only exist for
313 truth electrons and muons, so only those specs should be passed here."""
314 if any(spec and ("Particle" in spec or "Truth" in spec) for spec in specs):
315 alg.useDressedProperties = self.useDressedProperties
316

◆ _route_lepton()

python.EventSelectionConfig.EventSelectionConfig._route_lepton ( self,
alg,
config,
spec,
reco,
truth )
protected
Assign (name, selection) to the reco or truth handles of `alg`
depending on whether `spec` points to a truth container.
`reco`/`truth` are (nameAttr, selectionAttr) pairs.

Definition at line 332 of file EventSelectionConfig.py.

332 def _route_lepton(self, alg, config, spec, reco, truth):
333 """Assign (name, selection) to the reco or truth handles of `alg`
334 depending on whether `spec` points to a truth container.
335 `reco`/`truth` are (nameAttr, selectionAttr) pairs."""
336 name, sel = config.readNameAndSelection(spec)
337 nameAttr, selAttr = truth if ("Particle" in spec or "Truth" in spec) else reco
338 setattr(alg, nameAttr, name)
339 setattr(alg, selAttr, sel)
340

◆ _val_sign_count()

python.EventSelectionConfig.EventSelectionConfig._val_sign_count ( self,
items,
config,
alg,
container )
protected
Parse the trailing `[extraSel] value sign count` grammar (4 or 5
tokens), applying the optional extra object selection in place.
Returns (value, sign, count).

Definition at line 317 of file EventSelectionConfig.py.

317 def _val_sign_count(self, items, config, alg, container):
318 """Parse the trailing `[extraSel] value sign count` grammar (4 or 5
319 tokens), applying the optional extra object selection in place.
320 Returns (value, sign, count)."""
321 if len(items) == 5:
322 extraSel = self.check_string(items[1])
323 alg.objectSelection = self.extendObjectSelection(
324 config, container, alg.objectSelection, extraSel)
325 i = 2
326 else: # len == 4, already validated by the caller
327 i = 1
328 return (self.check_float(items[i]),
329 self.check_sign(items[i + 1]),
330 self.check_int(items[i + 2]))
331

◆ add_EVENTFLAG()

python.EventSelectionConfig.EventSelectionConfig.add_EVENTFLAG ( self,
text,
config )

Definition at line 718 of file EventSelectionConfig.py.

718 def add_EVENTFLAG(self, text, config):
719 items = text.split()
720 self._check_args(items, "EVENTFLAG", (2,))
721 existingDecoration = self.check_string(items[1])
722 self.setDecorationName(None, config, existingDecoration)
723 return
724

◆ add_EXPR_selector()

python.EventSelectionConfig.EventSelectionConfig.add_EXPR_selector ( self,
text,
config )

Definition at line 898 of file EventSelectionConfig.py.

898 def add_EXPR_selector(self, text, config):
899 body = text[len("EXPR"):].strip()
900 if not body:
901 self.raise_misconfig(text, "EXPR expression")
902 variable, separator, operands, sign, refValue = self._expr_parse(self._expr_tokenize(body))
903 self._expr_validate(variable, separator, operands)
904
905 thisalg = f'{self.selectionName}_EXPR_{self.step}'
906 alg = config.createAlgorithm('CP::ObjectKinematicSelectorAlg', thisalg)
907 alg.variable = variable
908 alg.sign = sign
909 alg.refValue = refValue
910
911 operandKinds, collections, selections, indices = [], [], [], []
912 usesMET = False
913 for coll, index in operands:
914 opt, applyBtag, isMET = self._EXPR_COLL[coll]
915 container = getattr(self, opt)
916 if not container:
917 self.raise_missinginput(opt)
918 if isMET:
919 operandKinds.append("MET")
920 usesMET = True
921 continue
922 operandKinds.append("PARTICLE")
923 name, selection = config.readNameAndSelection(container)
924 if applyBtag:
925 if not self.btagDecoration:
926 self.raise_missinginput("btagDecoration")
927 selection = (f'{selection}&&{self.btagDecoration},as_char'
928 if selection else f'{self.btagDecoration},as_char')
929 collections.append(name)
930 selections.append(selection)
931 indices.append(index)
932
933 alg.operandKinds = operandKinds
934 alg.collections = collections
935 alg.selections = selections
936 alg.indices = indices
937 if usesMET:
938 if not self.met:
939 self.raise_missinginput("met")
940 alg.met = config.readName(self.met)
941 alg.metTerm = self.metTerm
942 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
943 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
944 return
945

◆ add_GLOBALTRIGMATCH()

python.EventSelectionConfig.EventSelectionConfig.add_GLOBALTRIGMATCH ( self,
text,
config )

Definition at line 725 of file EventSelectionConfig.py.

725 def add_GLOBALTRIGMATCH(self, text, config):
726 items = text.split()
727 self._check_args(items, "GLOBALTRIGMATCH", (1, 2))
728 if len(items) == 1:
729 self.setDecorationName(None, config, "globalTriggerMatch_%SYS%,as_char")
730 else:
731 postfix = self.check_string(items[1])
732 self.setDecorationName(None, config, f"globalTriggerMatch{postfix}_%SYS%,as_char")
733 return
734

◆ add_IMPORT()

python.EventSelectionConfig.EventSelectionConfig.add_IMPORT ( self,
text,
config )

Definition at line 365 of file EventSelectionConfig.py.

365 def add_IMPORT(self, text, config):
366 # this is used to import a previous selection
367 items = text.split()
368 self._check_args(items, "IMPORT", (2,))
369 region = self.check_string(items[1])
370 if not self.currentDecoration:
371 self.currentDecoration = f'pass_{region}_%SYS%,as_char'
372 else:
373 self.currentDecoration = f'{self.currentDecoration},as_char&&pass_{region}_%SYS%'
374 # for the cutflow, we need to retrieve all the cuts corresponding to this IMPORT
375 imported_cuts = [cut for cut in config.getSelectionCutFlow('EventInfo', '') if cut.startswith(region)]
376 self.cutflow += imported_cuts
377 return
378

◆ add_MET_selector()

python.EventSelectionConfig.EventSelectionConfig.add_MET_selector ( self,
text,
config )

Definition at line 578 of file EventSelectionConfig.py.

578 def add_MET_selector(self, text, config):
579 items = text.split()
580 self._check_args(items, "MET", (3,))
581 if not self.met:
582 self.raise_missinginput("MET")
583 thisalg = f'{self.selectionName}_MET_{self.step}'
584 alg = config.createAlgorithm('CP::MissingETSelectorAlg', thisalg)
585 alg.met = config.readName(self.met)
586 alg.metTerm = self.metTerm
587 alg.sign = self.check_sign(items[1])
588 alg.refMET = self.check_float(items[2])
589 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
590 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
591 return
592

◆ add_METMWT_selector()

python.EventSelectionConfig.EventSelectionConfig.add_METMWT_selector ( self,
text,
config )

Definition at line 611 of file EventSelectionConfig.py.

611 def add_METMWT_selector(self, text, config):
612 items = text.split()
613 self._check_args(items, "MET+MWT", (3,))
614 if not self.met:
615 self.raise_missinginput("MET")
616 if not self.electrons and not self.muons:
617 self.raise_missinginput("electrons or muons")
618 thisalg = f'{self.selectionName}_METMWT_{self.step}'
619 alg = config.createAlgorithm('CP::MissingETPlusTransverseMassSelectorAlg', thisalg)
620 alg.met = config.readName(self.met)
621 alg.metTerm = self.metTerm
622 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
623 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
624 self._maybe_dressed(alg, self.electrons, self.muons)
625 alg.sign = self.check_sign(items[1])
626 alg.refMETMWT = self.check_float(items[2])
627 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
628 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
629 return
630

◆ add_MLL_OSSF_selector()

python.EventSelectionConfig.EventSelectionConfig.add_MLL_OSSF_selector ( self,
text,
config )

Definition at line 695 of file EventSelectionConfig.py.

695 def add_MLL_OSSF_selector(self, text, config):
696 items = text.split()
697 self._check_args(items, "MLL_OSSF", (3, 4))
698 if not self.electrons and not self.muons:
699 self.raise_missinginput("electrons or muons")
700 thisalg = f'{self.selectionName}_MLL_OSSF_{self.step}'
701 alg = config.createAlgorithm('CP::DileptonOSSFInvariantMassWindowSelectorAlg', thisalg)
702 if self.electrons:
703 self._route_lepton(alg, config, self.electrons,
704 ('electrons', 'electronSelection'),
705 ('truthElectrons', 'truthElectronSelection'))
706 if self.muons:
707 self._route_lepton(alg, config, self.muons,
708 ('muons', 'muonSelection'),
709 ('truthMuons', 'truthMuonSelection'))
710 self._maybe_dressed(alg, self.electrons, self.muons)
711 alg.lowMll = self.check_float(items[1])
712 alg.highMll = self.check_float(items[2])
713 alg.vetoMode = (len(items) == 4 and self.check_string(items[3]).lower() == "veto")
714 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
715 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
716 return
717

◆ add_MLL_selector()

python.EventSelectionConfig.EventSelectionConfig.add_MLL_selector ( self,
text,
config )

Definition at line 631 of file EventSelectionConfig.py.

631 def add_MLL_selector(self, text, config):
632 items = text.split()
633 self._check_args(items, "MLL", (3,))
634 if not self.electrons and not self.muons:
635 self.raise_missinginput("electrons or muons")
636 thisalg = f'{self.selectionName}_MLL_{self.step}'
637 alg = config.createAlgorithm('CP::DileptonInvariantMassSelectorAlg', thisalg)
638 if self.electrons:
639 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
640 if self.muons:
641 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
642 self._maybe_dressed(alg, self.electrons, self.muons)
643 alg.sign = self.check_sign(items[1])
644 alg.refMLL = self.check_float(items[2])
645 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
646 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
647 return
648

◆ add_MLLWINDOW_selector()

python.EventSelectionConfig.EventSelectionConfig.add_MLLWINDOW_selector ( self,
text,
config )

Definition at line 649 of file EventSelectionConfig.py.

649 def add_MLLWINDOW_selector(self, text, config):
650 items = text.split()
651 self._check_args(items, "MLLWINDOW", (3, 4))
652 if not self.electrons and not self.muons:
653 self.raise_missinginput("electrons or muons")
654 thisalg = f'{self.selectionName}_MLLWINDOW_{self.step}'
655 alg = config.createAlgorithm('CP::DileptonInvariantMassWindowSelectorAlg', thisalg)
656 if self.electrons:
657 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
658 if self.muons:
659 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
660 self._maybe_dressed(alg, self.electrons, self.muons)
661 alg.lowMLL = self.check_float(items[1])
662 alg.highMLL = self.check_float(items[2])
663 alg.vetoMode = (len(items) == 4 and self.check_string(items[3]).lower() == "veto")
664 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
665 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
666 return
667

◆ add_MWT_selector()

python.EventSelectionConfig.EventSelectionConfig.add_MWT_selector ( self,
text,
config )

Definition at line 593 of file EventSelectionConfig.py.

593 def add_MWT_selector(self, text, config):
594 items = text.split()
595 self._check_args(items, "MWT", (3,))
596 if not self.electrons and not self.muons:
597 self.raise_missinginput("electrons or muons")
598 thisalg = f'{self.selectionName}_MWT_{self.step}'
599 alg = config.createAlgorithm('CP::TransverseMassSelectorAlg', thisalg)
600 alg.met = config.readName(self.met)
601 alg.metTerm = self.metTerm
602 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
603 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
604 self._maybe_dressed(alg, self.electrons, self.muons)
605 alg.sign = self.check_sign(items[1])
606 alg.refMWT = self.check_float(items[2])
607 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
608 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
609 return
610

◆ add_NBJET_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NBJET_selector ( self,
text,
config )

Definition at line 379 of file EventSelectionConfig.py.

379 def add_NBJET_selector(self, text, config):
380 items = text.split()
381 self._check_args(items, "JET_N_BTAG", (3, 4, 5))
382 if not self.jets:
383 self.raise_missinginput("jets")
384 thisalg = f'{self.selectionName}_NBJET_{self.step}'
385 alg = config.createAlgorithm('CP::NObjectPtSelectorAlg', thisalg)
386 particles, selection = config.readNameAndSelection(self.jets)
387 alg.particles = particles
388 alg.objectSelection = f'{selection}&&{self.btagDecoration},as_char' if selection else f'{self.btagDecoration},as_char'
389 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
390 if len(items) == 3:
391 alg.sign = self.check_sign(items[1])
392 alg.count = self.check_int(items[2])
393 elif len(items) == 4:
394 if ":" in text:
395 btagger, btagWP = self.check_btagging(items[1])
396 customBtag = f'ftag_select_{btagger}_{btagWP}'
397 alg.objectSelection = f'{selection}&&{customBtag},as_char' if selection else f'{customBtag},as_char'
398 else:
399 extraSel = self.check_string(items[1])
400 alg.objectSelection = self.extendObjectSelection(config, self.jets.split(".")[0], alg.objectSelection, extraSel)
401 alg.sign = self.check_sign(items[2])
402 alg.count = self.check_int(items[3])
403 elif len(items) == 5:
404 extraSel = self.check_string(items[1])
405 btagger, btagWP = self.check_btagging(items[2])
406 customBtag = f'ftag_select_{btagger}_{btagWP}'
407 alg.objectSelection = f'{selection}&&{customBtag},as_char' if selection else f'{customBtag},as_char'
408 alg.objectSelection = self.extendObjectSelection(config, self.jets.split(".")[0], alg.objectSelection, extraSel)
409 alg.sign = self.check_sign(items[3])
410 alg.count = self.check_int(items[4])
411 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
412 return
413
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

◆ add_NJETGHOST_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NJETGHOST_selector ( self,
text,
config )

Definition at line 523 of file EventSelectionConfig.py.

523 def add_NJETGHOST_selector(self, text, config):
524 items = text.split()
525 self._check_args(items, "JET_N_GHOST", (4, 5))
526 thisalg = f'{self.selectionName}_NJETGHOST_{self.step}'
527 alg = config.createAlgorithm('CP::JetNGhostSelectorAlg', thisalg)
528 alg.jets, alg.jetSelection = config.readNameAndSelection(self.jets)
529 ghosts = self.check_ghosts(items[1])
530 alg.ghost = ghosts[0]
531 if len(ghosts) > 1 :
532 alg.veto = ghosts[1]
533 if len(items) == 4:
534 alg.sign = self.check_sign(items[2])
535 alg.count = self.check_int(items[3])
536 elif len(items) == 5:
537 alg.minPt = self.check_float(items[2])
538 alg.sign = self.check_sign(items[3])
539 alg.count = self.check_int(items[4])
540 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
541 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
542 return
543

◆ add_NLJETGHOST_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NLJETGHOST_selector ( self,
text,
config )

Definition at line 544 of file EventSelectionConfig.py.

544 def add_NLJETGHOST_selector(self, text, config):
545 items = text.split()
546 self._check_args(items, "LJET_N_GHOST", (4, 5))
547 thisalg = f'{self.selectionName}_NLJETGHOST_{self.step}'
548 alg = config.createAlgorithm('CP::JetNGhostSelectorAlg', thisalg)
549 alg.jets, alg.jetSelection = config.readNameAndSelection(self.largeRjets)
550 ghosts = self.check_ghosts(items[1])
551 alg.ghost = ghosts[0]
552 if len(ghosts) > 1 :
553 alg.veto = ghosts[1]
554 if len(items) == 4:
555 alg.sign = self.check_sign(items[2])
556 alg.count = self.check_int(items[3])
557 elif len(items) == 5:
558 alg.minPt = self.check_float(items[2])
559 alg.sign = self.check_sign(items[3])
560 alg.count = self.check_int(items[4])
561 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
562 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
563 return
564

◆ add_NLJETMASS_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NLJETMASS_selector ( self,
text,
config )

Definition at line 486 of file EventSelectionConfig.py.

486 def add_NLJETMASS_selector(self, text, config):
487 items = text.split()
488 self._check_args(items, "LJETMASS_N", (4, 5))
489 thisalg = f'{self.selectionName}_NLJETMASS_{self.step}'
490 alg = config.createAlgorithm('CP::NObjectMassSelectorAlg', thisalg)
491 alg.particles, alg.objectSelection = config.readNameAndSelection(self.largeRjets)
492 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
493 alg.minMass, alg.sign, alg.count = self._val_sign_count(
494 items, config, alg, self.largeRjets.split(".")[0])
495 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
496 return
497

◆ add_NLJETMASSWINDOW_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NLJETMASSWINDOW_selector ( self,
text,
config )

Definition at line 498 of file EventSelectionConfig.py.

498 def add_NLJETMASSWINDOW_selector(self, text, config):
499 items = text.split()
500 self._check_args(items, "LJETMASSWINDOW_N", (5, 6, 7))
501 thisalg = f'{self.selectionName}_NLJETMASSWINDOW_{self.step}'
502 alg = config.createAlgorithm('CP::NLargeRJetMassWindowSelectorAlg', thisalg)
503 alg.ljets, alg.ljetSelection = config.readNameAndSelection(self.largeRjets)
504 vetoMode = items[-1] == 'veto' or items[-1] == 'VETO'
505 if len(items) == 5 or (len(items) == 6 and vetoMode):
506 alg.lowMass = self.check_float(items[1])
507 alg.highMass = self.check_float(items[2])
508 alg.sign = self.check_sign(items[3])
509 alg.count = self.check_int(items[4])
510 alg.vetoMode = vetoMode
511 elif (len(items) == 6 and not vetoMode) or len(items) == 7:
512 extraSel = self.check_string(items[1])
513 alg.ljetSelection = self.extendObjectSelection(config, self.largeRjets.split(".")[0], alg.ljetSelection, extraSel)
514 alg.lowMass = self.check_float(items[2])
515 alg.highMass = self.check_float(items[3])
516 alg.sign = self.check_sign(items[4])
517 alg.count = self.check_int(items[5])
518 alg.vetoMode = vetoMode
519 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
520 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
521 return
522

◆ add_NOBJ_selector()

python.EventSelectionConfig.EventSelectionConfig.add_NOBJ_selector ( self,
text,
config )

Definition at line 565 of file EventSelectionConfig.py.

565 def add_NOBJ_selector(self, text, config):
566 items = text.split()
567 self._check_args(items, "OBJ_N", (5,))
568 thisalg = f'{self.selectionName}_NOBJ_{self.step}'
569 alg = config.createAlgorithm('CP::NObjectPtSelectorAlg', thisalg)
570 alg.particles, alg.objectSelection = config.readNameAndSelection(self.check_string(items[1]))
571 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
572 alg.minPt = self.check_float(items[2])
573 alg.sign = self.check_sign(items[3])
574 alg.count = self.check_int(items[4])
575 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
576 return
577

◆ add_RUNNUMBER()

python.EventSelectionConfig.EventSelectionConfig.add_RUNNUMBER ( self,
text,
config )

Definition at line 735 of file EventSelectionConfig.py.

735 def add_RUNNUMBER(self, text, config):
736 items = text.split()
737 self._check_args(items, "RUN_NUMBER", (3,))
738 thisalg = f'{self.selectionName}_RUN_NUMBER_{self.step}'
739 alg = config.createAlgorithm('CP::RunNumberSelectorAlg', thisalg)
740 alg.sign = self.check_sign(items[1])
741 alg.runNumber = self.check_int(items[2])
742 alg.useRandomRunNumber = config.dataType() is not DataType.Data
743 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
744 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
745 return
746

◆ add_SAVE()

python.EventSelectionConfig.EventSelectionConfig.add_SAVE ( self,
text,
config )

Definition at line 946 of file EventSelectionConfig.py.

946 def add_SAVE(self, text, config):
947 # SAVE is deprecated: the event filter is now emitted automatically at
948 # the end of the block (see makeAlgs). The keyword is accepted only to
949 # warn existing configs; it performs no operation itself.
950 items = text.split()
951 self._check_args(items, "SAVE", (1,))
952 warnings.warn(
953 "[EventSelectionConfig] The 'SAVE' keyword is deprecated: the event "
954 "filter is now created automatically at the end of each EventSelection "
955 f"block. Please remove the 'SAVE' line from selection '{self.selectionName}'.",
956 category=ConfigDeprecationWarning, stacklevel=2)
957 return
958

◆ add_SUMNELNMU_selector()

python.EventSelectionConfig.EventSelectionConfig.add_SUMNELNMU_selector ( self,
text,
config )

Definition at line 414 of file EventSelectionConfig.py.

414 def add_SUMNELNMU_selector(self, text, config):
415 items = text.split()
416 self._check_args(items, "SUM_EL_N_MU_N", (4, 5, 7))
417 if not self.electrons and not self.muons:
418 self.raise_missinginput("electrons or muons")
419 thisalg = f'{self.selectionName}_SUMNELNMU_{self.step}'
420 alg = config.createAlgorithm('CP::SumNLeptonPtSelectorAlg', thisalg)
421 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
422 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
423 self._maybe_dressed(alg, self.electrons, self.muons)
424 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
425 if len(items) == 4:
426 alg.minPtEl = self.check_float(items[1])
427 alg.minPtMu = self.check_float(items[1])
428 alg.sign = self.check_sign(items[2])
429 alg.count = self.check_int(items[3])
430 elif len(items) == 5:
431 alg.minPtEl = self.check_float(items[1])
432 alg.minPtMu = self.check_float(items[2])
433 alg.sign = self.check_sign(items[3])
434 alg.count = self.check_int(items[4])
435 elif len(items) == 7:
436 extraSelEl = self.check_string(items[1])
437 extraSelMu = self.check_string(items[2])
438 alg.electronSelection = self.extendObjectSelection(config, self.electrons.split(".")[0], alg.electronSelection, extraSelEl)
439 alg.muonSelection = self.extendObjectSelection(config, self.muons.split(".")[0], alg.muonSelection, extraSelMu)
440 alg.minPtEl = self.check_float(items[3])
441 alg.minPtMu = self.check_float(items[4])
442 alg.sign = self.check_sign(items[5])
443 alg.count = self.check_int(items[6])
444 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
445 return
446

◆ add_SUMNLEPTONS_selector()

python.EventSelectionConfig.EventSelectionConfig.add_SUMNLEPTONS_selector ( self,
text,
config )

Definition at line 447 of file EventSelectionConfig.py.

447 def add_SUMNLEPTONS_selector(self, text, config):
448 items = text.split()
449 self._check_args(items, "SUM_EL_N_MU_N_TAU_N", (4, 6, 9))
450 if not self.electrons and not self.muons and not self.taus:
451 self.raise_missinginput("electrons, muons or taus")
452 thisalg = f'{self.selectionName}_SUMNLEPTONS_{self.step}'
453 alg = config.createAlgorithm('CP::SumNLeptonPtSelectorAlg', thisalg)
454 alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons)
455 alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons)
456 alg.taus, alg.tauSelection = config.readNameAndSelection(self.taus)
457 self._maybe_dressed(alg, self.electrons, self.muons)
458 alg.eventPreselection = self.checkDecorationName(self.currentDecoration)
459 if len(items) == 4:
460 alg.minPtEl = self.check_float(items[1])
461 alg.minPtMu = self.check_float(items[1])
462 alg.minPtTau = self.check_float(items[1])
463 alg.sign = self.check_sign(items[2])
464 alg.count = self.check_int(items[3])
465 elif len(items) == 6:
466 alg.minPtEl = self.check_float(items[1])
467 alg.minPtMu = self.check_float(items[2])
468 alg.minPtTau = self.check_float(items[3])
469 alg.sign = self.check_sign(items[4])
470 alg.count = self.check_int(items[5])
471 elif len(items) == 9:
472 extraSelEl = self.check_string(items[1])
473 extraSelMu = self.check_string(items[2])
474 extraSelTau = self.check_string(items[3])
475 alg.electronSelection = self.extendObjectSelection(config, self.electrons.split(".")[0], alg.electronSelection, extraSelEl)
476 alg.muonSelection = self.extendObjectSelection(config, self.muons.split(".")[0], alg.muonSelection, extraSelMu)
477 alg.tauSelection = self.extendObjectSelection(config, self.taus.split(".")[0], alg.tauSelection, extraSelTau)
478 alg.minPtEl = self.check_float(items[4])
479 alg.minPtMu = self.check_float(items[5])
480 alg.minPtTau = self.check_float(items[6])
481 alg.sign = self.check_sign(items[7])
482 alg.count = self.check_int(items[8])
483 self.setDecorationName(alg, config, f'{thisalg}_%SYS%')
484 return
485

◆ check_btagging()

python.EventSelectionConfig.EventSelectionConfig.check_btagging ( self,
test )

Definition at line 250 of file EventSelectionConfig.py.

250 def check_btagging(self, test):
251 test = test.split(":")
252 if len(test) != 2:
253 raise ValueError (f"[EventSelectionConfig] Misconfiguration! {test} should be provided as 'btagger:btagWP'")
254 else:
255 return test
256

◆ check_float()

python.EventSelectionConfig.EventSelectionConfig.check_float ( self,
test,
requirePositive = True )

Definition at line 208 of file EventSelectionConfig.py.

208 def check_float(self, test, requirePositive=True):
209 try:
210 value = float(test)
211 if not requirePositive or value >= 0:
212 return value
213 else:
214 raise ValueError (f"[EventSelectionConfig] Misconfiguration! Float {test} is not positive!")
215 except ValueError:
216 raise ValueError (f"[EventSelectionConfig] Misconfiguration! {test} should be a float, not {type(test)}!")
217

◆ check_ghosts()

python.EventSelectionConfig.EventSelectionConfig.check_ghosts ( self,
test )

Definition at line 257 of file EventSelectionConfig.py.

257 def check_ghosts(self, test):
258 test = self.check_string(test)
259 values = test.split("!")
260 ghost_map = {
261 "B": "GhostBHadronsFinalCount",
262 "C": "GhostCHadronsFinalCount",
263 "T": "GhostTQuarksFinalCount",
264 "W": "GhostWBosonsCount",
265 "Z": "GhostZBosonsCount",
266 "H": "GhostHBosonsCount",
267 "TAU": "GhostTausFinalCount"
268 }
269 return [ghost_map.get(value.upper(), value) for value in values]
270

◆ check_int()

python.EventSelectionConfig.EventSelectionConfig.check_int ( self,
test,
requirePositive = True )

Definition at line 218 of file EventSelectionConfig.py.

218 def check_int(self, test, requirePositive=True):
219 try:
220 value = int(test)
221 if value == float(test):
222 if not requirePositive or value >= 0:
223 return value
224 else:
225 raise ValueError (f"[EventSelectionConfig] Misconfiguration! Int {test} us not positive!")
226 else:
227 raise ValueError (f"[EventSelectionConfig] Misconfiguration! {test} should be an int, not a float!")
228 except ValueError:
229 raise ValueError (f"[EventSelectionConfig] Misconfiguration! {test} should be an int, not {type(test)}")
230

◆ check_sign()

python.EventSelectionConfig.EventSelectionConfig.check_sign ( self,
test )

Definition at line 237 of file EventSelectionConfig.py.

237 def check_sign(self, test):
238 mapping = {
239 "<" : "LT",
240 ">" : "GT",
241 "==": "EQ",
242 ">=": "GE",
243 "<=": "LE"
244 }
245 try:
246 return mapping[test]
247 except KeyError:
248 raise KeyError (f"[EventSelectionConfig] Misconfiguration! {test} should be one of {list(mapping.keys())}")
249

◆ check_string()

python.EventSelectionConfig.EventSelectionConfig.check_string ( self,
test )

Definition at line 231 of file EventSelectionConfig.py.

231 def check_string(self, test):
232 if not isinstance(test, str):
233 raise ValueError (f"[EventSelectionConfig] Misconfiguration! {test} should be a string, not a number!")
234 else:
235 return test
236

◆ checkDecorationName()

python.EventSelectionConfig.EventSelectionConfig.checkDecorationName ( self,
decoration )

Definition at line 293 of file EventSelectionConfig.py.

293 def checkDecorationName(self, decoration):
294 if decoration == '':
295 return decoration
296 decoration = decoration.split("&&")
297 decoration = [sub + ',as_char' if ',as_char' not in sub else sub for sub in decoration]
298 return '&&'.join(decoration)
299

◆ extendObjectSelection()

python.EventSelectionConfig.EventSelectionConfig.extendObjectSelection ( self,
config,
container,
oldSelection,
newSelection )

Definition at line 300 of file EventSelectionConfig.py.

300 def extendObjectSelection(self, config, container, oldSelection, newSelection):
301 if oldSelection:
302 return oldSelection + "&&" + config.getFullSelection(container, newSelection)
303 else:
304 return config.getFullSelection(container, newSelection)
305

◆ getCutflow()

python.EventSelectionConfig.EventSelectionConfig.getCutflow ( self)

Definition at line 275 of file EventSelectionConfig.py.

275 def getCutflow(self):
276 return self.cutflow
277

◆ instanceName()

python.EventSelectionConfig.EventSelectionConfig.instanceName ( self)
Return the instance name for this block

Definition at line 123 of file EventSelectionConfig.py.

123 def instanceName (self) :
124 """Return the instance name for this block"""
125 return self.selectionName
126

◆ interpret()

python.EventSelectionConfig.EventSelectionConfig.interpret ( self,
text,
cfg )

Definition at line 180 of file EventSelectionConfig.py.

180 def interpret(self, text, cfg):
181 text = text.strip()
182 if not text or text.startswith("#"):
183 return
184 self.step += 1
185 keyword = text.split()[0]
186 handler = self._dispatch.get(keyword)
187 if handler is None:
188 raise ValueError (f"[EventSelectionConfig] The following selection cut is not recognised! --> {text}")
189 handler(text, cfg)
190
void handler(int sig)
signal handler
Definition rmain.cxx:99

◆ makeAlgs()

python.EventSelectionConfig.EventSelectionConfig.makeAlgs ( self,
config )

Definition at line 158 of file EventSelectionConfig.py.

158 def makeAlgs(self, config):
159 existing = config.getContainerMeta('EventInfo', 'eventSelectionNames', defaultValue=[])
160 config.setContainerMeta('EventInfo', 'eventSelectionNames',
161 existing + [f'pass_{self.selectionName}_%SYS%'], allowOverwrite=True)
162
163 # need to re-initialize here to deal with multiple passes
164 self.step = 0
165 # initialize the pre-selection
166 self.currentDecoration = self.preselection
167 # re-initialize the cutflow
168 self.cutflow = []
169 # read the selection cuts
170 if self.selectionCuts is None:
171 raise ValueError ("[EventSelectionConfig] You must provide the 'selectionCuts' option to 'EventSelectionConfig': "
172 "a single string where each line represents a different selection cut to apply in order.")
173 for line in self.selectionCuts.split("\n"):
174 self.interpret(line, config)
175 # the event filter is always created automatically at the end of the
176 # block; an explicit SAVE line only triggers a deprecation warning
177 self._emit_save(config)
178 config.addEventCutFlow(self.selectionName, self.getCutflow())
179

◆ raise_misconfig()

python.EventSelectionConfig.EventSelectionConfig.raise_misconfig ( self,
text,
keyword )

Definition at line 195 of file EventSelectionConfig.py.

195 def raise_misconfig(self, text, keyword):
196 raise ValueError (f"[EventSelectionConfig] Misconfiguration! Check {keyword} in: {text}")
197

◆ raise_missinginput()

python.EventSelectionConfig.EventSelectionConfig.raise_missinginput ( self,
collection )

Definition at line 198 of file EventSelectionConfig.py.

198 def raise_missinginput(self, collection):
199 raise ValueError (f"[EventSelectionConfig] Misconfiguration! Missing input collection for {collection}")
200

◆ setDecorationName()

python.EventSelectionConfig.EventSelectionConfig.setDecorationName ( self,
algorithm,
config,
decoration )

Definition at line 278 of file EventSelectionConfig.py.

278 def setDecorationName(self, algorithm, config, decoration):
279 self.cutflow.append( decoration )
280 if algorithm is not None:
281 algorithm.decorationName = f'{decoration},as_char'
282 self.currentDecoration = decoration
283 if self.debugMode:
284 config.addOutputVar('EventInfo', decoration, decoration.split("_%SYS%")[0])
285 else:
286 if self.currentDecoration:
287 self.currentDecoration += '&&' + decoration
288 else:
289 self.currentDecoration = decoration
290 config.addSelection('EventInfo', '', decoration)
291 return
292

Member Data Documentation

◆ _dispatch

python.EventSelectionConfig.EventSelectionConfig._dispatch = self._build_dispatch()
protected

Definition at line 121 of file EventSelectionConfig.py.

◆ _EXPR_COLL

dict python.EventSelectionConfig.EventSelectionConfig._EXPR_COLL
staticprotected
Initial value:
= {
"jet": ("jets", False, False),
"bjet": ("jets", True, False),
"el": ("electrons", False, False),
"mu": ("muons", False, False),
"tau": ("taus", False, False),
"ph": ("photons", False, False),
"ljet": ("largeRjets", False, False),
"met": ("met", False, True),
}

Definition at line 752 of file EventSelectionConfig.py.

◆ _EXPR_TOKEN_RE

python.EventSelectionConfig.EventSelectionConfig._EXPR_TOKEN_RE = re.compile(, re.VERBOSE)
staticprotected

Definition at line 776 of file EventSelectionConfig.py.

◆ _EXPR_VARS

dict python.EventSelectionConfig.EventSelectionConfig._EXPR_VARS
staticprotected
Initial value:
= {
"dR": (2, 2, ",", True, False),
"dEta": (2, 2, ",", True, False),
"dPhi": (2, 2, ",", False, True),
"m": (1, None, "+", False, False),
"e": (1, None, "+", False, False),
"pt": (1, None, "+", False, True),
"eta": (1, 1, None, True, False),
"phi": (1, 1, None, False, True),
}

Definition at line 765 of file EventSelectionConfig.py.

◆ _exprPos

int python.EventSelectionConfig.EventSelectionConfig._exprPos = 0
protected

Definition at line 816 of file EventSelectionConfig.py.

◆ _exprTokens

python.EventSelectionConfig.EventSelectionConfig._exprTokens = tokens
protected

Definition at line 815 of file EventSelectionConfig.py.

◆ _NOBJECT

dict python.EventSelectionConfig.EventSelectionConfig._NOBJECT
staticprotected
Initial value:
= {
"EL_N": ("electrons", "NEL"),
"MU_N": ("muons", "NMU"),
"JET_N": ("jets", "NJET"),
"PH_N": ("photons", "NPH"),
"TAU_N": ("taus", "NTAU"),
"LJET_N": ("largeRjets", "NLJET"),
}

Definition at line 64 of file EventSelectionConfig.py.

◆ btagDecoration

python.EventSelectionConfig.EventSelectionConfig.btagDecoration

Definition at line 925 of file EventSelectionConfig.py.

◆ currentDecoration

str python.EventSelectionConfig.EventSelectionConfig.currentDecoration = ''

Definition at line 119 of file EventSelectionConfig.py.

◆ cutflow

list python.EventSelectionConfig.EventSelectionConfig.cutflow = []

Definition at line 120 of file EventSelectionConfig.py.

◆ debugMode

python.EventSelectionConfig.EventSelectionConfig.debugMode

Definition at line 283 of file EventSelectionConfig.py.

◆ electrons

python.EventSelectionConfig.EventSelectionConfig.electrons

Definition at line 423 of file EventSelectionConfig.py.

◆ jets

python.EventSelectionConfig.EventSelectionConfig.jets

Definition at line 382 of file EventSelectionConfig.py.

◆ met

python.EventSelectionConfig.EventSelectionConfig.met

Definition at line 581 of file EventSelectionConfig.py.

◆ muons

python.EventSelectionConfig.EventSelectionConfig.muons

Definition at line 417 of file EventSelectionConfig.py.

◆ selectionName

python.EventSelectionConfig.EventSelectionConfig.selectionName

Definition at line 178 of file EventSelectionConfig.py.

◆ step

int python.EventSelectionConfig.EventSelectionConfig.step = 0

Definition at line 118 of file EventSelectionConfig.py.

◆ taus

python.EventSelectionConfig.EventSelectionConfig.taus

Definition at line 450 of file EventSelectionConfig.py.


The documentation for this class was generated from the following file: