ATLAS Offline Software
Loading...
Searching...
No Matches
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

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

Protected Attributes

 _executor = executor
 _eventCount = None
dict _eventCountConf = {}
dict _inEventDict = override['inEventDict']
dict _outEventDict = override['outEventDict']
 _skipEvents = override['skipEvents']
int _maxEvents = override['maxEvents']
float _evAccEff = override['evAccEff']

Detailed Description

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

Definition at line 978 of file trfValidation.py.

Constructor & Destructor Documentation

◆ __init__()

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

c executor eventCountConf instance for this check

Parameters

c eventCountConf dictionary to replace or append to default, see code for details

Parameters

c eventCountConfOver write Replace rather than append eventCountConf (Default: False) Takes efficiencies into account. All data is taken from _trf dict

Definition at line 987 of file trfValidation.py.

987 def __init__(self, executor, eventCountConf=None, eventCountConfOverwrite=False):
988 self._executor = executor
989 self._eventCount = None
990
991
1002 simEventEff = 0.995
1003 self._eventCountConf = {}
1004 self._eventCountConf['EVNT'] = {'EVNT_MRG':"match", "HITS": simEventEff, "EVNT_TR": "filter", "DAOD_TRUTH*" : "match"}
1005 self._eventCountConf['EVNT_TR'] = {'HITS': simEventEff}
1006 self._eventCountConf['HITS'] = {'RDO':"match", 'HITS_RSM': simEventEff, "HITS_MRG":"match", 'HITS_FILT': simEventEff, "RDO_FILT": "filter", "DAOD_TRUTH*" : "match", "HIST_SIM" : "match"}
1007 self._eventCountConf['BS'] = {'ESD': "match", 'DRAW_*':"filter", 'NTUP_*':"filter", "BS_MRG":"match", 'DESD*': "filter", 'AOD':"match", 'DAOD*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
1008 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"}
1009 self._eventCountConf['ESD'] = {'ESD_MRG': "match", 'AOD':"match", 'DESD*':"filter", 'DAOD_*':"filter", 'NTUP_*':"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
1010 self._eventCountConf['AOD'] = {'AOD_MRG' : "match", 'TAG':"match", "NTUP_*":"filter", "DAOD_*":"filter", "DAOD_PHYS":"match", "DAOD_PHYSLITE":"match"}
1011 self._eventCountConf['AOD_MRG'] = {'TAG':"match"}
1012 self._eventCountConf['DAOD_*'] = {'DAOD_*_MRG' : "match"}
1013 self._eventCountConf['TAG'] = {'TAG_MRG': "match"}
1014 self._eventCountConf['HIST'] = {'HIST_MRG': "match"}
1015 self._eventCountConf['NTUP_COMMON'] = {'DNTUP*': "filter"}
1016 self._eventCountConf['NTUP_*'] = {'NTUP_*_MRG': "match"}
1017 # Next one comprises special data type names for smart merging of AthenaMP worker outputs
1018 self._eventCountConf['POOL_MRG_INPUT'] = {'POOL_MRG_OUTPUT': "match"}
1019
1020
1021 if eventCountConf:
1022 if eventCountConfOverwrite is True:
1023 self._eventCountConf = eventCountConf
1024 else:
1025 self._eventCountConf.update(eventCountConf)
1026
1027 msg.debug('Event count check configuration is: {0}'.format(self._eventCountConf))
1028 if hasattr(self._executor, 'name'):
1029 msg.debug('Event count check ready for executor {0}'.format(self._executor.name))
1030
1031 if self._executor is not None:
1032 self.configureCheck(override=False)
1033

Member Function Documentation

◆ configureCheck()

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 1042 of file trfValidation.py.

1042 def configureCheck(self, override=False):
1043 if override:
1044 msg.info('Overriding check configuration with: {0}'.format(override))
1045 self._inEventDict = override['inEventDict']
1046 self._outEventDict = override['outEventDict']
1047 self._skipEvents = override['skipEvents']
1048 self._maxEvents = override['maxEvents']
1049 self._evAccEff = override['evAccEff']
1050 else:
1051 # Input data from executor
1052 self._inEventDict = {}
1053 for dataTypeName in self._executor.input:
1054 try:
1055 self._inEventDict[dataTypeName] = self._executor.conf.dataDictionary[dataTypeName].nentries
1056 msg.debug('Input data type {0} has {1} events'.format(dataTypeName, self._inEventDict[dataTypeName]))
1057 except KeyError:
1058 msg.warning('Found no dataDictionary entry for input data type {0}'.format(dataTypeName))
1059
1060 # Output data from executor
1061 self._outEventDict = {}
1062 for dataTypeName in self._executor.output:
1063 try:
1064 self._outEventDict[dataTypeName] = self._executor.conf.dataDictionary[dataTypeName].nentries
1065 msg.debug('Output data type {0} has {1} events'.format(dataTypeName, self._outEventDict[dataTypeName]))
1066 except KeyError:
1067 msg.warning('Found no dataDictionary entry for output data type {0}'.format(dataTypeName))
1068
1069 # Find if we have a skipEvents applied
1070 if "skipEvents" in self._executor.conf.argdict:
1071 self._skipEvents = self._executor.conf.argdict['skipEvents'].returnMyValue(exe=self._executor)
1072 else:
1073 self._skipEvents = None
1074
1075 # Find if we have a maxEvents applied
1076 if "maxEvents" in self._executor.conf.argdict:
1077 self._maxEvents = self._executor.conf.argdict['maxEvents'].returnMyValue(exe=self._executor)
1078 if self._maxEvents == -1:
1079 self._maxEvents = None
1080 else:
1081 self._maxEvents = None
1082
1083 # Executor substeps handling
1084 if self._executor.conf.totalExecutorSteps > 1 and self._executor.conf.executorStep < self._executor.conf.totalExecutorSteps - 1:
1085 executorEventCounts, executorEventSkips = getExecutorStepEventCounts(self._executor)
1086 self._maxEvents = executorEventCounts[self._executor.conf.executorStep]
1087 self._skipEvents = executorEventSkips[self._executor.conf.executorStep]
1088
1089 # Global eventAcceptanceEfficiency set?
1090 if "eventAcceptanceEfficiency" in self._executor.conf.argdict:
1091 self._evAccEff = self._executor.conf.argdict['eventAcceptanceEfficiency'].returnMyValue(exe=self._executor)
1092 if (self._evAccEff is None):
1093 self._evAccEff = 0.99
1094 else:
1095 self._evAccEff = 0.99
1096
1097 msg.debug("Event check conf: {0} {1}, {2}, {3}, {4}".format(self._inEventDict, self._outEventDict, self._skipEvents,
1098 self._maxEvents, self._evAccEff))
1099
1100

◆ decide()

python.trfValidation.eventMatch.decide ( self)

Perform an event count check.

Definition at line 1102 of file trfValidation.py.

1102 def decide(self):
1103 # We have all that we need to proceed: input and output data, skip and max events plus any efficiency factor
1104 # So loop over the input and output data and make our checks
1105 for inData, neventsInData in self._inEventDict.items():
1106 if not isinstance(neventsInData, int):
1107 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))
1108 continue
1109 if inData in self._eventCountConf:
1110 inDataKey = inData
1111 else:
1112 # OK, try a glob match in this case (YMMV)
1113 matchedInData = False
1114 for inDataKey in self._eventCountConf:
1115 if fnmatch.fnmatch(inData, inDataKey):
1116 msg.info("Matched input data type {inData} to {inDataKey} by globbing".format(inData=inData, inDataKey=inDataKey))
1117 matchedInData = True
1118 break
1119 if not matchedInData:
1120 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)))
1121 continue
1122
1123 # Now calculate the expected number of processed events for this input
1124 expectedEvents = neventsInData
1125 if self._skipEvents is not None and self._skipEvents > 0:
1126 expectedEvents -= self._skipEvents
1127 if expectedEvents < 0:
1128 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))
1129 expectedEvents = 0
1130 if self._maxEvents is not None:
1131 if expectedEvents < self._maxEvents:
1132 if self._skipEvents is not None:
1133 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))
1134 else:
1135 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))
1136 else:
1137 expectedEvents = self._maxEvents
1138 msg.debug('Expected number of processed events for {0} is {1}'.format(inData, expectedEvents))
1139
1140 # Loop over output data - first find event count configuration
1141 for outData, neventsOutData in self._outEventDict.items():
1142 if not isinstance(neventsOutData, int):
1143 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))
1144 continue
1145 if outData in self._eventCountConf[inDataKey]:
1146 checkConf = self._eventCountConf[inDataKey][outData]
1147 outDataKey = outData
1148 else:
1149 # Look for glob matches
1150 checkConf = None
1151 for outDataKey, outDataConf in self._eventCountConf[inDataKey].items():
1152 if fnmatch.fnmatch(outData, outDataKey):
1153 msg.info('Matched output data type {outData} to {outDatakey} by globbing'.format(outData=outData, outDatakey=outDataKey))
1154 outDataKey = outData
1155 checkConf = outDataConf
1156 break
1157 if not checkConf:
1158 msg.warning('No defined event count match for {inData} -> {outData}, so no check possible in this case.'.format(inData=inData, outData=outData))
1159 continue
1160 msg.debug('Event count check for {inData} to {outData} is {checkConf}'.format(inData=inData, outData=outData, checkConf=checkConf))
1161
1162 # Do the check for thsi input/output combination
1163 if checkConf == 'match':
1164 # We need an exact match
1165 if neventsOutData == expectedEvents:
1166 msg.info("Event count check for {inData} to {outData} passed: all processed events found ({neventsOutData} output events)".format(inData=inData, outData=outData, neventsOutData=neventsOutData))
1167 else:
1168 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1169 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData, expectedEvents=expectedEvents))
1170 elif checkConf == 'filter':
1171 if neventsOutData <= expectedEvents and neventsOutData >= 0:
1172 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))
1173 else:
1174 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1175 '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))
1176 elif checkConf == 'minEff':
1177 if neventsOutData >= int(expectedEvents * self._evAccEff) and neventsOutData <= expectedEvents:
1178 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))
1179 else:
1180 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1181 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1182 minEvents=int(expectedEvents * self._evAccEff), expectedEvents=expectedEvents))
1183 elif isinstance(checkConf, (float, int)):
1184 checkConf = float(checkConf)
1185 if checkConf < 0.0 or checkConf > 1.0:
1186 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1187 '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))
1188 if neventsOutData >= int(expectedEvents * checkConf) and neventsOutData <= expectedEvents:
1189 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))
1190 else:
1191 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1192 'Event count check for {inData} to {outData} failed: found {neventsOutData} events, expected from {minEvents} to {expectedEvents}'.format(inData=inData, outData=outData, neventsOutData=neventsOutData,
1193 minEvents=int(expectedEvents * checkConf), expectedEvents=expectedEvents))
1194 else:
1195 raise trfExceptions.TransformValidationException(trfExit.nameToCode('TRF_EXEC_VALIDATION_EVENTCOUNT'),
1196 'Unrecognised event count configuration for {inData} to {outData}: "{conf}" is not known'.format(inData=inData, outData=outData, conf=checkConf))
1197 self._eventCount = expectedEvents
1198 return True

