ATLAS Offline Software
Static Public Member Functions | Static Private Member Functions | List of all members
python.TriggerCoolUtil.TriggerCoolUtil Class Reference
Collaboration diagram for python.TriggerCoolUtil.TriggerCoolUtil:

Static Public Member Functions

def GetConnection (dbconn, verbosity=0)
 
def getHLTConfigKeys (db, runlist)
 
def getHLTPrescaleKeys (db, runlist)
 
def getL1ConfigKeys (db, runlist)
 
def getBunchGroupKey (db, runlist)
 
def getRunStartTime (db, runlist, runs)
 
def printL1Menu (db, run, verbosity)
 
def printHLTMenu (db, run, verbosity, printL2=True, printEF=True)
 
def printStreams (db, run, verbosity)
 

Static Private Member Functions

def _getKeys (db, runlist, folder, in_name, out_name)
 

Detailed Description

Definition at line 32 of file TriggerCoolUtil.py.

Member Function Documentation

◆ _getKeys()

def python.TriggerCoolUtil.TriggerCoolUtil._getKeys (   db,
  runlist,
  folder,
  in_name,
  out_name 
)
staticprivate
Helper to retrieve run/LB-index configuration keys

Definition at line 85 of file TriggerCoolUtil.py.

85  def _getKeys(db, runlist, folder, in_name, out_name):
86  """Helper to retrieve run/LB-index configuration keys"""
87  lbmask = 0xFFFFFFFF
88  configKeys = {}
89  f = db.getFolder( folder )
90  for (limmin,limmax) in iterate_runlist(runlist):
91  objs = f.browseObjects( limmin, limmax, cool.ChannelSelection(0))
92  while objs.goToNext():
93  obj=objs.currentRef()
94  runNr = obj.since()>>32
95  if runNr>1e9: continue # test runs in COOL
96  payload = obj.payload()
97  key = payload[in_name]
98  firstLB = obj.since() & lbmask
99  until = (obj.until() & lbmask)
100  lastLB = until-1 if until>0 else lbmask
101  configKeys.setdefault(runNr,{}).setdefault( out_name, [] ).append((key,firstLB,lastLB))
102 
103  return configKeys
104 

◆ getBunchGroupKey()

def python.TriggerCoolUtil.TriggerCoolUtil.getBunchGroupKey (   db,
  runlist 
)
static

Definition at line 116 of file TriggerCoolUtil.py.

116  def getBunchGroupKey(db,runlist):
117  return TriggerCoolUtil._getKeys(db, runlist, "/TRIGGER/LVL1/BunchGroupKey",
118  "Lvl1BunchGroupConfigurationKey", "BGKey")
119 

◆ GetConnection()

def python.TriggerCoolUtil.TriggerCoolUtil.GetConnection (   dbconn,
  verbosity = 0 
)
static

Definition at line 35 of file TriggerCoolUtil.py.

35  def GetConnection(dbconn,verbosity=0):
36  connection = None
37  m = match(r".*?([^/.]+)\.db",dbconn)
38  if dbconn in ["CONDBR2","COMP200","OFLP200"]:
39  connection = f'COOLONL_TRIGGER/{dbconn}'
40  elif m:
41  dbname=m.group(1).upper()
42  connection = "sqlite://;schema=%s;dbname=%s;" % (dbconn,dbname)
43  else:
44  raise RuntimeError ("Can't connect to COOL db %s" % dbconn)
45  try:
46  openConn = indirectOpen(connection,readOnly=True,debug=(verbosity>0))
47  except Exception:
48  import traceback
49  traceback.print_exc()
50  sys.exit(-1)
51  return openConn
52 

◆ getHLTConfigKeys()

def python.TriggerCoolUtil.TriggerCoolUtil.getHLTConfigKeys (   db,
  runlist 
)
static

Definition at line 54 of file TriggerCoolUtil.py.

