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