Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-10 23:53:30

0001 #!/usr/bin/env python3
0002 
0003 import uproot
0004 import argparse
0005 
0006 parser = argparse.ArgumentParser(description='List the full name of all MEs for a given run and lumi. ' +
0007                                              'If lumi is omitted, per run MEs will be printed out')
0008 
0009 parser.add_argument('filename', help='Name of local root file. For remote files, use edmCopyUtil first: `edmCopyUtil root://cms-xrd-global.cern.ch/<FILEPATH> .`')
0010 parser.add_argument('-r', type=int, help='Run to list MEs of')
0011 parser.add_argument('-l', type=int, default=0, help='Lumisection to list MEs of')
0012 
0013 args = parser.parse_args()
0014 
0015 if args.l == None or args.l < 0:
0016   print('Please provide a valid lumisection number')
0017   exit()
0018 
0019 f = uproot.open(args.filename)
0020 things = f.keys()
0021 if 'Indices;1' in things:
0022   indices = f['Indices']
0023   runs = indices['Run'].array()
0024   lumis = indices['Lumi'].array()
0025   firstindex = indices['FirstIndex'].array()
0026   lastindex = indices['LastIndex'].array()
0027   types = indices['Type'].array()
0028 
0029   # If run is not provided, print all available runs in a given file.
0030   if args.r == None or args.r < 0:
0031     print('Please provide a valid run number. Runs contained in a given file:')
0032     print('To figure out which lumisections are available for each run, use dqmiodumpmetadata.py')
0033     for run in set(runs):
0034       print(run)
0035     exit()
0036 
0037   treenames = [ # order matters!
0038     "Ints",
0039     "Floats",
0040     "Strings",
0041     "TH1Fs",
0042     "TH1Ss",
0043     "TH1Ds",
0044     "TH2Fs",
0045     "TH2Ss",
0046     "TH2Ds",
0047     "TH2Polys",
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)): # In DQMIO both ranges are inclusive
0059         print(trees[type][i])
0060 else:
0061   print("This does not look like DQMIO data.")