| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Public Attributes | List of all members
GaudiMP.GMPBase.GMPComponent Class Reference
Inheritance diagram for GaudiMP.GMPBase.GMPComponent:
[legend]
Collaboration diagram for GaudiMP.GMPBase.GMPComponent:
[legend]

## Public Member Functions
def | __init__ (self, nodeType, nodeID, queues, events, params, subworkers)
def | Start (self)
def | Engine (self)
def | processConfiguration (self)
def | SetupGaudiPython (self)
def | StartGaudiPython (self)
def | LoadTES (self, tbufferfile)
def | getEventNumber (self)
def | IdentifyWriters (self)
def | dumpHistograms (self)
def | Initialize (self)
def | Finalize (self)
def | Report (self)

## Public Attributes
| nodeType
| finalEvent
| lastEvent
| log
| subworkers
| nodeID
| msgFormat
| currentEvent
| queues
| num
| app
| evcom
| evcoms
| hq
| fq
| nIn
| nOut
| stat
| iTime
| rTime
| fTime
| firstEvTime
| tTime
| proc
| a
| evt
| hvt
| fsr
| inc
| pers
| ts
| TS
| cntr

## Detailed Description

Definition at line 413 of file GMPBase.py.

## Constructor & Destructor Documentation

## ◆ __init__()

def GaudiMP.GMPBase.GMPComponent.__init__ | ( |  | self,
|  |  | nodeType,
|  |  | nodeID,
|  |  | queues,
|  |  | events,
|  |  | params,
|  |  | subworkers
| ) |  |

Definition at line 420 of file GMPBase.py.

420 def __init__(self, nodeType, nodeID, queues, events, params, subworkers):
421 # declare a Gaudi MultiProcessing Node
422 # the nodeType is going to be one of Reader, Worker, Writer
423 # qPair is going to be a tuple of ( qin, qout )
424 # for sending and receiving
425 # if nodeType is "Writer", it will be a list of qPairs,
426 # as there's one queue-in from each Worker
427 #
428 # params is a tuple of (nWorkers, config, log)
429
430 self.nodeType = nodeType
431 current_process().name = nodeType
432
433 # Synchronisation Event() objects for keeping track of the system
434 self.initEvent, eventLoopSyncer, self.finalEvent = events
435 self.eventLoopSyncer, self.lastEvent = eventLoopSyncer # unpack tuple
436
437 # necessary for knowledge of the system
438 self.nWorkers, self.sEvent, self.config, self.log = params
439 self.subworkers = subworkers
440 self.nodeID = nodeID
441 self.msgFormat = self.config['MessageSvc'].Format
442
443 # describe the state of the node by the current Event Number
444 self.currentEvent = None
445
446 # Unpack the Queues : (events, histos, filerecords)
447 self.queues = queues
448 self.num = 0
449
450 ks = self.config.keys()
451 self.app = None
452 list = ["Brunel", "DaVinci", "Boole", "Gauss"]
453 for k in list:
454 if k in ks:
455 self.app = k
456

## Member Function Documentation

## ◆ dumpHistograms()

def GaudiMP.GMPBase.GMPComponent.dumpHistograms | ( |  | self | ) |

    Method used by the GaudiPython algorithm CollectHistos
    to obtain a dictionary of form { path : object }
    representing the Histogram Store

Definition at line 605 of file GMPBase.py.

605 def dumpHistograms(self):
606 '''
607 Method used by the GaudiPython algorithm CollectHistos
608 to obtain a dictionary of form { path : object }
609 representing the Histogram Store
610 '''
611 nlist = self.hvt.getHistoNames()
612 histDict = {}
613 objects = 0
614 histos = 0
615 if nlist:
616 for n in nlist:
617 o = self.hvt[n]
618 if type(o) in aidatypes:
619 o = aida2root(o)
620 histos += 1
621 else:
622 objects += 1
623 histDict[n] = o
624 else:
625 print 'WARNING : no histograms to recover?'
626 return histDict
627
gaudirun.type
type
Definition: gaudirun.py:142
GaudiMP.GMPBase.aida2root
aida2root
Definition: GMPBase.py:56

## ◆ Engine()

def GaudiMP.GMPBase.GMPComponent.Engine | ( |  | self | ) |

Reimplemented in GaudiMP.GMPBase.Writer, GaudiMP.GMPBase.Worker, GaudiMP.GMPBase.Subworker, and GaudiMP.GMPBase.Reader.

