CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dqmiolistmes.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 parser = argparse.ArgumentParser(description='List the full name of all MEs for a given run and lumi. ' +
8  'If lumi is omitted, per run MEs will be printed out')
9 
10 parser.add_argument('filename', help='Name of local root file. For remote files, use edmCopyUtil first: `edmCopyUtil root://cms-xrd-global.cern.ch/<FILEPATH> .`')
11 parser.add_argument('-r', type=int, help='Run to list MEs of')
12 parser.add_argument('-l', type=int, default=0, help='Lumisection to list MEs of')
13 
14 args = parser.parse_args()
15 
16 if args.l == None or args.l < 0:
17  print('Please provide a valid lumisection number')
18  exit()
19 
20 f = uproot.open(args.filename)
21 things = f.keys()
22 if 'Indices;1' in things:
23  indices = f['Indices']
24  runs = indices['Run'].array()
25  lumis = indices['Lumi'].array()
26  firstindex = indices['FirstIndex'].array()
27  lastindex = indices['LastIndex'].array()
28  types = indices['Type'].array()
29 
30  # If run is not provided, print all available runs in a given file.
31  if args.r == None or args.r < 0:
32  print('Please provide a valid run number. Runs contained in a given file:')
33  print('To figure out which lumisections are available for each run, use dqmiodumpmetadata.py')
34  for run in set(runs):
35  print(run)
36  exit()
37 
38  treenames = [ # order matters!
39  "Ints",
40  "Floats",
41  "Strings",
42  "TH1Fs",
43  "TH1Ss",
44  "TH1Ds",
45  "TH2Fs",
46  "TH2Ss",
47  "TH2Ds",
48  "TH3Fs",
49  "TProfiles",
50  "TProfile2Ds"
51  ]
52  trees = [f[name]["FullName"].array() for name in treenames]
53 
54  for run, lumi, first, last, type in zip(runs, lumis, firstindex, lastindex, types):
55  if run == args.r and lumi == args.l:
56  for i in range(first, int(last + 1)): # In DQMIO both ranges are inclusive
57  print(trees[type][i])
58 else:
59  print("This does not look like DQMIO data.")
tuple array
Definition: mps_check.py:216
const uint16_t range(const Frame &aFrame)
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