Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-03 04:17:58

0001 import FWCore.ParameterSet.Config as cms
0002 import re
0003 import itertools
0004 
0005 from FWCore.ParameterSet.MassReplace import massReplaceInputTag
0006 from HeterogeneousCore.AlpakaCore.functions import *
0007 from HLTrigger.Configuration.common import *
0008 
0009 ## PF HLT in Alpaka
0010 def customizeHLTforAlpakaParticleFlowClustering(process):
0011     '''Customization to introduce Particle Flow Reconstruction in Alpaka
0012     '''
0013     ## failsafe for fake menus
0014     if not hasattr(process, 'hltParticleFlowClusterHBHE'):
0015         return process
0016 
0017     for prod in producers_by_type(process, 'HCALRecHitSoAProducer@alpaka'):
0018         return process
0019 
0020     process.hltESSPFRecHitHCALParamsRecord = cms.ESSource('EmptyESSource',
0021         recordName = cms.string('PFRecHitHCALParamsRecord'),
0022         iovIsRunNotTime = cms.bool(True),
0023         firstValid = cms.vuint32(1)
0024     )
0025 
0026     process.hltESSPFRecHitHCALTopologyRecord = cms.ESSource('EmptyESSource',
0027         recordName = cms.string('PFRecHitHCALTopologyRecord'),
0028         iovIsRunNotTime = cms.bool(True),
0029         firstValid = cms.vuint32(1)
0030     )
0031 
0032     process.hltESSJobConfigurationGPURecord = cms.ESSource('EmptyESSource',
0033         recordName = cms.string('JobConfigurationGPURecord'),
0034         iovIsRunNotTime = cms.bool(True),
0035         firstValid = cms.vuint32(1)
0036     )
0037 
0038     process.hltHbheRecHitSoA = cms.EDProducer("HCALRecHitSoAProducer@alpaka",
0039         src = cms.InputTag("hltHbhereco"),
0040         synchronise = cms.untracked.bool(False),
0041         # autoselect the alpaka backend
0042         alpaka = cms.untracked.PSet(
0043             backend = cms.untracked.string('')
0044         )
0045     )
0046 
0047     process.hltESPPFRecHitHCALTopology = cms.ESProducer('PFRecHitHCALTopologyESProducer@alpaka',
0048         usePFThresholdsFromDB = cms.bool(True),
0049         appendToDataLabel = cms.string(''),
0050         # autoselect the alpaka backend
0051         alpaka = cms.untracked.PSet(
0052             backend = cms.untracked.string('')
0053         )
0054     )
0055 
0056     process.hltESPPFRecHitHCALParams = cms.ESProducer('PFRecHitHCALParamsESProducer@alpaka',
0057         energyThresholdsHB = cms.vdouble(0.1, 0.2, 0.3, 0.3),
0058         energyThresholdsHE = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2),
0059         appendToDataLabel = cms.string(''),
0060         # autoselect the alpaka backend
0061         alpaka = cms.untracked.PSet(
0062             backend = cms.untracked.string('')
0063         )
0064     )
0065 
0066     process.hltParticleFlowRecHitHBHESoA = cms.EDProducer("PFRecHitSoAProducerHCAL@alpaka",
0067         producers = cms.VPSet(
0068             cms.PSet(
0069                 src = cms.InputTag("hltHbheRecHitSoA"),
0070                 params = cms.ESInputTag("hltESPPFRecHitHCALParams:"),
0071             )
0072         ),
0073         topology = cms.ESInputTag("hltESPPFRecHitHCALTopology:"),
0074         synchronise = cms.untracked.bool(False),
0075         # autoselect the alpaka backend
0076         alpaka = cms.untracked.PSet(
0077             backend = cms.untracked.string('')
0078         )
0079     )
0080 
0081     process.hltParticleFlowRecHitHBHE = cms.EDProducer("LegacyPFRecHitProducer",
0082         src = cms.InputTag("hltParticleFlowRecHitHBHESoA")
0083     )
0084 
0085     process.hltESPPFClusterParams = cms.ESProducer("PFClusterParamsESProducer@alpaka",
0086         seedFinder = cms.PSet(
0087             nNeighbours = cms.int32(4),
0088             thresholdsByDetector = cms.VPSet(
0089                 cms.PSet(
0090                     detector = cms.string('HCAL_BARREL1'),
0091                     seedingThreshold = cms.vdouble(0.125, 0.25, 0.35, 0.35),
0092                     seedingThresholdPt = cms.double(0)
0093                 ),
0094                 cms.PSet(
0095                     detector = cms.string('HCAL_ENDCAP'),
0096                     seedingThreshold = cms.vdouble(0.1375, 0.275, 0.275, 0.275, 0.275, 0.275, 0.275),
0097                     seedingThresholdPt = cms.double(0)
0098                 )
0099             )
0100         ),
0101         initialClusteringStep = cms.PSet(
0102             thresholdsByDetector = cms.VPSet(
0103                 cms.PSet(
0104                     detector = cms.string('HCAL_BARREL1'),
0105                     gatheringThreshold = cms.vdouble(0.1, 0.2, 0.3, 0.3)
0106                 ),
0107                 cms.PSet(
0108                     detector = cms.string('HCAL_ENDCAP'),
0109                     gatheringThreshold = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
0110                 )
0111             )
0112         ),
0113         pfClusterBuilder = cms.PSet(
0114             maxIterations = cms.uint32(5),
0115             minFracTot = cms.double(1e-20),
0116             minFractionToKeep = cms.double(1e-07),
0117             excludeOtherSeeds = cms.bool(True),
0118             showerSigma = cms.double(10),
0119             stoppingTolerance = cms.double(1e-08),
0120             recHitEnergyNorms = cms.VPSet(
0121                 cms.PSet(
0122                     detector = cms.string('HCAL_BARREL1'),
0123                     recHitEnergyNorm = cms.vdouble(0.1, 0.2, 0.3, 0.3)
0124                 ),
0125                 cms.PSet(
0126                     detector = cms.string('HCAL_ENDCAP'),
0127                     recHitEnergyNorm = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
0128                 )
0129             ),
0130             positionCalc = cms.PSet(
0131                 minFractionInCalc = cms.double(1e-09),
0132                 minAllowedNormalization = cms.double(1e-09)
0133             ),
0134             timeResolutionCalcBarrel = cms.PSet(
0135                 corrTermLowE = cms.double(0),
0136                 threshLowE = cms.double(6),
0137                 noiseTerm = cms.double(21.86),
0138                 constantTermLowE = cms.double(4.24),
0139                 noiseTermLowE = cms.double(8),
0140                 threshHighE = cms.double(15),
0141                 constantTerm = cms.double(2.82)
0142             ),
0143             timeResolutionCalcEndcap = cms.PSet(
0144                 corrTermLowE = cms.double(0),
0145                 threshLowE = cms.double(6),
0146                 noiseTerm = cms.double(21.86),
0147                 constantTermLowE = cms.double(4.24),
0148                 noiseTermLowE = cms.double(8),
0149                 threshHighE = cms.double(15),
0150                 constantTerm = cms.double(2.82)
0151             )
0152         ),
0153         # autoselect the alpaka backend
0154         alpaka = cms.untracked.PSet(
0155             backend = cms.untracked.string('')
0156         )
0157     )
0158 
0159     process.hltParticleFlowClusterHBHESoA = cms.EDProducer("PFClusterSoAProducer@alpaka",
0160         pfRecHits = cms.InputTag("hltParticleFlowRecHitHBHESoA"),
0161         topology = cms.ESInputTag("hltESPPFRecHitHCALTopology:"),
0162         pfClusterParams = cms.ESInputTag("hltESPPFClusterParams:"),
0163         synchronise = cms.bool(False),
0164         # autoselect the alpaka backend
0165         alpaka = cms.untracked.PSet(
0166             backend = cms.untracked.string('')
0167         )
0168     )
0169 
0170     process.hltParticleFlowClusterHBHE = cms.EDProducer("LegacyPFClusterProducer",
0171         src = cms.InputTag("hltParticleFlowClusterHBHESoA"),
0172         pfClusterBuilder = process.hltParticleFlowClusterHBHE.pfClusterBuilder,
0173         usePFThresholdsFromDB = cms.bool(True),
0174         recHitsSource = cms.InputTag("hltParticleFlowRecHitHBHE"),
0175         PFRecHitsLabelIn = cms.InputTag("hltParticleFlowRecHitHBHESoA")
0176     )
0177 
0178     process.HLTPFHcalClustering = cms.Sequence(
0179         process.hltHbheRecHitSoA +
0180         process.hltParticleFlowRecHitHBHESoA +
0181         process.hltParticleFlowRecHitHBHE +
0182         process.hltParticleFlowClusterHBHESoA +
0183         process.hltParticleFlowClusterHBHE +
0184         process.hltParticleFlowClusterHCAL
0185     )
0186 
0187     # Some Sequences contain all the modules of process.HLTPFHcalClustering Sequence instead of the Sequence itself
0188     # find these Sequences and replace all the modules with the Sequence
0189     def replaceItemsInSequence(process, seqNames, itemsToReplace, replacingSequence):
0190         for seqName in seqNames:
0191             if not hasattr(process, seqName):
0192                 continue
0193             seq = getattr(process, seqName)
0194             for item in itemsToReplace:
0195                 # remove items that will be replaced by replacingSequence
0196                 if (item != itemsToReplace[-1]):
0197                     seq.remove(item)
0198                 else:
0199                     # if last item, replace it with the Sequence
0200                     seq.replace(item, replacingSequence)
0201         return process
0202 
0203     process = replaceItemsInSequence(
0204         process, [
0205             'HLTParticleFlowSequence',
0206             'HLTParticleFlowSequenceForTaus',
0207             'HLTParticleFlowSequenceForDisplTaus',
0208             'HLTParticleFlowSequencePPOnAA',
0209             'HLTPixelOnlyParticleFlowSequence',
0210         ], [
0211             process.hltParticleFlowRecHitHBHE,
0212             process.hltParticleFlowClusterHBHE,
0213             process.hltParticleFlowClusterHCAL
0214         ],
0215         process.HLTPFHcalClustering
0216     )
0217 
0218     process.hltHbheRecHitSoACPUSerial = makeSerialClone(process.hltHbheRecHitSoA)
0219 
0220     process.hltParticleFlowRecHitHBHESoACPUSerial = makeSerialClone(process.hltParticleFlowRecHitHBHESoA)
0221     process.hltParticleFlowRecHitHBHESoACPUSerial.producers[0].src = 'hltHbheRecHitSoACPUSerial'
0222 
0223     process.hltParticleFlowRecHitHBHECPUOnly = process.hltParticleFlowRecHitHBHE.clone(
0224         src = 'hltParticleFlowRecHitHBHESoACPUSerial',
0225     )
0226 
0227     process.hltParticleFlowClusterHBHESoACPUSerial = makeSerialClone(process.hltParticleFlowClusterHBHESoA,
0228         pfRecHits = 'hltParticleFlowRecHitHBHESoACPUSerial',
0229     )
0230 
0231     process.hltParticleFlowClusterHBHECPUOnly = process.hltParticleFlowClusterHBHE.clone(
0232         src = 'hltParticleFlowClusterHBHESoACPUSerial',
0233         recHitsSource = 'hltParticleFlowRecHitHBHECPUOnly',
0234         PFRecHitsLabelIn = 'hltParticleFlowRecHitHBHESoACPUSerial',
0235     )
0236 
0237     process.HLTPFHcalClusteringCPUOnly = cms.Sequence(
0238         process.hltHbheRecHitSoACPUSerial +
0239         process.hltParticleFlowRecHitHBHESoACPUSerial +
0240         process.hltParticleFlowRecHitHBHECPUOnly +
0241         process.hltParticleFlowClusterHBHESoACPUSerial +
0242         process.hltParticleFlowClusterHBHECPUOnly +
0243         process.hltParticleFlowClusterHCALCPUOnly
0244     )
0245 
0246     process = replaceItemsInSequence(process, ['HLTParticleFlowCPUOnlySequence'],
0247         [process.hltParticleFlowRecHitHBHECPUOnly, process.hltParticleFlowClusterHBHECPUOnly, process.hltParticleFlowClusterHCALCPUOnly],
0248         process.HLTPFHcalClusteringCPUOnly)
0249 
0250     # modify EventContent of *DQMGPUvsCPU streams
0251     for hltOutModMatch in ['hltOutputDQMGPUvsCPU', 'hltOutputHIDQMGPUvsCPU']:
0252         if hasattr(process, hltOutModMatch):
0253             outMod = getattr(process, hltOutModMatch)
0254             outMod.outputCommands.extend([
0255                 'keep *_hltParticleFlowClusterHBHESoA_*_*',
0256                 'keep *_hltParticleFlowClusterHBHESoACPUSerial_*_*',
0257             ])
0258 
0259     # Add PF sequences to DQM_*HcalReconstruction_v Path
0260     for pathNameMatch in ['DQM_HcalReconstruction_v', 'DQM_HIHcalReconstruction_v']:
0261         dqmHcalRecoPathName = None
0262         for pathName in process.paths_():
0263             if pathName.startswith(pathNameMatch):
0264                 dqmHcalRecoPathName = pathName
0265                 break
0266         if dqmHcalRecoPathName == None:
0267             continue
0268         dqmHcalPath = getattr(process, dqmHcalRecoPathName)
0269         dqmHcalRecoPathIndex = dqmHcalPath.index(process.hltHcalConsumerGPU) + 1
0270         dqmHcalPath.insert(dqmHcalRecoPathIndex, process.HLTPFHcalClusteringCPUOnly)
0271         dqmHcalPath.insert(dqmHcalRecoPathIndex, process.HLTPFHcalClustering)
0272 
0273     return process
0274 
0275 def customizeHLTforAlpakaPFSoA(process):
0276 
0277     # avoid the conversion from SoA to legacy to SoA for the HCAL rechits
0278     process.hltParticleFlowRecHitHBHESoA.producers[0].src = 'hltHbheRecoSoA'
0279     process.hltParticleFlowRecHitHBHESoASerialSync.producers[0].src = 'hltHbheRecoSoASerialSync'
0280 
0281     del process.hltHbheRecHitSoA
0282     del process.hltHbheRecHitSoASerialSync
0283 
0284     return process
0285 
0286 ## Pixel HLT in Alpaka
0287 def customizeHLTforDQMGPUvsCPUPixel(process):
0288     '''Ad-hoc changes to test HLT config containing only DQM_PixelReconstruction_v and DQMGPUvsCPU stream
0289        only up to the Pixel Local Reconstruction
0290     '''
0291     dqmPixelRecoPathName = None
0292     for pathName in process.paths_():
0293         if pathName.startswith('DQM_PixelReconstruction_v'):
0294             dqmPixelRecoPathName = pathName
0295             break
0296 
0297     if dqmPixelRecoPathName == None:
0298         return process
0299 
0300     for prod in producers_by_type(process, 'SiPixelPhase1MonitorRecHitsSoAAlpaka'):
0301         return process
0302 
0303     # modify EventContent of DQMGPUvsCPU stream
0304     try:
0305         outCmds_new = [foo for foo in process.hltOutputDQMGPUvsCPU.outputCommands if 'Pixel' not in foo]
0306         outCmds_new += [
0307             'keep *Cluster*_hltSiPixelClusters_*_*',
0308             'keep *Cluster*_hltSiPixelClustersSerialSync_*_*',
0309             'keep *_hltSiPixelDigiErrors_*_*',
0310             'keep *_hltSiPixelDigiErrorsSerialSync_*_*',
0311             'keep *RecHit*_hltSiPixelRecHits_*_*',
0312             'keep *RecHit*_hltSiPixelRecHitsSerialSync_*_*',
0313             'keep *_hltPixelTracks_*_*',
0314             'keep *_hltPixelTracksSerialSync_*_*',
0315             'keep *_hltPixelVertices_*_*',
0316             'keep *_hltPixelVerticesSerialSync_*_*',
0317         ]
0318         process.hltOutputDQMGPUvsCPU.outputCommands = outCmds_new[:]
0319     except:
0320         pass
0321 
0322     # PixelRecHits: monitor of SerialSync product (Alpaka backend: 'serial_sync')
0323     process.hltPixelRecHitsSoAMonitorCPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka',
0324         pixelHitsSrc = cms.InputTag('hltSiPixelRecHitsSoASerialSync'),
0325         TopFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCPU')
0326     )
0327 
0328     # PixelRecHits: monitor of GPU product (Alpaka backend: '')
0329     process.hltPixelRecHitsSoAMonitorGPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka',
0330         pixelHitsSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
0331         TopFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsGPU')
0332     )
0333 
0334     # PixelRecHits: 'GPUvsCPU' comparisons
0335     process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHitsSoAAlpaka',
0336         pixelHitsSrcHost = cms.InputTag('hltSiPixelRecHitsSoASerialSync'),
0337         pixelHitsSrcDevice = cms.InputTag('hltSiPixelRecHitsSoA'),
0338         topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU'),
0339         minD2cut = cms.double(1.0e-4)
0340     )
0341 
0342     process.hltPixelTracksSoAMonitorCPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka",
0343         minQuality = cms.string('loose'),
0344         pixelTrackSrc = cms.InputTag('hltPixelTracksSoASerialSync'),
0345         topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCPU'),
0346         useQualityCut = cms.bool(True)
0347     )
0348 
0349     process.hltPixelTracksSoAMonitorGPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka",
0350         minQuality = cms.string('loose'),
0351         pixelTrackSrc = cms.InputTag('hltPixelTracksSoA'),
0352         topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackGPU'),
0353         useQualityCut = cms.bool(True)
0354     )
0355 
0356     process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTrackSoAAlpaka",
0357         deltaR2cut = cms.double(0.04),
0358         minQuality = cms.string('loose'),
0359         pixelTrackSrcHost = cms.InputTag("hltPixelTracksSoASerialSync"),
0360         pixelTrackSrcDevice = cms.InputTag("hltPixelTracksSoA"),
0361         topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU'),
0362         useQualityCut = cms.bool(True)
0363     )
0364 
0365     process.hltPixelVertexSoAMonitorCPU = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka",
0366         beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
0367         pixelVertexSrc = cms.InputTag("hltPixelVerticesSoASerialSync"),
0368         topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCPU')
0369     )
0370 
0371     process.hltPixelVertexSoAMonitorGPU = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka",
0372         beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
0373         pixelVertexSrc = cms.InputTag("hltPixelVerticesSoA"),
0374         topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexGPU')
0375     )
0376 
0377     process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertexSoAAlpaka",
0378         beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
0379         dzCut = cms.double(1),
0380         pixelVertexSrcHost = cms.InputTag("hltPixelVerticesSoASerialSync"),
0381         pixelVertexSrcDevice = cms.InputTag("hltPixelVerticesSoA"),
0382         topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU')
0383     )
0384 
0385     process.HLTDQMPixelReconstruction = cms.Sequence(
0386         process.hltPixelRecHitsSoAMonitorCPU
0387       + process.hltPixelRecHitsSoAMonitorGPU
0388       + process.hltPixelRecHitsSoACompareGPUvsCPU
0389       + process.hltPixelTracksSoAMonitorCPU
0390       + process.hltPixelTracksSoAMonitorGPU
0391       + process.hltPixelTracksSoACompareGPUvsCPU
0392       + process.hltPixelVertexSoAMonitorCPU
0393       + process.hltPixelVertexSoAMonitorGPU
0394       + process.hltPixelVertexSoACompareGPUvsCPU
0395     )
0396 
0397     for delMod in ['hltPixelConsumerCPU', 'hltPixelConsumerGPU']:
0398         if hasattr(process, delMod):
0399             process.__delattr__(delMod)
0400 
0401     return process
0402 
0403 
0404 def customizeHLTforAlpakaPixelRecoLocal(process):
0405     '''Customisation to introduce the Local Pixel Reconstruction in Alpaka
0406     '''
0407 
0408     if not hasattr(process, 'HLTDoLocalPixelSequence'):
0409         return process
0410 
0411     for prod in producers_by_type(process, 'SiPixelRawToClusterPhase1@alpaka'):
0412         return process
0413 
0414     process.hltESPSiPixelCablingSoA = cms.ESProducer('SiPixelCablingSoAESProducer@alpaka',
0415         CablingMapLabel = cms.string(''),
0416         UseQualityInfo = cms.bool(False),
0417         appendToDataLabel = cms.string(''),
0418         alpaka = cms.untracked.PSet(
0419             backend = cms.untracked.string('')
0420         )
0421     )
0422 
0423     process.hltESPSiPixelGainCalibrationForHLTSoA = cms.ESProducer('SiPixelGainCalibrationForHLTSoAESProducer@alpaka',
0424         appendToDataLabel = cms.string(''),
0425         alpaka = cms.untracked.PSet(
0426             backend = cms.untracked.string('')
0427         )
0428     )
0429 
0430     process.hltESPPixelCPEFastParamsPhase1 = cms.ESProducer('PixelCPEFastParamsESProducerAlpakaPhase1@alpaka',
0431         appendToDataLabel = cms.string(''),
0432         alpaka = cms.untracked.PSet(
0433             backend = cms.untracked.string('')
0434         )
0435     )
0436 
0437     if hasattr(process, 'hltESPPixelCPEFast'):
0438         del process.hltESPPixelCPEFast
0439 
0440     # alpaka EDProducer
0441     # consumes
0442     #  - reco::BeamSpot
0443     # produces
0444     #  - BeamSpotDevice
0445     process.hltOnlineBeamSpotDevice = cms.EDProducer('BeamSpotDeviceProducer@alpaka',
0446         src = cms.InputTag('hltOnlineBeamSpot'),
0447         alpaka = cms.untracked.PSet(
0448             backend = cms.untracked.string('')
0449         )
0450     )
0451 
0452     if hasattr(process, 'hltOnlineBeamSpotToGPU'):
0453         # hltOnlineBeamSpotToGPU is currently still used in HIon menu,
0454         # remove it only if the relevant ConditionalTask of the HIon menu is not present
0455         # (this check mainly applies to the HLT combined table)
0456         if not (hasattr(process, 'HLTDoLocalPixelPPOnAATask') and process.HLTDoLocalPixelPPOnAATask.contains(process.hltOnlineBeamSpotToGPU)):
0457             del process.hltOnlineBeamSpotToGPU
0458 
0459     # alpaka EDProducer
0460     # consumes
0461     #  - FEDRawDataCollection
0462     # produces (* optional)
0463     #  - SiPixelClustersSoA
0464     #  - SiPixelDigisSoACollection
0465     #  - SiPixelDigiErrorsSoACollection *
0466     #  - SiPixelFormatterErrors *
0467     process.hltSiPixelClustersSoA = cms.EDProducer('SiPixelRawToClusterPhase1@alpaka',
0468         IncludeErrors = cms.bool(True),
0469         UseQualityInfo = cms.bool(False),
0470         clusterThreshold_layer1 = cms.int32(4000),
0471         clusterThreshold_otherLayers = cms.int32(4000),
0472         VCaltoElectronGain      = cms.double(1),  # all gains=1, pedestals=0
0473         VCaltoElectronGain_L1   = cms.double(1),
0474         VCaltoElectronOffset    = cms.double(0),
0475         VCaltoElectronOffset_L1 = cms.double(0),
0476         InputLabel = cms.InputTag('rawDataCollector'),
0477         Regions = cms.PSet(),
0478         CablingMapLabel = cms.string(''),
0479         # autoselect the alpaka backend
0480         alpaka = cms.untracked.PSet(
0481             backend = cms.untracked.string('')
0482         )
0483     )
0484 
0485     if hasattr(process, 'hltSiPixelClustersGPU'):
0486         del process.hltSiPixelClustersGPU
0487 
0488     process.hltSiPixelClusters = cms.EDProducer('SiPixelDigisClustersFromSoAAlpakaPhase1',
0489         src = cms.InputTag('hltSiPixelClustersSoA'),
0490         clusterThreshold_layer1 = cms.int32(4000),
0491         clusterThreshold_otherLayers = cms.int32(4000),
0492         produceDigis = cms.bool(False),
0493         storeDigis = cms.bool(False)
0494     )
0495 
0496     # used only in the PPRef menu for the legacy pixel track reconstruction
0497     process.hltSiPixelClustersCache = cms.EDProducer('SiPixelClusterShapeCacheProducer',
0498         src = cms.InputTag('hltSiPixelClusters'),
0499         onDemand = cms.bool(False)
0500     )
0501 
0502     # legacy EDProducer
0503     # consumes
0504     #  - SiPixelDigiErrorsHost
0505     #  - SiPixelFormatterErrors
0506     # produces
0507     #  - edm::DetSetVector<SiPixelRawDataError>
0508     #  - DetIdCollection
0509     #  - DetIdCollection, 'UserErrorModules'
0510     #  - edmNew::DetSetVector<PixelFEDChannel>
0511     process.hltSiPixelDigiErrors = cms.EDProducer('SiPixelDigiErrorsFromSoAAlpaka',
0512         digiErrorSoASrc = cms.InputTag('hltSiPixelClustersSoA'),
0513         fmtErrorsSoASrc = cms.InputTag('hltSiPixelClustersSoA'),
0514         CablingMapLabel = cms.string(''),
0515         UsePhase1 = cms.bool(True),
0516         ErrorList = cms.vint32(29),
0517         UserErrorList = cms.vint32(40)
0518     )
0519 
0520     if hasattr(process, 'hltSiPixelDigisSoA'):
0521         del process.hltSiPixelDigisSoA
0522     if hasattr(process, 'hltSiPixelDigiErrorsSoA'):
0523         del process.hltSiPixelDigiErrorsSoA
0524 
0525     # alpaka EDProducer
0526     # consumes
0527     #  - BeamSpotDevice
0528     #  - SiPixelClustersSoA
0529     #  - SiPixelDigisSoACollection
0530     # produces
0531     #  - TrackingRecHitsSoACollection<TrackerTraits>
0532     process.hltSiPixelRecHitsSoA = cms.EDProducer('SiPixelRecHitAlpakaPhase1@alpaka',
0533         beamSpot = cms.InputTag('hltOnlineBeamSpotDevice'),
0534         src = cms.InputTag('hltSiPixelClustersSoA'),
0535         CPE = cms.string('PixelCPEFastParams'),
0536         # autoselect the alpaka backend
0537         alpaka = cms.untracked.PSet(
0538             backend = cms.untracked.string('')
0539         )
0540     )
0541 
0542     if hasattr(process, 'hltSiPixelRecHitsGPU'):
0543         del process.hltSiPixelRecHitsGPU
0544     if hasattr(process, 'hltSiPixelRecHitsFromGPU'):
0545         del process.hltSiPixelRecHitsFromGPU
0546     if hasattr(process, 'hltSiPixelRecHitsSoAFromGPU'):
0547         del process.hltSiPixelRecHitsSoAFromGPU
0548 
0549     process.hltSiPixelRecHits = cms.EDProducer('SiPixelRecHitFromSoAAlpakaPhase1',
0550         pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
0551         src = cms.InputTag('hltSiPixelClusters'),
0552     )
0553 
0554     ###
0555     ### Sequence: Pixel Local Reconstruction
0556     ###
0557     process.HLTDoLocalPixelSequence = cms.Sequence(
0558         process.hltOnlineBeamSpotDevice +
0559         process.hltSiPixelClustersSoA +
0560         process.hltSiPixelClusters +
0561         process.hltSiPixelDigiErrors +    # renamed from hltSiPixelDigis
0562         process.hltSiPixelRecHitsSoA +
0563         process.hltSiPixelRecHits
0564     )
0565 
0566     # The module hltSiPixelClustersCache is only used in the PRef menu.
0567     # Previously, it being included in the GRun menu had no effect
0568     # because it was included in a ConditionalTask, which meant that
0569     # it was not executed in the GRun menu, since no other modules
0570     # in any Path of that menu were consuming it.
0571     # Since this customisation effectively replaces ConditionalTasks in the HLT menus with Sequences,
0572     # leaving hltSiPixelClustersCache in a Sequence of the GRun menu would lead to it being unnecessarily executed.
0573     # On the other hand, hltSiPixelClustersCache must be kept in the PRef menu,
0574     # as the latter does have reconstruction modules which consume it.
0575     # The solution implemented here is
0576     # (a) not to include hltSiPixelClustersCache in the Sequence HLTDoLocalPixelSequence used in the GRun menu, and
0577     # (b) include hltSiPixelClustersCache in a separate Sequence to be used only as part of the PRef menu.
0578     if hasattr(process, 'HLTPixelClusterSplittingForPFPPRefForDmeson') \
0579         and not hasattr(process, 'HLTDoLocalPixelSequenceForPFPPRefForDmeson') \
0580         and process.HLTPixelClusterSplittingForPFPPRefForDmeson.contains(process.HLTDoLocalPixelSequence):
0581 
0582         process.HLTDoLocalPixelSequenceForPFPPRefForDmeson = cms.Sequence(
0583             process.HLTDoLocalPixelSequence +
0584             process.hltSiPixelClustersCache
0585         )
0586 
0587         process.HLTPixelClusterSplittingForPFPPRefForDmeson.insert(
0588             process.HLTPixelClusterSplittingForPFPPRefForDmeson.index(process.HLTDoLocalPixelSequence),
0589             process.HLTDoLocalPixelSequenceForPFPPRefForDmeson
0590         )
0591 
0592     # remove HLTDoLocalPixelTask (not needed anymore)
0593     if hasattr(process, 'HLTDoLocalPixelTask'):
0594         del process.HLTDoLocalPixelTask
0595 
0596     ###
0597     ### SerialSync version of Pixel Local Reconstruction
0598     ###
0599     process.hltOnlineBeamSpotDeviceSerialSync = makeSerialClone(process.hltOnlineBeamSpotDevice)
0600 
0601     process.hltSiPixelClustersSoASerialSync = makeSerialClone(process.hltSiPixelClustersSoA)
0602 
0603     process.hltSiPixelClustersSerialSync = process.hltSiPixelClusters.clone(
0604         src = 'hltSiPixelClustersSoASerialSync'
0605     )
0606 
0607     process.hltSiPixelDigiErrorsSerialSync = process.hltSiPixelDigiErrors.clone(
0608         digiErrorSoASrc = 'hltSiPixelClustersSoASerialSync',
0609         fmtErrorsSoASrc = 'hltSiPixelClustersSoASerialSync',
0610     )
0611 
0612     process.hltSiPixelRecHitsSoASerialSync = makeSerialClone(process.hltSiPixelRecHitsSoA,
0613         beamSpot = 'hltOnlineBeamSpotDeviceSerialSync',
0614         src = 'hltSiPixelClustersSoASerialSync',
0615     )
0616 
0617     process.hltSiPixelRecHitsSerialSync = process.hltSiPixelRecHits.clone(
0618         pixelRecHitSrc = 'hltSiPixelRecHitsSoASerialSync',
0619         src = 'hltSiPixelClustersSerialSync',
0620     )
0621 
0622     process.HLTDoLocalPixelCPUOnlySequence = cms.Sequence(
0623         process.hltOnlineBeamSpotDeviceSerialSync +
0624         process.hltSiPixelClustersSoASerialSync +
0625         process.hltSiPixelClustersSerialSync +
0626         process.hltSiPixelDigiErrorsSerialSync +
0627         process.hltSiPixelRecHitsSoASerialSync +
0628         process.hltSiPixelRecHitsSerialSync
0629     )
0630 
0631     if hasattr(process, 'HLTDoLocalPixelCPUOnlyTask'):
0632         del process.HLTDoLocalPixelCPUOnlyTask
0633 
0634     if hasattr(process, 'hltMeasurementTrackerEventCPUOnly'):
0635         process.hltMeasurementTrackerEventCPUOnly.pixelClusterProducer = "hltSiPixelClustersSerialSync"
0636         process.hltMeasurementTrackerEventCPUOnly.inactivePixelDetectorLabels = ["hltSiPixelDigiErrorsSerialSync"]
0637         process.hltMeasurementTrackerEventCPUOnly.badPixelFEDChannelCollectionLabels = ["hltSiPixelDigiErrorsSerialSync"]
0638 
0639     if hasattr(process, 'hltDoubletRecoveryClustersRefRemovalCPUOnly'):
0640         process.hltDoubletRecoveryClustersRefRemovalCPUOnly.pixelClusters = "hltSiPixelClustersSerialSync"
0641 
0642     if hasattr(process, 'hltDoubletRecoveryPFlowPixelClusterCheckCPUOnly'):
0643         process.hltDoubletRecoveryPFlowPixelClusterCheckCPUOnly.PixelClusterCollectionLabel = "hltSiPixelClustersSerialSync"
0644 
0645     if hasattr(process, 'hltDoubletRecoveryPixelLayersAndRegionsCPUOnly'):
0646         process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.inactivePixelDetectorLabels = ['hltSiPixelDigiErrorsSerialSync']
0647         process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrorsSerialSync']
0648         process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.BPix.HitProducer = "hltSiPixelRecHitsSerialSync"
0649         process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.FPix.HitProducer = "hltSiPixelRecHitsSerialSync"
0650 
0651     if hasattr(process, 'hltIter3IterL3FromL1MuonClustersRefRemovalCPUOnly'):
0652         process.hltIter3IterL3FromL1MuonClustersRefRemovalCPUOnly.pixelClusters = "hltSiPixelClustersSerialSync"
0653 
0654     if hasattr(process, 'hltIter3IterL3FromL1MuonPixelClusterCheckCPUOnly'):
0655         process.hltIter3IterL3FromL1MuonPixelClusterCheckCPUOnly.PixelClusterCollectionLabel = "hltSiPixelClustersSerialSync"
0656 
0657     if hasattr(process, 'hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly'):
0658         process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.inactivePixelDetectorLabels = ['hltSiPixelDigiErrorsSerialSync']
0659         process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrorsSerialSync']
0660         process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.BPix.HitProducer = "hltSiPixelRecHitsSerialSync"
0661         process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.FPix.HitProducer = "hltSiPixelRecHitsSerialSync"
0662 
0663     for modLabel in [
0664         'hltDoubletRecoveryPixelLayersAndRegions',
0665         'hltFullIter6PixelTrackingRegionSeedLayersBPPRef',
0666         'hltIter3IterL3FromL1MuonPixelLayersAndRegions',
0667         'hltMeasurementTrackerEvent',
0668     ]:
0669         if hasattr(process, modLabel):
0670             mod = getattr(process, modLabel)
0671             mod.inactivePixelDetectorLabels = ['hltSiPixelDigiErrors']
0672             mod.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrors']
0673 
0674     return process
0675 
0676 
0677 def customizeHLTforAlpakaPixelRecoTracking(process):
0678     '''Customisation to introduce the Pixel-Track Reconstruction in Alpaka
0679     '''
0680 
0681     if not hasattr(process, 'HLTRecoPixelTracksSequence'):
0682         return process
0683 
0684     for prod in producers_by_type(process, 'CAHitNtupletAlpakaPhase1@alpaka'):
0685         return process
0686 
0687     # alpaka EDProducer
0688     # consumes
0689     #  - TrackingRecHitsSoACollection<TrackerTraits>
0690     # produces
0691     #  - TkSoADevice
0692     process.hltPixelTracksSoA = cms.EDProducer('CAHitNtupletAlpakaPhase1@alpaka',
0693         pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
0694         CPE = cms.string('PixelCPEFastParams'),
0695         ptmin = cms.double(0.9),
0696         CAThetaCutBarrel = cms.double(0.002),
0697         CAThetaCutForward = cms.double(0.003),
0698         hardCurvCut = cms.double(0.0328407225),
0699         dcaCutInnerTriplet = cms.double(0.15),
0700         dcaCutOuterTriplet = cms.double(0.25),
0701         earlyFishbone = cms.bool(True),
0702         lateFishbone = cms.bool(False),
0703         fillStatistics = cms.bool(False),
0704         minHitsPerNtuplet = cms.uint32(3),
0705         phiCuts = cms.vint32(
0706             522, 730, 730, 522, 626,
0707             626, 522, 522, 626, 626,
0708             626, 522, 522, 522, 522,
0709             522, 522, 522, 522
0710         ),
0711         maxNumberOfDoublets = cms.uint32(524288),
0712         minHitsForSharingCut = cms.uint32(10),
0713         fitNas4 = cms.bool(False),
0714         doClusterCut = cms.bool(True),
0715         doZ0Cut = cms.bool(True),
0716         doPtCut = cms.bool(True),
0717         useRiemannFit = cms.bool(False),
0718         doSharedHitCut = cms.bool(True),
0719         dupPassThrough = cms.bool(False),
0720         useSimpleTripletCleaner = cms.bool(True),
0721         idealConditions = cms.bool(False),
0722         includeJumpingForwardDoublets = cms.bool(True),
0723         trackQualityCuts = cms.PSet(
0724             chi2MaxPt = cms.double(10),
0725             chi2Coeff = cms.vdouble(0.9, 1.8),
0726             chi2Scale = cms.double(8),
0727             tripletMinPt = cms.double(0.5),
0728             tripletMaxTip = cms.double(0.3),
0729             tripletMaxZip = cms.double(12),
0730             quadrupletMinPt = cms.double(0.3),
0731             quadrupletMaxTip = cms.double(0.5),
0732             quadrupletMaxZip = cms.double(12)
0733         ),
0734         # autoselect the alpaka backend
0735         alpaka = cms.untracked.PSet(
0736             backend = cms.untracked.string('')
0737         )
0738     )
0739 
0740     if hasattr(process, 'hltL2TauTagNNProducer'):
0741         process.hltL2TauTagNNProducer = cms.EDProducer("L2TauNNProducerAlpaka", **process.hltL2TauTagNNProducer.parameters_())
0742 
0743     process.hltPixelTracksSoASerialSync = makeSerialClone(process.hltPixelTracksSoA,
0744         pixelRecHitSrc = 'hltSiPixelRecHitsSoASerialSync'
0745     )
0746 
0747     process.hltPixelTracks = cms.EDProducer("PixelTrackProducerFromSoAAlpakaPhase1",
0748         beamSpot = cms.InputTag("hltOnlineBeamSpot"),
0749         minNumberOfHits = cms.int32(0),
0750         minQuality = cms.string('loose'),
0751         pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHits"),
0752         trackSrc = cms.InputTag("hltPixelTracksSoA")
0753     )
0754 
0755     if hasattr(process, 'hltPixelTracksCPU'):
0756         del process.hltPixelTracksCPU
0757     if hasattr(process, 'hltPixelTracksCPUOnly'):
0758         del process.hltPixelTracksCPUOnly
0759     if hasattr(process, 'hltPixelTracksFromGPU'):
0760         del process.hltPixelTracksFromGPU
0761     if hasattr(process, 'hltPixelTracksGPU'):
0762         del process.hltPixelTracksGPU
0763 
0764     process.hltPixelTracksSerialSync = process.hltPixelTracks.clone(
0765         pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHitsSerialSync"),
0766         trackSrc = cms.InputTag("hltPixelTracksSoASerialSync")
0767     )
0768 
0769     process.HLTRecoPixelTracksSequence = cms.Sequence(
0770         process.hltPixelTracksSoA +
0771         process.hltPixelTracks
0772     )
0773 
0774     if hasattr(process, 'HLTRecoPixelTracksTask'):
0775         del process.HLTRecoPixelTracksTask
0776 
0777     process.HLTRecoPixelTracksSerialSyncSequence = cms.Sequence(
0778         process.hltPixelTracksSoASerialSync +
0779         process.hltPixelTracksSerialSync
0780     )
0781 
0782     if hasattr(process, 'HLTRecoPixelTracksCPUOnlyTask'):
0783         del process.HLTRecoPixelTracksCPUOnlyTask
0784 
0785     process.hltPixelTracksInRegionL2CPUOnly.tracks = "hltPixelTracksSerialSync"
0786 
0787     process.hltPixelTracksInRegionL1CPUOnly.tracks = "hltPixelTracksSerialSync"
0788 
0789     process.hltIter0PFLowPixelSeedsFromPixelTracksCPUOnly.InputCollection = "hltPixelTracksSerialSync"
0790 
0791     return process
0792 
0793 
0794 def customizeHLTforAlpakaPixelRecoVertexing(process):
0795     '''Customisation to introduce the Pixel-Vertex Reconstruction in Alpaka
0796     '''
0797 
0798     if not hasattr(process, 'HLTRecopixelvertexingSequence'):
0799         return process
0800 
0801     # do not apply the customisation if the menu is already using the alpaka pixel reconstruction
0802     for prod in producers_by_type(process, 'PixelVertexProducerAlpakaPhase1@alpaka'):
0803         return process
0804 
0805     # alpaka EDProducer
0806     # consumes
0807     #  - TkSoADevice
0808     # produces
0809     #  - ZVertexDevice
0810     process.hltPixelVerticesSoA = cms.EDProducer('PixelVertexProducerAlpakaPhase1@alpaka',
0811         oneKernel = cms.bool(True),
0812         useDensity = cms.bool(True),
0813         useDBSCAN = cms.bool(False),
0814         useIterative = cms.bool(False),
0815         minT = cms.int32(2),
0816         eps = cms.double(0.07),
0817         errmax = cms.double(0.01),
0818         chi2max = cms.double(9),
0819         PtMin = cms.double(0.5),
0820         PtMax = cms.double(75),
0821         pixelTrackSrc = cms.InputTag('hltPixelTracksSoA'),
0822         # autoselect the alpaka backend
0823         alpaka = cms.untracked.PSet(
0824             backend = cms.untracked.string('')
0825         )
0826     )
0827 
0828     process.hltPixelVerticesSoASerialSync = makeSerialClone(process.hltPixelVerticesSoA,
0829         pixelTrackSrc = 'hltPixelTracksSoASerialSync'
0830     )
0831 
0832     process.hltPixelVertices = cms.EDProducer("PixelVertexProducerFromSoAAlpaka",
0833         TrackCollection = cms.InputTag("hltPixelTracks"),
0834         beamSpot = cms.InputTag("hltOnlineBeamSpot"),
0835         src = cms.InputTag("hltPixelVerticesSoA")
0836     )
0837 
0838     process.hltPixelVerticesSerialSync = process.hltPixelVertices.clone(
0839         TrackCollection = cms.InputTag("hltPixelTracksSerialSync"),
0840         src = cms.InputTag("hltPixelVerticesSoASerialSync")
0841     )
0842 
0843     if hasattr(process, 'hltPixelVerticesCPU'):
0844         del process.hltPixelVerticesCPU
0845     if hasattr(process, 'hltPixelVerticesCPUOnly'):
0846         del process.hltPixelVerticesCPUOnly
0847     if hasattr(process, 'hltPixelVerticesFromGPU'):
0848         del process.hltPixelVerticesFromGPU
0849     if hasattr(process, 'hltPixelVerticesGPU'):
0850         del process.hltPixelVerticesGPU
0851 
0852     ## failsafe for fake menus
0853     if not hasattr(process, 'hltTrimmedPixelVertices'):
0854         return process
0855 
0856     process.HLTRecopixelvertexingSequence = cms.Sequence(
0857         process.HLTRecoPixelTracksSequence +
0858         process.hltPixelVerticesSoA +
0859         process.hltPixelVertices +
0860         process.hltTrimmedPixelVertices
0861     )
0862 
0863     if hasattr(process, 'HLTRecopixelvertexingTask'):
0864         del process.HLTRecopixelvertexingTask
0865 
0866     process.HLTRecopixelvertexingCPUOnlySequence = cms.Sequence(
0867         process.HLTRecoPixelTracksSerialSyncSequence +
0868         process.hltPixelVerticesSoASerialSync +
0869         process.hltPixelVerticesSerialSync +
0870         process.hltTrimmedPixelVerticesCPUOnly
0871     )
0872 
0873     if hasattr(process, 'HLTRecopixelvertexingCPUOnlyTask'):
0874         del process.HLTRecopixelvertexingCPUOnlyTask
0875 
0876     process.hltTrimmedPixelVerticesCPUOnly.src = 'hltPixelVerticesSerialSync'
0877     process.hltParticleFlowCPUOnly.vertexCollection = 'hltPixelVerticesSerialSync'
0878     process.hltAK4PFJetsCPUOnly.srcPVs = 'hltPixelVerticesSerialSync'
0879 
0880     return process
0881 
0882 
0883 def customizeHLTforAlpakaPixelReco(process):
0884     '''Customisation to introduce the Pixel Local+Track+Vertex Reconstruction in Alpaka
0885     '''
0886     process = customizeHLTforAlpakaPixelRecoLocal(process)
0887     process = customizeHLTforAlpakaPixelRecoTracking(process)
0888     process = customizeHLTforAlpakaPixelRecoVertexing(process)
0889     process = customizeHLTforDQMGPUvsCPUPixel(process)
0890 
0891     return process
0892 
0893 
0894 ## ECAL HLT in Alpaka
0895 def customizeHLTforAlpakaEcalLocalReco(process):
0896 
0897     if not hasattr(process, 'hltEcalDigisGPU'):
0898         return process
0899 
0900     for prod in producers_by_type(process, 'EcalRawToDigiPortable@alpaka'):
0901         return process
0902 
0903     # remove existing ECAL GPU-related ES modules
0904     for foo in [foo for foo in process.es_producers_() if ('ecal' in foo and 'GPU' in foo)]:
0905         process.__delattr__(foo)
0906 
0907     for foo in [foo for foo in process.es_sources_() if ('ecal' in foo and 'GPU' in foo)]:
0908         process.__delattr__(foo)
0909 
0910     # redefine ECAL local reconstruction sequence
0911     process.hltEcalDigisPortableSoA = cms.EDProducer("EcalRawToDigiPortable@alpaka",
0912         FEDs = process.hltEcalDigisGPU.FEDs,
0913         InputLabel = process.hltEcalDigisGPU.InputLabel,
0914         digisLabelEB = process.hltEcalDigisGPU.digisLabelEB,
0915         digisLabelEE = process.hltEcalDigisGPU.digisLabelEE,
0916         maxChannelsEB = process.hltEcalDigisGPU.maxChannelsEB,
0917         maxChannelsEE = process.hltEcalDigisGPU.maxChannelsEE,
0918         # autoselect the alpaka backend
0919         alpaka = cms.untracked.PSet(
0920             backend = cms.untracked.string('')
0921         )
0922     )
0923 
0924     from EventFilter.EcalRawToDigi.ecalElectronicsMappingHostESProducer_cfi import ecalElectronicsMappingHostESProducer as _ecalElectronicsMappingHostESProducer
0925     process.ecalElectronicsMappingHostESProducer = _ecalElectronicsMappingHostESProducer.clone()
0926 
0927     process.hltEcalDigis = cms.EDProducer("EcalDigisFromPortableProducer",
0928         digisInLabelEB = cms.InputTag('hltEcalDigisPortableSoA', 'ebDigis'),
0929         digisInLabelEE = cms.InputTag('hltEcalDigisPortableSoA', 'eeDigis'),
0930         digisOutLabelEB = cms.string("ebDigis"),
0931         digisOutLabelEE = cms.string("eeDigis"),
0932         produceDummyIntegrityCollections = cms.bool(False)
0933     )
0934 
0935     process.hltEcalUncalibRecHitPortableSoA = cms.EDProducer("EcalUncalibRecHitProducerPortable@alpaka",
0936         EBtimeConstantTerm = process.hltEcalUncalibRecHitGPU.EBtimeConstantTerm,
0937         EBtimeFitLimits_Lower = process.hltEcalUncalibRecHitGPU.EBtimeFitLimits_Lower,
0938         EBtimeFitLimits_Upper = process.hltEcalUncalibRecHitGPU.EBtimeFitLimits_Upper,
0939         EBtimeNconst = process.hltEcalUncalibRecHitGPU.EBtimeNconst,
0940         EEtimeConstantTerm = process.hltEcalUncalibRecHitGPU.EEtimeConstantTerm,
0941         EEtimeFitLimits_Lower = process.hltEcalUncalibRecHitGPU.EEtimeFitLimits_Lower,
0942         EEtimeFitLimits_Upper = process.hltEcalUncalibRecHitGPU.EEtimeFitLimits_Upper,
0943         EEtimeNconst = process.hltEcalUncalibRecHitGPU.EEtimeNconst,
0944         amplitudeThresholdEB = process.hltEcalUncalibRecHitGPU.amplitudeThresholdEB,
0945         amplitudeThresholdEE = process.hltEcalUncalibRecHitGPU.amplitudeThresholdEE,
0946         digisLabelEB = cms.InputTag("hltEcalDigisPortableSoA", "ebDigis"),
0947         digisLabelEE = cms.InputTag("hltEcalDigisPortableSoA", "eeDigis"),
0948         kernelMinimizeThreads = process.hltEcalUncalibRecHitGPU.kernelMinimizeThreads,
0949         outOfTimeThresholdGain12mEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12mEB,
0950         outOfTimeThresholdGain12mEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12mEE,
0951         outOfTimeThresholdGain12pEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12pEB,
0952         outOfTimeThresholdGain12pEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12pEE,
0953         outOfTimeThresholdGain61mEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61mEB,
0954         outOfTimeThresholdGain61mEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61mEE,
0955         outOfTimeThresholdGain61pEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61pEB,
0956         outOfTimeThresholdGain61pEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61pEE,
0957         recHitsLabelEB = process.hltEcalUncalibRecHitGPU.recHitsLabelEB,
0958         recHitsLabelEE = process.hltEcalUncalibRecHitGPU.recHitsLabelEE,
0959         shouldRunTimingComputation = process.hltEcalUncalibRecHitGPU.shouldRunTimingComputation,
0960         # autoselect the alpaka backend
0961         alpaka = cms.untracked.PSet(
0962             backend = cms.untracked.string('')
0963         )
0964     )
0965 
0966     if hasattr(process, 'hltEcalUncalibRecHitGPU'):
0967         del process.hltEcalUncalibRecHitGPU
0968 
0969     process.ecalMultifitParametersSource = cms.ESSource("EmptyESSource",
0970         firstValid = cms.vuint32(1),
0971         iovIsRunNotTime = cms.bool(True),
0972         recordName = cms.string('EcalMultifitParametersRcd')
0973     )
0974 
0975     from RecoLocalCalo.EcalRecProducers.ecalMultifitConditionsHostESProducer_cfi import ecalMultifitConditionsHostESProducer as _ecalMultifitConditionsHostESProducer
0976     process.ecalMultifitConditionsHostESProducer = _ecalMultifitConditionsHostESProducer.clone()
0977 
0978     from RecoLocalCalo.EcalRecProducers.ecalMultifitParametersHostESProducer_cfi import ecalMultifitParametersHostESProducer as _ecalMultifitParametersHostESProducer
0979     process.ecalMultifitParametersHostESProducer = _ecalMultifitParametersHostESProducer.clone()
0980 
0981     process.hltEcalUncalibRecHit = cms.EDProducer("EcalUncalibRecHitSoAToLegacy",
0982         isPhase2 = process.hltEcalUncalibRecHitFromSoA.isPhase2,
0983         recHitsLabelCPUEB = process.hltEcalUncalibRecHitFromSoA.recHitsLabelCPUEB,
0984         recHitsLabelCPUEE = process.hltEcalUncalibRecHitFromSoA.recHitsLabelCPUEE,
0985         uncalibRecHitsPortableEB = cms.InputTag("hltEcalUncalibRecHitPortableSoA", "EcalUncalibRecHitsEB"),
0986         uncalibRecHitsPortableEE = cms.InputTag("hltEcalUncalibRecHitPortableSoA", "EcalUncalibRecHitsEE")
0987     )
0988 
0989     if hasattr(process, 'hltEcalUncalibRecHitSoA'):
0990         delattr(process, 'hltEcalUncalibRecHitSoA')
0991 
0992     process.hltEcalDetIdToBeRecovered = cms.EDProducer("EcalDetIdToBeRecoveredProducer",
0993         integrityBlockSizeErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityBlockSizeErrors'),
0994         integrityTTIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityTTIdErrors'),
0995 
0996         ebIntegrityGainErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainErrors'),
0997         eeIntegrityGainErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainErrors'),
0998 
0999         ebIntegrityGainSwitchErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainSwitchErrors'),
1000         eeIntegrityGainSwitchErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainSwitchErrors'),
1001 
1002         ebIntegrityChIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityChIdErrors'),
1003         eeIntegrityChIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityChIdErrors'),
1004 
1005         ebSrFlagCollection = cms.InputTag("hltEcalDigisLegacy"),
1006         eeSrFlagCollection = cms.InputTag("hltEcalDigisLegacy"),
1007 
1008         ebDetIdToBeRecovered = cms.string("ebDetId"),
1009         eeDetIdToBeRecovered = cms.string("eeDetId"),
1010 
1011         ebFEToBeRecovered = cms.string("ebFE"),
1012         eeFEToBeRecovered = cms.string("eeFE"),
1013     )
1014 
1015     process.hltEcalRecHit.triggerPrimitiveDigiCollection = 'hltEcalDigisLegacy:EcalTriggerPrimitives'
1016 
1017     process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence(
1018         process.hltEcalDigisLegacy +
1019         process.hltEcalDigisPortableSoA +
1020         process.hltEcalDigis +          # conversion of PortableSoA to legacy format
1021         process.hltEcalUncalibRecHitPortableSoA +
1022         process.hltEcalUncalibRecHit +  # conversion of PortableSoA to legacy format
1023         process.hltEcalDetIdToBeRecovered +
1024         process.hltEcalRecHit
1025     )
1026 
1027     process.HLTPreshowerSequence = cms.Sequence(process.hltEcalPreshowerDigis + process.hltEcalPreshowerRecHit)
1028 
1029     process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence(
1030         process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence +
1031         process.HLTPreshowerSequence
1032     )
1033 
1034     process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence(process.HLTDoFullUnpackingEgammaEcalSequence)
1035 
1036     process.hltEcalDigisCPUSerialSoA = makeSerialClone(process.hltEcalDigisPortableSoA)
1037 
1038     process.hltEcalDigisCPUSerial = process.hltEcalDigis.clone(
1039         digisInLabelEB = 'hltEcalDigisCPUSerialSoA:ebDigis',
1040         digisInLabelEE = 'hltEcalDigisCPUSerialSoA:eeDigis',
1041     )
1042 
1043     process.hltEcalUncalibRecHitCPUSerialSoA = makeSerialClone(process.hltEcalUncalibRecHitPortableSoA,
1044         digisLabelEB = "hltEcalDigisCPUSerialSoA:ebDigis",
1045         digisLabelEE = "hltEcalDigisCPUSerialSoA:eeDigis",
1046     )
1047 
1048     process.hltEcalUncalibRecHitCPUSerial = process.hltEcalUncalibRecHit.clone(
1049         uncalibRecHitsPortableEB = "hltEcalUncalibRecHitCPUSerialSoA:EcalUncalibRecHitsEB",
1050         uncalibRecHitsPortableEE = "hltEcalUncalibRecHitCPUSerialSoA:EcalUncalibRecHitsEE",
1051     )
1052 
1053     process.hltEcalRecHitCPUOnly = process.hltEcalRecHit.clone(
1054         EBuncalibRecHitCollection = 'hltEcalUncalibRecHitCPUSerial:EcalUncalibRecHitsEB',
1055         EEuncalibRecHitCollection = 'hltEcalUncalibRecHitCPUSerial:EcalUncalibRecHitsEE',
1056     )
1057 
1058     process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerCPUOnlySequence = cms.Sequence(
1059         process.hltEcalDigisLegacy +
1060         process.hltEcalDigisCPUSerialSoA +
1061         process.hltEcalDigisCPUSerial + # conversion of CPUSerialSoA to legacy format
1062         process.hltEcalUncalibRecHitCPUSerialSoA +
1063         process.hltEcalUncalibRecHitCPUSerial + # conversion of CPUSerialSoA to legacy format
1064         process.hltEcalDetIdToBeRecovered +
1065         process.hltEcalRecHitCPUOnly
1066     )
1067 
1068     for prod in producers_by_type(process, 'HLTRechitsToDigis'):
1069         prod.srFlagsIn = 'hltEcalDigisLegacy'
1070 
1071     for prod in producers_by_type(process, 'CorrectedECALPFClusterProducer'):
1072         try:
1073             prod.energyCorrector.ebSrFlagLabel = 'hltEcalDigisLegacy'
1074             prod.energyCorrector.eeSrFlagLabel = 'hltEcalDigisLegacy'
1075         except:
1076             pass
1077 
1078     for pathNameMatch in ['DQM_EcalReconstruction_v', 'DQM_HIEcalReconstruction_v']:
1079         dqmEcalRecoPathName = None
1080         for pathName in process.paths_():
1081             if pathName.startswith(pathNameMatch):
1082                 dqmEcalRecoPath = getattr(process, pathName)
1083                 dqmEcalRecoPath.insert(dqmEcalRecoPath.index(process.HLTEndSequence), getattr(process, 'HLTDoFullUnpackingEgammaEcalWithoutPreshowerCPUOnlySequence'))
1084                 for delmod in ['hltEcalConsumerCPU', 'hltEcalConsumerGPU']:
1085                     if hasattr(process, delmod):
1086                         process.__delattr__(delmod)
1087 
1088     for hltOutModMatch in ['hltOutputDQMGPUvsCPU', 'hltOutputHIDQMGPUvsCPU']:
1089         if hasattr(process, hltOutModMatch):
1090             outMod = getattr(process, hltOutModMatch)
1091             outCmds_new = [foo for foo in outMod.outputCommands if 'Ecal' not in foo]
1092             outCmds_new += [
1093                 'keep *_hltEcalDigis_*_*',
1094                 'keep *_hltEcalDigisCPUSerial_*_*',
1095                 'keep *_hltEcalUncalibRecHit_*_*',
1096                 'keep *_hltEcalUncalibRecHitCPUSerial_*_*',
1097             ]
1098             outMod.outputCommands = outCmds_new[:]
1099 
1100     return process
1101 
1102 
1103 def customizeHLTforAlpakaHcalLocalReco(process):
1104 
1105     ## failsafe for fake menus
1106     if not hasattr(process, 'HLTDoLocalHcalSequence'):
1107         return process
1108 
1109     ## do not re-apply the customization if the menu is already migrated to alpaka
1110     for prod in producers_by_type(process, 'HcalDigisSoAProducer@alpaka'):
1111         return process
1112 
1113     # EventSetup modules
1114     process.load('RecoLocalCalo.HcalRecProducers.hcalMahiConditionsESProducer_cfi')
1115     process.load('RecoLocalCalo.HcalRecProducers.hcalMahiPulseOffsetsESProducer_cfi')
1116     process.load('RecoLocalCalo.HcalRecProducers.hcalSiPMCharacteristicsESProducer_cfi')
1117     process.load('RecoLocalCalo.HcalRecAlgos.hcalRecoParamWithPulseShapeESProducer_cfi')
1118 
1119     # the JobConfigurationGPURecord is provided by the hltESSJobConfigurationGPURecord ESSource
1120 
1121     # convert the HCAL digis to SoA format
1122     from EventFilter.HcalRawToDigi.hcalDigisSoAProducer_cfi import hcalDigisSoAProducer as _hcalDigisSoAProducer
1123 
1124     # convert the HCAL digis to SoA format, and copies them to the device
1125     process.hltHcalDigisSoA = _hcalDigisSoAProducer.clone(
1126       hbheDigisLabel = 'hltHcalDigis',
1127       qie11DigiLabel = 'hltHcalDigis'
1128     )
1129 
1130     # convert the HCAL digis to SoA format, and copies them to the host
1131     process.hltHcalDigisSoASerialSync = makeSerialClone(process.hltHcalDigisSoA)
1132 
1133 
1134     # run the HCAL local reconstruction (MAHI) and produce the rechits in SoA format
1135     from RecoLocalCalo.HcalRecProducers.hbheRecHitProducerPortable_cfi import hbheRecHitProducerPortable as _hbheRecHitProducerPortable
1136 
1137     # run the HCAL local reconstruction (MAHI) and produce the rechits in SoA format on the device, and optionally copy the rechits to the host
1138     process.hltHbheRecoSoA = _hbheRecHitProducerPortable.clone(
1139       digisLabelF01HE = ('hltHcalDigisSoA', 'f01HEDigis'),
1140       digisLabelF5HB = ('hltHcalDigisSoA', 'f5HBDigis'),
1141       digisLabelF3HB = ('hltHcalDigisSoA', 'f3HBDigis'),
1142       recHitsLabelM0HBHE = '',
1143       mahiPulseOffSets = 'hcalMahiPulseOffsetsESProducer:'
1144     )
1145 
1146     # run the HCAL local reconstruction (MAHI) and produce the rechits in SoA format on the host
1147     process.hltHbheRecoSoASerialSync = makeSerialClone(process.hltHbheRecoSoA,
1148       digisLabelF01HE = ('hltHcalDigisSoASerialSync', 'f01HEDigis'),
1149       digisLabelF5HB = ('hltHcalDigisSoASerialSync', 'f5HBDigis'),
1150       digisLabelF3HB = ('hltHcalDigisSoASerialSync', 'f3HBDigis'),
1151     )
1152 
1153 
1154     # convert the rechits in SoA format on the host to legacy format
1155     from RecoLocalCalo.HcalRecProducers.hcalRecHitSoAToLegacy_cfi import hcalRecHitSoAToLegacy as _hcalRecHitSoAToLegacy
1156 
1157     # convert the rechits in SoA format on the host to legacy format
1158     process.hltHbhereco = _hcalRecHitSoAToLegacy.clone(
1159       src = 'hltHbheRecoSoA'
1160     )
1161 
1162     # convert the rechits in SoA format on the host to legacy format
1163     process.hltHbherecoSerialSync = process.hltHbhereco.clone(
1164       src = 'hltHbheRecoSoASerialSync'
1165     )
1166 
1167     # update the label of the rechits produced on the host
1168     process.hltTowerMakerForAllSerialSync.hbheInput = "hltHbherecoSerialSync"
1169     process.hltAK4CaloJetsIDPassedSerialSync.JetIDParams.hbheRecHitsColl = "hltHbherecoSerialSync"
1170     process.hltHbheRecHitSoASerialSync.src = "hltHbherecoSerialSync"
1171     process.hltMuonsSerialSync.TrackAssociatorParameters.HBHERecHitCollectionLabel = "hltHbherecoSerialSync"
1172     process.hltMuonsSerialSync.CaloExtractorPSet.TrackAssociatorParameters.HBHERecHitCollectionLabel = "hltHbherecoSerialSync"
1173     process.hltMuonsSerialSync.JetExtractorPSet.TrackAssociatorParameters.HBHERecHitCollectionLabel = "hltHbherecoSerialSync"
1174 
1175     # run the HCAL local reconstruction, potentially offloading the MHI step to the device
1176     process.HLTDoLocalHcalSequence = cms.Sequence(
1177       process.hltHcalDigis +
1178       process.hltHcalDigisSoA +
1179       process.hltHbheRecoSoA +
1180       process.hltHbhereco +
1181       process.hltHfprereco +
1182       process.hltHfreco +
1183       process.hltHoreco )
1184 
1185     # run the HCAL local reconstruction on the host
1186     process.HLTDoLocalHcalSequenceSerialSync = cms.Sequence(
1187       process.hltHcalDigis +
1188       process.hltHcalDigisSoASerialSync +
1189       process.hltHbheRecoSoASerialSync +
1190       process.hltHbherecoSerialSync +
1191       process.hltHfprereco +
1192       process.hltHfreco +
1193       process.hltHoreco )
1194 
1195     process.HLTDoCaloSequenceSerialSync = cms.Sequence(
1196         process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequenceSerialSync +
1197         process.HLTDoLocalHcalSequenceSerialSync +
1198         process.hltTowerMakerForAllSerialSync )
1199 
1200     process.HLTDoCaloSequencePFSerialSync = cms.Sequence(
1201         process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequenceSerialSync +
1202         process.HLTDoLocalHcalSequenceSerialSync +
1203         process.hltTowerMakerForAllSerialSync )
1204 
1205     # run the HBHE local reconstruction, potentially offloading the MHI step to the device
1206     process.HLTStoppedHSCPLocalHcalReco = cms.Sequence(
1207       process.hltHcalDigis +
1208       process.hltHcalDigisSoA +
1209       process.hltHbheRecoSoA +
1210       process.hltHbhereco )
1211 
1212     # PFJet reconstruction running on the host
1213     process.HLTPFHcalClusteringSerialSync = cms.Sequence(
1214       process.hltHbheRecHitSoASerialSync +
1215       process.hltParticleFlowRecHitHBHESoASerialSync +
1216       process.hltParticleFlowRecHitHBHESerialSync +
1217       process.hltParticleFlowClusterHBHESoASerialSync +
1218       process.hltParticleFlowClusterHBHESerialSync +
1219       process.hltParticleFlowClusterHCALSerialSync )
1220 
1221     # compare the HCAL local reconstruction running on the device and on the host
1222     for pathNameMatch in ['DQM_HcalReconstruction_v', 'DQM_HIHcalReconstruction_v']:
1223         dqmHcalRecoPathName = None
1224         for pathName in process.paths_():
1225             if pathName.startswith(pathNameMatch):
1226                 dqmHcalRecoPath = getattr(process, pathName)
1227                 dqmHcalRecoPath.insert(dqmHcalRecoPath.index(process.HLTPFHcalClustering), getattr(process, 'HLTDoLocalHcalSequenceSerialSync'))
1228                 for delmod in ['hltHcalConsumerCPU', 'hltHcalConsumerGPU']:
1229                     if hasattr(process, delmod):
1230                         process.__delattr__(delmod)
1231 
1232     # modify EventContent of *DQMGPUvsCPU streams
1233     for hltOutModMatch in ['hltOutputDQMGPUvsCPU', 'hltOutputHIDQMGPUvsCPU']:
1234         if hasattr(process, hltOutModMatch):
1235             outMod = getattr(process, hltOutModMatch)
1236             outCmds_new = [foo for foo in outMod.outputCommands if 'Hbhe' not in foo]
1237             outCmds_new += [
1238                 'keep *_hltHbhereco_*_*',
1239                 'keep *_hltHbherecoSerialSync_*_*',
1240             ]
1241             outMod.outputCommands = outCmds_new[:]
1242 
1243     # delete the obsolete modules and tasks
1244     del process.hcalMahiPulseOffsetsGPUESProducer
1245     del process.hcalChannelQualityGPUESProducer
1246     del process.hcalConvertedEffectivePedestalWidthsGPUESProducer
1247     del process.hcalConvertedEffectivePedestalsGPUESProducer
1248     del process.hcalConvertedPedestalWidthsGPUESProducer
1249     del process.hcalConvertedPedestalsGPUESProducer
1250     del process.hcalElectronicsMappingGPUESProducer
1251     del process.hcalGainWidthsGPUESProducer
1252     del process.hcalGainsGPUESProducer
1253     del process.hcalLUTCorrsGPUESProducer
1254     del process.hcalQIECodersGPUESProducer
1255     del process.hcalQIETypesGPUESProducer
1256     del process.hcalRecoParamsWithPulseShapesGPUESProducer
1257     del process.hcalRespCorrsGPUESProducer
1258     del process.hcalSiPMCharacteristicsGPUESProducer
1259     del process.hcalSiPMParametersGPUESProducer
1260     del process.hcalTimeCorrsGPUESProducer
1261 
1262     del process.hltHbherecoLegacy
1263     del process.hltHcalDigisGPU
1264     del process.hltHbherecoGPU
1265     del process.hltHbherecoFromGPU
1266 
1267     del process.HLTDoLocalHcalTask
1268     del process.HLTStoppedHSCPLocalHcalRecoTask
1269 
1270     return process
1271 
1272 def customizeHLTforAlpakaStatus(process):
1273 
1274     if not hasattr(process, 'statusOnGPU'):
1275         return process
1276 
1277     process.hltBackend = cms.EDProducer('AlpakaBackendProducer@alpaka')
1278 
1279     insert_modules_before(process, process.statusOnGPU, process.hltBackend)
1280 
1281     del process.statusOnGPU
1282 
1283     process.hltStatusOnGPUFilter = cms.EDFilter('AlpakaBackendFilter',
1284         producer = cms.InputTag('hltBackend', 'backend'),
1285         backends = cms.vstring('CudaAsync', 'ROCmAsync')
1286     )
1287 
1288     insert_modules_before(process, process.statusOnGPUFilter, process.hltStatusOnGPUFilter)
1289     insert_modules_before(process, ~process.statusOnGPUFilter, ~process.hltStatusOnGPUFilter)
1290 
1291     del process.statusOnGPUFilter
1292 
1293     return process
1294 
1295 
1296 def _replace_object(process, target, obj):
1297     for container in itertools.chain(
1298         process.sequences_().values(),
1299         process.paths_().values(),
1300         process.endpaths_().values()
1301     ):
1302         if target.label() in [bar for foo,bar in container.directDependencies()]:
1303             try:
1304                 position = container.index(target)
1305                 container.insert(position, obj)
1306                 container.remove(target)
1307             except ValueError:
1308                 container.associate(obj)
1309                 container.remove(target)
1310 
1311     for container in itertools.chain(
1312         process.tasks_().values(),
1313         process.conditionaltasks_().values(),
1314     ):
1315         if target.label() in [bar for foo,bar in container.directDependencies()]:
1316             container.add(obj)
1317             container.remove(target)
1318 
1319     return process
1320 
1321 def _rename_edmodule(process, oldModuleLabel, newModuleLabel, typeBlackList):
1322     if not hasattr(process, oldModuleLabel) or hasattr(process, newModuleLabel) or oldModuleLabel == newModuleLabel:
1323         return process
1324     oldObj = getattr(process, oldModuleLabel)
1325     if oldObj.type_() in typeBlackList:
1326         return process
1327     setattr(process, newModuleLabel, oldObj.clone())
1328     newObj = getattr(process, newModuleLabel)
1329     process = _replace_object(process, oldObj, newObj)
1330     process.__delattr__(oldModuleLabel)
1331     process = massReplaceInputTag(process, oldModuleLabel, newModuleLabel, False, True, False)
1332     for outputModuleLabel in process.outputModules_():
1333         outputModule = getattr(process, outputModuleLabel)
1334         if not hasattr(outputModule, 'outputCommands'):
1335             continue
1336         for outputCmdIdx, outputCmd in enumerate(outputModule.outputCommands):
1337             outputModule.outputCommands[outputCmdIdx] = outputCmd.replace(f'_{oldModuleLabel}_', f'_{newModuleLabel}_')
1338     return process
1339 
1340 def _rename_edmodules(process, matchExpr, oldStr, newStr, typeBlackList):
1341     for moduleDict in [process.producers_(), process.filters_(), process.analyzers_()]:
1342         moduleLabels = list(moduleDict.keys())
1343         for moduleLabel in moduleLabels:
1344             if bool(re.match(matchExpr, moduleLabel)):
1345                 moduleLabelNew = moduleLabel.replace(oldStr, '') + newStr
1346                 process = _rename_edmodule(process, moduleLabel, moduleLabelNew, typeBlackList)
1347     return process
1348 
1349 def _rename_container(process, oldContainerLabel, newContainerLabel):
1350     if not hasattr(process, oldContainerLabel) or hasattr(process, newContainerLabel) or oldContainerLabel == newContainerLabel:
1351         return process
1352     oldObj = getattr(process, oldContainerLabel)
1353     setattr(process, newContainerLabel, oldObj.copy())
1354     newObj = getattr(process, newContainerLabel)
1355     process = _replace_object(process, oldObj, newObj)
1356     process.__delattr__(oldContainerLabel)
1357     return process
1358 
1359 def _rename_containers(process, matchExpr, oldStr, newStr):
1360     for containerName in itertools.chain(
1361         process.sequences_().keys(),
1362         process.tasks_().keys(),
1363         process.conditionaltasks_().keys()
1364     ):
1365         if bool(re.match(matchExpr, containerName)):
1366             containerNameNew = containerName.replace(oldStr, '') + newStr
1367             process = _rename_container(process, containerName, containerNameNew)
1368     return process
1369 
1370 def customizeHLTforAlpakaRename(process):
1371     # mass renaming of EDModules and Sequences:
1372     # if the label matches matchRegex, remove oldStr and append newStr
1373     for matchRegex, oldStr, newStr in [
1374         [".*Portable.*", "Portable", ""],
1375         [".*SerialSync.*", "SerialSync", "SerialSync"],
1376         [".*CPUSerial.*", "CPUSerial", "SerialSync"],
1377         [".*CPUOnly.*", "CPUOnly", "SerialSync"],
1378     ]:
1379         process = _rename_edmodules(process, matchRegex, oldStr, newStr, ['HLTPrescaler'])
1380         process = _rename_containers(process, matchRegex, oldStr, newStr)
1381 
1382     return process
1383 
1384 
1385 def customizeHLTforAlpaka(process):
1386     process.load('Configuration.StandardSequences.Accelerators_cff')
1387 
1388     process = customizeHLTforAlpakaStatus(process)
1389     process = customizeHLTforAlpakaPixelReco(process)
1390     process = customizeHLTforAlpakaEcalLocalReco(process)
1391     process = customizeHLTforAlpakaHcalLocalReco(process)
1392     process = customizeHLTforAlpakaParticleFlowClustering(process)
1393     process = customizeHLTforAlpakaPFSoA(process)
1394     process = customizeHLTforAlpakaRename(process)
1395 
1396     return process