Definition at line 502 of file GMPBase.py.

502 def Engine(self):
503 # This will be the method carried out by the Node
504 # Different for all
505 pass
506

## ◆ Finalize()

def GaudiMP.GMPBase.GMPComponent.Finalize | ( |  | self | ) |

Definition at line 644 of file GMPBase.py.

644 def Finalize(self):
645 start = time.time()
646 self.a.stop()
647 self.a.finalize()
648 self.log.info('%s-%i Finalized' % (self.nodeType, self.nodeID))
649 self.finalEvent.set()
650 self.fTime = time.time() - start
651

## ◆ getEventNumber()

def GaudiMP.GMPBase.GMPComponent.getEventNumber | ( |  | self | ) |

Definition at line 541 of file GMPBase.py.

541 def getEventNumber(self):
542 if self.app != 'Gauss':
543 # Using getList or getHistoNames can result in the EventSelector
544 # re-initialising connection to RootDBase, which costs a lot of
545 # time... try to build a set of Header paths??
546
547 # First Attempt : Unpacked Event Data
548 lst = ['/Event/Gen/Header', '/Event/Rec/Header']
549 for l in lst:
550 path = l
551 try:
552 n = self.evt[path].evtNumber()
553
554 return n
555 except:
556 # No evt number at this path
557 continue
558
559 # second attepmt : try DAQ/RawEvent data
560 # The Evt Number is in bank type 16, bank 0, data pt 4
561 try:
562 n = self.evt['/Event/DAQ/RawEvent'].banks(16)[0].data()[4]
563
564 return n
565 except:
566 pass
567
568 # Default Action
569 if self.nIn > 0 or self.nOut > 0:
570 pass
571 else:
572 self.log.warning('Could not determine Event Number')
573 return -1
574 else:
575 if self.nodeID == -1:
576 self.num = self.num + 1
577
578 return self.num
579
GaudiMP.pTools.getEventNumber
def getEventNumber(evt)
Definition: pTools.py:719

## ◆ IdentifyWriters()

def GaudiMP.GMPBase.GMPComponent.IdentifyWriters | ( |  | self | ) |

Definition at line 580 of file GMPBase.py.

580 def IdentifyWriters(self):
581 #
582 # Identify Writers in the Configuration
583 #
584 d = {}
585 keys = ["events", "records", "tuples", "histos"]
586 for k in keys:
587 d[k] = []
588
589 # Identify Writers and Classify
590 wkeys = WRITERTYPES.keys()
591 for v in self.config.values():
592 if v.__class__.__name__ in wkeys:
593 writerType = WRITERTYPES[v.__class__.__name__]
594 d[writerType].append(MiniWriter(v, writerType, self.config))
595 if self.nodeID == 0:
596 self.log.info('Writer Found : %s' % (v.name()))
597
598 # Now Check for the Histogram Service
599 if 'HistogramPersistencySvc' in self.config.keys():
600 hfile = self.config['HistogramPersistencySvc'].getProp(
601 'OutputFile')
602 d["histos"].append(hfile)
603 return d
604

## ◆ Initialize()

def GaudiMP.GMPBase.GMPComponent.Initialize | ( |  | self | ) |

Definition at line 628 of file GMPBase.py.

628 def Initialize(self):
629 start = time.time()
630 self.processConfiguration()
631 self.SetupGaudiPython()
632 self.initEvent.set()
633 self.StartGaudiPython()
634
635 if self.app == 'Gauss':
636
637 tool = self.a.tool("ToolSvc.EvtCounter")
638 self.cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())
639 else:
640 self.cntr = None
641
642 self.iTime = time.time() - start
643

## ◆ LoadTES()

def GaudiMP.GMPBase.GMPComponent.LoadTES | ( |  | self,
|  |  | tbufferfile
| ) |  |

Definition at line 535 of file GMPBase.py.

535 def LoadTES(self, tbufferfile):
536 root = gbl.DataObject()
537 setOwnership(root, False)
538 self.evt.setRoot('/Event', root)
539 self.ts.loadBuffer(tbufferfile)
540
GaudiPython.Bindings.setOwnership
setOwnership
Definition: Bindings.py:87

## ◆ processConfiguration()

def GaudiMP.GMPBase.GMPComponent.processConfiguration | ( |  | self | ) |

