3 from GaudiPython
import AppMgr, gbl
4 from ROOT
import TFile, TBufferFile, TBuffer
5 from multiprocessing
import Process, Queue
6 from Configurables
import LHCbApp
18 tf = TFile( fname,
'REC' )
35 AppName =
'File Check - Serial vs Parallel' )
42 pf = TFile( pname,
'REC' )
43 sf = TFile( sname,
'REC' )
45 pfks = pf.GetListOfKeys()
46 sfks = sf.GetListOfKeys()
47 pfkeys = list( [pfk.GetName()
for pfk
in pfks] ) ; pfkeys.sort()
48 sfkeys = list( [sfk.GetName()
for sfk
in sfks] ) ; sfkeys.sort()
49 pMeta = [] ; pEvent = [] ; pOther = []
51 if k.startswith( event ) : pEvent.append( k )
52 elif k.startswith(
'##' ) : pMeta.append( k )
53 else : pOther.append( k )
54 sMeta = [] ; sEvent = [] ; sOther = []
56 if k.startswith( event ) : sEvent.append( k )
57 elif k.startswith(
'##' ) : sMeta.append( k )
58 else : sOther.append( k )
60 if pMeta == sMeta :
pass
61 else :
print 'Meta Data differs'
63 if pEvent == sEvent :
pass
64 else :
print 'Event data differs'
71 if pExtra :
print 'Extra Data in parallel file : ', pExtra
72 if sExtra :
print 'Extra Data in serial file : ', sExtra
73 if sExtra
or pExtra :
print 'Files will have different sizes'
80 nkeys = len( d.keys() )
84 if vals.count( v ) > 1 :
85 print 'Dictionary cannot be switched, values not unique'
87 print 'Dict has keys/values : %i/%i' % ( nkeys, nvals )
90 for k, entry
in pairs : newd[entry] = k
103 print 'Dictionary %s : ' % ( name )
104 for k
in iter( d.keys() ) :
105 print '\t', k,
'\t', d[k]
109 def Reader( readerType, filename, qacross, qToEngine ) :
126 header =
'/Event/Rec/Header'
136 eNumber = int( evt[header].evtNumber() )
141 if readerType == SER :
148 elif readerType == PAR :
150 for serOrder
in iter( qacross.get,
None ) :
pass
151 lsks = len( serOrder.keys() )
152 lpks = len( order.keys() )
153 print 'Events in Files (serial/parallel) : %i / %i' % ( lsks, lpks )
157 for i
in iter( serOrder.keys() ) :
158 if readerType == PAR : i = order[serOrder[i]]
160 a.runSelectedEvents( fname, i )
164 ascii = dict( [ ( l, ( evt[l].__class__.__name__, evt[l].__repr__() ) )
for l
in lst ] )
165 qToEngine.put( ascii )
166 qToEngine.put(
None )
167 print '%s Reader Finished' % ( readerType )
182 if pitem == sitem ==
None :
print 'Termination Signals received ok' ;
break
183 elif pitem ==
None :
print 'pitem != sitem : ', pitem, sitem ;
break
184 elif sitem ==
None :
print 'pitem != sitem : ', pitem, sitem ;
break
187 print 'Comparison Engine Finished'
189 print 'Total Events Checked : %i' % ( len( results ) )
190 print 'Perfect Matches : %i' % (
sum( results ) )
191 print 'Errors : %i' % ( len( results ) -
sum( results ) )
203 ref =
'DataObject at 0x'
204 if a[:16] == b[:16] == ref :
return True
213 sks = s.keys() ; pks = p.keys()
214 sks.sort() ; pks.sort()
215 if len( sks ) == len( pks ) :
pass
225 extras = list( set( pks ) - set( sks ) )
227 if p[e][0] ==
'DataObject' : pks.remove( e )
228 else :
print 'Extra Other thing found!', e, p[e][0] ;
return False
237 for i
in xrange( l ) :
240 if s[key][0] == p[key][0] :
pass
241 else : diffs.append( key )
243 if s[key][1] == p[key][1] :
pass
245 else : diffs.append( key )
248 if diffs :
return False
253 print "Checking File Records"
255 parFSR = GetFSRdicts( par )
256 serFSR = GetFSRdicts( ser )
260 diff1 = set( parFSR[
"TimeSpanFSR"].iteritems() ) - set( serFSR[
"TimeSpanFSR"].iteritems() )
261 diff2 = set( parFSR[
"EventCountFSR"].iteritems() ) - set( serFSR[
"EventCountFSR"].iteritems() )
263 print "\nDifferent entries in TimeSpanFSR: \t" + str( len( diff1 ) ) +
"\nDifferent entries in EventCountFSR:\t" + str( len( diff2 ) )
265 for k
in [
"LumiFSRBeamCrossing",
"LumiFSRBeam2",
"LumiFSRNoBeam"]:
266 diff3 = set( parFSR[k][
"key"] ) - set( serFSR[k][
"key"] )
267 diff4 = set( parFSR[k][
"incr"] ) - set( serFSR[k][
"incr"] )
268 diff5 = set( parFSR[k][
"integral"] ) - set( serFSR[k][
"integral"] )
269 print "Different entries in " + str( k ) +
": \tkey: " + str( len( diff3 ) ) +
" increment: " + str( len( diff4 ) ) +
" integral: " + str( len( diff5 ) )
279 for r
in lumi.runNumbers() :
282 for f
in lumi.fileIDs() :
285 sa = s.split(
"info (key/incr/integral) : " )[-1]
286 sa = sa.split(
'/' )[:-1]
292 k, i, t = rec.split()
293 key.append( int( k ) )
294 incr.append( int( i ) )
295 integral.append( int( t ) )
297 return ( runs, files, key, incr, integral )
303 FSR = {
"TimeSpanFSR" : {
'earliest': 0,
'latest': 0},
304 "LumiFSRBeamCrossing" : {
'key': 0,
'incr': 0,
'integral':0},
305 "LumiFSRBeam1" : {
'key': 0,
'incr': 0,
'integral':0},
306 "LumiFSRBeam2" : {
'key': 0,
'incr': 0,
'integral':0},
307 "LumiFSRNoBeam" : {
'key': 0,
'incr': 0,
'integral':0},
308 "EventCountFSR" : {
'input': 0,
'output': 0,
'statusFlag': 0}}
310 options =
"from LumiAlgs.LumiFsrReaderConf import LumiFsrReaderConf as LumiFsrReader; LumiFsrReader().OutputLevel = INFO; LumiFsrReader().inputFiles = ['%s'] ;" %filename
311 options +=
"LumiFsrReader().Persistency='ROOT'; LumiFsrReader().EvtMax = 1; from Configurables import LHCbApp; LHCbApp().Persistency='ROOT'; from Configurables import CondDB, DDDBConf;"
312 options +=
" CondDB().UseLatestTags=['%s']; DDDBConf(DataType='%s');"%( 2011, 2011 )
316 fsr = app.filerecordsvc()
318 lst = fsr.getHistoNames()
323 ob = fsr.retrieveObject( l )
328 assert ob.numberOfObjects() == 1
329 k = ob.containedObject( 0 )
330 runs, files, keys, increment, integral =
LumiFSR( k )
332 FSR[l[l.rfind(
'/' ) + 1:]][
'runs'] = runs
333 FSR[l[l.rfind(
'/' ) + 1:]][
'files'] = files
334 FSR[l[l.rfind(
'/' ) + 1:]][
'key'] = keys
335 FSR[l[l.rfind(
'/' ) + 1:]][
'incr'] = increment
336 FSR[l[l.rfind(
'/' ) + 1:]][
'integral'] = integral
340 if "TimeSpanFSR" in l:
342 FSR[
"TimeSpanFSR"][
'earliest'] = ob.containedObject( 0 ).earliest()
343 FSR[
"TimeSpanFSR"][
'latest'] = ob.containedObject( 0 ).latest()
345 if "EventCountFSR" in l:
347 FSR[
"EventCountFSR"][
'input'] = ob.input()
348 FSR[
"EventCountFSR"][
'output'] = ob.output()
349 FSR[
"EventCountFSR"][
'statusFlag'] = ob.statusFlag()
361 print "Comparing File Records"
363 diff1 = set( parFSR[
"TimeSpanFSR"].iteritems() ) - set( serFSR[
"TimeSpanFSR"].iteritems() )
364 diff2 = set( parFSR[
"EventCountFSR"].iteritems() ) - set( serFSR[
"EventCountFSR"].iteritems() )
366 print "\nDifferent entries in TimeSpanFSR: \t" + str( len( diff1 ) ) +
"\nDifferent entries in EventCountFSR:\t" + str( len( diff2 ) )
368 for k
in [
"LumiFSRBeamCrossing",
"LumiFSRBeam2",
"LumiFSRNoBeam"]:
369 diff3 = set( parFSR[k][
'key'] ) - set( serFSR[k][
'key'] )
370 diff4 = set( parFSR[k][
'incr'] ) - set( serFSR[k][
'incr'] )
371 diff5 = set( parFSR[k][
'integral'] ) - set( serFSR[k][
"integral"] )
372 print "Different entries in " + str( k ) +
": \tkey: " + str( len( diff3 ) ) +
" increment: " + str( len( diff4 ) ) +
" integral: " + str( len( diff5 ) )
375 print "\nParallel: \n" + str( parFSR )
376 print "\nSerial: \n" + str( serFSR )
378 if __name__ ==
'__main__' :
382 if len( args ) != 2 :
383 print 'Please supply two arguments : > python loadFile <parallelFile> <serialFile>'
386 par =
'PFN:' + args[0]
387 ser =
'PFN:' + args[1]
388 print 'Parallel File to be analysed : %s' % ( par )
389 print 'Serial File to be analysed : %s' % ( ser )
399 par = Process( target = Reader, args = ( PAR, par, qacross, pout ) )
400 ser = Process( target = Reader, args = ( SER, ser, qacross, sout ) )
401 com = Process( target = ComparisonEngine, args = ( pout, sout ) )
408 print "Check File Records"
416 sp = Process( target = GetFSRdict, args = ( ser, sout ) )
417 pp = Process( target = GetFSRdict, args = ( par, pout ) )
418 cp = Process( target = CompareFSR, args = ( pout, sout ) )
420 sp.start(); pp.start(); cp.start()
421 sp.join();pp.join(); cp.join()
def checkForAddressDifference
double sum(double x, double y, double z)
A small to stream Data I/O.
HistogramPersistencySvc class implementation definition.
The Application Manager class.
Definition of class EventSelector.