diff --git a/HLT/Trigger/TrigTransforms/TrigTransform/python/dbgAnalysis.py b/HLT/Trigger/TrigTransforms/TrigTransform/python/dbgAnalysis.py index 44a6eb7b88bac8dd556e3b3449755d12d01e804f..cb2803178cf2196896a786c9b28f3d9ad1ba3d7f 100644 --- a/HLT/Trigger/TrigTransforms/TrigTransform/python/dbgAnalysis.py +++ b/HLT/Trigger/TrigTransforms/TrigTransform/python/dbgAnalysis.py @@ -101,59 +101,49 @@ def dbgPreRun(inputFileList, outputFileList, argdict = None): return None, dbAlias -def dbgPostRun(inputFileList, outputFileList, argdict = None): - msg.info('Running debug_stream analysis PostRun operations on files :{0} '.format(inputFileList)) - msg.info('Running debug_stream analysis PostRun, histogram output in :{0} '.format(outputFileList)) +def dbgPostRun(inputFile, outputFile, argdict = None): + msg.info('Running debug_stream analysis PostRun operations on files :{0} '.format(inputFile)) + msg.info('Running debug_stream analysis PostRun, histogram output in :{0} '.format(outputFile)) # Open root output file - outFile = outputFileList[0] - hfile = TFile(outFile, 'UPDATE') + hfile = TFile(outputFile, 'UPDATE') # Inicialize dbgEventInfo, this is the main event analysis class - eventInfo = dbgEventInfo('_Pos', inputFileList.value[0]) + eventInfo = dbgEventInfo('_Pos', inputFile) data = [] l1Info = [] hltInfo = [] configKeys = None - for inputFile in inputFileList.value: - # Find input file - files = [f for f in os.listdir() if inputFile in f] - if len(files) == 0: - msg.error('No BS file matched name :{0} '.format(inputFileList)) - continue - elif len(files) > 1: - msg.error('Found multiple BS files that match name :{0} '.format(inputFile)) - continue - - bsfile = eformat.istream(files[0]) - n = 0 - isFirstEvent = True - - for event in bsfile: - # If fist event get l1 and hlt counter and chain info from DB - if isFirstEvent: - configKeys = getHLTConfigKeys(event.run_no(), argdict) - - if not argdict.get('useDB'): - msg.debug("Reading chains and items from database is skipped (missing --useDB=True)") - l1Info, hltInfo = ([], []) - else: - l1Info, hltInfo = TriggerDBInfo(configKeys.get('DB'), configKeys.get('SMK')) - isFirstEvent = False - - # Log the details of first 5 events - n += 1 - if n < 5: - data = [event.run_no(), event.lumi_block(), event.global_id(), - event.lvl1_id(), event.bc_time_seconds(), event.bc_time_nanoseconds()] - msg.info('Event details :{0}'.format(data)) - - # Run debug event analysis and fill output TTree - eventInfo.eventCount(event) - eventInfo.eventInfo(event, l1Info, hltInfo) - eventInfo.eventConfig(configKeys, event) - eventInfo.fillTree() + bsfile = eformat.istream(inputFile) + n = 0 + isFirstEvent = True + + for event in bsfile: + # If fist event get l1 and hlt counter and chain info from DB + if isFirstEvent: + configKeys = getHLTConfigKeys(event.run_no(), argdict) + + if not argdict.get('useDB'): + msg.debug("Reading chains and items from database is skipped (missing --useDB=True)") + l1Info, hltInfo = ([], []) + else: + l1Info, hltInfo = TriggerDBInfo(configKeys.get('DB'), configKeys.get('SMK')) + + isFirstEvent = False + + # Log the details of first 5 events + n += 1 + if n < 5: + data = [event.run_no(), event.lumi_block(), event.global_id(), + event.lvl1_id(), event.bc_time_seconds(), event.bc_time_nanoseconds()] + msg.info('Event details :{0}'.format(data)) + + # Run debug event analysis and fill output TTree + eventInfo.eventCount(event) + eventInfo.eventInfo(event, l1Info, hltInfo) + eventInfo.eventConfig(configKeys, event) + eventInfo.fillTree() # Close output TFile hfile.Write() diff --git a/HLT/Trigger/TrigTransforms/TrigTransform/python/trigRecoExe.py b/HLT/Trigger/TrigTransforms/TrigTransform/python/trigRecoExe.py index baac6c242b6ddeb199190d4f37b028dd1db19e07..ef57cb835f3cf83221ff65cf73ad9d0e5aa6c2cd 100644 --- a/HLT/Trigger/TrigTransforms/TrigTransform/python/trigRecoExe.py +++ b/HLT/Trigger/TrigTransforms/TrigTransform/python/trigRecoExe.py @@ -121,20 +121,10 @@ class trigRecoExecutor(athenaExecutor): optionList = getTranslated(self.conf.argdict, name=self._name, substep=self._substep, first=self.conf.firstExecutor, output = outputFiles) self._cmd.extend(optionList) - # Run preRun step debug stream analysis if output BS file and output histogram are set - if "outputHIST_DEBUGSTREAMMONFile" in self.conf.argdict and 'BS' in self.conf.dataDictionary: - inputFiles = dict() - for dataType in input: - inputFiles[dataType] = self.conf.dataDictionary[dataType] - outputFiles = dict() - for dataType in output: - outputFiles[dataType] = self.conf.dataDictionary[dataType] - - # Set file name for debug stream analysis output - fileNameDbg = outputFiles['HIST_DEBUGSTREAMMON'].value - + # Run preRun step debug stream analysis if output histogram are set + if "outputHIST_DEBUGSTREAMMONFile" in self.conf.argdict: # Do debug stream preRun step and get asetup string from debug stream input files - dbgAsetupString, dbAlias = dbgStream.dbgPreRun(inputFiles['BS_RDO'], fileNameDbg, self.conf.argdict) + dbgAsetupString, dbAlias = dbgStream.dbgPreRun(self.conf.dataDictionary['BS_RDO'], self.conf.dataDictionary['HIST_DEBUGSTREAMMON'].value, self.conf.argdict) # Setup asetup from debug stream # if no --asetup r2b:string was given and is not running with tzero/software/patches as TestArea if asetupString is None and dbgAsetupString is not None: @@ -146,7 +136,7 @@ class trigRecoExecutor(athenaExecutor): msg.warn("Database alias will be set to %s", dbAlias) self._cmd.append("--db-server " + dbAlias) else: - msg.info("Flag outputHIST_DEBUGSTREAMMONFile or outputBSFile not defined - debug stream analysis will not run.") + msg.info("Flag outputHIST_DEBUGSTREAMMONFile not defined - debug stream analysis will not run.") # Call athenaExecutor parent as the above overrides what athenaExecutor would have done @@ -334,10 +324,7 @@ class trigRecoExecutor(athenaExecutor): argInDict = {} if self._rc != 0: msg.error('HLT step failed (with status %s) so skip BS filename check', self._rc) - elif 'BS' in self.conf.dataDictionary: - argInDict = self.conf.dataDictionary['BS'] - # keep dataset in case need to update argument - dataset_argInDict = argInDict._dataset + elif 'BS' in self.conf.dataDictionary or 'DRAW_TRIGCOST' in self.conf.dataDictionary or 'HIST_DEBUGSTREAMMON' in self.conf.dataDictionary: # expected string based on knowing that the format will be of form: ####._HLTMPPy_####.data expectedOutputFileName = '*_HLTMPPy_*.data' # list of filenames of files matching expectedOutputFileName @@ -345,10 +332,13 @@ class trigRecoExecutor(athenaExecutor): # check there are file matches and rename appropriately if(len(matchedOutputFileNames) > 1): msg.warning('Multiple BS files found: will only rename internal arg') - msg.info('Renaming internal BS arg from %s to %s', argInDict.value[0], matchedOutputFileNames) - argInDict.multipleOK = True - argInDict.value = matchedOutputFileNames - argInDict._dataset = dataset_argInDict + if 'BS' in self.conf.dataDictionary: + argInDict = self.conf.dataDictionary['BS'] + dataset_argInDict = argInDict._dataset + msg.info('Renaming internal BS arg from %s to %s', argInDict.value[0], matchedOutputFileNames) + argInDict.multipleOK = True + argInDict.value = matchedOutputFileNames + argInDict._dataset = dataset_argInDict elif(len(matchedOutputFileNames)): msg.info('Single BS file found: will split (if requested) and rename file') @@ -360,28 +350,33 @@ class trigRecoExecutor(athenaExecutor): 'Did not produce any BS file when selecting CostMonitoring stream with trigbs_extractStream.py in file') # Run debug step for all streams - if "outputHIST_DEBUGSTREAMMONFile" in self.conf.argdict: - self._postExecuteDebug(argInDict) - - # If a stream (not All) is selected, then slim the orignal (many stream) BS output to the particular stream - if 'streamSelection' in self.conf.argdict and self.conf.argdict['streamSelection'].value != "All": - splitFailed = self._splitBSfile(self.conf.argdict['streamSelection'].value, matchedOutputFileNames[0], argInDict.value[0]) - if(splitFailed): - raise trfExceptions.TransformExecutionException(trfExit.nameToCode('TRF_OUTPUT_FILE_ERROR'), - 'Did not produce any BS file when selecting stream with trigbs_extractStream.py in file') + if "HIST_DEBUGSTREAMMON" in self.conf.dataDictionary: + self._postExecuteDebug(matchedOutputFileNames[0]) + + # Rename BS file if requested + if 'BS' in self.conf.dataDictionary: + argInDict = self.conf.dataDictionary['BS'] + # If a stream (not All) is selected, then slim the orignal (many stream) BS output to the particular stream + if 'streamSelection' in self.conf.argdict and self.conf.argdict['streamSelection'].value != "All": + splitFailed = self._splitBSfile(self.conf.argdict['streamSelection'].value, matchedOutputFileNames[0], argInDict.value[0]) + if(splitFailed): + raise trfExceptions.TransformExecutionException(trfExit.nameToCode('TRF_OUTPUT_FILE_ERROR'), + 'Did not produce any BS file when selecting stream with trigbs_extractStream.py in file') + else: + msg.info('Stream "All" requested, so not splitting BS file') + self._renamefile(matchedOutputFileNames[0], argInDict.value[0]) else: - msg.info('Stream "All" requested, so not splitting BS file') - self._renamefile(matchedOutputFileNames[0], argInDict.value[0]) + msg.info('BS output filetype not defined so skip renaming BS') else: msg.error('no BS files created with expected name: %s', expectedOutputFileName) else: - msg.info('BS output filetype not defined so skip BS filename check') + msg.info('BS, DRAW_TRIGCOST or HIST_DEBUGSTREAMMON output filetypes not defined so skip BS post processing') msg.info('Now run athenaExecutor:postExecute') super(trigRecoExecutor, self).postExecute() - def _postExecuteDebug(self, argInDict): + def _postExecuteDebug(self, outputBSFile): # Run postRun step debug stream analysis if output BS file and output histogram are set msg.info("debug stream analysis in postExecute") @@ -396,4 +391,4 @@ class trigRecoExecutor(athenaExecutor): msg.info('No file created in PreRun step {0}'.format(fileNameDbg)) # Do debug stream postRun step - dbgStream.dbgPostRun(argInDict, fileNameDbg, self.conf.argdict) + dbgStream.dbgPostRun(outputBSFile, fileNameDbg[0], self.conf.argdict) diff --git a/HLT/Trigger/TrigTransforms/TrigTransform/python/trigTranslate.py b/HLT/Trigger/TrigTransforms/TrigTransform/python/trigTranslate.py index 4fc33c2b5a4a8d331c0c7b1d1d7f31935a374b9a..6ad09bf8637db31f23e3d7d87644b11b1a5a499f 100644 --- a/HLT/Trigger/TrigTransforms/TrigTransform/python/trigTranslate.py +++ b/HLT/Trigger/TrigTransforms/TrigTransform/python/trigTranslate.py @@ -44,6 +44,9 @@ def getOption(runArgs, name, substep, first, output): option['save-output'] = runArgs['outputBSFile'].value[0] elif 'BS' in output: option['save-output'] = output['BS'].value[0] + elif 'DRAW_TRIGCOST' in output or 'HIST_DEBUGSTREAMMON' in output: + msg.info('BS output needed, but not defined. Saving as temp.BS, but not avaialable to other steps') + option['save-output'] = "temp.BS" else: msg.warning('No BS filename defined, athenaHLT will not save the output')