ATLAS Offline Software
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
python.TriggerAPI.TriggerInfo.TriggerLeg Class Reference
Collaboration diagram for python.TriggerAPI.TriggerInfo.TriggerLeg:

Public Member Functions

def __init__ (self, legname, chainseed, chainname=None)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __repr__ (self)
 
def isLegLowerThan (self, other, is2015, debug=False)
 
def compareDetails (self, other, is2015, debug=False)
 
def compareTags (self, tag1, tag2, stringSubset=False, debug=False)
 
def parse_legs (cls, name, l1seed, chainname)
 

Public Attributes

 legname
 
 l1seed
 
 count
 
 thr
 
 legtype
 
 details
 

Static Public Attributes

 types
 
 uctTypes
 
 legpattern
 
 detailpattern
 
 bjetpattern
 
 bphyspattern
 
 exoticspattern
 
 afppattern
 

Detailed Description

Definition at line 128 of file TriggerInfo.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TriggerAPI.TriggerInfo.TriggerLeg.__init__ (   self,
  legname,
  chainseed,
  chainname = None 
)

Definition at line 138 of file TriggerInfo.py.

138  def __init__(self,legname, chainseed, chainname=None):
139  self.legname = legname
140  self.l1seed = ""
141  details = []
142  chainseed= chainseed.replace("L1_","")
143  blocks = legname.split("_L1")
144 
145  for token in blocks[0].split("_"):
146  m = self.legpattern.match(token)
147  if m:
148  count,legtype,thr,noL1 = m.groups()
149  self.count = int(count) if count else 1
150  self.thr = int(thr)
151  if legtype == 'e':
152  if self.count > 1: self.legtype = TriggerType.el_multi
153  else: self.legtype = TriggerType.el_single
154  elif legtype == 'mu':
155  if self.count > 1: self.legtype = TriggerType.mu_multi
156  else: self.legtype = TriggerType.mu_single
157  elif legtype == 'j':
158  if self.count > 1: self.legtype = TriggerType.j_multi
159  else: self.legtype = TriggerType.j_single
160  elif legtype == 'tau':
161  if self.count > 1: self.legtype = TriggerType.tau_multi
162  else: self.legtype = TriggerType.tau_single
163  elif legtype == 'g':
164  if self.count > 1: self.legtype = TriggerType.g_multi
165  else: self.legtype = TriggerType.g_single
166  elif legtype == 'xe':
167  self.legtype = TriggerType.xe
168  elif legtype == 'ht':
169  self.legtype = TriggerType.ht
170  elif legtype in self.uctTypes:
171  self.legtype = TriggerType.exotics
172  # all these leg types are actually distinct, so include legtype in the detail list too
173  details.append(legtype)
174  else:
175  log.info("Unknown trigger type: %s",legtype)
176  if noL1: details.append(noL1)
177  else:
178  if self.bjetpattern.match(token):
179  if self.legtype == TriggerType.j_single: self.legtype = TriggerType.bj_single
180  if self.legtype == TriggerType.j_multi: self.legtype = TriggerType.bj_multi
181  if self.bphyspattern.match(token):
182  self.legtype = TriggerType.mu_bphys
183  if self.exoticspattern.search(token):
184  self.legtype = TriggerType.exotics
185  if self.afppattern.search(token):
186  self.legtype = TriggerType.afp
187  details.append(token)
188 
189  for l1seed in blocks[1:]:
190  if self.exoticspattern.search(l1seed):
191  self.legtype = TriggerType.exotics
192  if self.afppattern.search(l1seed):
193  self.legtype = TriggerType.afp
194  if l1seed == chainseed: continue
195  else:
196  assert self.l1seed=="", (self.l1seed, chainseed, chainname, blocks[1:])
197  self.l1seed = l1seed
198  if not self.l1seed: self.l1seed = chainseed
199  self.details = tuple(details)
200 

Member Function Documentation

◆ __eq__()

def python.TriggerAPI.TriggerInfo.TriggerLeg.__eq__ (   self,
  other 
)

