File indexing completed on 2023-03-17 10:58:57
0001
0002 from __future__ import print_function
0003
0004 import uproot
0005 import argparse
0006
0007 parser = argparse.ArgumentParser(description='List the full name of all MEs for a given run and lumi. ' +
0008 'If lumi is omitted, per run MEs will be printed out')
0009
0010 parser.add_argument('filename', help='Name of local root file. For remote files, use edmCopyUtil first: `edmCopyUtil root://cms-xrd-global.cern.ch/<FILEPATH> .`')
0011 parser.add_argument('-r', type=int, help='Run to list MEs of')
0012 parser.add_argument('-l', type=int, default=0, help='Lumisection to list MEs of')
0013
0014 args = parser.parse_args()
0015
0016 if args.l == None or args.l < 0:
0017 print('Please provide a valid lumisection number')
0018 exit()
0019
0020 f = uproot.open(args.filename)
0021 things = f.keys()
0022 if 'Indices;1' in things:
0023 indices = f['Indices']
0024 runs = indices['Run'].array()
0025 lumis = indices['Lumi'].array()
0026 firstindex = indices['FirstIndex'].array()
0027 lastindex = indices['LastIndex'].array()
0028 types = indices['Type'].array()
0029
0030
0031 if args.r == None or args.r < 0:
0032 print('Please provide a valid run number. Runs contained in a given file:')
0033 print('To figure out which lumisections are available for each run, use dqmiodumpmetadata.py')
0034 for run in set(runs):
0035 print(run)
0036 exit()
0037
0038 treenames = [
0039 "Ints",
0040 "Floats",
0041 "Strings",
0042 "TH1Fs",
0043 "TH1Ss",
0044 "TH1Ds",
0045 "TH2Fs",
0046 "TH2Ss",
0047 "TH2Ds",
0048 "TH3Fs",
0049 "TProfiles",
0050 "TProfile2Ds",
0051 "TH1Is",
0052 "TH2Is"
0053 ]
0054 trees = [f[name]["FullName"].array() for name in treenames]
0055
0056 for run, lumi, first, last, type in zip(runs, lumis, firstindex, lastindex, types):
0057 if run == args.r and lumi == args.l:
0058 for i in range(first, int(last + 1)):
0059 print(trees[type][i])
0060 else:
0061 print("This does not look like DQMIO data.")