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