Skip to content

Commit

Permalink
Merge pull request #35858 from missirol/devel_hltSchedule
Browse files Browse the repository at this point in the history
make HLT use "schedule"
  • Loading branch information
cmsbuild authored Nov 5, 2021
2 parents 8cf1f3b + 8cc72bd commit 06f15e3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 43 deletions.
49 changes: 27 additions & 22 deletions Configuration/Applications/python/ConfigBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def __init__(self, options, process = None, with_output = False, with_input = Fa
self.create_process()
self.define_Configs()
self.schedule = list()
self.scheduleIndexOfFirstHLTPath = None

# we are doing three things here:
# creating a process to catch errors
Expand Down Expand Up @@ -1525,7 +1526,6 @@ def prepare_L1REPACK(self, sequence = None):
print("L1REPACK with '",sequence,"' is not supported! Supported choices are: ",supported)
raise Exception('unsupported feature')


def prepare_HLT(self, sequence = None):
""" Enrich the schedule with the HLT simulation step"""
if not sequence:
Expand Down Expand Up @@ -1560,7 +1560,7 @@ def prepare_HLT(self, sequence = None):
else:
self.executeAndRemember('process.loadHltConfiguration("%s",%s)'%(sequence.replace(',',':'),optionsForHLTConfig))
else:
self.loadAndRemember('HLTrigger/Configuration/HLT_%s_cff' % sequence)
self.loadAndRemember('HLTrigger/Configuration/HLT_%s_cff' % sequence)

if self._options.isMC:
self._options.customisation_file.append("HLTrigger/Configuration/customizeHLTforMC.customizeHLTforMC")
Expand All @@ -1572,10 +1572,13 @@ def prepare_HLT(self, sequence = None):
from HLTrigger.Configuration.CustomConfigs import ProcessName
self.process = ProcessName(self.process)

self.schedule.append(self.process.HLTSchedule)
[self.blacklist_paths.append(path) for path in self.process.HLTSchedule if isinstance(path,(cms.Path,cms.EndPath))]
if self.process.schedule == None:
raise Exception('the HLT step did not attach a valid schedule to the process')

self.scheduleIndexOfFirstHLTPath = len(self.schedule)
[self.blacklist_paths.append(path) for path in self.process.schedule if isinstance(path,(cms.Path,cms.EndPath))]

#this is a fake, to be removed with fastim migration and HLT menu dump
# this is a fake, to be removed with fastim migration and HLT menu dump
if self._options.fast:
if not hasattr(self.process,'HLTEndSequence'):
self.executeAndRemember("process.HLTEndSequence = cms.Sequence( process.dummyModule )")
Expand Down Expand Up @@ -2241,27 +2244,29 @@ def prepare(self, doChecking = False):

# dump the schedule
self.pythonCfgCode += "\n# Schedule definition\n"
result = "process.schedule = cms.Schedule("

# handling of the schedule
self.process.schedule = cms.Schedule()
for item in self.schedule:
if not isinstance(item, cms.Schedule):
pathNames = ['process.'+p.label_() for p in self.schedule]
if self.process.schedule == None:
self.process.schedule = cms.Schedule()
for item in self.schedule:
self.process.schedule.append(item)
else:
self.process.schedule.extend(item)

if hasattr(self.process,"HLTSchedule"):
beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
pathNames = ['process.'+p.label_() for p in beforeHLT]
result += ','.join(pathNames)+')\n'
result += 'process.schedule.extend(process.HLTSchedule)\n'
pathNames = ['process.'+p.label_() for p in afterHLT]
result += 'process.schedule.extend(['+','.join(pathNames)+'])\n'
result = 'process.schedule = cms.Schedule('+','.join(pathNames)+')\n'
else:
pathNames = ['process.'+p.label_() for p in self.schedule]
result ='process.schedule = cms.Schedule('+','.join(pathNames)+')\n'
if not isinstance(self.scheduleIndexOfFirstHLTPath, int):
raise Exception('the schedule was imported from a cff in HLTrigger.Configuration, but the final index of the first HLT path is undefined')

for index, item in enumerate(self.schedule):
if index < self.scheduleIndexOfFirstHLTPath:
self.process.schedule.insert(index, item)
else:
self.process.schedule.append(item)

result = "# process.schedule imported from cff in HLTrigger.Configuration\n"
for index, item in enumerate(pathNames[:self.scheduleIndexOfFirstHLTPath]):
result += 'process.schedule.insert('+str(index)+', '+item+')\n'
if self.scheduleIndexOfFirstHLTPath < len(pathNames):
result += 'process.schedule.extend(['+','.join(pathNames[self.scheduleIndexOfFirstHLTPath:])+'])\n'

self.pythonCfgCode += result

Expand Down
9 changes: 9 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforALL.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

def customizeHLTforAll(process, menuType = "GRun", _customInfo = None):

# rename "HLTSchedule" to "schedule":
# CMSSW policy is to have at most 1 schedule
# in the cms.Process, named "schedule"
if hasattr(process, 'HLTSchedule'):
if process.schedule_() != None:
raise Exception('process.schedule already exists')
process.setSchedule_(process.HLTSchedule)
del process.HLTSchedule

if (_customInfo is not None):

_maxEvents = _customInfo['maxEvents']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def customizeHLTforNewDatasetDefinition(process):
datasetPath = 'Dataset_'+dataset+'_v1'
setattr( process, datasetPath, cms.Path( process.hltGtStage2Digis + getattr( process , 'hltPreDataset'+dataset ) + getattr( process, 'hltDataset'+dataset ) + process.HLTEndSequence ) )
# Append dataset path
process.HLTSchedule.insert( process.HLTSchedule.index( process.HLTriggerFinalPath ), getattr( process, datasetPath ) )
process.schedule.insert( process.schedule.index( process.HLTriggerFinalPath ), getattr( process, datasetPath ) )
setattr( process.datasets, dataset, cms.vstring( datasetPath ) )
streamPaths.append( datasetPath )
# Set stream paths
Expand Down
18 changes: 0 additions & 18 deletions HLTrigger/Configuration/python/customizeHLTforPatatrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,16 @@ def customiseCommon(process):
replace_with(process.Status_OnCPU, cms.Path(process.statusOnGPU + ~process.statusOnGPUFilter))
else:
process.Status_OnCPU = cms.Path(process.statusOnGPU + ~process.statusOnGPUFilter)
if 'HLTSchedule' in process.__dict__:
process.HLTSchedule.append(process.Status_OnCPU)
if process.schedule is not None:
process.schedule.append(process.Status_OnCPU)

if 'Status_OnGPU' in process.__dict__:
replace_with(process.Status_OnGPU, cms.Path(process.statusOnGPU + process.statusOnGPUFilter))
else:
process.Status_OnGPU = cms.Path(process.statusOnGPU + process.statusOnGPUFilter)
if 'HLTSchedule' in process.__dict__:
process.HLTSchedule.append(process.Status_OnGPU)
if process.schedule is not None:
process.schedule.append(process.Status_OnGPU)


# make the ScoutingCaloMuonOutput endpath compatible with using Tasks in the Scouting paths
if 'hltOutputScoutingCaloMuon' in process.__dict__ and not 'hltPreScoutingCaloMuonOutputSmart' in process.__dict__:
process.hltPreScoutingCaloMuonOutputSmart = cms.EDFilter( "TriggerResultsFilter",
Expand Down Expand Up @@ -244,9 +239,6 @@ def customisePixelLocalReconstruction(process):
# workaround for AlCa paths

if 'AlCa_LumiPixelsCounts_Random_v1' in process.__dict__:
if "HLTSchedule" in process.__dict__:
ind = process.HLTSchedule.index(process.AlCa_LumiPixelsCounts_Random_v1)
process.HLTSchedule.remove(process.AlCa_LumiPixelsCounts_Random_v1)
# redefine the path to use the HLTDoLocalPixelSequence
process.AlCa_LumiPixelsCounts_Random_v1 = cms.Path(
process.HLTBeginSequenceRandom +
Expand All @@ -256,13 +248,8 @@ def customisePixelLocalReconstruction(process):
process.HLTDoLocalPixelSequence +
process.hltAlcaPixelClusterCounts +
process.HLTEndSequence )
if "HLTSchedule" in process.__dict__:
process.HLTSchedule.insert(ind, process.AlCa_LumiPixelsCounts_Random_v1)

if 'AlCa_LumiPixelsCounts_ZeroBias_v1' in process.__dict__:
if "HLTSchedule" in process.__dict__:
ind = process.HLTSchedule.index(process.AlCa_LumiPixelsCounts_ZeroBias_v1)
process.HLTSchedule.remove(process.AlCa_LumiPixelsCounts_ZeroBias_v1)
# redefine the path to use the HLTDoLocalPixelSequence
process.AlCa_LumiPixelsCounts_ZeroBias_v1 = cms.Path(
process.HLTBeginSequence +
Expand All @@ -273,9 +260,6 @@ def customisePixelLocalReconstruction(process):
process.HLTDoLocalPixelSequence +
process.hltAlcaPixelClusterCounts +
process.HLTEndSequence )
if "HLTSchedule" in process.__dict__:
process.HLTSchedule.insert(ind, process.AlCa_LumiPixelsCounts_ZeroBias_v1)


# done
return process
Expand Down Expand Up @@ -741,8 +725,6 @@ def _addConsumerPath(process):
process.HLTDoLocalHcalTask,
)

if 'HLTSchedule' in process.__dict__:
process.HLTSchedule.append(process.Consumer)
if process.schedule is not None:
process.schedule.append(process.Consumer)

Expand Down
3 changes: 1 addition & 2 deletions RecoTauTag/HLTProducers/test/testL2TauTagNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ def addFilesToList(fileList, inputFiles, fileNamePrefix):


# Schedule definition
process.schedule = cms.Schedule()
process.schedule.extend(process.HLTSchedule)
# process.schedule imported from cff in HLTrigger.Configuration
process.schedule.extend([process.endjob_step])
from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
associatePatAlgosToolsTask(process)
Expand Down

0 comments on commit 06f15e3

Please sign in to comment.