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("dqm_lumi_only.root")
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 startIndex = 0
0017 lastIndex =-1
0018 for i in range(0,nRuns):
0019     for j in range(0,nHists):
0020         lastIndex +=1
0021         values.append(("Foo"+str(j)+"_lumi", 0, 1.0))
0022     expectedIndices.append( (i+1,1,3,startIndex,lastIndex) )
0023     startIndex = lastIndex+1
0024 
0025 
0026 if nRuns*nHists != th1fs.GetEntries():
0027     print("wrong number of entries in TH1Fs",th1fs.GetEntries())
0028     sys.exit(1)
0029 
0030 if nRuns != indices.GetEntries():
0031     print("wrong number of entries in Indices", indices.GetEntries())
0032     sys.exit(1)
0033 
0034 for run in range(0,nRuns):
0035     indices.GetEntry(run)
0036     v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex)
0037     if v != expectedIndices[run]:
0038         print('ERROR: unexpected value for indices at index :',run)
0039         print(' expected:', expectedIndices[run])
0040         print(' found:',v)
0041         sys.exit(1)
0042     for ihist in range(indices.FirstIndex,indices.LastIndex+1):
0043         index = ihist
0044         th1fs.GetEntry(ihist)
0045         v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries())
0046         if v != values[index]:
0047             print('ERROR: unexpected value for index, runIndex :',index,run)
0048             print(' expected:',values[index])
0049             print(' found:',v)
0050             sys.exit(1)
0051 print("SUCCEEDED")
0052