Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:53

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 
0010 indices = f.Get("Indices")
0011 
0012 expectedIndices = list()
0013 values = list()
0014 nRuns = 10
0015 nHists = 10
0016 nLumiPerRun = 1
0017 startIndex = 0
0018 lastIndex =-1
0019 for i in range(0,nRuns):
0020     for l in range(0,1):
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, 1.0))
0029     expectedIndices.append( (i+1,0,3,startIndex,lastIndex) )
0030     startIndex = lastIndex+1
0031 
0032 
0033 if nRuns*nHists+nRuns*nLumiPerRun*nHists != th1fs.GetEntries():
0034     print("wrong number of entries in TH1Fs",th1fs.GetEntries())
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,1):
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