3 from GaudiPython
import AppMgr, gbl
4 from ROOT
import TFile, TBufferFile, TBuffer
5 from multiprocessing
import Process, Queue
6 from Configurables
import LHCbApp
19 tf = TFile(fname,
'REC')
33 AppName=
'File Check - Serial vs Parallel')
41 pf = TFile(pname,
'REC')
42 sf = TFile(sname,
'REC')
44 pfks = pf.GetListOfKeys()
45 sfks = sf.GetListOfKeys()
46 pfkeys = list([pfk.GetName()
for pfk
in pfks])
48 sfkeys = list([sfk.GetName()
for sfk
in sfks])
54 if k.startswith(event):
56 elif k.startswith(
'##'):
64 if k.startswith(event):
66 elif k.startswith(
'##'):
74 print 'Meta Data differs' 79 print 'Event data differs' 87 print 'Extra Data in parallel file : ', pExtra
89 print 'Extra Data in serial file : ', sExtra
91 print 'Files will have different sizes' 103 if vals.count(v) > 1:
104 print 'Dictionary cannot be switched, values not unique' 106 print 'Dict has keys/values : %i/%i' % (nkeys, nvals)
109 for k, entry
in pairs:
123 print 'Dictionary %s : ' % (name)
124 for k
in iter(d.keys()):
125 print '\t', k,
'\t', d[k]
129 def Reader(readerType, filename, qacross, qToEngine):
146 header =
'/Event/Rec/Header' 156 eNumber = int(evt[header].evtNumber())
162 if readerType == SER:
169 elif readerType == PAR:
171 for serOrder
in iter(qacross.get,
None):
173 lsks = len(serOrder.keys())
174 lpks = len(order.keys())
175 print 'Events in Files (serial/parallel) : %i / %i' % (lsks, lpks)
179 for i
in iter(serOrder.keys()):
180 if readerType == PAR:
181 i = order[serOrder[i]]
183 a.runSelectedEvents(fname, i)
188 [(l, (evt[l].__class__.__name__, evt[l].
__repr__()))
for l
in lst])
191 print '%s Reader Finished' % (readerType)
207 if pitem == sitem ==
None:
208 print 'Termination Signals received ok' 211 print 'pitem != sitem : ', pitem, sitem
214 print 'pitem != sitem : ', pitem, sitem
218 print 'Comparison Engine Finished' 220 print 'Total Events Checked : %i' % (len(results))
221 print 'Perfect Matches : %i' % (
sum(results))
222 print 'Errors : %i' % (len(results) -
sum(results))
235 ref =
'DataObject at 0x' 236 if a[:16] == b[:16] == ref:
251 if len(sks) == len(pks):
262 extras = list(set(pks) - set(sks))
264 if p[e][0] ==
'DataObject':
267 print 'Extra Other thing found!', e, p[e][0]
282 if s[key][0] == p[key][0]:
287 if s[key][1] == p[key][1]:
303 print "Checking File Records" 305 parFSR = GetFSRdicts(par)
306 serFSR = GetFSRdicts(ser)
308 diff1 = set(parFSR[
"TimeSpanFSR"].iteritems()) - \
309 set(serFSR[
"TimeSpanFSR"].iteritems())
310 diff2 = set(parFSR[
"EventCountFSR"].iteritems()) - \
311 set(serFSR[
"EventCountFSR"].iteritems())
313 print "\nDifferent entries in TimeSpanFSR: \t" + \
314 str(len(diff1)) +
"\nDifferent entries in EventCountFSR:\t" + str(len(diff2))
316 for k
in [
"LumiFSRBeamCrossing",
"LumiFSRBeam2",
"LumiFSRNoBeam"]:
317 diff3 = set(parFSR[k][
"key"]) - set(serFSR[k][
"key"])
318 diff4 = set(parFSR[k][
"incr"]) - set(serFSR[k][
"incr"])
319 diff5 = set(parFSR[k][
"integral"]) - set(serFSR[k][
"integral"])
320 print "Different entries in " + str(k) +
": \tkey: " + str(
321 len(diff3)) +
" increment: " + str(len(diff4)) +
" integral: " + str(len(diff5))
331 for r
in lumi.runNumbers():
334 for f
in lumi.fileIDs():
337 sa = s.split(
"info (key/incr/integral) : ")[-1]
338 sa = sa.split(
'/')[:-1]
344 k, i, t = rec.split()
347 integral.append(int(t))
349 return (runs, files, key, incr, integral)
354 FSR = {
"TimeSpanFSR": {
'earliest': 0,
'latest': 0},
355 "LumiFSRBeamCrossing": {
'key': 0,
'incr': 0,
'integral': 0},
356 "LumiFSRBeam1": {
'key': 0,
'incr': 0,
'integral': 0},
357 "LumiFSRBeam2": {
'key': 0,
'incr': 0,
'integral': 0},
358 "LumiFSRNoBeam": {
'key': 0,
'incr': 0,
'integral': 0},
359 "EventCountFSR": {
'input': 0,
'output': 0,
'statusFlag': 0}}
361 options =
"from LumiAlgs.LumiFsrReaderConf import LumiFsrReaderConf as LumiFsrReader; LumiFsrReader().OutputLevel = INFO; LumiFsrReader().inputFiles = ['%s'] ;" % filename
362 options +=
"LumiFsrReader().Persistency='ROOT'; LumiFsrReader().EvtMax = 1; from Configurables import LHCbApp; LHCbApp().Persistency='ROOT'; from Configurables import CondDB, DDDBConf;" 363 options +=
" CondDB().UseLatestTags=['%s']; DDDBConf(DataType='%s');" % (
368 fsr = app.filerecordsvc()
370 lst = fsr.getHistoNames()
375 ob = fsr.retrieveObject(l)
379 assert ob.numberOfObjects() == 1
380 k = ob.containedObject(0)
381 runs, files, keys, increment, integral =
LumiFSR(k)
383 FSR[l[l.rfind(
'/') + 1:]][
'runs'] = runs
384 FSR[l[l.rfind(
'/') + 1:]][
'files'] = files
385 FSR[l[l.rfind(
'/') + 1:]][
'key'] = keys
386 FSR[l[l.rfind(
'/') + 1:]][
'incr'] = increment
387 FSR[l[l.rfind(
'/') + 1:]][
'integral'] = integral
389 if "TimeSpanFSR" in l:
391 FSR[
"TimeSpanFSR"][
'earliest'] = ob.containedObject(
393 FSR[
"TimeSpanFSR"][
'latest'] = ob.containedObject(0).latest()
395 if "EventCountFSR" in l:
397 FSR[
"EventCountFSR"][
'input'] = ob.input()
398 FSR[
"EventCountFSR"][
'output'] = ob.output()
399 FSR[
"EventCountFSR"][
'statusFlag'] = ob.statusFlag()
412 print "Comparing File Records" 414 diff1 = set(parFSR[
"TimeSpanFSR"].iteritems()) - \
415 set(serFSR[
"TimeSpanFSR"].iteritems())
416 diff2 = set(parFSR[
"EventCountFSR"].iteritems()) - \
417 set(serFSR[
"EventCountFSR"].iteritems())
419 print "\nDifferent entries in TimeSpanFSR: \t" + \
420 str(len(diff1)) +
"\nDifferent entries in EventCountFSR:\t" + str(len(diff2))
422 for k
in [
"LumiFSRBeamCrossing",
"LumiFSRBeam2",
"LumiFSRNoBeam"]:
423 diff3 = set(parFSR[k][
'key']) - set(serFSR[k][
'key'])
424 diff4 = set(parFSR[k][
'incr']) - set(serFSR[k][
'incr'])
425 diff5 = set(parFSR[k][
'integral']) - set(serFSR[k][
"integral"])
426 print "Different entries in " + str(k) +
": \tkey: " + str(
427 len(diff3)) +
" increment: " + str(len(diff4)) +
" integral: " + str(len(diff5))
429 print "\nParallel: \n" + str(parFSR)
430 print "\nSerial: \n" + str(serFSR)
433 if __name__ ==
'__main__':
438 print 'Please supply two arguments : > python loadFile <parallelFile> <serialFile>' 441 par =
'PFN:' + args[0]
442 ser =
'PFN:' + args[1]
443 print 'Parallel File to be analysed : %s' % (par)
444 print 'Serial File to be analysed : %s' % (ser)
453 par = Process(target=Reader, args=(PAR, par, qacross, pout))
454 ser = Process(target=Reader, args=(SER, ser, qacross, sout))
455 com = Process(target=ComparisonEngine, args=(pout, sout))
462 print "Check File Records" 470 sp = Process(target=GetFSRdict, args=(ser, sout))
471 pp = Process(target=GetFSRdict, args=(par, pout))
472 cp = Process(target=CompareFSR, args=(pout, sout))
def printDict(d, name='unspecified')
def CheckFileRecords(par, ser)
def CompareFSR(pout, sout)
def ComparisonEngine(pQueue, sQueue)
double sum(double x, double y, double z)
A small to stream Data I/O.
def importOptions(optsfile)
def CompareTrees(pname, sname)
HistogramPersistencySvc class implementation definition.
def checkForAddressDifference(a, b)
def GetFSRdict(filename, queue)
The Application Manager class.
Definition of class EventSelector.
def Reader(readerType, filename, qacross, qToEngine)