Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:20

0001 #!/usr/bin/env python
0002 
0003 import os
0004 import re
0005 
0006 def retrieveFedEntries(fedNumberingHeader):
0007     reFedEntry = re.compile('\s*(MIN|MAX)(?P<name>.*)FEDID\s*=\s*(?P<id>[0-9]+).*')
0008     entries = {}
0009 
0010     with open(fedNumberingHeader) as fedNumbering:
0011         for line in fedNumbering:
0012             match = reFedEntry.match(line)
0013             if match and match.group('name'):
0014                 try:
0015                     entries[match.group('name')].append(int(match.group('id')))
0016                 except KeyError:
0017                     entries[match.group('name')] = [int(match.group('id'))]
0018                 entries[match.group('name')].sort()
0019     return sorted(entries.items(), key=lambda e: e[1][0])
0020 
0021 def printHtmlTable(fedEntries):
0022     lastId = -1
0023     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>"
0024     print("<table width='75%' border='1' align='center'>")
0025     print("<tr style='color:#FF0000'><th>Detector</th><th>Min FED id (decimal)</th><th>Max FED id (decimal)</th></tr>")
0026     for item in fedEntries:
0027         if lastId+1 < item[1][0]:
0028             print(tableRow%('#FF0000','Free IDs',lastId+1,item[1][0]-1))
0029         print(tableRow%('#000000',item[0],item[1][0],item[1][1]))
0030         lastId = item[1][1]
0031     print("</table>")
0032 
0033 def printTwikiTable(fedEntries):
0034     lastId = -1
0035     tableRow = "|%(color)s !%(label)s|%(color)s %(minId)s|%(color)s %(maxId)s|"
0036     print("|*Detector*|*Min FED id (decimal)*|*Max FED id (decimal)*|")
0037     for item in fedEntries:
0038         if lastId+1 < item[1][0]:
0039             print(tableRow%{'color':'%RED%','label':'Free IDs','minId':lastId+1,'maxId':item[1][0]-1})
0040         print(tableRow%{'color':'%BLACK%','label':item[0],'minId':item[1][0],'maxId':item[1][1]})
0041         lastId = item[1][1]
0042 
0043 if __name__ == "__main__":
0044     fedEntries = retrieveFedEntries(os.environ['CMSSW_BASE']+'/src/DataFormats/FEDRawData/interface/FEDNumbering.h')
0045     printHtmlTable(fedEntries)
0046 #    printTwikiTable(fedEntries)