File indexing completed on 2024-04-06 12:10:13
0001 from __future__ import print_function
0002 from builtins import range
0003 import ROOT as R
0004 import sys
0005
0006 f = R.TFile.Open("dqm_run_only.root")
0007
0008 th1fs = f.Get("TH1Fs")
0009
0010 indices = f.Get("Indices")
0011
0012 expectedIndices = list()
0013 values = list()
0014 nRuns = 10
0015 nLumiPerRun = 1
0016 nHists = 10
0017 startIndex = 0
0018 lastIndex =-1
0019 for i in range(0,nRuns):
0020 for l in range(0,nLumiPerRun):
0021
0022 expectedIndices.append((i+1,l+1,1000,0,0))
0023 for j in range(0,nHists):
0024 lastIndex +=1
0025 values.append(("Foo"+str(j), 0, 1.0))
0026 expectedIndices.append( (i+1,0,3,startIndex,lastIndex) )
0027 startIndex = lastIndex+1
0028
0029
0030 if nRuns*nHists != th1fs.GetEntries():
0031 print("wrong number of entries in TH1Fs",th1fs.GetEntries())
0032 sys.exit(1)
0033
0034 if nRuns+nRuns*nLumiPerRun != indices.GetEntries():
0035 print("wrong number of entries in Indices", indices.GetEntries())
0036 sys.exit(1)
0037
0038 for run in range(0,nRuns+nRuns*nLumiPerRun):
0039 indices.GetEntry(run)
0040 v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex)
0041 if v != expectedIndices[run]:
0042 print('ERROR: unexpected value for indices at index :',run)
0043 print(' expected:', expectedIndices[run])
0044 print(' found:',v)
0045 sys.exit(1)
0046 if indices.Type !=1000:
0047 for ihist in range(indices.FirstIndex,indices.LastIndex+1):
0048 index = ihist
0049 th1fs.GetEntry(ihist)
0050 v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries())
0051 if v != values[index]:
0052 print('ERROR: unexpected value for index, runIndex :',index,run)
0053 print(' expected:',values[index])
0054 print(' found:',v)
0055 sys.exit(1)
0056 print("SUCCEEDED")
0057