ATLAS Offline Software
prefilter_mask.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from TrigHLTJetHypo.RepeatedConditionParams import RepeatedConditionParams
4 from TrigHLTJetHypo.ConditionDefaults import defaults
5 from TrigHLTJetHypo.make_repeatedCondConfigurer import make_repeatedCondCfgFromParams
6 from TrigHLTJetHypo.FastReductionAlgToolFactory import toolfactory
7 
8 import re
9 
10 pattern = r'^MASK'\
11  r'(?P<etalo>\d*)(?P<etatype>neta|ceta|peta>)(?P<etahi>\d*)XX'\
12  r'(?P<philo>\d*)(?P<phitype>nphi|cphi|pphi>)(?P<phihi>\d*)$'
13 
14 rgx = re.compile(pattern)
15 
16 
17 def prefilter_mask(pf_string):
18  """calculate the parameters needed to generate a ConditonFilter config
19  AlgTool starting from the prefilter substring if it appears in the
20  chain dict"""
21 
22  assert pf_string.startswith('MASK'),\
23  'routing error, module %s: bad prefilter %s' % (__name__, pf_string)
24 
25  m = rgx.match(pf_string)
26  groupdict = m.groupdict()
27 
28  etatype = groupdict['etatype']
29  etalo = groupdict['etalo']
30  etahi = groupdict['etahi']
31  if etatype in ('neta', 'ceta'):
32  etalo = '-'+ etalo
33  if etatype == 'neta':
34  etahi = '-' + etahi
35 
36 
37  phitype = groupdict['phitype']
38  philo = groupdict['philo']
39  phihi = groupdict['phihi']
40  if phitype in ('nphi', 'cphi'):
41  philo = '-'+ philo
42  if phitype == 'nphi':
43  phihi = '-' + phihi
44 
45  condargs = []
46 
47  vals = defaults(etatype, lo=etalo, hi=etahi)
48  condargs.append((etatype, vals))
49 
50  vals = defaults(phitype, lo=philo, hi=phihi)
51  condargs.append((phitype, vals))
52 
53  repcondarg = RepeatedConditionParams(tree_id=0,
54  tree_pid=0,
55  chainPartInd=-1,
56  condargs=condargs,
57  invert=True)
58 
59  repConditionMaker = make_repeatedCondCfgFromParams(repcondarg)
60 
61 
62  toolclass, name = toolfactory('ConditionFilterConfigTool')
63  vals = {'name' : name,
64  'conditionMakers': [repConditionMaker]}
65 
66  return toolclass(**vals)
67 
python.prefilter_mask.prefilter_mask
def prefilter_mask(pf_string)
Definition: prefilter_mask.py:17
Base_Fragment.defaults
dictionary defaults
This includes now the top quark, the leptons and the bosons.
Definition: GeneratorFilters/share/common/Base_Fragment.py:79
python.make_repeatedCondConfigurer.make_repeatedCondCfgFromParams
def make_repeatedCondCfgFromParams(repcondarg)
Definition: make_repeatedCondConfigurer.py:44
python.FastReductionAlgToolFactory.toolfactory
toolfactory
Definition: FastReductionAlgToolFactory.py:106