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