| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

## Public Member Functions
def | __init__ (self, workerID, queues, events, params, subworkers)
def | processConfiguration (self)
def | Engine (self)
def | getCheckAlgs (self)
def | checkExecutedPassed (self, algName)
def | isEventPassed (self)
Public Member Functions inherited from GaudiMP.GMPBase.GMPComponent
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
| writerDict
| vetoAlgs
| eventOutput
| app
| filerecordsAgent
| nIn
| firstEvTime
| currentEvent
| tTime
Public Attributes inherited from GaudiMP.GMPBase.GMPComponent
| nodeType
| finalEvent
| lastEvent
| log
| subworkers
| nodeID
| 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 972 of file GMPBase.py.

## Constructor & Destructor Documentation

def GaudiMP.GMPBase.Worker.__init__ | ( |  | self,
|  |  | workerID,
|  |  | queues,
|  |  | events,
|  |  | params,
|  |  | subworkers
| ) |  |

Definition at line 973 of file GMPBase.py.

973 def __init__(self, workerID, queues, events, params, subworkers):
974 GMPComponent.__init__(self, 'Worker', workerID,
975 queues, events, params, subworkers)
976 # Identify the writer streams
977 self.writerDict = self.IdentifyWriters()
978 # Identify the accept/veto checks for each event
979 self.acceptAlgs, self.requireAlgs, self.vetoAlgs = self.getCheckAlgs()
980 self.log.name = "Worker-%i" % (self.nodeID)
981 self.log.info("Worker-%i Created OK" % (self.nodeID))
982 self.eventOutput = True
983
GaudiMP.GMPBase.Worker.vetoAlgs
vetoAlgs
Definition: GMPBase.py:979
GaudiMP.GMPBase.GMPComponent.nodeID
nodeID
Definition: GMPBase.py:440
GaudiMP.GMPBase.GMPComponent.IdentifyWriters
def IdentifyWriters(self)
Definition: GMPBase.py:580
GaudiMP.GMPBase.Worker.eventOutput
eventOutput
Definition: GMPBase.py:982
GaudiMP.GMPBase.Worker.getCheckAlgs
def getCheckAlgs(self)
Definition: GMPBase.py:1145
GaudiMP.GMPBase.Worker.__init__
def __init__(self, workerID, queues, events, params, subworkers)
Definition: GMPBase.py:973
GaudiMP.GMPBase.Worker.writerDict
writerDict
Definition: GMPBase.py:977

## Member Function Documentation

def GaudiMP.GMPBase.Worker.checkExecutedPassed | ( |  | self,
|  |  | algName
| ) |  |

Definition at line 1163 of file GMPBase.py.

1163 def checkExecutedPassed(self, algName):
1164 if self.a.algorithm(algName)._ialg.isExecuted()\
1165 and self.a.algorithm(algName)._ialg.filterPassed():
1166 return True
1167 else:
1168 return False
1169
GaudiMP.GMPBase.Worker.checkExecutedPassed
def checkExecutedPassed(self, algName)
Definition: GMPBase.py:1163

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

Definition at line 1025 of file GMPBase.py.