Definition at line 201 of file TriggerInfo.py.

201  def __eq__(self,other):
202  return (self.l1seed == other.l1seed and self.count == other.count and self.thr == other.thr and self.legtype == other.legtype and self.details == other.details)
203 

◆ __hash__()

def python.TriggerAPI.TriggerInfo.TriggerLeg.__hash__ (   self)

Definition at line 204 of file TriggerInfo.py.

204  def __hash__(self):
205  return hash((self.l1seed,self.count,self.thr,self.legtype,self.details))
206 

◆ __repr__()

def python.TriggerAPI.TriggerInfo.TriggerLeg.__repr__ (   self)

Definition at line 207 of file TriggerInfo.py.

207  def __repr__(self):
208  return "{0} l1seed={1} count={2} thr={3} details={4} legtype={5}".format(self.legname,self.l1seed,self.count,self.thr,self.details,TriggerType.toStr(self.legtype))
209 

◆ compareDetails()

def python.TriggerAPI.TriggerInfo.TriggerLeg.compareDetails (   self,
  other,
  is2015,
  debug = False 
)
Returns -9 if none of them is lower than the other (e.g. different met flavour).
    Returns -1 if identical
    Returns  0 if other is lower than self.
    Returns  1 if self  is lower than other.

Definition at line 237 of file TriggerInfo.py.

237  def compareDetails(self, other, is2015, debug=False):
238  ''' Returns -9 if none of them is lower than the other (e.g. different met flavour).
239  Returns -1 if identical
240  Returns 0 if other is lower than self.
241  Returns 1 if self is lower than other.
242  '''
243  from copy import deepcopy
244 
245  if debug: log.info(f"compareDetails: {len(self.details)} {len(other.details)} {(self.l1seed == other.l1seed)} {(self.details == other.details)}")
246  if len(self.details) != len(other.details):
247  if not is2015 and any([x.startswith("noL1") for x in self.details]):
248  cloneself = deepcopy(self)
249  cloneself.details = [ x for x in self.details if not x.startswith("noL1")]
250  compno = cloneself.compareDetails(other,is2015,debug)
251  if compno ==1 or compno == -1:
252  return 1
253  if not is2015 and any([x.startswith("noL1") for x in other.details]):
254  cloneother = deepcopy(other)
255  cloneother.details = [ x for x in other.details if not x.startswith("noL1")]
256  compno = self.compareDetails(cloneother,is2015,debug)
257  if compno ==0 or compno == -1:
258  return 0
259  if not is2015 and any([x.startswith("nod0") for x in self.details]):
260  cloneself = deepcopy(self)
261  cloneself.details = [ x for x in self.details if not x.startswith("nod0")]
262  compno = cloneself.compareDetails(other,is2015,debug)
263  if compno ==1 or compno == -1:
264  return 1
265  if not is2015 and any([x.startswith("nod0") for x in other.details]):
266  cloneother = deepcopy(other)
267  cloneother.details = [ x for x in other.details if not x.startswith("nod0")]
268  compno = self.compareDetails(cloneother,is2015,debug)
269  if compno ==0 or compno == -1:
270  return 0
271  if any([x.startswith("cut") for x in self.details]):
272  cloneself = deepcopy(self)
273  cloneself.details = [ x for x in self.details if not x.startswith("cut")]
274  compno = cloneself.compareDetails(other,is2015,debug)
275  if compno ==0 or compno == -1:
276  return 0
277  if any([x.startswith("cut") for x in other.details]):
278  cloneother = deepcopy(other)
279  cloneother.details = [ x for x in other.details if not x.startswith("cut")]
280  compno = self.compareDetails(cloneother,is2015,debug)
281  if compno ==1 or compno == -1:
282  return 1
283  return -9
284  compl1seed = self.compareTags(self.l1seed, other.l1seed, stringSubset=True, debug=debug)
285  compdetails = self.compareTags(" ".join(self.details), " ".join(other.details), debug=debug )
286  if self.l1seed == other.l1seed:
287  if self.details == other.details: return -1
288  if debug: log.info(f"compareTags 1: {compdetails}")
289  return compdetails
290 
291  if self.details == other.details:
292  if debug: log.info(f"compareTags 2: {compl1seed}")
293  return compl1seed
294 
295  if compl1seed == compdetails:
296  return compl1seed
297  return -9
298 

