| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
def | processConfiguration
def | Engine
def | getCheckAlgs
def | checkExecutedPassed
def | isEventPassed
Public Member Functions inherited from GaudiMP.GMPBase.GMPComponent
def | __init__
def | Start
def | Engine
def | processConfiguration
def | SetupGaudiPython
def | StartGaudiPython
def | LoadTES
def | getEventNumber
def | IdentifyWriters
def | dumpHistograms
def | Initialize
def | Finalize
def | Report

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

## Constructor & Destructor Documentation

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

Definition at line 941 of file GMPBase.py.

941
942 def __init__( self, workerID, queues, events, params , subworkers ) :
943 GMPComponent.__init__(self,'Worker', workerID, queues, events, params, subworkers )
944 # Identify the writer streams
945 self.writerDict = self.IdentifyWriters( )
946 # Identify the accept/veto checks for each event
947 self.acceptAlgs, self.requireAlgs, self.vetoAlgs = self.getCheckAlgs()
948 self.log.name = "Worker-%i"%(self.nodeID)
949 self.log.info("Worker-%i Created OK"%(self.nodeID))
950 self.eventOutput = True

## Member Function Documentation

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

Definition at line 1123 of file GMPBase.py.

1123
1124 def checkExecutedPassed( self, algName ) :
1125 if self.a.algorithm( algName )._ialg.isExecuted()\
1126 and self.a.algorithm( algName )._ialg.filterPassed() :
1127 return True
1128 else :
1129 return False

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

Definition at line 991 of file GMPBase.py.

991
992 def Engine( self ) :
993
994 # rename process
995 import os
996 import ctypes
997 libc = ctypes.CDLL('libc.so.6')
998 name = str(self.nodeType) + str(self.nodeID) + '\0'
999 libc.prctl(15,name,0,0,0)
1000
1001 startEngine = time.time()
1002 self.log.info("Worker %i starting Engine"%(self.nodeID))
1003 self.Initialize()
1004 self.filerecordsAgent = FileRecordsAgent(self)
1005
1006 # populate the TESSerializer itemlist
1007 self.log.info('EVT WRITERS ON WORKER : %i'\
1008 %( len(self.writerDict['events'])))
1009
1010 nEventWriters = len( self.writerDict[ "events" ] )
1011 if nEventWriters :
1012 itemList = set()
1013 optItemList = set()
1014 for m in self.writerDict[ "events" ] :
1015 for item in m.ItemList :
1016 hsh = item.find( '#' )
1017 if hsh != -1:
1018 item = item[:hsh]
1019 itemList.add( item )
1020 for item in m.OptItemList :
1021 hsh = item.find( '#' )
1022 if hsh != -1:
1023 item = item[:hsh]
1024 optItemList.add( item )
1025 # If an item is mandatory and optional, keep it only in the optional list
1026 itemList -= optItemList
1027 for item in sorted( itemList ):
1028 self.log.info( ' adding ItemList Item to ts : %s' % ( item ) )
1029 self.ts.addItem( item )
1030 for item in sorted( optItemList ):
1031 self.log.info( ' adding Optional Item to ts : %s' % ( item ) )
1032 self.ts.addOptItem( item )
1033 else :
1034 self.log.info( 'There is no Event Output for this app' )
1035 self.eventOutput = False
1036
1037 # Begin processing
1038 Go = True
1039 while Go :
1040 packet = self.evcom.receive( )
1041 if packet : pass
1042 else : continue
1043 if packet == 'FINISHED' : break
1044 evtNumber, tbin = packet # unpack
1045 if self.cntr != None:
1046 self.cntr.setEventCounter( evtNumber )
1047
1048 # subworkers are forked before the first event is processed
1049 # reader-thread for ConDB must be closed and reopened in each subworker
1050 # this is done by disconnect()
1051 if self.nIn == 0:
1052
1053 self.log.info("Fork new subworkers and disconnect from CondDB")
1054 condDB = self.a.service('CondDBCnvSvc', gbl.ICondDBReader)
1055 condDB.disconnect()
1056
1057 # Fork subworkers and share services
1058 for k in self.subworkers:
1059 k.SetServices(self.a, self.evt, self.hvt, self.fsr, self.inc, self.pers, self.ts, self.cntr)
1060 k.Start()
1061 self.a.addAlgorithm( CollectHistograms(self) )
1062 self.nIn += 1
1063 self.TS.Load( tbin )
1064
1065 t = time.time()
1066 sc = self.a.executeEvent()
1067 if self.nIn == 1 :
1068 self.firstEvTime = time.time()-t
1069 else :
1070 self.rTime += (time.time()-t)
1071 if sc.isSuccess() :
1072 pass
1073 else :
1074 self.log.warning('Did not Execute Event')
1075 self.evt.clearStore()
1076 continue
1077 if self.isEventPassed() :
1078 pass
1079 else :
1080 self.log.warning( 'Event did not pass : %i'%(evtNumber) )
1081 self.evt.clearStore()
1082 continue
1083 if self.eventOutput :
1084 # It may be the case of generating Event Tags; hence
1085 # no event output
1086 self.currentEvent = self.getEventNumber( )
1087 tb = self.TS.Dump( )
1088 self.evcom.send( (self.currentEvent, tb) )
1089 self.nOut += 1
1090 self.inc.fireIncident(gbl.Incident('Worker','EndEvent'))
1091 self.eventLoopSyncer.set()
1092 self.evt.clearStore( )
1093 self.log.info('Setting <Last> Event')
1094 self.lastEvent.set()
1095
1096 self.evcom.finalize()
1097 self.log.info( 'Worker-%i Finished Processing Events'%(self.nodeID) )
1098 # Now send the FileRecords and stop/finalize the appMgr
1099 self.filerecordsAgent.SendFileRecords()
1100 self.Finalize()
1101 self.tTime = time.time()-startEngine
1102 self.Report()
1103
1104 for k in self.subworkers:
1105 self.log.info('Join subworkers')
1106 k.proc.join()

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