1025 def Engine(self):
1026
1027 # rename process
1028 import os
1029 import ctypes
1030 libc = ctypes.CDLL('libc.so.6')
1031 name = str(self.nodeType) + str(self.nodeID) + '\0'
1032 libc.prctl(15, name, 0, 0, 0)
1033
1034 startEngine = time.time()
1035 self.log.info("Worker %i starting Engine" % (self.nodeID))
1036 self.Initialize()
1037 self.filerecordsAgent = FileRecordsAgent(self)
1038
1039 # populate the TESSerializer itemlist
1040 self.log.info('EVT WRITERS ON WORKER : %i'
1041 % (len(self.writerDict['events'])))
1042
1043 nEventWriters = len(self.writerDict["events"])
1044 if nEventWriters:
1045 itemList = set()
1046 optItemList = set()
1047 for m in self.writerDict["events"]:
1048 for item in m.ItemList:
1049 hsh = item.find('#')
1050 if hsh != -1:
1051 item = item[:hsh]
1052 itemList.add(item)
1053 for item in m.OptItemList:
1054 hsh = item.find('#')
1055 if hsh != -1:
1056 item = item[:hsh]
1057 optItemList.add(item)
1058 # If an item is mandatory and optional, keep it only in the optional list
1059 itemList -= optItemList
1060 for item in sorted(itemList):
1061 self.log.info(' adding ItemList Item to ts : %s' % (item))
1062 self.ts.addItem(item)
1063 for item in sorted(optItemList):
1064 self.log.info(' adding Optional Item to ts : %s' % (item))
1065 self.ts.addOptItem(item)
1066 else:
1067 self.log.info('There is no Event Output for this app')
1068 self.eventOutput = False
1069
1070 # Begin processing
1071 Go = True
1072 while Go:
1073 packet = self.evcom.receive()
1074 if packet:
1075 pass
1076 else:
1077 continue
1078 if packet == 'FINISHED':
1079 break
1080 evtNumber, tbin = packet # unpack
1081 if self.cntr != None:
1082 self.cntr.setEventCounter(evtNumber)
1083
1084 # subworkers are forked before the first event is processed
1085 # reader-thread for ConDB must be closed and reopened in each subworker
1086 # this is done by disconnect()
1087 if self.nIn == 0:
1088
1089 self.log.info("Fork new subworkers and disconnect from CondDB")
1090 condDB = self.a.service('CondDBCnvSvc', gbl.ICondDBReader)
1091 condDB.disconnect()
1092
1093 # Fork subworkers and share services
1094 for k in self.subworkers:
1095 k.SetServices(self.a, self.evt, self.hvt, self.fsr,
1096 self.inc, self.pers, self.ts, self.cntr)
1097 k.Start()
1098 self.a.addAlgorithm(CollectHistograms(self))
1099 self.nIn += 1
1100 self.TS.Load(tbin)
1101
1102 t = time.time()
1103 sc = self.a.executeEvent()
1104 if self.nIn == 1:
1105 self.firstEvTime = time.time() - t
1106 else:
1107 self.rTime += (time.time() - t)
1108 if sc.isSuccess():
1109 pass
1110 else:
1111 self.log.warning('Did not Execute Event')
1112 self.evt.clearStore()
1113 continue
1114 if self.isEventPassed():
1115 pass
1116 else:
1117 self.log.warning('Event did not pass : %i' % (evtNumber))
1118 self.evt.clearStore()
1119 continue
1120 if self.eventOutput:
1121 # It may be the case of generating Event Tags; hence
1122 # no event output
1123 self.currentEvent = self.getEventNumber()
1124 tb = self.TS.Dump()
1125 self.evcom.send((self.currentEvent, tb))
1126 self.nOut += 1
1127 self.inc.fireIncident(gbl.Incident('Worker', 'EndEvent'))
1128 self.eventLoopSyncer.set()
1129 self.evt.clearStore()
1130 self.log.info('Setting <Last> Event')
1131 self.lastEvent.set()
1132
1133 self.evcom.finalize()
1134 self.log.info('Worker-%i Finished Processing Events' % (self.nodeID))
1135 # Now send the FileRecords and stop/finalize the appMgr
1136 self.filerecordsAgent.SendFileRecords()
1137 self.Finalize()
1138 self.tTime = time.time() - startEngine
1139 self.Report()
1140
1141 for k in self.subworkers:
1142 self.log.info('Join subworkers')
1143 k.proc.join()
1144
GaudiMP.GMPBase.GMPComponent.tTime
tTime
Definition: GMPBase.py:495
GaudiMP.GMPBase.GMPComponent.nodeID
nodeID
Definition: GMPBase.py:440
GaudiMP.GMPBase.Worker.Engine
def Engine(self)
Definition: GMPBase.py:1025
GaudiMP.GMPBase.GMPComponent.fsr
fsr
Definition: GMPBase.py:521
GaudiMP.GMPBase.GMPComponent.Report
def Report(self)
Definition: GMPBase.py:652
GaudiMP.GMPBase.GMPComponent.nOut
nOut
Definition: GMPBase.py:481
GaudiMP.GMPBase.CollectHistograms
Definition: GMPBase.py:187
GaudiMP.GMPBase.GMPComponent.nodeType
nodeType
Definition: GMPBase.py:430
GaudiMP.GMPBase.GMPComponent.rTime
rTime
Definition: GMPBase.py:492
GaudiMP.GMPBase.Worker.filerecordsAgent
filerecordsAgent
Definition: GMPBase.py:1037
GaudiMP.GMPBase.GMPComponent.pers
pers
Definition: GMPBase.py:523
GaudiMP.GMPBase.Worker.eventOutput
eventOutput
Definition: GMPBase.py:982
GaudiMP.GMPBase.GMPComponent.inc
inc
Definition: GMPBase.py:522
GaudiMP.GMPBase.GMPComponent.Finalize
def Finalize(self)
Definition: GMPBase.py:644
GaudiMP.GMPBase.GMPComponent.hvt
hvt
Definition: GMPBase.py:520
GaudiMP.GMPBase.GMPComponent.currentEvent
currentEvent
Definition: GMPBase.py:443
GaudiMP.GMPBase.GMPComponent.firstEvTime
firstEvTime
Definition: GMPBase.py:494
GaudiMP.GMPBase.GMPComponent.getEventNumber
def getEventNumber(self)
Definition: GMPBase.py:540
GaudiMP.GMPBase.GMPComponent.a
a
Definition: GMPBase.py:513
GaudiMP.GMPBase.GMPComponent.ts
ts
Definition: GMPBase.py:524
GaudiMP.GMPBase.GMPComponent.subworkers
subworkers
Definition: GMPBase.py:439
GaudiMP.GMPBase.GMPComponent.cntr
cntr
Definition: GMPBase.py:638
GaudiMP.GMPBase.GMPComponent.nIn
nIn
Definition: GMPBase.py:480
GaudiMP.GMPBase.GMPComponent.Initialize
def Initialize(self)
Definition: GMPBase.py:628
GaudiMP.GMPBase.Worker.isEventPassed
def isEventPassed(self)
Definition: GMPBase.py:1170
GaudiMP.GMPBase.Worker.writerDict
writerDict
Definition: GMPBase.py:977
GaudiMP.pTools.FileRecordsAgent
Definition: pTools.py:210
GaudiMP.GMPBase.GMPComponent.evt
evt
Definition: GMPBase.py:519

