The Gaudi Framework  v36r6 (b1ee9983)
GaudiMP.GMPBase.GMPComponent Class Reference
Inheritance diagram for GaudiMP.GMPBase.GMPComponent:
Collaboration diagram for GaudiMP.GMPBase.GMPComponent:

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 445 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 452 of file GMPBase.py.

452  def __init__(self, nodeType, nodeID, queues, events, params, subworkers):
453  # declare a Gaudi MultiProcessing Node
454  # the nodeType is going to be one of Reader, Worker, Writer
455  # qPair is going to be a tuple of ( qin, qout )
456  # for sending and receiving
457  # if nodeType is "Writer", it will be a list of qPairs,
458  # as there's one queue-in from each Worker
459  #
460  # params is a tuple of (nWorkers, config, log)
461 
462  self.nodeType = nodeType
463  current_process().name = nodeType
464 
465  # Synchronisation Event() objects for keeping track of the system
466  self.initEvent, eventLoopSyncer, self.finalEvent = events
467  self.eventLoopSyncer, self.lastEvent = eventLoopSyncer # unpack tuple
468 
469  # necessary for knowledge of the system
470  self.nWorkers, self.sEvent, self.config, self.log = params
471  self.subworkers = subworkers
472  self.nodeID = nodeID
473  self.msgFormat = self.config["MessageSvc"].Format
474 
475  # describe the state of the node by the current Event Number
476  self.currentEvent = None
477 
478  # Unpack the Queues : (events, histos, filerecords)
479  self.queues = queues
480  self.num = 0
481 
482  ks = self.config.keys()
483  self.app = None
484  list = ["Brunel", "DaVinci", "Boole", "Gauss"]
485  for k in list:
486  if k in ks:
487  self.app = k
488 

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 636 of file GMPBase.py.

636  def dumpHistograms(self):
637  """
638  Method used by the GaudiPython algorithm CollectHistos
639  to obtain a dictionary of form { path : object }
640  representing the Histogram Store
641  """
642  nlist = self.hvt.getHistoNames()
643  histDict = {}
644  objects = 0
645  histos = 0
646  if nlist:
647  for n in nlist:
648  o = self.hvt[n]
649  if type(o) in aidatypes:
650  o = aida2root(o)
651  histos += 1
652  else:
653  objects += 1
654  histDict[n] = o
655  else:
656  print("WARNING : no histograms to recover?")
657  return histDict
658 

◆ 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 534 of file GMPBase.py.

534  def Engine(self):
535  # This will be the method carried out by the Node
536  # Different for all
537  pass
538 

◆ Finalize()

def GaudiMP.GMPBase.GMPComponent.Finalize (   self)

Definition at line 675 of file GMPBase.py.

675  def Finalize(self):
676  start = time.time()
677  self.a.stop()
678  self.a.finalize()
679  self.log.info("%s-%i Finalized" % (self.nodeType, self.nodeID))
680  self.finalEvent.set()
681  self.fTime = time.time() - start
682 

◆ getEventNumber()

def GaudiMP.GMPBase.GMPComponent.getEventNumber (   self)

Definition at line 573 of file GMPBase.py.

573  def getEventNumber(self):
574  if self.app != "Gauss":
575  # Using getList or getHistoNames can result in the EventSelector
576  # re-initialising connection to RootDBase, which costs a lot of
577  # time... try to build a set of Header paths??
578 
579  # First Attempt : Unpacked Event Data
580  lst = ["/Event/Gen/Header", "/Event/Rec/Header"]
581  for l in lst:
582  path = l
583  try:
584  n = self.evt[path].evtNumber()
585 
586  return n
587  except:
588  # No evt number at this path
589  continue
590 
591  # second attepmt : try DAQ/RawEvent data
592  # The Evt Number is in bank type 16, bank 0, data pt 4
593  try:
594  n = self.evt["/Event/DAQ/RawEvent"].banks(16)[0].data()[4]
595 
596  return n
597  except:
598  pass
599 
600  # Default Action
601  if self.nIn > 0 or self.nOut > 0:
602  pass
603  else:
604  self.log.warning("Could not determine Event Number")
605  return -1
606  else:
607  if self.nodeID == -1:
608  self.num = self.num + 1
609 
610  return self.num
611 

◆ IdentifyWriters()

def GaudiMP.GMPBase.GMPComponent.IdentifyWriters (   self)

Definition at line 612 of file GMPBase.py.

612  def IdentifyWriters(self):
613  #
614  # Identify Writers in the Configuration
615  #
616  d = {}
617  keys = ["events", "records", "tuples", "histos"]
618  for k in keys:
619  d[k] = []
620 
621  # Identify Writers and Classify
622  wkeys = WRITERTYPES.keys()
623  for v in self.config.values():
624  if v.__class__.__name__ in wkeys:
625  writerType = WRITERTYPES[v.__class__.__name__]
626  d[writerType].append(MiniWriter(v, writerType, self.config))
627  if self.nodeID == 0:
628  self.log.info("Writer Found : %s" % (v.name()))
629 
630  # Now Check for the Histogram Service
631  if "HistogramPersistencySvc" in self.config.keys():
632  hfile = self.config["HistogramPersistencySvc"].getProp("OutputFile")
633  d["histos"].append(hfile)
634  return d
635 

