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