ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigJetHypoToolConfig Namespace Reference

Classes

class  TestStringMethods

Functions

 _find_momemfrac_cut (chain_dict)
 trigJetHypoToolFromDict (flags, chain_dict)
 trigJetTLAHypoToolFromDict (flags, chain_dict)
 trigJetEJsHypoToolFromDict (flags, chain_dict)
 trigJetCRVARHypoToolFromDict (flags, chain_dict)
 trigJetCRHypoToolFromDict (flags, chain_dict)

Variables

 logger = logging.getLogger(__name__)
str debug = 'JETHYPODEBUG' in os.environ

Function Documentation

◆ _find_momemfrac_cut()

python.TrigJetHypoToolConfig._find_momemfrac_cut ( chain_dict)
protected
Return momemfrac cut value as string from chain_dict, or None if not found.

Definition at line 19 of file TrigJetHypoToolConfig.py.

19def _find_momemfrac_cut(chain_dict):
20 """
21 Return momemfrac cut value as string from chain_dict, or None if not found.
22 """
23 parts = chain_dict.get("chainParts") or []
24
25 for idx, cp in enumerate(parts):
26 momcuts = (cp.get("momCuts") or "").strip()
27 if not momcuts:
28 continue
29
30 m = re.search(r"momemfrac(?P<cut>\d{3})(?!\d)", momcuts)
31 if not m:
32 continue
33
34 val = m.group("cut")
35
36 return val
37
38 return None
39

◆ trigJetCRHypoToolFromDict()

python.TrigJetHypoToolConfig.trigJetCRHypoToolFromDict ( flags,
chain_dict )

Definition at line 194 of file TrigJetHypoToolConfig.py.

194def trigJetCRHypoToolFromDict(flags, chain_dict):
195 chain_name = chain_dict['chainName']
196
197 doBIBrm = int(0)
198 if len(chain_dict['chainParts'][0]['exotHypo']) > 0:
199 exot_hypo = chain_dict['chainParts'][0]['exotHypo'][0]
200 else:
201 raise Exception("Unable to extract exotHypo calratio jet configuration from chain dict")
202 if 'calratio' in exot_hypo and ('calratiovar' not in exot_hypo):
203 if 'calratiormbib' in exot_hypo:
204 doBIBrm = int(1)
205 else:
206 raise Exception("misconfiguration of new calratio jet chain")
207
208 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
209
210
211 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
212 hypo.MinjetlogR = 1.2
213 import math
214 emf_cut = _find_momemfrac_cut(chain_dict)
215 if emf_cut is None:
216 pass
217 else:
218 try:
219 emf_val = int(emf_cut) / 100.0
220 except (TypeError, ValueError):
221 logger.warning(
222 "Invalid emf_cut '%s' for chain %s; using default MinjetlogR=%s",
223 emf_cut, chain_name, 1.2,
224 )
225 else:
226 if not (0.0 < emf_val < 1.0):
227 logger.warning(
228 "emf_cut '%s' -> %s out of (0,1) range for chain %s; using default MinjetlogR=%s",
229 emf_cut, emf_val, chain_name, 1.2,
230 )
231 else:
232 try:
233 hypo.MinjetlogR = math.log10(1.0 / emf_val - 1.0)
234 except (ValueError, OverflowError):
235 logger.warning(
236 "Computed MinjetlogR invalid for emf_cut='%s' (emf_val=%s) in chain %s; using default %s",
237 emf_cut, emf_val, chain_name, 1.2,
238 )
239
240 hypo.MintrackPt = 2*GeV
241 hypo.MindeltaR = 0.2
242 hypo.countBIBcells = 4
243 hypo.doBIBremoval = doBIBrm
244
245 return hypo
246

◆ trigJetCRVARHypoToolFromDict()

python.TrigJetHypoToolConfig.trigJetCRVARHypoToolFromDict ( flags,
chain_dict )

Definition at line 138 of file TrigJetHypoToolConfig.py.

