Back to home page

Project CMSSW displayed by LXR

 
 

    


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("dqm_run_only.root")
0006 
0007 th1fs = f.Get("TH1Fs")
0008 
0009 indices = f.Get("Indices")
0010 
0011 expectedIndices = list()
0012 values = list()
0013 nRuns = 10
0014 nLumiPerRun = 1
0015 nHists = 10
0016 startIndex = 0
0017 lastIndex =-1
0018 for i in range(0,nRuns):
0019     for l in range(0,nLumiPerRun):
0020         #we put dummy lumi entries in for each lumi seen
0021         expectedIndices.append((i+1,l+1,1000,0,0))
0022     for j in range(0,nHists):
0023         lastIndex +=1
0024         values.append(("Foo"+str(j), 0, 1.0))
0025     expectedIndices.append( (i+1,0,3,startIndex,lastIndex) )
0026     startIndex = lastIndex+1
0027 
0028 
0029 if nRuns*nHists != th1fs.GetEntries():
0030     print("wrong number of entries in TH1Fs",th1fs.GetEntries())
0031     sys.exit(1)
0032 
0033 if nRuns+nRuns*nLumiPerRun != indices.GetEntries():
0034     print("wrong number of entries in Indices", indices.GetEntries())
0035     sys.exit(1)
0036 
0037 for run in range(0,nRuns+nRuns*nLumiPerRun):
0038     indices.GetEntry(run)
0039     v = (indices.Run,indices.Lumi,indices.Type,indices.FirstIndex,indices.LastIndex)
0040     if v != expectedIndices[run]:
0041         print('ERROR: unexpected value for indices at index :',run)
0042         print(' expected:', expectedIndices[run])
0043         print(' found:',v)
0044         sys.exit(1)
0045     if indices.Type !=1000:
0046         for ihist in range(indices.FirstIndex,indices.LastIndex+1):
0047             index = ihist
0048             th1fs.GetEntry(ihist)
0049             v = (th1fs.FullName,th1fs.Flags,th1fs.Value.GetEntries())
0050             if v != values[index]:
0051                 print('ERROR: unexpected value for index, runIndex :',index,run)
0052                 print(' expected:',values[index])
0053                 print(' found:',v)
0054                 sys.exit(1)
0055 print("SUCCEEDED")
0056