CMS 3D CMS Logo

dqmiolistmes.py
Go to the documentation of this file.
1 #!/usr/bin/env python
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 b'Indices;1' in things:
23  indices = f[b'Indices']
24  runs = indices.array(b"Run")
25  lumis = indices.array(b"Lumi")
26  firstindex = indices.array(b"FirstIndex")
27  lastindex = indices.array(b"LastIndex")
28  types = indices.array(b"Type")
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  b"Ints",
40  b"Floats",
41  b"Strings",
42  b"TH1Fs",
43  b"TH1Ss",
44  b"TH1Ds",
45  b"TH2Fs",
46  b"TH2Ss",
47  b"TH2Ds",
48  b"TH3Fs",
49  b"TProfiles",
50  b"TProfile2Ds"
51  ]
52  trees = [f[name][b"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].decode())
58 else:
59  print("This does not look like DQMIO data.")
60 
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_check.array
array
Definition: mps_check.py:216
dqmiolistmes.int
int
Definition: dqmiolistmes.py:11
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
ComparisonHelper::zip
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
Definition: L1TStage2CaloLayer1.h:41
edm::decode
bool decode(bool &, std::string const &)
Definition: types.cc:72
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53