138def trigJetCRVARHypoToolFromDict(flags, chain_dict):
139 chain_name = chain_dict['chainName']
140 doBIBrm = int(0)
141 doExoCal = int(0)
142 ExoCalCut = 220
143 if len(chain_dict['chainParts'][0]['exotHypo']) > 0:
144 exot_hypo = chain_dict['chainParts'][0]['exotHypo'][0]
145 calratioX_matched = re.match(r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict['chainParts'][0]['exotHypo'][0])
146 if calratioX_matched:
147 doExoCal= int(1)
148 ExoCalCut = calratioX_matched.groupdict()['cut']
149 else:
150 if len(chain_dict['chainParts'][1]['exotHypo']) > 0:
151 exot_hypo = chain_dict['chainParts'][1]['exotHypo'][0]
152 logger.warning(chain_dict)
153 calratioX_matched = re.match(r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict['chainParts'][1]['exotHypo'][0])
154 if calratioX_matched:
155 doExoCal= int(1)
156 ExoCalCut = calratioX_matched.groupdict()['cut']
157 else:
158 raise Exception("Unable to extract exotHypo calratio jet configuration from chain dict")
159 if 'calratiovar' in exot_hypo:
160 if 'calratiovarrmbib' in exot_hypo:
161 doBIBrm = int(1)
162 else:
163 raise Exception("misconfiguration of new calratio jet chain")
164
165 presel_matched = re.match(r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict['chainParts'][0]['trkpresel'])
166 if presel_matched:
167 emf_cut = presel_matched.groupdict()['cut']
168 elif len(chain_dict['chainParts'])>1:
169 presel_matched = re.match(r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict['chainParts'][1]['trkpresel'])
170 if presel_matched:
171 emf_cut = presel_matched.groupdict()['cut']
172 elif len(chain_dict['chainParts'])>3:
173 presel_matched = re.match(r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict['chainParts'][3]['trkpresel'])
174 if presel_matched:
175 emf_cut = presel_matched.groupdict()['cut']
176 else:
177 raise Exception("misconfiguration of Exotic jet chain")
178 else:
179 raise Exception("misconfiguration of Exotic jet chain")
180
181 import math
182 hypo = CompFactory.TrigJetCRVARHypoTool(chain_name)
183 hypo.MpufixLogRatio = math.log10(1./(float(emf_cut)*0.01) - 1.)
184 hypo.MinjetlogR = 1.2
185 if doExoCal:
186 hypo.MinjetlogR = (float(ExoCalCut)*0.01) - 1.
187 hypo.MintrackPt = 2*GeV
188 hypo.MindeltaR = 0.2
189 hypo.countBIBcells = 4
190 hypo.doBIBremoval = doBIBrm
191
192 return hypo
193

◆ trigJetEJsHypoToolFromDict()

python.TrigJetHypoToolConfig.trigJetEJsHypoToolFromDict ( flags,
chain_dict )

Definition at line 109 of file TrigJetHypoToolConfig.py.

109def trigJetEJsHypoToolFromDict(flags, chain_dict):
110 if len(chain_dict['chainParts']) > 1:
111 raise Exception("misconfiguration of emerging jet chain")
112
113 if len(chain_dict['chainParts'][0]['exotHypo']) > 0:
114 exot_hypo = chain_dict['chainParts'][0]['exotHypo'][0]
115 else:
116 raise Exception("Unable to extract exotHypo emerging jet configuration from chain dict")
117
118 if 'emerging' in exot_hypo:
119 trackless = int(0)
120 ptf = float(exot_hypo.split('PTF')[1].split('dR')[0].replace('p', '.'))
121 dr = float(exot_hypo.split('dR')[1].split('_')[0].replace('p', '.'))
122 elif 'trackless' in exot_hypo:
123 trackless = int(1)
124 ptf = 0.0
125 dr = float(exot_hypo.split('dR')[1].split('_')[0].replace('p', '.'))
126 else:
127 raise Exception("misconfiguration of emerging jet chain")
128
129 chain_name = chain_dict['chainName']
130
131 hypo = CompFactory.TrigJetEJsHypoTool(chain_name)
132 hypo.PTF = ptf
133 hypo.dR = dr
134 hypo.Trackless = trackless
135
136 return hypo
137
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ trigJetHypoToolFromDict()

python.TrigJetHypoToolConfig.trigJetHypoToolFromDict ( flags,
chain_dict )

Definition at line 40 of file TrigJetHypoToolConfig.py.