1107
1108 def getCheckAlgs( self ) :
1109 '''
1110 For some output writers, a check is performed to see if the event has
1111 executed certain algorithms.
1112 These reside in the AcceptAlgs property for those writers
1113 '''
1114 acc = []
1115 req = []
1116 vet = []
1117 for m in self.writerDict[ "events" ] :
1118 if hasattr(m.w, 'AcceptAlgs') : acc += m.w.AcceptAlgs
1119 if hasattr(m.w, 'RequireAlgs') : req += m.w.RequireAlgs
1120 if hasattr(m.w, 'VetoAlgs') : vet += m.w.VetoAlgs
1121 return (acc, req, vet)
1122

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

1130
1131 def isEventPassed( self ) :
1132 '''
1133 Check the algorithm status for an event.
1134 Depending on output writer settings, the event
1135 may be declined based on various criteria.
1136 This is a transcript of the check that occurs in GaudiSvc::OutputStream
1137 '''
1138 passed = False
1139
1140 self.log.debug('self.acceptAlgs is %s'%(str(self.acceptAlgs)))
1141 if self.acceptAlgs :
1142 for name in self.acceptAlgs :
1143 if self.checkExecutedPassed( name ) :
1144 passed = True
1145 break
1146 else :
1147 passed = True
1148
1149 self.log.debug('self.requireAlgs is %s'%(str(self.requireAlgs)))
1150 for name in self.requireAlgs :
1151 if self.checkExecutedPassed( name ) :
1152 pass
1153 else :
1154 self.log.info('Evt declined (requireAlgs) : %s'%(name) )
1155 passed = False
1156
1157 self.log.debug('self.vetoAlgs is %s'%(str(self.vetoAlgs)))
1158 for name in self.vetoAlgs :
1159 if self.checkExecutedPassed( name ) :
1160 pass
1161 else :
1162 self.log.info( 'Evt declined : (vetoAlgs) : %s'%(name) )
1163 passed = False
1164 return passed
1165
1166 # =============================================================================

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

Definition at line 951 of file GMPBase.py.

951
952 def processConfiguration( self ) :
953
954 # Worker :
955 # No input
956 # No output
957 # No Histos
958 self.config[ 'EventSelector' ].Input = []
959 self.config[ 'ApplicationMgr' ].OutStream = []
960 if "HistogramPersistencySvc" in self.config.keys() :
961 self.config[ 'HistogramPersistencySvc' ].OutputFile = ''
962 formatHead = '[Worker-%i] '%(self.nodeID)
963 self.config['MessageSvc'].Format = formatHead+'% F%18W%S%7W%R%T %0W%M'
964
965 for key, lst in self.writerDict.iteritems() :
966 self.log.info( 'Writer Type : %s\t : %i'%(key, len(lst)) )
967
968 for m in self.writerDict[ "tuples" ] :
969 # rename Tuple output file with an appendix
970 # based on worker id, for merging later
971 newName = m.getNewName( '.', '.w%i.'%(self.nodeID) )
972 self.config[ m.key ].Output = newName
973
974 # Suppress INFO Output for all but Worker-0
975 #if self.nodeID == 0 :
976 # pass
977 #else :
978 # self.config[ 'MessageSvc' ].OutputLevel = ERROR
979
980 if self.app == "Gauss":
981 try:
982 if "ToolSvc.EvtCounter" not in self.config:
983 from Configurables import EvtCounter
984 counter = EvtCounter()
985 else:
986 counter = self.config["ToolSvc.EvtCounter"]
987 counter.UseIncident = False
988 except:
989 # ignore errors when trying to change the configuration of the EvtCounter
990 self.log.warning('Cannot configure EvtCounter')

## Member Data Documentation

GaudiMP.GMPBase.Worker.app

Definition at line 979 of file GMPBase.py.

GaudiMP.GMPBase.Worker.currentEvent

Definition at line 1085 of file GMPBase.py.

GaudiMP.GMPBase.Worker.eventOutput

Definition at line 949 of file GMPBase.py.

GaudiMP.GMPBase.Worker.filerecordsAgent

Definition at line 1003 of file GMPBase.py.

GaudiMP.GMPBase.Worker.firstEvTime

Definition at line 1067 of file GMPBase.py.

GaudiMP.GMPBase.Worker.nIn

Definition at line 1050 of file GMPBase.py.

GaudiMP.GMPBase.Worker.tTime

Definition at line 1100 of file GMPBase.py.

GaudiMP.GMPBase.Worker.vetoAlgs

Definition at line 946 of file GMPBase.py.

GaudiMP.GMPBase.Worker.writerDict

Definition at line 944 of file GMPBase.py.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiMP/python/GaudiMP/GMPBase.py