CMS 3D CMS Logo

createFEDtable.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import os
4 import re
5 
6 def retrieveFedEntries(fedNumberingHeader):
7  reFedEntry = re.compile('\s*(MIN|MAX)(?P<name>.*)FEDID\s*=\s*(?P<id>[0-9]+).*')
8  entries = {}
9 
10  with open(fedNumberingHeader) as fedNumbering:
11  for line in fedNumbering:
12  match = reFedEntry.match(line)
13  if match and match.group('name'):
14  try:
15  entries[match.group('name')].append(int(match.group('id')))
16  except KeyError:
17  entries[match.group('name')] = [int(match.group('id'))]
18  entries[match.group('name')].sort()
19  return sorted(entries.items(), key=lambda e: e[1][0])
20 
21 def printHtmlTable(fedEntries):
22  lastId = -1
23  tableRow = "<tr style='color:%s'><td><div align='center'>%s</div></td><td><div align='center'>%s</div></td><td><div align='center'>%s</div></td></tr>"
24  print("<table width='75%' border='1' align='center'>")
25  print("<tr style='color:#FF0000'><th>Detector</th><th>Min FED id (decimal)</th><th>Max FED id (decimal)</th></tr>")
26  for item in fedEntries:
27  if lastId+1 < item[1][0]:
28  print(tableRow%('#FF0000','Free IDs',lastId+1,item[1][0]-1))
29  print(tableRow%('#000000',item[0],item[1][0],item[1][1]))
30  lastId = item[1][1]
31  print("</table>")
32 
33 def printTwikiTable(fedEntries):
34  lastId = -1
35  tableRow = "|%(color)s !%(label)s|%(color)s %(minId)s|%(color)s %(maxId)s|"
36  print("|*Detector*|*Min FED id (decimal)*|*Max FED id (decimal)*|")
37  for item in fedEntries:
38  if lastId+1 < item[1][0]:
39  print(tableRow%{'color':'%RED%','label':'Free IDs','minId':lastId+1,'maxId':item[1][0]-1})
40  print(tableRow%{'color':'%BLACK%','label':item[0],'minId':item[1][0],'maxId':item[1][1]})
41  lastId = item[1][1]
42 
43 if __name__ == "__main__":
44  fedEntries = retrieveFedEntries(os.environ['CMSSW_BASE']+'/src/DataFormats/FEDRawData/interface/FEDNumbering.h')
45  printHtmlTable(fedEntries)
46 # printTwikiTable(fedEntries)
createFEDtable.retrieveFedEntries
def retrieveFedEntries(fedNumberingHeader)
Definition: createFEDtable.py:6
createFEDtable.printTwikiTable
def printTwikiTable(fedEntries)
Definition: createFEDtable.py:33
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
mps_setup.append
append
Definition: mps_setup.py:85
createfilelist.int
int
Definition: createfilelist.py:10
createFEDtable.printHtmlTable
def printHtmlTable(fedEntries)
Definition: createFEDtable.py:21