Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:58:57

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