◆ Initialize()

def GaudiMP.GMPBase.GMPComponent.Initialize (   self)

Definition at line 659 of file GMPBase.py.

659  def Initialize(self):
660  start = time.time()
661  self.processConfiguration()
662  self.SetupGaudiPython()
663  self.initEvent.set()
664  self.StartGaudiPython()
665 
666  if self.app == "Gauss":
667 
668  tool = self.a.tool("ToolSvc.EvtCounter")
669  self.cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())
670  else:
671  self.cntr = None
672 
673  self.iTime = time.time() - start
674 

◆ LoadTES()

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

Definition at line 567 of file GMPBase.py.

567  def LoadTES(self, tbufferfile):
568  root = gbl.DataObject()
569  setOwnership(root, False)
570  self.evt.setRoot("/Event", root)
571  self.ts.loadBuffer(tbufferfile)
572 

◆ processConfiguration()

def GaudiMP.GMPBase.GMPComponent.processConfiguration (   self)

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

Definition at line 539 of file GMPBase.py.

539  def processConfiguration(self):
540  # Different for all ; customize Configuration for multicore
541  pass
542 

◆ Report()

def GaudiMP.GMPBase.GMPComponent.Report (   self)

Definition at line 683 of file GMPBase.py.

683  def Report(self):
684  self.log.name = "%s-%i Audit" % (self.nodeType, self.nodeID)
685  allTime = "Alive Time : %5.2f" % (self.tTime)
686  initTime = "Init Time : %5.2f" % (self.iTime)
687  frstTime = "1st Event Time : %5.2f" % (self.firstEvTime)
688  runTime = "Run Time : %5.2f" % (self.rTime)
689  finTime = "Finalise Time : %5.2f" % (self.fTime)
690  tup = (allTime, initTime, frstTime, runTime, finTime)
691  for t in tup:
692  self.log.info(t)
693  self.log.name = "%s-%i" % (self.nodeType, self.nodeID)
694  # and report from the TESSerializer
695  self.TS.Report()
696 
697 
698 # =============================================================================
699 
700 

◆ SetupGaudiPython()

def GaudiMP.GMPBase.GMPComponent.SetupGaudiPython (   self)

Definition at line 543 of file GMPBase.py.

543  def SetupGaudiPython(self):
544  # This method will initialize the GaudiPython Tools
545  # such as the AppMgr and so on
546  self.a = AppMgr()
547  if SMAPS:
548  from AlgSmapShot import SmapShot
549 
550  smapsLog = self.nodeType + "-" + str(self.nodeID) + ".smp"
551  ss = SmapShot(logname=smapsLog)
552  self.a.addAlgorithm(ss)
553  self.evt = self.a.evtsvc()
554  self.hvt = self.a.histsvc()
555  self.fsr = self.a.filerecordsvc()
556  self.inc = self.a.service("IncidentSvc", "IIncidentSvc")
557  self.pers = self.a.service("EventPersistencySvc", "IAddressCreator")
558  self.ts = gbl.GaudiMP.TESSerializer(self.evt._idp, self.pers)
559  self.TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID, self.log)
560  return SUCCESS
561 

◆ Start()

def GaudiMP.GMPBase.GMPComponent.Start (   self)

Definition at line 489 of file GMPBase.py.

489  def Start(self):
490  # define the separate process
491  qPair, histq, fq = self.queues
492 
493  # Set up the Queue Mechanisms ( Event Communicators )
494  if self.nodeType == "Reader" or self.nodeType == "Worker":
495  # Reader or Worker Node
496  qin, qout = qPair
497  self.evcom = EventCommunicator(self, qin, qout)
498  else:
499  # Writer : many queues in, no queue out
500  assert self.nodeType == "Writer"
501  self.evcoms = []
502  qsin = qPair[0]
503  for q in qsin:
504  ec = EventCommunicator(self, q, None)
505  self.evcoms.append(ec)
506  # Histogram Queue
507  self.hq = histq
508  # FileRecords Queue
509  self.fq = fq
510 
511  # Universal Counters (available to all nodes)
512  # Use sensibly!!!
513  self.nIn = 0
514  self.nOut = 0
515 
516  # Status Flag (possibly remove later)
517  self.stat = SUCCESS
518 
519  # Set logger name
520  self.log.name = "%s-%i" % (self.nodeType, self.nodeID)
521 
522  # Heuristic variables
523  # time for init, run, final, firstEventTime, totalTime
524  self.iTime = 0.0
525  self.rTime = 0.0
526  self.fTime = 0.0
527  self.firstEvTime = 0.0
528  self.tTime = 0.0
529 
530  self.proc = Process(target=self.Engine)
531  # Fork and start the separate process
532  self.proc.start()
533 