def GaudiMP.GMPBase.Worker.getCheckAlgs | ( |  | self | ) |

    For some output writers, a check is performed to see if the event has
    executed certain algorithms.
    These reside in the AcceptAlgs property for those writers

Definition at line 1145 of file GMPBase.py.

1145 def getCheckAlgs(self):
1146 '''
1147 For some output writers, a check is performed to see if the event has
1148 executed certain algorithms.
1149 These reside in the AcceptAlgs property for those writers
1150 '''
1151 acc = []
1152 req = []
1153 vet = []
1154 for m in self.writerDict["events"]:
1155 if hasattr(m.w, 'AcceptAlgs'):
1156 acc += m.w.AcceptAlgs
1157 if hasattr(m.w, 'RequireAlgs'):
1158 req += m.w.RequireAlgs
1159 if hasattr(m.w, 'VetoAlgs'):
1160 vet += m.w.VetoAlgs
1161 return (acc, req, vet)
1162
GaudiMP.GMPBase.Worker.getCheckAlgs
def getCheckAlgs(self)
Definition: GMPBase.py:1145
GaudiMP.GMPBase.Worker.writerDict
writerDict
Definition: GMPBase.py:977

def GaudiMP.GMPBase.Worker.isEventPassed | ( |  | self | ) |

    Check the algorithm status for an event.
    Depending on output writer settings, the event
      may be declined based on various criteria.
    This is a transcript of the check that occurs in GaudiSvc::OutputStream

Definition at line 1170 of file GMPBase.py.

