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

Public Member Functions

 __init__ (self, queues, events, params, subworkers)
 processConfiguration (self)
 DumpEvent (self)
 DoFirstEvent (self)
 Engine (self)
Public Member Functions inherited from GaudiMP.GMPBase.GMPComponent
 __init__ (self, nodeType, nodeID, queues, events, params, subworkers)
 Start (self)
 SetupGaudiPython (self)
 StartGaudiPython (self)
 LoadTES (self, tbufferfile)
 getEventNumber (self)
 IdentifyWriters (self)
 dumpHistograms (self)
 Initialize (self)
 Finalize (self)
 Report (self)

Public Attributes

 evtMax = self.config["ApplicationMgr"].EvtMax
Public Attributes inherited from GaudiMP.GMPBase.GMPComponent
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 695 of file GMPBase.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiMP.GMPBase.Reader.__init__ ( self,
queues,
events,
params,
subworkers )

Definition at line 696 of file GMPBase.py.

696 def __init__(self, queues, events, params, subworkers):
697 GMPComponent.__init__(self, "Reader", -1, queues, events, params, subworkers)
698

Member Function Documentation

◆ DoFirstEvent()

GaudiMP.GMPBase.Reader.DoFirstEvent ( self)

Definition at line 718 of file GMPBase.py.

718 def DoFirstEvent(self):
719 # Do First Event ------------------------------------------------------
720 # Check Termination Criteria
721 startFirst = time.time()
722 self.log.info("Reader : First Event")
723 if self.nOut == self.evtMax:
724 self.log.info(f"evtMax( {self.evtMax} ) reached")
725 self.lastEvent.set()
726 return SUCCESS
727 else:
728 # Continue to read, dump and send event
729 self.a.run(1)
730 if not bool(self.evt["/Event"]):
731 self.log.warning(f"No More Events! (So Far : {self.nOut})")
732 self.lastEvent.set()
733 return SUCCESS
734 else:
735 # Popluate TESSerializer list and send Event
736 if self.app == "Gauss":
737 lst = self.evt.getHistoNames()
738 else:
739 try:
740 lst = self.evt.getList()
741 if self.app == "DaVinci":
742 daqnode = self.evt.retrieveObject("/Event/DAQ").registry()
743 setOwnership(daqnode, False)
744 self.evt.getList(daqnode, lst, daqnode.address().par())
745 except Exception:
746 self.log.critical("Reader could not acquire TES List!")
747 self.lastEvent.set()
748 return FAILURE
749 self.log.info(f"Reader : TES List : {len(lst)} items")
750 for l in lst:
751 self.ts.addItem(l)
752 self.currentEvent = self.getEventNumber()
753 tb = self.TS.Dump()
754 self.log.info("First Event Sent")
755 self.evcom.send((self.currentEvent, tb))
756 self.nOut += 1
757 self.eventLoopSyncer.set()
758 self.evt.clearStore()
759 self.firstEvTime = time.time() - startFirst
760 return SUCCESS
761

◆ DumpEvent()

GaudiMP.GMPBase.Reader.DumpEvent ( self)

Definition at line 711 of file GMPBase.py.

711 def DumpEvent(self):
712 tb = TBufferFile(TBuffer.kWrite)
713 # print '----Reader dumping Buffer!!!'
714 self.ts.dumpBuffer(tb)
715 # print f'\tBuffer Dumped, size : {tb.Length()}'
716 return tb
717

◆ Engine()

GaudiMP.GMPBase.Reader.Engine ( self)

Reimplemented from GaudiMP.GMPBase.GMPComponent.

Definition at line 762 of file GMPBase.py.

762 def Engine(self):
763 # rename process
764 import ctypes
765
766 libc = ctypes.CDLL("libc.so.6")
767 name = str(self.nodeType) + str(self.nodeID) + "\0"
768 libc.prctl(15, ctypes.create_unicode_buffer(name), 0, 0, 0)
769
770 startEngine = time.time()
771 self.log.name = "Reader"
772 self.log.info("Reader Process starting")
773
774 self.Initialize()
775
776 # add the Histogram Collection Algorithm
777 self.a.addAlgorithm(CollectHistograms(self))
778
779 self.log.info("Reader Beginning Distribution")
780 sc = self.DoFirstEvent()
781 if sc.isSuccess():
782 self.log.info("Reader First Event OK")
783 else:
784 self.log.critical("Reader Failed on First Event")
785 self.stat = FAILURE
786
787 # Do All Others -------------------------------------------------------
788 while True:
789 # Check Termination Criteria
790 if self.nOut == self.evtMax:
791 self.log.info(f"evtMax( {self.evtMax} ) reached")
792 break
793 # Check Health
794 if not self.stat.isSuccess():
795 self.log.critical("Reader is Damaged!")
796 break
797 # Continue to read, dump and send event
798 t = time.time()
799 self.a.run(1)
800 self.rTime += time.time() - t
801 if not bool(self.evt["/Event"]):
802 self.log.warning(f"No More Events! (So Far : {self.nOut})")
803 break
804 self.currentEvent = self.getEventNumber()
805 tb = self.TS.Dump()
806 self.evcom.send((self.currentEvent, tb))
807 # clean up
808 self.nOut += 1
809 self.eventLoopSyncer.set()
810 self.evt.clearStore()
811 self.log.info("Setting <Last> Event")
812 self.lastEvent.set()
813
814 # Finalize
815 self.log.info("Reader : Event Distribution complete.")
816 self.evcom.finalize()
817 self.Finalize()
818 self.tTime = time.time() - startEngine
819 self.Report()
820
821
822# =============================================================================
823
824

◆ processConfiguration()

GaudiMP.GMPBase.Reader.processConfiguration ( self)

Reimplemented from GaudiMP.GMPBase.GMPComponent.

Definition at line 699 of file GMPBase.py.

699 def processConfiguration(self):
700 # Reader :
701 # No algorithms
702 # No output
703 # No histos
704 self.config["ApplicationMgr"].TopAlg = []
705 self.config["ApplicationMgr"].OutStream = []
706 if "HistogramPersistencySvc" in self.config.keys():
707 self.config["HistogramPersistencySvc"].OutputFile = ""
708 self.config["MessageSvc"].Format = "[Reader] " + self.msgFormat
709 self.evtMax = self.config["ApplicationMgr"].EvtMax
710

Member Data Documentation

◆ evtMax

GaudiMP.GMPBase.Reader.evtMax = self.config["ApplicationMgr"].EvtMax

Definition at line 709 of file GMPBase.py.


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