Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
python.trfValidation.eventMatch Class Reference

Small class used for vailiadating event counts between input and output files. More...

Inheritance diagram for python.trfValidation.eventMatch:
Collaboration diagram for python.trfValidation.eventMatch:

Public Member Functions

def __init__ (self, executor, eventCountConf=None, eventCountConfOverwrite=False)
 check in- and output event counts More...
 
def eventCount (self)
 
def configureCheck (self, override=False)
 Setup the parameters needed to define particular checks. More...
 
def decide (self)
 Perform an event count check. More...
 

Private Attributes

 _executor
 
 _eventCount
 
 _eventCountConf
 
 _inEventDict
 
 _outEventDict
 
 _skipEvents
 
 _maxEvents
 
 _evAccEff
 

Detailed Description

Small class used for vailiadating event counts between input and output files.

Definition at line 912 of file trfValidation.py.

Constructor & Destructor Documentation

◆ __init__()

def python.trfValidation.eventMatch.__init__ (   self,
  executor,
  eventCountConf = None,
  eventCountConfOverwrite = False 
)

check in- and output event counts

Class to verify that in- and output event counts are in a reasonable relationship.

Parameters

Definition at line 921 of file trfValidation.py.

921  def __init__(self, executor, eventCountConf=None, eventCountConfOverwrite=False):
922  self._executor = executor
923  self._eventCount = None
924 
925 
936  simEventEff = 0.995
937  self._eventCountConf = {}
938  self._eventCountConf['EVNT'] = {'EVNT_MRG':"match", "HITS": simEventEff, "EVNT_TR": "filter", "DAOD_TRUTH*" : "match"}
939  self._eventCountConf['EVNT_TR'] = {'HITS': simEventEff}
940  self._eventCountConf['HITS'] = {'RDO':"match", 'HITS_RSM': simEventEff, "HITS_MRG":"match", 'HITS_FILT': simEventEff, "RDO_FILT": "filter", "DAOD_TRUTH*" : "match", "HIST_SIM" : "match"}
941  self._eventCountConf['BS'] = {'ESD': "match", 'DRAW_*':"filter", 'NTUP_*':"filter", "BS_MRG":"match", 'DESD*': "filter", 'AOD':"match", 'DAOD*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
942  self._eventCountConf['RDO*'] = {'ESD': "match", 'DRAW_*':"filter", 'NTUP_*':"filter", "RDO_MRG":"match", "RDO_TRIG":"match", 'AOD':"match", 'DAOD*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match", "HIST_DIGI":"match"}
943  self._eventCountConf['ESD'] = {'ESD_MRG': "match", 'AOD':"match", 'DESD*':"filter", 'DAOD_*':"filter", 'NTUP_*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
944  self._eventCountConf['AOD'] = {'AOD_MRG' : "match", 'TAG':"match", "NTUP_*":"filter", "DAOD_*":"filter", 'NTUP_*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
945  self._eventCountConf['AOD_MRG'] = {'TAG':"match"}
946  self._eventCountConf['DAOD_*'] = {'DAOD_*_MRG' : "match"}
947  self._eventCountConf['TAG'] = {'TAG_MRG': "match"}
948  self._eventCountConf['HIST'] = {'HIST_MRG': "match"}
949  self._eventCountConf['NTUP_COMMON'] = {'DNTUP*': "filter"}
950  self._eventCountConf['NTUP_*'] = {'NTUP_*_MRG': "match"}
951  # Next one comprises special data type names for smart merging of AthenaMP worker outputs
952  self._eventCountConf['POOL_MRG_INPUT'] = {'POOL_MRG_OUTPUT': "match"}
953 
954 
955  if eventCountConf:
956  if eventCountConfOverwrite is True:
957  self._eventCountConf = eventCountConf
958  else:
959  self._eventCountConf.update(eventCountConf)
960 
961  msg.debug('Event count check configuration is: {0}'.format(self._eventCountConf))
962  if hasattr(self._executor, 'name'):
963  msg.debug('Event count check ready for executor {0}'.format(self._executor.name))
964 
965  if self._executor is not None:
966  self.configureCheck(override=False)
967 

Member Function Documentation

◆ configureCheck()

def python.trfValidation.eventMatch.configureCheck (   self,
  override = False 
)

Setup the parameters needed to define particular checks.

Parameters
overrideIf set then configure the checks using this dictionary, which needs to have keys inEventDict, outEventDict, skipEvents, maxEvents, evAccEff
Note
Default is to configure the checks from the associated executor

Definition at line 976 of file trfValidation.py.

976  def configureCheck(self, override=False):
977  if override:
978  msg.info('Overriding check configuration with: {0}'.format(override))
979  self._inEventDict = override['inEventDict']
980  self._outEventDict = override['outEventDict']
981  self._skipEvents = override['skipEvents']
982  self._maxEvents = override['maxEvents']
983  self._evAccEff = override['evAccEff']
984  else:
985  # Input data from executor
986  self._inEventDict = {}
987  for dataTypeName in self._executor.input:
988  try:
989  self._inEventDict[dataTypeName] = self._executor.conf.dataDictionary[dataTypeName].nentries
990  msg.debug('Input data type {0} has {1} events'.format(dataTypeName, self._inEventDict[dataTypeName]))
991  except KeyError:
992  msg.warning('Found no dataDictionary entry for input data type {0}'.format(dataTypeName))
993 
994  # Output data from executor
995  self._outEventDict = {}
996  for dataTypeName in self._executor.output:
997  try:
998  self._outEventDict[dataTypeName] = self._executor.conf.dataDictionary[dataTypeName].nentries
999  msg.debug('Output data type {0} has {1} events'.format(dataTypeName, self._outEventDict[dataTypeName]))
1000  except KeyError:
1001  msg.warning('Found no dataDictionary entry for output data type {0}'.format(dataTypeName))
1002 
1003  # Find if we have a skipEvents applied
1004  if "skipEvents" in self._executor.conf.argdict:
1005  self._skipEvents = self._executor.conf.argdict['skipEvents'].returnMyValue(exe=self._executor)
1006  else:
1007  self._skipEvents = None
1008 
1009  # Find if we have a maxEvents applied
1010  if "maxEvents" in self._executor.conf.argdict:
1011  self._maxEvents = self._executor.conf.argdict['maxEvents'].returnMyValue(exe=self._executor)
1012  if self._maxEvents == -1:
1013  self._maxEvents = None
1014  else:
1015  self._maxEvents = None
1016 
1017  # Executor substeps handling
1018  if self._executor.conf.totalExecutorSteps > 1 and self._executor.conf.executorStep < self._executor.conf.totalExecutorSteps - 1:
1019  executorEventCounts, executorEventSkips = getExecutorStepEventCounts(self._executor)
1020  self._maxEvents = executorEventCounts[self._executor.conf.executorStep]
1021  self._skipEvents = executorEventSkips[self._executor.conf.executorStep]
1022 
1023  # Global eventAcceptanceEfficiency set?
1024  if "eventAcceptanceEfficiency" in self._executor.conf.argdict:
1025  self._evAccEff = self._executor.conf.argdict['eventAcceptanceEfficiency'].returnMyValue(exe=self._executor)
1026  if (self._evAccEff is None):
1027  self._evAccEff = 0.99
1028  else:
1029  self._evAccEff = 0.99
1030 
1031  msg.debug("Event check conf: {0} {1}, {2}, {3}, {4}".format(self._inEventDict, self._outEventDict, self._skipEvents,
1032  self._maxEvents, self._evAccEff))
1033 
1034 

◆ decide()

def python.trfValidation.eventMatch.decide (   self)

Perform an event count check.

Definition at line 1036 of file trfValidation.py.

1036  def decide(self):
1037  # We have all that we need to proceed: input and output data, skip and max events plus any efficiency factor
1038  # So loop over the input and output data and make our checks
1039  for inData, neventsInData in self._inEventDict.items():
1040  if not isinstance(neventsInData, int):
1041  msg.warning('File size metadata for {inData} was not countable, found {neventsInData}. No event checks possible for this input data.'.format(inData=inData, neventsInData=neventsInData))
1042  continue
1043  if inData in self._eventCountConf:
1044  inDataKey = inData
1045  else:
1046  # OK, try a glob match in this case (YMMV)
1047  matchedInData = False
1048  for inDataKey in self._eventCountConf:
1049  if fnmatch.fnmatch(inData, inDataKey):
1050  msg.info("Matched input data type {inData} to {inDataKey} by globbing".format(inData=inData, inDataKey=inDataKey))
1051  matchedInData = True
1052  break
1053  if not matchedInData:
1054  msg.warning('No defined event count match for {inData} -> {outData}, so no check(s) possible in this case.'.format(inData=inData, outData=list(self._outEventDict)))
1055  continue
1056 
1057  # Now calculate the expected number of processed events for this input
1058  expectedEvents = neventsInData
1059  if self._skipEvents is not None and self._skipEvents > 0:
1060  expectedEvents -= self._skipEvents
1061  if expectedEvents < 0:
1062  msg.warning('skipEvents was set higher than the input events in {inData}: {skipEvents} > {neventsInData}. This is not an error, but it is not a normal configuration. Expected events is now 0.'.format(inData=inData, skipEvents=self._skipEvents, neventsInData=neventsInData))
1063  expectedEvents = 0
1064  if self._maxEvents is not None:
1065  if expectedEvents < self._maxEvents:
1066  if self._skipEvents is not None:
1067  msg.warning('maxEvents was set higher than inputEvents-skipEvents for {inData}: {maxEvents} > {neventsInData}-{skipEvents}. This is not an error, but it is not a normal configuration. Expected events remains {expectedEvents}.'.format(inData=inData, maxEvents=self._maxEvents, neventsInData=neventsInData, skipEvents=self._skipEvents, expectedEvents=expectedEvents))
1068  else:
1069  msg.warning('maxEvents was set higher than inputEvents for {inData}: {maxEvents} > {neventsInData}. This is not an error, but it is not a normal configuration. Expected events remains {expectedEvents}.'.format(inData=inData, maxEvents=self._maxEvents, neventsInData=neventsInData, expectedEvents=expectedEvents))
1070  else:
1071  expectedEvents = self._maxEvents
1072  msg.debug('Expected number of processed events for {0} is {1}'.format(inData, expectedEvents))
1073 
1074  # Loop over output data - first find event count configuration
1075  for outData, neventsOutData in self._outEventDict.items():
1076  if not isinstance(neventsOutData, int):
1077  msg.warning('File size metadata for {outData} was not countable, found "{neventsOutData}". No event checks possible for this output data.'.format(outData=outData, neventsOutData=neventsOutData))
1078  continue
1079  if outData in self._eventCountConf[inDataKey]:
1080  checkConf = self._eventCountConf[inDataKey][outData]
1081  outDataKey = outData
1082  else:
1083  # Look for glob matches
1084  checkConf = None
1085  for outDataKey, outDataConf in self._eventCountConf[inDataKey].items():
1086  if fnmatch.fnmatch(outData, outDataKey):
1087  msg.info('Matched output data type {outData} to {outDatakey} by globbing'.format(outData=outData, outDatakey=outDataKey))
1088  outDataKey = outData
1089  checkConf = outDataConf
1090  break
1091  if not checkConf:
1092  msg.warning('No defined event count match for {inData} -> {outData}, so no check possible in this case.'.format(inData=inData, outData=outData))
1093  continue
1094  msg.debug('Event count check for {inData} to {outData} is {checkConf}'.format(inData=inData, outData=outData, checkConf=checkConf))
1095 
1096  # Do the check for thsi input/output combination
1097  if checkConf == 'match':
1098  # We need an exact match
1099  if neventsOutData == expectedEvents:
1100  msg.info("Event count check for {inData} to {outData} passed: all processed events found ({neventsOutData} output events)".format(inData=inData, outData=outData, neventsOutData=neventsOutData))
1101  else:
1102  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1103  'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1104  elif checkConf == 'filter':
1105  if neventsOutData <= expectedEvents and neventsOutData >= 0:
1106  msg.info("Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1107  else:
1108  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1109  'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from 0 to {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1110  elif checkConf == 'minEff':
1111  if neventsOutData >= int(expectedEvents * self._evAccEff) and neventsOutData <= expectedEvents:
1112  msg.info("Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1113  else:
1114  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1115  'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1116  minEvents=int(expectedEvents * self._evAccEff), expectedEvents=expectedEvents))
1117  elif isinstance(checkConf, (float, int)):
1118  checkConf = float(checkConf)
1119  if checkConf < 0.0 or checkConf > 1.0:
1120  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1121  'Event count check for {inData} to {outData} is misconfigured: the efficiency factor of {eff} is not between 0 and 1.'.format(inData=inData, outData=outData, eff=checkConf))
1122  if neventsOutData >= int(expectedEvents * checkConf) and neventsOutData <= expectedEvents:
1123  msg.info("Event count check for {inData} to {outData} passed: found ({neventsOutData} output events selected from {expectedEvents} processed events)".format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1124  else:
1125  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1126  'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1127  minEvents=int(expectedEvents * checkConf), expectedEvents=expectedEvents))
1128  else:
1129  raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1130  'Unrecognised event count configuration for {inData} to {outData}: "{conf}" is not known'.format(inData=inData, outData=outData, conf=checkConf))
1131  self._eventCount = expectedEvents
1132  return True

◆ eventCount()

def python.trfValidation.eventMatch.eventCount (   self)

Definition at line 969 of file trfValidation.py.

969  def eventCount(self):
970  return self._eventCount
971 

Member Data Documentation

◆ _evAccEff

python.trfValidation.eventMatch._evAccEff
private

Definition at line 983 of file trfValidation.py.

◆ _eventCount

python.trfValidation.eventMatch._eventCount
private

Definition at line 923 of file trfValidation.py.

◆ _eventCountConf

python.trfValidation.eventMatch._eventCountConf
private
Note
This double dictionary is formed of INPUT data, then a dictionary of the expected event counts from different output data types. If there is no exact match for the output datatype then globbing matches are allowed. Thus self._eventCountConf[input][output] gives the test for input -> output. The dictionary recognises the following options:
  • match : exact match of input and output events, n_in = n_out
  • filter : any event count from 0 up to input events is ok, 0 <= n_out <= n_in
  • minEff : any event count from n_in * eventAcceptanceEfficiency <= n_out <= n_in
  • float in range [0,1] : same as minEff with this efficiency factor For any case where the output events can be less than the input ones an integer conversion is applied, so the result is rounded down. i.e., 1 * 0.5 -> 0.

Definition at line 937 of file trfValidation.py.

◆ _executor

python.trfValidation.eventMatch._executor
private

Definition at line 922 of file trfValidation.py.

◆ _inEventDict

python.trfValidation.eventMatch._inEventDict
private

Definition at line 979 of file trfValidation.py.

◆ _maxEvents

python.trfValidation.eventMatch._maxEvents
private

Definition at line 982 of file trfValidation.py.

◆ _outEventDict

python.trfValidation.eventMatch._outEventDict
private

Definition at line 980 of file trfValidation.py.

◆ _skipEvents

python.trfValidation.eventMatch._skipEvents
private

Definition at line 981 of file trfValidation.py.


The documentation for this class was generated from the following file:
vtune_athena.format
format
Definition: vtune_athena.py:14
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.trfExeStepTools.getExecutorStepEventCounts
def getExecutorStepEventCounts(executor, argdict=None)
Definition: trfExeStepTools.py:44
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65