Reimplemented in GaudiMP.GMPBase.Writer, GaudiMP.GMPBase.Worker, and GaudiMP.GMPBase.Reader.

Definition at line 507 of file GMPBase.py.

507 def processConfiguration(self):
508 # Different for all ; customize Configuration for multicore
509 pass
510

## ◆ Report()

def GaudiMP.GMPBase.GMPComponent.Report | ( |  | self | ) |

Definition at line 652 of file GMPBase.py.

652 def Report(self):
653 self.log.name = "%s-%i Audit" % (self.nodeType, self.nodeID)
654 allTime = "Alive Time : %5.2f" % (self.tTime)
655 initTime = "Init Time : %5.2f" % (self.iTime)
656 frstTime = "1st Event Time : %5.2f" % (self.firstEvTime)
657 runTime = "Run Time : %5.2f" % (self.rTime)
658 finTime = "Finalise Time : %5.2f" % (self.fTime)
659 tup = (allTime, initTime, frstTime, runTime, finTime)
660 for t in tup:
661 self.log.info(t)
662 self.log.name = "%s-%i" % (self.nodeType, self.nodeID)
663 # and report from the TESSerializer
664 self.TS.Report()
665
666
667 # =============================================================================
668
669

## ◆ SetupGaudiPython()

def GaudiMP.GMPBase.GMPComponent.SetupGaudiPython | ( |  | self | ) |

Definition at line 511 of file GMPBase.py.

511 def SetupGaudiPython(self):
512 # This method will initialize the GaudiPython Tools
513 # such as the AppMgr and so on
514 self.a = AppMgr()
515 if SMAPS:
516 from AlgSmapShot import SmapShot
517 smapsLog = self.nodeType + '-' + str(self.nodeID) + '.smp'
518 ss = SmapShot(logname=smapsLog)
519 self.a.addAlgorithm(ss)
520 self.evt = self.a.evtsvc()
521 self.hvt = self.a.histsvc()
522 self.fsr = self.a.filerecordsvc()
523 self.inc = self.a.service('IncidentSvc', 'IIncidentSvc')
524 self.pers = self.a.service('EventPersistencySvc', 'IAddressCreator')
525 self.ts = gbl.GaudiMP.TESSerializer(self.evt._idp, self.pers)
526 self.TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID,
527 self.log)
528 return SUCCESS
529

## ◆ Start()

def GaudiMP.GMPBase.GMPComponent.Start | ( |  | self | ) |

Definition at line 457 of file GMPBase.py.

457 def Start(self):
458 # define the separate process
459 qPair, histq, fq = self.queues
460
461 # Set up the Queue Mechanisms ( Event Communicators )
462 if self.nodeType == 'Reader' or self.nodeType == 'Worker':
463 # Reader or Worker Node
464 qin, qout = qPair
465 self.evcom = EventCommunicator(self, qin, qout)
466 else:
467 # Writer : many queues in, no queue out
468 assert self.nodeType == 'Writer'
469 self.evcoms = []
470 qsin = qPair[0]
471 for q in qsin:
472 ec = EventCommunicator(self, q, None)
473 self.evcoms.append(ec)
474 # Histogram Queue
475 self.hq = histq
476 # FileRecords Queue
477 self.fq = fq
478
479 # Universal Counters (available to all nodes)
480 # Use sensibly!!!
481 self.nIn = 0
482 self.nOut = 0
483
484 # Status Flag (possibly remove later)
485 self.stat = SUCCESS
486
487 # Set logger name
488 self.log.name = '%s-%i' % (self.nodeType, self.nodeID)
489
490 # Heuristic variables
491 # time for init, run, final, firstEventTime, totalTime
492 self.iTime = 0.0
493 self.rTime = 0.0
494 self.fTime = 0.0
495 self.firstEvTime = 0.0
496 self.tTime = 0.0
497
498 self.proc = Process(target=self.Engine)
499 # Fork and start the separate process
500 self.proc.start()
501
IOTest.start
def start
Definition: IOTest.py:97

## ◆ StartGaudiPython()

def GaudiMP.GMPBase.GMPComponent.StartGaudiPython | ( |  | self | ) |

Definition at line 530 of file GMPBase.py.

530 def StartGaudiPython(self):
531 self.a.initialize()
532 self.a.start()
533 return SUCCESS
534
IOTest.start
def start
Definition: IOTest.py:97

## Member Data Documentation

## ◆ a

