The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiMP.GMPBase.GMPComponent Class Reference
Inheritance diagram for GaudiMP.GMPBase.GMPComponent:

Public Member Functions

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

Public Attributes

str nodeType = nodeType
 initEvent
 finalEvent = events
 eventLoopSyncer
 lastEvent = eventLoopSyncer
 nWorkers
 sEvent
 config
 log = params
 subworkers = subworkers
int nodeID = nodeID
 msgFormat = self.config["MessageSvc"].Format
 currentEvent = None
 queues = queues
int num = 0
str app = None
 evcom = EventCommunicator(self, qin, qout)
list evcoms = []
 hq = histq
 fq = fq
int nIn = 0
int nOut = 0
 stat = SUCCESS
float iTime = 0.0
float rTime = 0.0
float fTime = 0.0
float firstEvTime = 0.0
float tTime = 0.0
 proc = Process(target=self.Engine)
 a = AppMgr()
 evt = self.a.evtsvc()
 hvt = self.a.histsvc()
 fsr = self.a.filerecordsvc()
 inc = self.a.service("IncidentSvc", "IIncidentSvc")
 pers = self.a.service("EventPersistencySvc", "IAddressCreator")
 ts = gbl.GaudiMP.TESSerializer(self.evt._idp, self.pers)
 TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID, self.log)
 cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())

Detailed Description

Definition at line 440 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 447 of file GMPBase.py.

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

Member Function Documentation

◆ dumpHistograms()

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

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

◆ Engine()

GaudiMP.GMPBase.GMPComponent.Engine ( self)

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

Definition at line 529 of file GMPBase.py.

529 def Engine(self):
530 # This will be the method carried out by the Node
531 # Different for all
532 pass
533

◆ Finalize()

GaudiMP.GMPBase.GMPComponent.Finalize ( self)

Definition at line 669 of file GMPBase.py.

669 def Finalize(self):
670 start = time.time()
671 self.a.stop()
672 self.a.finalize()
673 self.log.info(f"{self.nodeType}-{self.nodeID} Finalized")
674 self.finalEvent.set()
675 self.fTime = time.time() - start
676

◆ getEventNumber()

GaudiMP.GMPBase.GMPComponent.getEventNumber ( self)

Definition at line 568 of file GMPBase.py.

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

◆ IdentifyWriters()

GaudiMP.GMPBase.GMPComponent.IdentifyWriters ( self)

Definition at line 607 of file GMPBase.py.

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

◆ Initialize()

GaudiMP.GMPBase.GMPComponent.Initialize ( self)

Definition at line 654 of file GMPBase.py.

654 def Initialize(self):
655 start = time.time()
656 self.processConfiguration()
657 self.SetupGaudiPython()
658 self.initEvent.set()
659 self.StartGaudiPython()
660
661 if self.app == "Gauss":
662 tool = self.a.tool("ToolSvc.EvtCounter")
663 self.cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())
664 else:
665 self.cntr = cppyy.nullptr
666
667 self.iTime = time.time() - start
668

◆ LoadTES()

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

Definition at line 562 of file GMPBase.py.

562 def LoadTES(self, tbufferfile):
563 root = gbl.DataObject()
564 setOwnership(root, False)
565 self.evt.setRoot("/Event", root)
566 self.ts.loadBuffer(tbufferfile)
567

◆ processConfiguration()

GaudiMP.GMPBase.GMPComponent.processConfiguration ( self)

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

Definition at line 534 of file GMPBase.py.

534 def processConfiguration(self):
535 # Different for all ; customize Configuration for multicore
536 pass
537

◆ Report()

GaudiMP.GMPBase.GMPComponent.Report ( self)

Definition at line 677 of file GMPBase.py.

677 def Report(self):
678 self.log.name = f"{self.nodeType}-{self.nodeID} Audit"
679 allTime = f"Alive Time : {self.tTime:5.2f}"
680 initTime = f"Init Time : {self.iTime:5.2f}"
681 frstTime = f"1st Event Time : {self.firstEvTime:5.2f}"
682 runTime = f"Run Time : {self.rTime:5.2f}"
683 finTime = f"Finalise Time : {self.fTime:5.2f}"
684 tup = (allTime, initTime, frstTime, runTime, finTime)
685 for t in tup:
686 self.log.info(t)
687 self.log.name = f"{self.nodeType}-{self.nodeID}"
688 # and report from the TESSerializer
689 self.TS.Report()
690
691
692# =============================================================================
693
694

◆ SetupGaudiPython()

GaudiMP.GMPBase.GMPComponent.SetupGaudiPython ( self)

Definition at line 538 of file GMPBase.py.

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

◆ Start()

GaudiMP.GMPBase.GMPComponent.Start ( self)

Definition at line 484 of file GMPBase.py.

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

◆ StartGaudiPython()

GaudiMP.GMPBase.GMPComponent.StartGaudiPython ( self)

Definition at line 557 of file GMPBase.py.

557 def StartGaudiPython(self):
558 self.a.initialize()
559 self.a.start()
560 return SUCCESS
561

Member Data Documentation

◆ a

GaudiMP.GMPBase.GMPComponent.a = AppMgr()

Definition at line 541 of file GMPBase.py.

◆ app

str GaudiMP.GMPBase.GMPComponent.app = None

Definition at line 478 of file GMPBase.py.

◆ cntr

