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 129 of file TriggerInfo.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 139 of file TriggerInfo.py.

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

Member Function Documentation

◆ __eq__()

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

Definition at line 202 of file TriggerInfo.py.

202  def __eq__(self,other):
203  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)
204 

◆ __hash__()

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

Definition at line 205 of file TriggerInfo.py.

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

◆ __repr__()

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

Definition at line 208 of file TriggerInfo.py.

208  def __repr__(self):
209  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))
210 

◆ 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 238 of file TriggerInfo.py.

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

◆ compareTags()

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

Definition at line 300 of file TriggerInfo.py.

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

◆ 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 211 of file TriggerInfo.py.

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

◆ parse_legs()

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

Definition at line 358 of file TriggerInfo.py.

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

Member Data Documentation

◆ afppattern

python.TriggerAPI.TriggerInfo.TriggerLeg.afppattern
static

Definition at line 137 of file TriggerInfo.py.

◆ bjetpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.bjetpattern
static

Definition at line 134 of file TriggerInfo.py.

◆ bphyspattern

python.TriggerAPI.TriggerInfo.TriggerLeg.bphyspattern
static

Definition at line 135 of file TriggerInfo.py.

◆ count

python.TriggerAPI.TriggerInfo.TriggerLeg.count

Definition at line 150 of file TriggerInfo.py.

◆ detailpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.detailpattern
static

Definition at line 133 of file TriggerInfo.py.

◆ details

python.TriggerAPI.TriggerInfo.TriggerLeg.details

Definition at line 200 of file TriggerInfo.py.

◆ exoticspattern

python.TriggerAPI.TriggerInfo.TriggerLeg.exoticspattern
static

Definition at line 136 of file TriggerInfo.py.

◆ l1seed

python.TriggerAPI.TriggerInfo.TriggerLeg.l1seed

Definition at line 141 of file TriggerInfo.py.

◆ legname

python.TriggerAPI.TriggerInfo.TriggerLeg.legname

Definition at line 140 of file TriggerInfo.py.

◆ legpattern

python.TriggerAPI.TriggerInfo.TriggerLeg.legpattern
static

Definition at line 132 of file TriggerInfo.py.

◆ legtype

python.TriggerAPI.TriggerInfo.TriggerLeg.legtype

Definition at line 153 of file TriggerInfo.py.

◆ thr

python.TriggerAPI.TriggerInfo.TriggerLeg.thr

Definition at line 151 of file TriggerInfo.py.

◆ types

python.TriggerAPI.TriggerInfo.TriggerLeg.types
static

Definition at line 130 of file TriggerInfo.py.

◆ uctTypes

python.TriggerAPI.TriggerInfo.TriggerLeg.uctTypes
static

Definition at line 131 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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
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
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
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
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
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