5 histos = [
'TH1D',
'TH2D',
'TProfile']
20 def rec( o, path=None, lst=None ) :
21 if not path : path =
'/stat' ; lst = []
22 else : path = path +
'/' + o.GetName()
23 lst.append( (path,o) )
24 if 'GetListOfKeys' in dir(o) :
25 keys = o.GetListOfKeys()
28 rec( o.Get(name), path, lst )
46 if d[k].__class__.__name__
in histos : hists += 1
65 if t1[0] == ser : ds = t1[1] ; dp = t2[1]
66 elif t2[0] == ser : ds = t2[1] ; dp = t1[1]
67 else :
print 'Neither tuple is Serial Root file reference?' ;
return
69 dsks = ds.keys() ; dpks = dp.keys()
70 dsks.sort() ; dpks.sort()
72 sset = sets.Set( dsks )
73 pset = sets.Set( dpks )
77 print 'Comparison of Paths : Serial vs Parallel ROOT files'
79 print 'Number of paths in Serial file : %i (objects, histos) = ( %i, %i )'%( len(dsks), os, hs )
80 print 'Number of paths in Parall file : %i (objects, histos) = ( %i, %i )'%( len(dpks), op, hp )
81 matching = sset.intersection(pset)
84 if ds[n].__class__.__name__
in histos : matchingHistos += 1
85 print '\nMatching paths : %i'%( len(matching) )
88 uniqueSerialHistos = 0
90 if ds[n].__class__.__name__
in histos : uniqueSerialHistos += 1
91 print 'Paths unique to Serial file : %i ( %i Histos )'%( len(uSer), uniqueSerialHistos )
93 for n
in uSer :
print '\t%s : \t%s'%( ds[n], n )
95 uniqueParallHistos = 0
97 if dp[n].__class__.__name__
in histos : uniqueParallHistos += 1
98 print 'Paths unique to Parall file : %i ( %i Histos )'%( len(uPar), uniqueParallHistos )
100 for n
in uPar :
print '\t%s : \t%s'%( dp[n], n )
101 print 'Matching Histos to test : %i'%( matchingHistos )
103 return ( ((os,hs),(op,hp)), (uSer, uniqueSerialHistos), (uPar, uniqueParallHistos), matchingHistos )
123 ( ((serialObjects,serialHistos),(parallObjects, parallHistos)), (uniqueSerPaths,uniqueSerHistos), (uniqueParPaths,uniqueParHistos), mh ) = state
126 if t1[0] == ser : ds = t1[1] ; dp = t2[1]
127 elif t2[0] == ser : ds = t2[1] ; dp = t1[1]
128 else :
print 'Neither tuple is Serial Root file reference?' ;
return
131 hcp = 0 ; pHistos = []
132 hcs = 0 ; sHistos = []
134 omit = [
'/stat/Brunel/MemoryTool/Virtual mem, all entries',
135 '/stat/Brunel/MemoryTool/Virtual mem, downscaled']
141 if ds[k].__class__.__name__
in histos : hcs += 1 ; sHistos.append( k )
145 if dp[k].__class__.__name__
in histos : hcp += 1 ; pHistos.append( k )
148 cEntries = 0 ; xEntries = 0 ; diffEntries = []
149 cIntegrals = 0 ; xIntegrals = 0 ; diffIntegrals = []
150 passedKol = 0 ; failedKol = 0 ; diffKols = [] ; zeroIntegrals = 0
152 notfound = 0 ; integralMatch = 0 ; otherTest = 0 ; zeroIntegralMatch = 0
157 sh = ds[h] ; ph = dp[h]
159 if sh.GetEntries() != ph.GetEntries() : diffEntries.append(h) ; xEntries += 1 ;
continue
161 sBinError = 0.0 ; pBinError = 0.0
162 for i
in xrange(sh.GetNbinsX()) : sBinError += sh.GetBinError(i)
163 for i
in xrange(ph.GetNbinsX()) : pBinError += ph.GetBinError(i)
164 sint = sh.Integral() ; pint = ph.Integral()
165 if (bool(sint)
and bool(pint))
and ( sBinError>0
and pBinError>0 ) :
167 kTest = sh.KolmogorovTest(ph)
168 if int(kTest) : passedKol += 1
169 else : failedKol += 1 ; diffKols.append(h)
173 if all((sint, pint))
and (sint==pint) :
176 zeroIntegralMatch += 1
178 diffIntegrals.append( h )
181 notfound += 1 ;
print 'not found? ', h
185 print 'Summary of histos with different Entries'
189 for e
in diffEntries :
print '\t\t\t%s:\t%i != %i'%( e, int(ds[e].GetEntries()), int(dp[e].GetEntries()) )
194 print 'Summary of histos which failed Kolmogorov Test'
199 result = ds[e].KolmogorovTest(dp[e])
200 print '%s\t\t%s :\tK-Test Result :\t %5.16f'%(
type(ds[e]), e, result )
205 print 'Summary of histos which failed Integral Check'
209 for e
in diffIntegrals :
212 print '%s\t\t%s:\t Diff = %5.6f\tPercent Diff to Serial : %5.6f '%(
type(ds[e]), e, diff, pc )
217 print 'Comparison : Serial/Parallel ROOT Histo files'
218 print '\n\t\tSerial\tParall'
219 print '\tObjects : %i\t%i\t\t( p-s = %i )'%( serialObjects, parallObjects, parallObjects-serialObjects )
220 print '\tHistos : %i\t%i\t\t( p-s = %i )'%( serialHistos, parallHistos, parallHistos-serialHistos )
221 print '\t __________'
222 print '\tTotal : %i\t%i\n'%( serialHistos+serialObjects, parallHistos+parallObjects )
223 print 'Objects/Histos unique to Serial File : %i / %i'%( len(uniqueSerPaths)-uniqueSerHistos, uniqueSerHistos )
224 print 'Objects/Histos unique to Parall File : %i / %i'%( len(uniqueParPaths)-uniqueParHistos, uniqueParHistos )
225 print '\nMatching Histograms valid for Comparison : %i'%( mh )
226 print '\nOmissions : '
227 for entry
in omit :
print '\t%s'%( entry )
228 print '\nHistograms for Comparison (after Omissions) : %i'%( mh-len(omit) )
229 print '\n\tHISTOGRAM TESTS : '
230 print '\t\tKOLMOGOROV TEST : %i'%( kTested )
231 print '\t\tINTEGRAL TEST : %i'%( otherTest )
232 print '\t\tENTRIES TEST : %i'%( xEntries )
234 print '\t\tTested : %i'%( cEntries )
236 print '\n\tDISCREPANCIES : '
237 print '\t\tK-Test : %i'%( failedKol )
238 print '\t\tIntegrals : %i'%( xIntegrals )
239 print '\t\tEntries : %i'%( xEntries )
244 if __name__ ==
'__main__' :
246 if len(sys.argv) == 2 :
251 print 'Wrong count of arguments? > python compareRootHistos.py someParallelFile.root someSerialFile.root'
254 tfs = TFile( sFile,
'REC' ) ;
print 'opening Serial File : %s'%( sFile )
255 tfp = TFile( pFile,
'REC' ) ;
print 'opening Parall File : %s'%( pFile )
260 dserial = dict( [(n, o)
for n, o
in lser] )
261 dparall = dict( [(n, o)
for n, o
in lpar] )
263 ts = ( ser, dserial ) ; tp = ( par, dparall )
GAUDI_API double Integral(const Genfun::AbsFunction &function, const double a, const double b, const GaudiMath::Integration::Type type=GaudiMath::Integration::Adaptive, const GaudiMath::Integration::KronrodRule rule=GaudiMath::Integration::Default, const double epsabs=1.e-10, const double epsrel=1.e-7, const size_t size=1000)