8 from AthenaCommon 
import Logging
 
   14     def __init__ ( self, name = 'evgenLogParser', **kw ):
 
   15         self.
msg = Logging.logging.getLogger(name)
 
   21         self.
TestHepMCDict = {
'p':0,
'f':0,
'pfline':
None,
'rate':{},
'notinc':[],
'rline':
None,
'effline':
None,
'lastpf':0}
 
   23         self.
FilterSeqDict = {
'num':0,
'den':0,
'wnum':0,
'wden':0,
'line':
None,
'wline':
None}
 
   25         self.
MetadataDict = {
'sumOfPosWeights':0.,
'sumOfNegWeights':0.,
'sumOfSqrWeights':0.,
 
   26                              'sumOfPosWeightsNoFilter':0.,
'sumOfNegWeightsNoFilter':0.,
'sumOfSqrWeightsNoFilter':0.,
 
   27                              'xsec_holder':0.,
'xsec_weight':0.,
'xsec_sum':0.}
 
   31         ''' Function to process a log line and keep what's needed for final reporting''' 
   34         if "PerfMonMTSvc" in line:
 
   38         if 'FixHepMC' in line 
and 'INFO Removed' in line:
 
   40             if 'because of loops' in line:
 
   43             reason = line.split(
'particles')[1]
 
   50                 self.
FixHepMCDict[
'lines'][reason] = [ line.split(
'Removed')[0] , line.split(
'particles')[1] ]
 
   52         elif 'Py:EvgenFilterSeq' in line:
 
   54             if 'Weighted Filter Efficiency' in line:
 
   56                 numbers = re.findall(
r'[\d.]+',line)
 
   61             elif 'Filter Efficiency' in line:
 
   63                 numbers = re.findall(
r'[\d.]+',line)
 
   70         elif 'TestHepMC' in line 
and 'Event' in line:
 
   71             if 'Events passed' in line:
 
   73                 numbers = re.findall(
r'[\d.]+',line)
 
   82                 reason = line.split(
'Event rate')[1].
split(
'=')[0]
 
   86                     if 'not included in test efficiency' in line:
 
   89                 my_perc = 
float( line.split(
'=')[1].
split(
'%')[0] )
 
   94         elif 'TestHepMC' in line 
and 'Efficiency' in line:
 
   99         elif 'MetaData:' in line:
 
  101             field = line.split(
'MetaData:')[1].
split(
'=')[0].strip()
 
  106             if field == 
'cross-section (nb)':
 
  110             elif field == 
'sumOfPosWeightsNoFilter':
 
  113             elif field == 
'sumOfNegWeightsNoFilter':
 
  114                 my_negw = 
float( line.split(
'=')[1] )
 
  119         ''' Function to print final statistics grabbed from the logs''' 
  122             self.
msg.
debug(
'Not running MP, nothing to do')
 
  126         self.
msg.
info(f
'Printing final summary statistics from {self.isMP} MP workers')
 
  129             print(f
"{self.FixHepMCDict['lines'][reason][0]}Removed {self.FixHepMCDict['reasons'][reason]} of {self.FixHepMCDict['denominator']} particles {self.FixHepMCDict['lines'][reason][1]}")
 
  131         print(f
"{self.TestHepMCDict['pfline']}= {self.TestHepMCDict['p']}, Events Failed = {self.TestHepMCDict['f']}")
 
  140             print(f
"{self.TestHepMCDict['rline']}Event rate {rate} = {pct}%{' (not included in test efficiency)' if rate in self.TestHepMCDict['notinc'] else ''}")
 
  145         print(f
"{self.TestHepMCDict['effline']}= {final_eff*100.}%")
 
  148         print(f
"{self.FilterSeqDict['line']} = {eff} [{self.FilterSeqDict['num']} / {self.FilterSeqDict['den']}]")
 
  150         print(f
"{self.FilterSeqDict['wline']} = {eff} [{self.FilterSeqDict['wnum']} / {self.FilterSeqDict['wden']}]")
 
  154         ''' Update the metadata based on the logfile information''' 
  157             self.
msg.
debug(
'Not running MP, nothing to do')
 
  165         self.
msg.
info(f
'cross-section (nb)= {my_xsec:e}')
 
  166         metadata[
'cross-section (nb)'] = f
'{my_xsec:e}' 
  168         self.
msg.
info(
'Updated metadata:')
 
  171             if field 
in metadata:
 
  172                 self.
msg.
info(f
'{field} = {self.MetadataDict[field]:e}')
 
  173                 metadata[field] = f
'{self.MetadataDict[field]:e}' 
  178         self.
msg.
info(f
'GenFiltEff = {geneff:e}')
 
  179         if 'GenFiltEff' in metadata:
 
  180             metadata[
'GenFiltEff'] = f
'{geneff:e}'