GaudiMP.GMPBase.GMPComponent.cntr = InterfaceCast(gbl.IEventCounter)(tool.getInterface())

Definition at line 663 of file GMPBase.py.

◆ config

GaudiMP.GMPBase.GMPComponent.config

Definition at line 465 of file GMPBase.py.

◆ currentEvent

GaudiMP.GMPBase.GMPComponent.currentEvent = None

Definition at line 471 of file GMPBase.py.

◆ evcom

GaudiMP.GMPBase.GMPComponent.evcom = EventCommunicator(self, qin, qout)

Definition at line 492 of file GMPBase.py.

◆ evcoms

list GaudiMP.GMPBase.GMPComponent.evcoms = []

Definition at line 496 of file GMPBase.py.

◆ eventLoopSyncer

GaudiMP.GMPBase.GMPComponent.eventLoopSyncer

Definition at line 462 of file GMPBase.py.

◆ evt

GaudiMP.GMPBase.GMPComponent.evt = self.a.evtsvc()

Definition at line 548 of file GMPBase.py.

◆ finalEvent

GaudiMP.GMPBase.GMPComponent.finalEvent = events

Definition at line 461 of file GMPBase.py.

◆ firstEvTime

float GaudiMP.GMPBase.GMPComponent.firstEvTime = 0.0

Definition at line 522 of file GMPBase.py.

◆ fq

GaudiMP.GMPBase.GMPComponent.fq = fq

Definition at line 504 of file GMPBase.py.

◆ fsr

GaudiMP.GMPBase.GMPComponent.fsr = self.a.filerecordsvc()

Definition at line 550 of file GMPBase.py.

◆ fTime

float GaudiMP.GMPBase.GMPComponent.fTime = 0.0

Definition at line 521 of file GMPBase.py.

◆ hq

GaudiMP.GMPBase.GMPComponent.hq = histq

Definition at line 502 of file GMPBase.py.

◆ hvt

GaudiMP.GMPBase.GMPComponent.hvt = self.a.histsvc()

Definition at line 549 of file GMPBase.py.

◆ inc

GaudiMP.GMPBase.GMPComponent.inc = self.a.service("IncidentSvc", "IIncidentSvc")

Definition at line 551 of file GMPBase.py.

◆ initEvent

GaudiMP.GMPBase.GMPComponent.initEvent

Definition at line 461 of file GMPBase.py.

◆ iTime

float GaudiMP.GMPBase.GMPComponent.iTime = 0.0

Definition at line 519 of file GMPBase.py.

◆ lastEvent

GaudiMP.GMPBase.GMPComponent.lastEvent = eventLoopSyncer

Definition at line 462 of file GMPBase.py.

◆ log

GaudiMP.GMPBase.GMPComponent.log = params

Definition at line 465 of file GMPBase.py.

◆ msgFormat

GaudiMP.GMPBase.GMPComponent.msgFormat = self.config["MessageSvc"].Format

Definition at line 468 of file GMPBase.py.

◆ nIn

int GaudiMP.GMPBase.GMPComponent.nIn = 0

Definition at line 508 of file GMPBase.py.

◆ nodeID

int GaudiMP.GMPBase.GMPComponent.nodeID = nodeID

Definition at line 467 of file GMPBase.py.

◆ nodeType

str GaudiMP.GMPBase.GMPComponent.nodeType = nodeType

Definition at line 457 of file GMPBase.py.

◆ nOut

int GaudiMP.GMPBase.GMPComponent.nOut = 0

Definition at line 509 of file GMPBase.py.

◆ num

int GaudiMP.GMPBase.GMPComponent.num = 0

Definition at line 475 of file GMPBase.py.

◆ nWorkers

GaudiMP.GMPBase.GMPComponent.nWorkers

Definition at line 465 of file GMPBase.py.

◆ pers

GaudiMP.GMPBase.GMPComponent.pers = self.a.service("EventPersistencySvc", "IAddressCreator")

Definition at line 552 of file GMPBase.py.

◆ proc

GaudiMP.GMPBase.GMPComponent.proc = Process(target=self.Engine)

Definition at line 525 of file GMPBase.py.

◆ queues

GaudiMP.GMPBase.GMPComponent.queues = queues

Definition at line 474 of file GMPBase.py.

◆ rTime

float GaudiMP.GMPBase.GMPComponent.rTime = 0.0

Definition at line 520 of file GMPBase.py.

◆ sEvent

GaudiMP.GMPBase.GMPComponent.sEvent

Definition at line 465 of file GMPBase.py.

◆ stat

GaudiMP.GMPBase.GMPComponent.stat = SUCCESS

Definition at line 512 of file GMPBase.py.

◆ subworkers

GaudiMP.GMPBase.GMPComponent.subworkers = subworkers

Definition at line 466 of file GMPBase.py.

◆ TS

GaudiMP.GMPBase.GMPComponent.TS = TESSerializer(self.ts, self.evt, self.nodeType, self.nodeID, self.log)

Definition at line 554 of file GMPBase.py.

◆ ts

GaudiMP.GMPBase.GMPComponent.ts = gbl.GaudiMP.TESSerializer(self.evt._idp, self.pers)

Definition at line 553 of file GMPBase.py.

◆ tTime

float GaudiMP.GMPBase.GMPComponent.tTime = 0.0

Definition at line 523 of file GMPBase.py.


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