40def trigJetHypoToolFromDict(flags, chain_dict):
41
42 from DecisionHandling.TrigCompositeUtils import isLegId, getLegIndexInt
43 chain_name = chain_dict['chainName']
44 chain_mg = chain_dict['monGroups']
45 jet_signature_identifiers = ['Jet:Jet', 'Bjet:Bjet', 'Tau:Ditau']
46
47 if isLegId(chain_name):
48 # For multi-leg chains which include jet legs we have a -- SPECIAL BEHAVIOUR --
49 # We instantiate a HypoTool only for the *first* jet leg, whichever leg that happens to be in the chain
50 # This single HypoTool gets configured to perform the selection for _all_ of the jet legs, and to report
51 # the per-jet passing status for all of these legs.
52 #
53 # Here we determine if this is the 2nd+ jet leg of a multi-leg chain which has jet legs, and return no tool if it is
54
55 # Can we fetch this from elsewhere?
56
57 leg_id = getLegIndexInt(chain_name)
58 chain_sig_w_sub_sig = [f'{sig}:{subsig}' for sig, subsigs in chain_dict['sigDicts'].items() for subsig in subsigs]
59 # CHECK: If we have called trigJetHypoToolFromDict, then the chain_sig_w_sub_sig list must contain at minimum one entry from the jet_signature_identifiers list.
60 if not any(signature in chain_sig_w_sub_sig for signature in jet_signature_identifiers):
61 raise Exception("[trigJetHypoToolFromDict] No {} in {} for chain {}. Please update this list of jet signatures.".format(tuple(jet_signature_identifiers),tuple(chain_sig_w_sub_sig),chain_name))
62
63 # CHECK: All Jet and Bjet legs (i.e. signatures from jet_signature_identifiers) must be contiguous
64 # (this check is probable best put somewhere else?)
65 status = 0
66 for entry in chain_sig_w_sub_sig:
67 if status == 0 and entry in jet_signature_identifiers:
68 status = 1
69 elif status == 1 and entry not in jet_signature_identifiers:
70 status = 2
71 elif status == 2 and entry in jet_signature_identifiers:
72 raise Exception("[trigJetHypoToolFromDict] All {} legs should be contiguous in the signatures list, modify the ordering of the chain {}. Signatures:{}.".format(tuple(jet_signature_identifiers),chain_name, tuple(chain_sig_w_sub_sig)))
73
74 # CHECK: The leg_id must correspond to a Signature from jet_signature_identifiers. At the time of implementation, this is not guaranteed and can be affected by alignment.
75 # If this check fails for any chain, then we need to look again at how the legXXX ordering maps to the chain_sig_w_sub_sig ordering.
76 if not any(signature in chain_sig_w_sub_sig[leg_id] for signature in jet_signature_identifiers):
77 raise Exception("[trigJetHypoToolFromDict] For this code to work for chain {}, the signature at index {} must be one of {}. But the signature list is: {}".format(chain_name,leg_id,tuple(jet_signature_identifiers),tuple(chain_sig_w_sub_sig)))
78
79 # Locate the first index within chain_sig_w_sub_sig which contains an signature listed in jet_signature_identifiers
80 first_leg_index = 999
81 for signature in jet_signature_identifiers:
82 if signature in chain_sig_w_sub_sig:
83 first_leg_index = min(first_leg_index, chain_sig_w_sub_sig.index(signature))
84
85 if leg_id > first_leg_index:
86 logger.debug("Not returning a HypoTool for %s as this is not the first leg "
87 "with any of %s (leg signatures are %s)",
88 chain_name, tuple(jet_signature_identifiers), tuple(chain_sig_w_sub_sig))
89 raise NoHypoToolCreated("No HypoTool created for %s" % chain_name)
90
91 logger.debug("Returning a HypoTool for %s as this is the first leg with any of %s (leg signatures are %s)",
92 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict['signatures']))
93
94 hypo_tool = hypotool_from_chaindict(chain_dict, debug)
95
96 #if menu has chain in an online monitoring group, unpack the recoalg(s) and hyposcenario(s) to configure monitoring
97 if any('jetMon:online' in group for group in chain_mg):
98 cpl = chain_dict["chainParts"]
99 histFlags = []
100 for cp in cpl:
101 histFlags += [ cp['recoAlg'] ] + [ cp['hypoScenario']]
102 hypo_tool.MonTool = TrigJetHypoToolMonitoring(flags, "HLTJetHypo/"+chain_name, histFlags)
103 return hypo_tool
104
105
bool isLegId(const HLT::Identifier &legIdentifier)
Recognise whether the chain ID is a leg ID.
#define min(a, b)
Definition cfImp.cxx:40

◆ trigJetTLAHypoToolFromDict()

python.TrigJetHypoToolConfig.trigJetTLAHypoToolFromDict ( flags,
chain_dict )

Definition at line 106 of file TrigJetHypoToolConfig.py.

106def trigJetTLAHypoToolFromDict(flags, chain_dict):
107 return CompFactory.TrigJetTLAHypoTool(chain_dict['chainName'])
108

Variable Documentation

◆ debug

str python.TrigJetHypoToolConfig.debug = 'JETHYPODEBUG' in os.environ

Definition at line 14 of file TrigJetHypoToolConfig.py.

◆ logger

python.TrigJetHypoToolConfig.logger = logging.getLogger(__name__)

Definition at line 10 of file TrigJetHypoToolConfig.py.