◆ compareTags()

def python.TriggerAPI.TriggerInfo.TriggerLeg.compareTags (   self,
  tag1,
  tag2,
  stringSubset = False,
  debug = False 
)

Definition at line 299 of file TriggerInfo.py.

299  def compareTags(self, tag1, tag2, stringSubset=False,debug=False):
300  def mycomp(x,y):
301  ''' Return -9 for different strings,
302  -1 for identical strings/nums,
303  0/1 for high/low numbers or string subsets
304  '''
305  try:
306  x,y = int(x), int(y)
307  if x < y: return 1
308  elif x > y: return 0
309  else: return -1
310  except ValueError:
311  if x==y: return -1
312  if x == y.replace("vloose","loose"): return 0
313  if x == y.replace("vloose","loose").replace("loose","medium"): return 0
314  if x == y.replace("vloose","loose").replace("loose","medium").replace("medium","tight"): return 0
315  if y == x.replace("vloose","loose"): return 1
316  if y == x.replace("vloose","loose").replace("loose","medium"): return 1
317  if y == x.replace("vloose","loose").replace("loose","medium").replace("medium","tight"): return 1
318  l1ThresholdLevels = ["L","M","T"]
319  if x in l1ThresholdLevels and y in l1ThresholdLevels:
320  if l1ThresholdLevels.index(x) > l1ThresholdLevels.index(y): return 0
321  return 1 # don't need to check for equality, that was done above
322  if stringSubset:
323  if x in y: return 1
324  if y in x: return 0
325  return -9
326 
327  if tag1 == tag2: return -1
328  #lower mv2 and deltaR/deltaZ/deltaPhi values are tighter, put a minus sign to trick it
329  inverseCuts = ("mv2c","dr","dz","dphi","dl1d","dl1r","gn1","gn2")
330  for cut in inverseCuts:
331  tag1 = tag1.replace(cut,cut+"-")
332  tag2 = tag2.replace(cut,cut+"-")
333  #only make a statement on the numerical values, with everything else identical
334  extra_inverseCuts = ("b","emf","bgtwo","gntau", "uht1tau") # all only appear in "presel" block
335  def findall(tag): # do the findall per tag block, so that can apply special rule to presel block only
336  out = []
337  for s in tag.split(" "):
338  l = self.detailpattern.findall(s)
339  if len(l) and l[0]=='presel':
340  for i,s in enumerate(l):
341  for cut in extra_inverseCuts:
342  if s==cut: l[i+1] = "-" + l[i+1] # adds a minus sign to the number that follows
343  out += l
344  return out
345  reself = findall(tag1)
346  reother = findall(tag2)
347 
348  if len(reself) != len(reother): return -9
349  thecomp = [mycomp(a,b) for a,b in zip(reself,reother)]
350  if debug: log.info(f"thecomp: {thecomp} {reself} {reother}")
351  if any([x == -9 for x in thecomp]): return -9
352  if all([x !=0 for x in thecomp]) and any([x == 1 for x in thecomp]): return 1
353  if all([x !=1 for x in thecomp]) and any([x == 0 for x in thecomp]): return 0
354  return -9
355 

◆ isLegLowerThan()

def python.TriggerAPI.TriggerInfo.TriggerLeg.isLegLowerThan (   self,
  other,
  is2015,
  debug = False 
)
Returns -9 if none of them is lower than the other (e.g. different met flavour).
    Returns -1 if identical
    Returns  0 if other is lower than self.
    Returns  1 if self  is lower than other.

Definition at line 210 of file TriggerInfo.py.