◆ StartGaudiPython()

def GaudiMP.GMPBase.GMPComponent.StartGaudiPython (   self)

Definition at line 562 of file GMPBase.py.

562  def StartGaudiPython(self):
563  self.a.initialize()
564  self.a.start()
565  return SUCCESS
566 

Member Data Documentation

◆ a

GaudiMP.GMPBase.GMPComponent.a

Definition at line 546 of file GMPBase.py.

◆ app

GaudiMP.GMPBase.GMPComponent.app

Definition at line 483 of file GMPBase.py.

◆ cntr

GaudiMP.GMPBase.GMPComponent.cntr

Definition at line 669 of file GMPBase.py.

◆ currentEvent

GaudiMP.GMPBase.GMPComponent.currentEvent

Definition at line 476 of file GMPBase.py.

◆ evcom

GaudiMP.GMPBase.GMPComponent.evcom

Definition at line 497 of file GMPBase.py.

◆ evcoms

GaudiMP.GMPBase.GMPComponent.evcoms

Definition at line 501 of file GMPBase.py.

◆ evt

GaudiMP.GMPBase.GMPComponent.evt

Definition at line 553 of file GMPBase.py.

◆ finalEvent

GaudiMP.GMPBase.GMPComponent.finalEvent

Definition at line 466 of file GMPBase.py.

◆ firstEvTime

GaudiMP.GMPBase.GMPComponent.firstEvTime

Definition at line 527 of file GMPBase.py.

◆ fq

GaudiMP.GMPBase.GMPComponent.fq

Definition at line 509 of file GMPBase.py.

◆ fsr

GaudiMP.GMPBase.GMPComponent.fsr

Definition at line 555 of file GMPBase.py.

◆ fTime

GaudiMP.GMPBase.GMPComponent.fTime

Definition at line 526 of file GMPBase.py.

◆ hq

GaudiMP.GMPBase.GMPComponent.hq

Definition at line 507 of file GMPBase.py.

◆ hvt

GaudiMP.GMPBase.GMPComponent.hvt

Definition at line 554 of file GMPBase.py.

◆ inc

GaudiMP.GMPBase.GMPComponent.inc

Definition at line 556 of file GMPBase.py.

◆ iTime

GaudiMP.GMPBase.GMPComponent.iTime

Definition at line 524 of file GMPBase.py.

◆ lastEvent

GaudiMP.GMPBase.GMPComponent.lastEvent

Definition at line 467 of file GMPBase.py.

◆ log

GaudiMP.GMPBase.GMPComponent.log

Definition at line 470 of file GMPBase.py.

◆ msgFormat

GaudiMP.GMPBase.GMPComponent.msgFormat

Definition at line 473 of file GMPBase.py.

◆ nIn

GaudiMP.GMPBase.GMPComponent.nIn

Definition at line 513 of file GMPBase.py.

◆ nodeID

GaudiMP.GMPBase.GMPComponent.nodeID

Definition at line 472 of file GMPBase.py.

◆ nodeType

GaudiMP.GMPBase.GMPComponent.nodeType

Definition at line 462 of file GMPBase.py.

◆ nOut

GaudiMP.GMPBase.GMPComponent.nOut

Definition at line 514 of file GMPBase.py.

◆ num

GaudiMP.GMPBase.GMPComponent.num

Definition at line 480 of file GMPBase.py.

◆ pers

GaudiMP.GMPBase.GMPComponent.pers

Definition at line 557 of file GMPBase.py.

◆ proc

GaudiMP.GMPBase.GMPComponent.proc

Definition at line 530 of file GMPBase.py.

◆ queues

GaudiMP.GMPBase.GMPComponent.queues

Definition at line 479 of file GMPBase.py.

◆ rTime

GaudiMP.GMPBase.GMPComponent.rTime

Definition at line 525 of file GMPBase.py.

◆ stat

GaudiMP.GMPBase.GMPComponent.stat

Definition at line 517 of file GMPBase.py.

◆ subworkers

GaudiMP.GMPBase.GMPComponent.subworkers

Definition at line 471 of file GMPBase.py.

◆ ts

GaudiMP.GMPBase.GMPComponent.ts

Definition at line 558 of file GMPBase.py.

◆ TS

GaudiMP.GMPBase.GMPComponent.TS

Definition at line 559 of file GMPBase.py.

◆ tTime

GaudiMP.GMPBase.GMPComponent.tTime

Definition at line 528 of file GMPBase.py.


The documentation for this class was generated from the following file:
GaudiPython.Bindings.setOwnership
setOwnership
Definition: Bindings.py:136
bug_34121.tool
tool
Definition: bug_34121.py:17
GaudiMP.pTools.getEventNumber
def getEventNumber(evt)
Definition: pTools.py:752
gaudirun.type
type
Definition: gaudirun.py:160
GaudiMP.GMPBase.aida2root
aida2root
Definition: GMPBase.py:84
IOTest.start
def start
Definition: IOTest.py:113
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67