| # 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 | Private Attributes | List of all members
GaudiMP.pTools.FileRecordsAgent Class Reference

## Public Member Functions
def | __init__
def | localCmp
def | SendFileRecords
def | Receive
def | Rebuild
def | MergeFSRobject
def | ProcessTimeSpanFSR
def | ProcessEventCountFSR
def | MergeLumiFSR

## Public Attributes
| fsr
| q
| log
| objectsIn
| objectsOut

## Private Attributes
| _gmpc

## Detailed Description

Definition at line 206 of file pTools.py.

## Constructor & Destructor Documentation

def GaudiMP.pTools.FileRecordsAgent.__init__ | ( |  | self,
|  |  | gmpComponent
| ) |  |

Definition at line 207 of file pTools.py.

207
208 def __init__( self, gmpComponent ) :
209 self._gmpc = gmpComponent
210 self.fsr = self._gmpc.fsr
211 self.q = self._gmpc.fq
212 self.log = self._gmpc.log
213 self.objectsIn = [] # used for collecting FSR store objects
214 self.objectsOut = []

## Member Function Documentation

def GaudiMP.pTools.FileRecordsAgent.localCmp | ( |  | self,
|  |  | tupA,
|  |  | tupB
| ) |  |

Definition at line 215 of file pTools.py.

215
216 def localCmp( self, tupA, tupB ) :
217 # sort tuples by a particular element
218 # for the sort() method
219 ind = 0
220 valA = tupA[ind]
221 valB = tupB[ind]
222 if valA<valB : return -1
223 elif valA>valB : return 1
224 else : return 0
225

def GaudiMP.pTools.FileRecordsAgent.MergeFSRobject | ( |  | self,
|  |  | sourceNode,
|  |  | path,
|  |  | ob
| ) |  |

Definition at line 349 of file pTools.py.

349
350 def MergeFSRobject( self, sourceNode, path, ob ) :
351 # Merge Non-Empty Keyed Container from Worker>0
352 if path == '/FileRecords/TimeSpanFSR' :
353 # TimeSpanFSR is a straightforward case
354 self.ProcessTimeSpanFSR( path, ob )
355 elif path == '/FileRecords/EventCountFSR' :
356 # Event Counter is also easy
357 self.ProcessEventCountFSR( path, ob )
358 # now other cases may not be so easy...
359 elif "KeyedContainer" in ob.__class__.__name__ :
360 # Keyed Container of LumiFSRs : extract and re-register
361 # self.ProcessLumiFSR( path, ob )
362 if "LumiFSR" in ob.__class__.__name__ :
363 self.MergeLumiFSR( path, ob )
364 else:
365 self.log.info("Skipping Merge of Keyed Container %s for %s"\
366 %(ob.__class__.__name__,path))

def GaudiMP.pTools.FileRecordsAgent.MergeLumiFSR | ( |  | self,
|  |  | path,
|  |  | keyedC
| ) |  |

Definition at line 393 of file pTools.py.

393
394 def MergeLumiFSR( self, path, keyedC ) :
395 from ROOT import string
396 # Fetch the first lumi
397 keyedContainer = self.fsr.retrieveObject(path)
398 # The LumiFSR KeyedContainers only have one object
399 assert keyedContainer.numberOfObjects() == 1
400 l = keyedContainer.containedObject(0)
401 baseLumi = LumiFSR( l )
402 # Now deal with the argument Non-empty Keyed Container of LumiFSRs
403 nCont = keyedC.numberOfObjects()
404 for i in xrange(nCont) :
405 obj = keyedC.containedObject(i)
406 nextLumi = LumiFSR( obj )
407 baseLumi.merge( nextLumi )
408 # Now Rebuild and ReRegister
409 newLumi = gbl.LHCb.LumiFSR()
410 for r in baseLumi.runs :
411 newLumi.addRunNumber( r )
412 for f in baseLumi.files :
413 newLumi.addFileID( string(f) )
414 for k in baseLumi.keys :
415 increment, integral = baseLumi.info[k]
416 newLumi.addInfo(k, increment, integral)
417 # clear existing Keyed Container
418 self.fsr[path].clear()
419 # Add newly merged lumiFSR
420 self.fsr[path].add(newLumi)
421 return SUCCESS
422
423 # =============================================================================