210  def isLegLowerThan(self, other, is2015, debug=False):
211  ''' Returns -9 if none of them is lower than the other (e.g. different met flavour).
212  Returns -1 if identical
213  Returns 0 if other is lower than self.
214  Returns 1 if self is lower than other.
215  '''
216  if debug:
217  log.info("DEBUG LEGS --------")
218  log.info(f"{self.legname} {other.legname}")
219  log.info(f"{self.legtype} {other.legtype}")
220  log.info(f"{self.l1seed} {other.l1seed}")
221  log.info(f"{self.details} {other.details}")
222  log.info(f"{self.thr} {other.thr}")
223  log.info(self.compareDetails(other, is2015, debug=True))
224  log.info(self.details == other.details)
225  log.info("DEBUG LEGS END --------")
226 
227  if self.legtype != other.legtype: return -9
228  if self.compareDetails(other, is2015) == -1:
229  if self.thr < other.thr: return 1
230  if self.thr > other.thr: return 0
231  else: return -1
232 
233  if self.compareDetails(other, is2015) == 1 and self.thr <= other.thr: return 1
234  if self.compareDetails(other, is2015) == 0 and other.thr <= self.thr: return 0
235  return -9
236 

◆ parse_legs()

def python.TriggerAPI.TriggerInfo.TriggerLeg.parse_legs (   cls,
  name,
  l1seed,
  chainname 
)

Definition at line 357 of file TriggerInfo.py.

357  def parse_legs(cls,name,l1seed,chainname):
358  legsname = []
359  name = name.replace("HLT_","")
360  for token in name.split("_"):
361  m = cls.legpattern.match(token)
362  if m:
363  legsname.append(token)
364  elif legsname:
365  legsname[-1] += "_"+token
366  else: #first token doesn't match
367  #log.info("parse_legs: Problem parsing",name)
368  return []
369  return [TriggerLeg(l,l1seed,chainname) for l in legsname]
370 

Member Data Documentation

◆ afppattern

python.TriggerAPI.TriggerInfo.TriggerLeg.afppattern
static

Definition at line 136 of file TriggerInfo.py.

◆ bjetpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.bjetpattern
static

Definition at line 133 of file TriggerInfo.py.

◆ bphyspattern

python.TriggerAPI.TriggerInfo.TriggerLeg.bphyspattern
static

Definition at line 134 of file TriggerInfo.py.

◆ count

python.TriggerAPI.TriggerInfo.TriggerLeg.count

Definition at line 149 of file TriggerInfo.py.

◆ detailpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.detailpattern
static

Definition at line 132 of file TriggerInfo.py.

◆ details

python.TriggerAPI.TriggerInfo.TriggerLeg.details

Definition at line 199 of file TriggerInfo.py.

◆ exoticspattern

python.TriggerAPI.TriggerInfo.TriggerLeg.exoticspattern
static

Definition at line 135 of file TriggerInfo.py.

◆ l1seed

python.TriggerAPI.TriggerInfo.TriggerLeg.l1seed

Definition at line 140 of file TriggerInfo.py.

◆ legname

python.TriggerAPI.TriggerInfo.TriggerLeg.legname

Definition at line 139 of file TriggerInfo.py.

◆ legpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.legpattern
static

Definition at line 131 of file TriggerInfo.py.

◆ legtype

python.TriggerAPI.TriggerInfo.TriggerLeg.legtype

Definition at line 152 of file TriggerInfo.py.

◆ thr

python.TriggerAPI.TriggerInfo.TriggerLeg.thr

Definition at line 150 of file TriggerInfo.py.

◆ types

python.TriggerAPI.TriggerInfo.TriggerLeg.types
static

Definition at line 129 of file TriggerInfo.py.

◆ uctTypes

python.TriggerAPI.TriggerInfo.TriggerLeg.uctTypes
static

Definition at line 130 of file TriggerInfo.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
vtune_athena.format
format
Definition: vtune_athena.py:14
search
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
Definition: hcg.cxx:738
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356