Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:12

0001 #!/usr/bin/env python3
0002 
0003 import uproot
0004 import argparse
0005 
0006 from prettytable import PrettyTable
0007 from collections import defaultdict
0008 
0009 parser = argparse.ArgumentParser(description="Shows Indices table in a DQMIO file. Last column (ME count) is computed like this: lastIndex - firstIndex + 1")
0010 
0011 parser.add_argument('filename', help='Name of local root file. For remote files, use edmCopyUtil first: `edmCopyUtil root://cms-xrd-global.cern.ch/<FILEPATH> .`')
0012 
0013 args = parser.parse_args()
0014 
0015 typeNames = ['Ints','Floats', 'Strings', 'TH1Fs','TH1Ss', 'TH1Ds',
0016              'TH2Fs', 'TH2Ss', 'TH2Ds', 'TH3Fs', 'TProfiles','TProfile2Ds']
0017 
0018 f = uproot.open(args.filename)
0019 things = f.keys()
0020 if 'Indices;1' in things:
0021   indices = f['Indices']
0022   runs = indices.array('Run')
0023   lumis = indices.array('Lumi')
0024   firstindex = indices.array('FirstIndex')
0025   lastindex = indices.array('LastIndex')
0026   types = indices.array('Type')
0027 
0028   table = PrettyTable()
0029   table.field_names = ['Run', 'Lumi', 'FirstIndex', 'LastIndex', 'Type', 'ME Count']
0030   
0031   for run, lumi, first, last, type in zip(runs, lumis, firstindex, lastindex, types):
0032     typeName = 'Unknown'
0033     if type < len(typeNames):
0034       typeName = typeNames[type]
0035     
0036     table.add_row([run, lumi, first, last, '%s (%s)' % (type, typeName), int(last - first + 1)])
0037 
0038   print(table)
0039 else:
0040   print("This does not look like DQMIO data.")