def GaudiMP.pTools.FileRecordsAgent.ProcessEventCountFSR | ( |  | self,
|  |  | path,
|  |  | ob
| ) |  |

Definition at line 389 of file pTools.py.

389
390 def ProcessEventCountFSR( self, path, ob ) :
391 self.log.debug('Event Count Input Addition')
392 self.fsr[path].setInput( self.fsr[path].input()+ob.input() )

def GaudiMP.pTools.FileRecordsAgent.ProcessTimeSpanFSR | ( |  | self,
|  |  | path,
|  |  | ob
| ) |  |

Definition at line 367 of file pTools.py.

367
368 def ProcessTimeSpanFSR( self, path, ob ) :
369 ob2 = self.fsr.retrieveObject( path )
370 if ob.containedObjects().size() :
371 sz = ob.containedObjects().size()
372 cob = ob2.containedObjects()[0]
373 min = cob.earliest()
374 max = cob.latest()
375 for j in xrange( sz ) :
376 cob = ob.containedObjects()[j]
377 self.log.debug( 'Adding TimeSpanFSR' )
378 if cob.earliest() < min:
379 min = cob.earliest()
380 if cob.latest() > max:
381 max = cob.latest()
382 # this is annoying: it has to be rebuilt, without a key & added
383 continue
384 tsfsr = gbl.LHCb.TimeSpanFSR()
385 tsfsr.setEarliest( min )
386 tsfsr.setLatest( max )
387 self.fsr[path].clear()
388 self.fsr[path].add( tsfsr )

def GaudiMP.pTools.FileRecordsAgent.Rebuild | ( |  | self | ) |

Definition at line 305 of file pTools.py.

305
306 def Rebuild( self ) :
307 # objects is a list of (path, serializedObject) tuples
308 for sourceNode, path, serialob in self.objectsIn :
309 self.log.debug('Working with %s'%(path))
310 ob = pickle.loads(serialob)
311 if hasattr( ob, 'update' ) :
312 ob.update()
313 if hasattr( ob, 'numberOfObjects' ) :
314 nCont = ob.numberOfObjects()
315 self.log.debug( '\t %s has containedObjects : %i'%(type(ob).__name__, nCont) )
316 if sourceNode == 0 :
317 self.log.debug('Registering Object to : %s'%(path))
318 self.fsr.registerObject( path, ob )
319 else :
320 self.log.debug('Merging Object to : %s'%(path))
321 self.MergeFSRobject( sourceNode, path, ob )
322 # As RecordStream has been split into Worker and Writer parts, the
323 # count for output is wrong... fix that here, as every event received
324 # by the writer is written (validation testing occurs on the worker)
325
326 self.log.info('FSR Store Rebuilt. Correcting EventCountFSR')
327 if bool( self.fsr._idp ) : # There might not be an FSR stream (Gauss)
328 ecount = '/FileRecords/EventCountFSR'
329 if self.fsr[ecount] :
330 self.fsr[ecount].setOutput( self._gmpc.nIn )
331 self.log.info( 'Event Counter Output set : %s : %i'\
332 %(ecount, self.fsr[ecount].output()) )
333 # Do some reporting
334 self.log.debug('FSR store reconstructed!')
335 lst = self.fsr.getHistoNames()
336 if lst :
337 for l in lst :
338 ob = self.fsr.retrieveObject(l)
339 if hasattr( ob, 'configureDirectAccess' ) :
340 ob.configureDirectAccess()
341 if hasattr( ob, 'containedObjects' ) :
342 # if ob.numberOfObjects() :
343 self.log.debug('\t%s (cont. objects : %i)'\
344 %(l, ob.numberOfObjects()))
345 else :
346 self.log.debug('\t%s'%(l))
347 self.log.info('FSR Store fully rebuilt.')
348 return SUCCESS

