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_merged_file1_file2.root")
0007
0008 th1fs = f.Get("TH1Fs")
0009
0010 indices = f.Get("Indices")
0011
0012 expectedIndices = list()
0013 values = list()
0014 nRuns = 1
0015 nHists = 10
0016 nLumiPerRun = 20
0017 startIndex = 0
0018 lastIndex =-1
0019 for i in range(0,nRuns):
0020 for l in range(0,nLumiPerRun):
0021 for j in range(0,nHists):
0022 lastIndex +=1
0023 values.append(("Foo"+str(j)+"_lumi", 0, 1.0))
0024 expectedIndices.append( (i+1,l+1,3,startIndex,lastIndex) )
0025 startIndex = lastIndex+1
0026 for j in range(0,nHists):
0027 lastIndex +=1
0028 values.append(("Foo"+str(j), 0, 2.0))
0029 expectedIndices.append( (i+1,0,3,startIndex,lastIndex) )
0030 startIndex = lastIndex+1
0031
0032
0033 expected = nRuns*nHists+nRuns*nLumiPerRun*nHists
0034 if expected != th1fs.GetEntries():
0035 print("wrong number of entries in TH1Fs",th1fs.GetEntries(),"expected",expected)
0036 sys.exit(1)
0037
0038 if nRuns+nRuns*nLumiPerRun != indices.GetEntries():
0039 print("wrong number of entries in Indices", indices.GetEntries())
0040 sys.exit(1)
0041
0042 indexTreeIndex = 0
0043 for run in range(0,nRuns):
0044 for lumi in range(0,nLumiPerRun):
0045 indices.GetEntry(indexTreeIndex)
0046 v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex)
0047 if v != expectedIndices[indexTreeIndex]:
0048 print('ERROR: unexpected value for indices at run,lumi :',run,lumi)
0049 print(' expected:', expectedIndices[indexTreeIndex])
0050 print(' found:',v)
0051 sys.exit(1)
0052 for ihist in range(indices.FirstIndex,indices.LastIndex+1):
0053 index = ihist
0054 th1fs.GetEntry(ihist)
0055 v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries())
0056 if v != values[index]:
0057 print('ERROR: unexpected value for index, runIndex,lumiIndex :',index,run,lumi)
0058 print(' expected:',values[index])
0059 print(' found:',v)
0060 sys.exit(1)
0061 indexTreeIndex +=1
0062 indices.GetEntry(indexTreeIndex)
0063 for ihist in range(indices.FirstIndex,indices.LastIndex+1):
0064 index = ihist
0065 th1fs.GetEntry(ihist)
0066 v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries())
0067 if v != values[index]:
0068 print('ERROR: unexpected value for index, runIndex :',index,run)
0069 print(' expected:',values[index])
0070 print(' found:',v)
0071 sys.exit(1)
0072 indexTreeIndex +=1
0073
0074 print("SUCCEEDED")
0075