CMS 3D CMS Logo

dqmiodumpindices.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 from __future__ import print_function
3 
4 import uproot
5 import argparse
6 
7 from prettytable import PrettyTable
8 from collections import defaultdict
9 
10 parser = argparse.ArgumentParser(description="Shows Indices table in a DQMIO file. Last column (ME count) is computed like this: lastIndex - firstIndex + 1")
11 
12 parser.add_argument('filename', help='Name of local root file. For remote files, use edmCopyUtil first: `edmCopyUtil root://cms-xrd-global.cern.ch/<FILEPATH> .`')
13 
14 args = parser.parse_args()
15 
16 typeNames = ['Ints','Floats', 'Strings', 'TH1Fs','TH1Ss', 'TH1Ds',
17  'TH2Fs', 'TH2Ss', 'TH2Ds', 'TH3Fs', 'TProfiles','TProfile2Ds']
18 
19 f = uproot.open(args.filename)
20 things = f.keys()
21 if 'Indices;1' in things:
22  indices = f['Indices']
23  runs = indices.array('Run')
24  lumis = indices.array('Lumi')
25  firstindex = indices.array('FirstIndex')
26  lastindex = indices.array('LastIndex')
27  types = indices.array('Type')
28 
29  table = PrettyTable()
30  table.field_names = ['Run', 'Lumi', 'FirstIndex', 'LastIndex', 'Type', 'ME Count']
31 
32  for run, lumi, first, last, type in zip(runs, lumis, firstindex, lastindex, types):
33  typeName = 'Unknown'
34  if type < len(typeNames):
35  typeName = typeNames[type]
36 
37  table.add_row([run, lumi, first, last, '%s (%s)' % (type, typeName), int(last - first + 1)])
38 
39  print(table)
40 else:
41  print("This does not look like DQMIO data.")
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47