def GaudiMP.pTools.FileRecordsAgent.Receive | ( |  | self | ) |

Definition at line 285 of file pTools.py.

285
286 def Receive( self ) :
287 # Receive contents of all Workers FileRecords Transient Stores
288 self.log.info('Receiving FSR store data...')
289 nc = self._gmpc.nWorkers
290 while nc > 0 :
291 objects = self.q.get( )
292 if objects == 'END_FSR' :
293 nc -= 1
294 continue
295 if nc==0 :
296 break
297 # but if it's regular objects...
298 for o in objects :
299 self.objectsIn.append(o)
300 # Now sort it by which worker it came from
301 # an object is : (nodeID, path, pickledObject)
302 self.objectsIn.sort(cmp=self.localCmp)
303 self.log.info('All FSR data received')
304 return SUCCESS

def GaudiMP.pTools.FileRecordsAgent.SendFileRecords | ( |  | self | ) |

Definition at line 226 of file pTools.py.

226
227 def SendFileRecords( self ) :
228 # send the FileRecords data as part of finalisation
229
230 # Take Care of FileRecords!
231 # There are two main things to consider here
232 # 1) The DataObjects in the FileRecords Transient Store
233 # 2) The fact that they are Keyed Containers, containing other objects
234 #
235 # The Lead Worker, nodeID=0, sends everything in the FSR store, as
236 # a completeness guarantee,
237 #
238 # send in form ( nodeID, path, object)
239 self.log.info('Sending FileRecords...')
240 lst = self.fsr.getHistoNames()
241
242 # Check Validity
243 if not lst :
244 self.log.info('No FileRecords Data to send to Writer.')
245 self.q.put( 'END_FSR' )
246 return SUCCESS
247
248 # no need to send the root node
249 if '/FileRecords' in lst : lst.remove('/FileRecords')
250
251 for l in lst :
252 o = self.fsr.retrieveObject( l )
253 if hasattr(o, "configureDirectAccess") :
254 o.configureDirectAccess()
255 # lead worker sends everything, as completeness guarantee
256 if self._gmpc.nodeID == 0 :
257 self.objectsOut.append( (0, l, pickle.dumps(o)) )
258 else :
259 # only add the Event Counter
260 # and non-Empty Keyed Containers (ignore empty ones)
261 if l == '/FileRecords/EventCountFSR' :
262 tup = (self._gmpc.nodeID, l, pickle.dumps(o))
263 self.objectsOut.append( tup )
264 else :
265 # It's a Keyed Container
266 assert "KeyedContainer" in o.__class__.__name__
267 nObjects = o.numberOfObjects()
268 if nObjects :
269 self.log.debug("Keyed Container %s with %i objects"\
270 %(l, nObjects))
271 tup = (self._gmpc.nodeID, l, pickle.dumps(o))
272 self.objectsOut.append( tup )
273 self.log.debug('Done with FSR store, just to send to Writer.')
274
275 if self.objectsOut :
276 self.log.debug('%i FSR objects to Writer'%(len(self.objectsOut)))
277 for ob in self.objectsOut :
278 self.log.debug('\t%s'%(ob[0]))
279 self.q.put( self.objectsOut )
280 else :
281 self.log.info('Valid FSR Store, but no data to send to Writer')
282 self.log.info('SendFSR complete')
283 self.q.put( 'END_FSR' )
284 return SUCCESS

## Member Data Documentation

GaudiMP.pTools.FileRecordsAgent._gmpc
| private

Definition at line 208 of file pTools.py.

GaudiMP.pTools.FileRecordsAgent.fsr

Definition at line 209 of file pTools.py.

GaudiMP.pTools.FileRecordsAgent.log

Definition at line 211 of file pTools.py.

GaudiMP.pTools.FileRecordsAgent.objectsIn

Definition at line 212 of file pTools.py.

GaudiMP.pTools.FileRecordsAgent.objectsOut

Definition at line 213 of file pTools.py.

GaudiMP.pTools.FileRecordsAgent.q

Definition at line 210 of file pTools.py.

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

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