54  def getHLTConfigKeys(db,runlist):
55  configKeys = {}
56  f = db.getFolder( "/TRIGGER/HLT/HltConfigKeys" )
57  for (limmin,limmax) in iterate_runlist(runlist):
58  objs = f.browseObjects( limmin, limmax, cool.ChannelSelection(0))
59  while objs.goToNext():
60  obj=objs.currentRef()
61  runNr = obj.since()>>32
62  if runNr>1e9: continue # test runs in COOL
63  payload=obj.payload()
64  smk = payload['MasterConfigurationKey']
65  hltpsk = payload['HltPrescaleConfigurationKey']
66  # Format for ConfigSource (see ATR-21550):
67  # Run-2: TRIGGERDBR2R,21.1.24,AthenaP1
68  # Run-3: TRIGGERDB_RUN3;22.0.101;Athena,22.0.101 --extra_args ...
69  release = 'unknown'
70  if runNr>379000:
71  confsrc = payload['ConfigSource'].split(';')
72  if len(confsrc)>2: release = confsrc[2].split()[0]
73  else:
74  confsrc = payload['ConfigSource'].split(',', maxsplit=1)
75  if len(confsrc)>1: release = confsrc[1]
76 
77  dbalias = confsrc[0]
78  configKeys[runNr] = { "REL" : release,
79  "SMK" : smk,
80  "HLTPSK" : hltpsk,
81  "DB" : dbalias }
82  return configKeys
83 

◆ getHLTPrescaleKeys()

def python.TriggerCoolUtil.TriggerCoolUtil.getHLTPrescaleKeys (   db,
  runlist 
)
static

Definition at line 106 of file TriggerCoolUtil.py.

106  def getHLTPrescaleKeys(db,runlist):
107  return TriggerCoolUtil._getKeys(db, runlist, "/TRIGGER/HLT/PrescaleKey",
108  "HltPrescaleKey", "HLTPSK2")
109 

◆ getL1ConfigKeys()

def python.TriggerCoolUtil.TriggerCoolUtil.getL1ConfigKeys (   db,
  runlist 
)
static

Definition at line 111 of file TriggerCoolUtil.py.

111  def getL1ConfigKeys(db,runlist):
112  return TriggerCoolUtil._getKeys(db, runlist, "/TRIGGER/LVL1/Lvl1ConfigKey",
113  "Lvl1PrescaleConfigurationKey", "LVL1PSK")
114 

◆ getRunStartTime()

def python.TriggerCoolUtil.TriggerCoolUtil.getRunStartTime (   db,
  runlist,
  runs 
)
static

Definition at line 121 of file TriggerCoolUtil.py.

121  def getRunStartTime(db,runlist, runs):
122  latestRunNr=0
123  startTime = {}
124  f = db.getFolder( "/TRIGGER/LUMI/LBLB" )
125  for rr in runlist:
126  limmin=(rr[0] << 32)+0
127  limmax=((rr[1]+1) << 32)+0
128  objs = f.browseObjects( limmin, limmax, cool.ChannelSelection(0) )
129  while objs.goToNext():
130  obj=objs.currentRef()
131  runNr = obj.since()>>32
132  if runNr==latestRunNr: continue
133  latestRunNr=runNr
134  if runNr not in runs: continue
135  payload=obj.payload()
136  starttime = payload['StartTime']
137  startTime[runNr] = { "STARTTIME" : ctime(starttime/1E9).replace(' ','_') }
138  return startTime
139 
140 

◆ printHLTMenu()

def python.TriggerCoolUtil.TriggerCoolUtil.printHLTMenu (   db,
  run,
  verbosity,
  printL2 = True,
  printEF = True 
)
static

Definition at line 185 of file TriggerCoolUtil.py.

185  def printHLTMenu(db, run, verbosity, printL2=True, printEF=True):
186  limmin=run<<32
187  limmax=((run+1)<<32)-1
188  print ("HLT Menu:")
189  f = db.getFolder( "/TRIGGER/HLT/Menu" )
190  chansel=cool.ChannelSelection.all()
191  objs = f.browseObjects( limmin,limmax,chansel)
192  sizeName=0
193  sizePS=0
194  sizePT=0
195  sizeStr=0
196  sizeLow=0
197  chainNames = {}
198  chainExtraInfo = {}
199  while objs.goToNext():
200  obj=objs.currentRef()
201  payload=obj.payload()
202  level = payload['TriggerLevel']
203  if level=='L2' and not printL2: continue
204  if level=='EF' and not printEF: continue
205  name = payload['ChainName']
206  sizeName=max(sizeName,len(name))
207  counter = payload['ChainCounter']
208  chainNames[(level,counter)] = name
209  if verbosity>0:
210  version = payload['ChainVersion']
211  prescale = payload['Prescale']
212  passthr = payload['PassThrough']
213  stream = payload['StreamInfo']
214  lower = payload['LowerChainName']
215  sizePS=max(sizePS,prescale)
216  sizePT=max(sizePT,passthr)
217  sizeStr=max(sizeStr,len(stream))
218  sizeLow=max(sizeLow,len(lower))
219  chainExtraInfo[(name,level)] = (version, prescale, passthr, stream, lower)
220  sizePS = len("%i"%sizePS)
221  sizePT = len("%i"%sizePT)
222  counters = chainNames.keys()
223  counters.sort()
224  for c in counters:
225  name = chainNames[c]
226  print ("%s %4i: %-*s" % (c[0], c[1], sizeName, name),)
227  if verbosity>0:
228  (version, prescale, passthr, stream, lower) = chainExtraInfo[(name,c[0])]
229  print ("[V %1s, PS %*i, PT %*i, by %-*s , => %-*s ]" %
230  (version, sizePS, prescale, sizePT, passthr, sizeLow, lower, sizeStr, stream), end='')
231  print()
232 

