ATLAS Offline Software
TIDAChains.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 # access the list of configured chains and expand the analysis chains
4 # to be actual configued entries
5 
6 
7 # get the list of configured chains matching the regex
8 # input parameter
9 
10 import re
11 
12 
13 # get a chain configuration of the form "some_regex:key=Track:vtx=Vertex" etc
14 # parse to determine the trigger chain pattern, determine the chains
15 # matching the pattern, then recreate the full analysis string using all the
16 # matched chains - can take an individual analysis pattern, or a list of them
17 
18 def getchains( flags, analyses, monlevel=None ):
19 
20  if isinstance( analyses, list ):
21  a = analyses
22  else:
23  a = [ analyses ]
24 
25  chains = []
26 
27  for analysis in a:
28  if ":" in analysis:
29 
30  parts = analysis.split( ":", 1 )
31  cchains = getconfiguredchains( flags, parts[0], monlevel )
32 
33  for c in cchains:
34  if parts[1] is not None:
35  chain = c + ":" + parts[1]
36  else:
37  chain = c
38 
39  if chain not in chains:
40  chains.append( chain )
41 
42  return chains
43 
44 
45 
46 
47 def getconfiguredchains( flags, regex, monlevel=None ):
48  if monlevel is None:
49  return _getconfiguredchains( flags, regex )
50  else:
51  return _getmonchains( flags, regex, monlevel )
52 
53 
54 
55 # cached full chain list
56 
57 _chains = None
58 
59 def _getconfiguredchains( flags, regex ):
60 
61  global _chains
62 
63  if _chains is None :
64 # from datetime import datetime
65 # print( datetime.now(), "getting trigger configuration" )
66 
67  from TrigConfigSvc.TriggerConfigAccess import getHLTMenuAccess
68 
69  if flags is None:
70 
71  from AthenaConfiguration.AllConfigFlags import ConfigFlags
72  flags = ConfigFlags
73 
74  _chains = getHLTMenuAccess( flags )
75 
76 # print( datetime.now(), "configured chains: ", len(_chains) )
77 
78  chains = []
79  for c in _chains:
80  # print( c )
81  chain = re.findall( regex, c )
82  for a in chain:
83  if a is not None and c == a :
84  chains.append( a )
85 
86  return chains
87 
88 
89 
90 
91 def _getmonchains( flags, regex, monlevel=None ):
92 
93  chains = []
94 
95  if monlevel is None:
96  return chains
97 
98  parts = monlevel.split( ":", 1 )
99 
100  if parts[0] is None:
101  return chains
102 
103  if parts[1] is None:
104  return chains
105 
106  sig = parts[0]
107  levels = parts[1].split(":")
108 
109  _monchains = None
110 
111  if _monchains is None :
112 
113 # from datetime import datetime
114 # print( datetime.now(), "getting trigger configuration" )
115 
116  from TrigConfigSvc.TriggerConfigAccess import getHLTMonitoringAccess
117 
118  if flags is None:
119  from AthenaConfiguration.AllConfigFlags import ConfigFlags
120  flags = ConfigFlags
121 
122  moniAccess = getHLTMonitoringAccess(flags)
123 
124  _monchains = moniAccess.monitoredChains( signatures=sig, monLevels=levels )
125 
126 # print( datetime.now(), "configured chains: ", len(_monchains) )
127 
128  for c in _monchains:
129  chain = re.findall( regex, c )
130  for a in chain:
131  if a is not None and c == a :
132  chains.append( a )
133 
134  return chains
135 
136 
python.TIDAChains.getchains
def getchains(flags, analyses, monlevel=None)
Definition: TIDAChains.py:18
python.TriggerConfigAccess.getHLTMonitoringAccess
HLTMonitoringAccess getHLTMonitoringAccess(flags=None)
Definition: TriggerConfigAccess.py:256
python.TIDAChains._getmonchains
def _getmonchains(flags, regex, monlevel=None)
Definition: TIDAChains.py:91
python.TIDAChains._getconfiguredchains
def _getconfiguredchains(flags, regex)
Definition: TIDAChains.py:59
python.TriggerConfigAccess.getHLTMenuAccess
HLTMenuAccess getHLTMenuAccess(flags=None)
Definition: TriggerConfigAccess.py:196
python.TIDAChains.getconfiguredchains
def getconfiguredchains(flags, regex, monlevel=None)
Definition: TIDAChains.py:47
Trk::split
@ split
Definition: LayerMaterialProperties.h:38