Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make HLT use "schedule" #35858

Merged
merged 2 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -230,9 +225,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)
Comment on lines -233 to -235
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@missirol these adding/removing of the paths to/from the schedule are no longer necessary, because the "official" schedule object handles them automatically ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's my understanding from Matti's explanations (and I verified it by hand on a few examples). Since in this PR I used customizeHLTforAll to do the trick, that should always be used before other customisations, and afaik that's always the case.

# redefine the path to use the HLTDoLocalPixelSequence
process.AlCa_LumiPixelsCounts_Random_v1 = cms.Path(
process.HLTBeginSequenceRandom +
Expand All @@ -242,13 +234,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 @@ -259,9 +246,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 @@ -736,8 +720,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