◆ eventCount()

python.trfValidation.eventMatch.eventCount ( self)

Definition at line 1035 of file trfValidation.py.

1035 def eventCount(self):
1036 return self._eventCount
1037

Member Data Documentation

◆ _evAccEff

python.trfValidation.eventMatch._evAccEff = override['evAccEff']
protected

Definition at line 1049 of file trfValidation.py.

◆ _eventCount

python.trfValidation.eventMatch._eventCount = None
protected

Definition at line 989 of file trfValidation.py.

◆ _eventCountConf

python.trfValidation.eventMatch._eventCountConf = {}
protected

Definition at line 1003 of file trfValidation.py.

◆ _executor

python.trfValidation.eventMatch._executor = executor
protected

Definition at line 988 of file trfValidation.py.

◆ _inEventDict

python.trfValidation.eventMatch._inEventDict = override['inEventDict']
protected

Definition at line 1045 of file trfValidation.py.

◆ _maxEvents

python.trfValidation.eventMatch._maxEvents = override['maxEvents']
protected

Definition at line 1048 of file trfValidation.py.

◆ _outEventDict

python.trfValidation.eventMatch._outEventDict = override['outEventDict']
protected

Definition at line 1046 of file trfValidation.py.

◆ _skipEvents

python.trfValidation.eventMatch._skipEvents = override['skipEvents']
protected

Definition at line 1047 of file trfValidation.py.


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