◆ printL1Menu()

def python.TriggerCoolUtil.TriggerCoolUtil.printL1Menu (   db,
  run,
  verbosity 
)
static

Definition at line 142 of file TriggerCoolUtil.py.

142  def printL1Menu(db, run, verbosity):
143  limmin=run<<32
144  limmax=(run+1)<<32
145 
146  printPrescales = verbosity>0
147  printDisabled = verbosity>1
148  print ("LVL1 Menu:")
149  f = db.getFolder( "/TRIGGER/LVL1/Menu" )
150  chansel=cool.ChannelSelection.all()
151  objs = f.browseObjects( limmin,limmax,chansel)
152  fps = db.getFolder( "/TRIGGER/LVL1/Prescales" )
153  objsps = fps.browseObjects( limmin,limmax,chansel)
154  itemName = {}
155  itemPrescale = {}
156  longestName = 0
157  while objs.goToNext():
158  obj=objs.currentRef()
159  channel = obj.channelId()
160  payload=obj.payload()
161  itemname = payload['ItemName']
162  itemName[channel] = itemname
163  longestName=max(longestName,len(itemname))
164  while objsps.goToNext():
165  objps=objsps.currentRef()
166  channel = objps.channelId()
167  payloadps=objps.payload()
168  ps = payloadps['Lvl1Prescale']
169  if channel in itemPrescale:
170  itemPrescale[channel] += [ ps ]
171  else:
172  itemPrescale[channel] = [ ps ]
173  for channel in itemName:
174  doPrint = False
175  for x in itemPrescale[channel]:
176  if x>0 or printDisabled: doPrint = True
177  if not doPrint: continue
178  if printPrescales:
179  print ("%4i: %-*s PS " % (channel, longestName, itemName[channel]), itemPrescale[channel])
180  else:
181  print ("%4i: %s" % (channel, itemName[channel]))
182 
183 

◆ printStreams()

def python.TriggerCoolUtil.TriggerCoolUtil.printStreams (   db,
  run,
  verbosity 
)
static

Definition at line 234 of file TriggerCoolUtil.py.

234  def printStreams(db, run, verbosity):
235  limmin=run<<32
236  limmax=((run+1)<<32)-1
237  print ("Used Streams:")
238  f = db.getFolder( "/TRIGGER/HLT/Menu" )
239  chansel=cool.ChannelSelection.all()
240  objs = f.browseObjects( limmin,limmax,chansel)
241  streams = set()
242  while objs.goToNext():
243  obj=objs.currentRef()
244  payload=obj.payload()
245  streamsOfChain = payload['StreamInfo']
246  for streamprescale in streamsOfChain.split(';'):
247  streamname = streamprescale.split(',')[0]
248  streams.add(streamname)
249  for s in sorted(list(streams)):
250  print (s)
251 
252 
253 # Testing

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
max
#define max(a, b)
Definition: cfImp.cxx:41
python.dbgAnalysis.getHLTConfigKeys
def getHLTConfigKeys(runNumber=None, args=None)
Definition: dbgAnalysis.py:214
python.TriggerCoolUtil.iterate_runlist
def iterate_runlist(runlist)
Definition: TriggerCoolUtil.py:10
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.AtlCoolLib.indirectOpen
def indirectOpen(coolstr, readOnly=True, debug=False)
Definition: AtlCoolLib.py:130
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