1170 def isEventPassed(self):
1171 '''
1172 Check the algorithm status for an event.
1173 Depending on output writer settings, the event
1174 may be declined based on various criteria.
1175 This is a transcript of the check that occurs in GaudiSvc::OutputStream
1176 '''
1177 passed = False
1178
1179 self.log.debug('self.acceptAlgs is %s' % (str(self.acceptAlgs)))
1180 if self.acceptAlgs:
1181 for name in self.acceptAlgs:
1182 if self.checkExecutedPassed(name):
1183 passed = True
1184 break
1185 else:
1186 passed = True
1187
1188 self.log.debug('self.requireAlgs is %s' % (str(self.requireAlgs)))
1189 for name in self.requireAlgs:
1190 if self.checkExecutedPassed(name):
1191 pass
1192 else:
1193 self.log.info('Evt declined (requireAlgs) : %s' % (name))
1194 passed = False
1195
1196 self.log.debug('self.vetoAlgs is %s' % (str(self.vetoAlgs)))
1197 for name in self.vetoAlgs:
1198 if self.checkExecutedPassed(name):
1199 pass
1200 else:
1201 self.log.info('Evt declined : (vetoAlgs) : %s' % (name))
1202 passed = False
1203 return passed
1204
1205 # =============================================================================
1206
1207
GaudiMP.GMPBase.Worker.vetoAlgs
vetoAlgs
Definition: GMPBase.py:979
GaudiMP.GMPBase.Worker.isEventPassed
def isEventPassed(self)
Definition: GMPBase.py:1170
GaudiMP.GMPBase.Worker.checkExecutedPassed
def checkExecutedPassed(self, algName)
Definition: GMPBase.py:1163

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

Definition at line 984 of file GMPBase.py.

984 def processConfiguration(self):
985
986 # Worker :
987 # No input
988 # No output
989 # No Histos
990 self.config['EventSelector'].Input = []
991 self.config['ApplicationMgr'].OutStream = []
992 if "HistogramPersistencySvc" in self.config.keys():
993 self.config['HistogramPersistencySvc'].OutputFile = ''
994 formatHead = '[Worker-%i] ' % (self.nodeID)
995 self.config['MessageSvc'].Format = formatHead + \
996 '% F%18W%S%7W%R%T %0W%M'
997
998 for key, lst in self.writerDict.iteritems():
999 self.log.info('Writer Type : %s\t : %i' % (key, len(lst)))
1000
1001 for m in self.writerDict["tuples"]:
1002 # rename Tuple output file with an appendix
1003 # based on worker id, for merging later
1004 newName = m.getNewName('.', '.w%i.' % (self.nodeID))
1005 self.config[m.key].Output = newName
1006
1007 # Suppress INFO Output for all but Worker-0
1008 # if self.nodeID == 0 :
1009 # pass
1010 # else :
1011 # self.config[ 'MessageSvc' ].OutputLevel = ERROR
1012
1013 if self.app == "Gauss":
1014 try:
1015 if "ToolSvc.EvtCounter" not in self.config:
1016 from Configurables import EvtCounter
1017 counter = EvtCounter()
1018 else:
1019 counter = self.config["ToolSvc.EvtCounter"]
1020 counter.UseIncident = False
1021 except:
1022 # ignore errors when trying to change the configuration of the EvtCounter
1023 self.log.warning('Cannot configure EvtCounter')
1024
GaudiMP.GMPBase.GMPComponent.nodeID
nodeID
Definition: GMPBase.py:440
GaudiMP.GMPBase.Worker.processConfiguration
def processConfiguration(self)
Definition: GMPBase.py:984
GaudiMP.GMPBase.GMPComponent.app
app
Definition: GMPBase.py:450
GaudiMP.GMPBase.Worker.writerDict
writerDict
Definition: GMPBase.py:977

## Member Data Documentation

GaudiMP.GMPBase.Worker.app

Definition at line 1013 of file GMPBase.py.

GaudiMP.GMPBase.Worker.currentEvent

Definition at line 1123 of file GMPBase.py.

GaudiMP.GMPBase.Worker.eventOutput

Definition at line 982 of file GMPBase.py.

GaudiMP.GMPBase.Worker.filerecordsAgent

Definition at line 1037 of file GMPBase.py.

GaudiMP.GMPBase.Worker.firstEvTime

Definition at line 1105 of file GMPBase.py.

GaudiMP.GMPBase.Worker.nIn

Definition at line 1087 of file GMPBase.py.

GaudiMP.GMPBase.Worker.tTime

Definition at line 1138 of file GMPBase.py.

GaudiMP.GMPBase.Worker.vetoAlgs

Definition at line 979 of file GMPBase.py.

GaudiMP.GMPBase.Worker.writerDict

Definition at line 977 of file GMPBase.py.

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

- GaudiMP/python/GaudiMP/GMPBase.py