GaudiMP.GMPBase.GMPComponent.a

Definition at line 514 of file GMPBase.py.

## ◆ app

GaudiMP.GMPBase.GMPComponent.app

Definition at line 451 of file GMPBase.py.

## ◆ cntr

GaudiMP.GMPBase.GMPComponent.cntr

Definition at line 638 of file GMPBase.py.

## ◆ currentEvent

GaudiMP.GMPBase.GMPComponent.currentEvent

Definition at line 444 of file GMPBase.py.

## ◆ evcom

GaudiMP.GMPBase.GMPComponent.evcom

Definition at line 465 of file GMPBase.py.

## ◆ evcoms

GaudiMP.GMPBase.GMPComponent.evcoms

Definition at line 469 of file GMPBase.py.

## ◆ evt

GaudiMP.GMPBase.GMPComponent.evt

Definition at line 520 of file GMPBase.py.

## ◆ finalEvent

GaudiMP.GMPBase.GMPComponent.finalEvent

Definition at line 434 of file GMPBase.py.

## ◆ firstEvTime

GaudiMP.GMPBase.GMPComponent.firstEvTime

Definition at line 495 of file GMPBase.py.

## ◆ fq

GaudiMP.GMPBase.GMPComponent.fq

Definition at line 477 of file GMPBase.py.

## ◆ fsr

GaudiMP.GMPBase.GMPComponent.fsr

Definition at line 522 of file GMPBase.py.

## ◆ fTime

GaudiMP.GMPBase.GMPComponent.fTime

Definition at line 494 of file GMPBase.py.

## ◆ hq

GaudiMP.GMPBase.GMPComponent.hq

Definition at line 475 of file GMPBase.py.

## ◆ hvt

GaudiMP.GMPBase.GMPComponent.hvt

Definition at line 521 of file GMPBase.py.

## ◆ inc

GaudiMP.GMPBase.GMPComponent.inc

Definition at line 523 of file GMPBase.py.

## ◆ iTime

GaudiMP.GMPBase.GMPComponent.iTime

Definition at line 492 of file GMPBase.py.

## ◆ lastEvent

GaudiMP.GMPBase.GMPComponent.lastEvent

Definition at line 435 of file GMPBase.py.

## ◆ log

GaudiMP.GMPBase.GMPComponent.log

Definition at line 438 of file GMPBase.py.

## ◆ msgFormat

GaudiMP.GMPBase.GMPComponent.msgFormat

Definition at line 441 of file GMPBase.py.

## ◆ nIn

GaudiMP.GMPBase.GMPComponent.nIn

Definition at line 481 of file GMPBase.py.

## ◆ nodeID

GaudiMP.GMPBase.GMPComponent.nodeID

Definition at line 440 of file GMPBase.py.

## ◆ nodeType

GaudiMP.GMPBase.GMPComponent.nodeType

Definition at line 430 of file GMPBase.py.

## ◆ nOut

GaudiMP.GMPBase.GMPComponent.nOut

Definition at line 482 of file GMPBase.py.

## ◆ num

GaudiMP.GMPBase.GMPComponent.num

Definition at line 448 of file GMPBase.py.

## ◆ pers

GaudiMP.GMPBase.GMPComponent.pers

Definition at line 524 of file GMPBase.py.

## ◆ proc

GaudiMP.GMPBase.GMPComponent.proc

Definition at line 498 of file GMPBase.py.

## ◆ queues

GaudiMP.GMPBase.GMPComponent.queues

Definition at line 447 of file GMPBase.py.

## ◆ rTime

GaudiMP.GMPBase.GMPComponent.rTime

Definition at line 493 of file GMPBase.py.

## ◆ stat

GaudiMP.GMPBase.GMPComponent.stat

Definition at line 485 of file GMPBase.py.

## ◆ subworkers

GaudiMP.GMPBase.GMPComponent.subworkers

Definition at line 439 of file GMPBase.py.

## ◆ ts

GaudiMP.GMPBase.GMPComponent.ts

Definition at line 525 of file GMPBase.py.

## ◆ TS

GaudiMP.GMPBase.GMPComponent.TS

Definition at line 526 of file GMPBase.py.

## ◆ tTime

GaudiMP.GMPBase.GMPComponent.tTime

Definition at line 496 of file GMPBase.py.

The documentation for this class was generated from the following file:

- GaudiMP/python/GaudiMP/GMPBase.py