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