Exemple #1
0
def customisePixelLocalReconstruction(process):

    if not 'HLTDoLocalPixelSequence' in process.__dict__:
        return process

    # FIXME replace the Sequences with empty ones to avoid exanding them during the (re)definition of Modules and EDAliases

    process.HLTDoLocalPixelSequence = cms.Sequence()

    # Event Setup

    process.load(
        "CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load(
        "CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load("RecoLocalTracker.SiPixelRecHits.PixelCPEFastESProducer_cfi")

    # Modules and EDAliases

    # referenced in HLTDoLocalPixelTask

    # transfer the beamspot to the gpu
    from RecoVertex.BeamSpotProducer.offlineBeamSpotToCUDA_cfi import offlineBeamSpotToCUDA as _offlineBeamSpotToCUDA
    process.hltOnlineBeamSpotToCUDA = _offlineBeamSpotToCUDA.clone(
        src="hltOnlineBeamSpot")

    # reconstruct the pixel digis and clusters on the gpu
    from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA
    process.hltSiPixelClustersCUDA = _siPixelRawToClusterCUDA.clone()
    # use the pixel channel calibrations scheme for Run 3
    run3_common.toModify(process.hltSiPixelClustersCUDA, isRun2=False)

    # copy the pixel digis errors to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA
    process.hltSiPixelDigiErrorsSoA = _siPixelDigiErrorsSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # convert the pixel digis errors to the legacy format
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA
    process.hltSiPixelDigiErrors = _siPixelDigiErrorsFromSoA.clone(
        digiErrorSoASrc="hltSiPixelDigiErrorsSoA", UsePhase1=True)

    # copy the pixel digis (except errors) and clusters to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA
    process.hltSiPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # convert the pixel digis (except errors) and clusters to the legacy format
    from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA
    process.hltSiPixelDigisClusters = _siPixelDigisClustersFromSoA.clone(
        src="hltSiPixelDigisSoA")

    # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA
    process.hltSiPixelDigis = SwitchProducerCUDA(
        # legacy producer
        cpu=process.hltSiPixelDigis,
        # alias used to access products from multiple conversion modules
        cuda=cms.EDAlias(
            hltSiPixelDigisClusters=cms.VPSet(
                cms.PSet(type=cms.string("PixelDigiedmDetSetVector"))),
            hltSiPixelDigiErrors=cms.VPSet(
                cms.PSet(type=cms.string("DetIdedmEDCollection")),
                cms.PSet(
                    type=cms.string("SiPixelRawDataErroredmDetSetVector")),
                cms.PSet(
                    type=cms.string("PixelFEDChanneledmNewDetSetVector")))))

    # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA
    process.hltSiPixelClusters = SwitchProducerCUDA(
        # legacy producer
        cpu=process.hltSiPixelClusters,
        # alias used to access products from multiple conversion modules
        cuda=cms.EDAlias(hltSiPixelDigisClusters=cms.VPSet(
            cms.PSet(type=cms.string("SiPixelClusteredmNewDetSetVector")))))

    # reconstruct the pixel rechits on the gpu
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA
    process.hltSiPixelRecHitsCUDA = _siPixelRecHitCUDA.clone(
        src="hltSiPixelClustersCUDA", beamSpot="hltOnlineBeamSpotToCUDA")

    # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA
    process.hltSiPixelRecHits = SwitchProducerCUDA(
        # legacy producer
        cpu=process.hltSiPixelRecHits,
        # converter to legacy format
        cuda=_siPixelRecHitFromCUDA.clone(
            pixelRecHitSrc="hltSiPixelRecHitsCUDA", src="hltSiPixelClusters"))

    # Tasks and Sequences

    process.HLTDoLocalPixelTask = cms.Task(
        process.hltOnlineBeamSpotToCUDA,  # transfer the beamspot to the gpu
        process.
        hltSiPixelClustersCUDA,  # reconstruct the pixel digis and clusters on the gpu
        process.
        hltSiPixelRecHitsCUDA,  # reconstruct the pixel rechits on the gpu
        process.
        hltSiPixelDigisSoA,  # copy the pixel digis (except errors) and clusters to the host
        process.
        hltSiPixelDigisClusters,  # convert the pixel digis (except errors) and clusters to the legacy format
        process.
        hltSiPixelDigiErrorsSoA,  # copy the pixel digis errors to the host
        process.
        hltSiPixelDigiErrors,  # convert the pixel digis errors to the legacy format
        process.
        hltSiPixelDigis,  # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA
        process.
        hltSiPixelClusters,  # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA
        process.
        hltSiPixelClustersCache,  # legacy module, used by the legacy pixel quadruplet producer
        process.hltSiPixelRecHits
    )  # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA

    process.HLTDoLocalPixelSequence = cms.Sequence(process.HLTDoLocalPixelTask)

    # done
    return process
Exemple #2
0
# transfer the pixel rechits to the host and convert them from SoA
from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA

#this is an alias for the SoA on GPU or CPU to be used for DQM
siPixelRecHitsPreSplittingSoA = SwitchProducerCUDA(
    cpu=cms.EDAlias(siPixelRecHitsPreSplittingCPU=cms.VPSet(
        cms.PSet(type=cms.string(
            "cmscudacompatCPUTraitsTrackingRecHit2DHeterogeneous")),
        cms.PSet(type=cms.string("uintAsHostProduct")))), )

(gpu & pixelNtupletFit).toModify(siPixelRecHitsPreSplittingSoA,
                                 cuda=_siPixelRecHitSoAFromCUDA.clone())

(gpu & pixelNtupletFit).toModify(siPixelRecHitsPreSplitting,
                                 cuda=_siPixelRecHitFromCUDA.clone())

pixelNtupletFit.toReplaceWith(
    siPixelRecHitsPreSplittingTask,
    cms.Task(
        cms.Task(
            # reconstruct the pixel rechits on the cpu
            siPixelRecHitsPreSplittingCPU,
            # SwitchProducer wrapping an EDAlias on cpu or the converter from SoA to legacy on gpu
            siPixelRecHitsPreSplittingTask.copy(),
            # producing and converting on cpu (if needed)
            siPixelRecHitsPreSplittingSoA)))

(gpu & pixelNtupletFit).toReplaceWith(
    siPixelRecHitsPreSplittingTask,
    cms.Task(
Exemple #3
0
# SwitchProducer wrapping the legacy pixel rechit producer
siPixelRecHitsPreSplitting = SwitchProducerCUDA(cpu=siPixelRecHits.clone(
    src='siPixelClustersPreSplitting'))

# convert the pixel rechits from legacy to SoA format
from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy as siPixelRecHitsPreSplittingSoA

siPixelRecHitsPreSplittingTask = cms.Task(
    # SwitchProducer wrapping the legacy pixel rechit producer
    siPixelRecHitsPreSplitting,
    # convert the pixel rechits from legacy to SoA format
    siPixelRecHitsPreSplittingSoA)

# reconstruct the pixel rechits on the gpu
from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA
siPixelRecHitsPreSplittingCUDA = _siPixelRecHitCUDA.clone(
    beamSpot="offlineBeamSpotToCUDA")

# transfer the pixel rechits to the host and convert them from SoA
from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA
gpu.toModify(siPixelRecHitsPreSplitting, cuda=_siPixelRecHitFromCUDA.clone())

gpu.toReplaceWith(
    siPixelRecHitsPreSplittingTask,
    cms.Task(
        # reconstruct the pixel rechits on the gpu
        siPixelRecHitsPreSplittingCUDA,
        # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
        siPixelRecHitsPreSplittingTask.copy()))
def customisePixelLocalReconstruction(process):

    if not 'HLTDoLocalPixelSequence' in process.__dict__:
        return process

    # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases

    process.HLTDoLocalPixelSequence = cms.Sequence()

    # Event Setup

    process.load(
        "CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load(
        "CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load("RecoLocalTracker.SiPixelRecHits.PixelCPEFastESProducer_cfi")

    # Modules and EDAliases

    # referenced in HLTDoLocalPixelTask

    # transfer the beamspot to the gpu
    from RecoVertex.BeamSpotProducer.offlineBeamSpotToCUDA_cfi import offlineBeamSpotToCUDA as _offlineBeamSpotToCUDA
    process.hltOnlineBeamSpotToCUDA = _offlineBeamSpotToCUDA.clone(
        src="hltOnlineBeamSpot")

    # reconstruct the pixel digis and clusters on the gpu
    from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA
    process.hltSiPixelClustersCUDA = _siPixelRawToClusterCUDA.clone(
        # use the same thresholds as the legacy module
        clusterThreshold_layer1=process.hltSiPixelClusters.ClusterThreshold_L1,
        clusterThreshold_otherLayers=process.hltSiPixelClusters.
        ClusterThreshold)
    # use the pixel channel calibrations scheme for Run 3
    run3_common.toModify(process.hltSiPixelClustersCUDA, isRun2=False)

    # copy the pixel digis errors to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA
    process.hltSiPixelDigiErrorsSoA = _siPixelDigiErrorsSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # copy the pixel digis (except errors) and clusters to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA
    process.hltSiPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # reconstruct the pixel digis on the cpu
    process.hltSiPixelDigisLegacy = process.hltSiPixelDigis.clone()

    # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors to the legacy format
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA
    process.hltSiPixelDigis = SwitchProducerCUDA(
        # legacy producer
        cpu=cms.EDAlias(hltSiPixelDigisLegacy=cms.VPSet(
            cms.PSet(type=cms.string("DetIdedmEDCollection")),
            cms.PSet(type=cms.string("SiPixelRawDataErroredmDetSetVector")),
            cms.PSet(type=cms.string("PixelFEDChanneledmNewDetSetVector")))),
        # conversion from SoA to legacy format
        cuda=_siPixelDigiErrorsFromSoA.clone(
            digiErrorSoASrc="hltSiPixelDigiErrorsSoA", UsePhase1=True))

    # reconstruct the pixel clusters on the cpu
    process.hltSiPixelClustersLegacy = process.hltSiPixelClusters.clone(
        src="hltSiPixelDigisLegacy")

    # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters to the legacy format
    from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA
    process.hltSiPixelClusters = SwitchProducerCUDA(
        # legacy producer
        cpu=cms.EDAlias(hltSiPixelClustersLegacy=cms.VPSet(
            cms.PSet(type=cms.string("SiPixelClusteredmNewDetSetVector")))),
        # conversion from SoA to legacy format
        cuda=_siPixelDigisClustersFromSoA.clone(
            src="hltSiPixelDigisSoA",
            produceDigis=False,
            storeDigis=False,
            # use the same thresholds as the legacy module
            clusterThreshold_layer1=process.hltSiPixelClusters.
            ClusterThreshold_L1,
            clusterThreshold_otherLayers=process.hltSiPixelClusters.
            ClusterThreshold))

    # reconstruct the pixel rechits on the gpu
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA
    process.hltSiPixelRecHitsCUDA = _siPixelRecHitCUDA.clone(
        src="hltSiPixelClustersCUDA", beamSpot="hltOnlineBeamSpotToCUDA")

    # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA
    process.hltSiPixelRecHits = SwitchProducerCUDA(
        # legacy producer
        cpu=process.hltSiPixelRecHits,
        # conversion from SoA to legacy format
        cuda=_siPixelRecHitFromCUDA.clone(
            pixelRecHitSrc="hltSiPixelRecHitsCUDA", src="hltSiPixelClusters"))

    # Tasks and Sequences

    process.HLTDoLocalPixelTask = cms.Task(
        process.hltOnlineBeamSpotToCUDA,  # transfer the beamspot to the gpu
        process.
        hltSiPixelClustersCUDA,  # reconstruct the pixel digis and clusters on the gpu
        process.
        hltSiPixelRecHitsCUDA,  # reconstruct the pixel rechits on the gpu
        process.
        hltSiPixelDigisSoA,  # copy the pixel digis (except errors) and clusters to the host
        process.
        hltSiPixelDigiErrorsSoA,  # copy the pixel digis errors to the host
        process.hltSiPixelDigisLegacy,  # legacy pixel digis producer
        process.
        hltSiPixelDigis,  # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors from SoA
        process.hltSiPixelClustersLegacy,  # legacy pixel cluster producer
        process.
        hltSiPixelClusters,  # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters from SoA
        process.
        hltSiPixelClustersCache,  # legacy module, used by the legacy pixel quadruplet producer
        process.hltSiPixelRecHits
    )  # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA

    process.HLTDoLocalPixelSequence = cms.Sequence(process.HLTDoLocalPixelTask)

    # 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 + process.hltScalersRawToDigi +
            process.hltPreAlCaLumiPixelsCountsRandom +
            process.hltPixelTrackerHVOn + 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 + process.hltScalersRawToDigi +
            process.hltL1sZeroBias +
            process.hltPreAlCaLumiPixelsCountsZeroBias +
            process.hltPixelTrackerHVOn + process.HLTDoLocalPixelSequence +
            process.hltAlcaPixelClusterCounts + process.HLTEndSequence)
        if "HLTSchedule" in process.__dict__:
            process.HLTSchedule.insert(
                ind, process.AlCa_LumiPixelsCounts_ZeroBias_v1)

    # done
    return process
Exemple #5
0
def customisePixelLocalReconstruction(process):

    if not 'HLTDoLocalPixelSequence' in process.__dict__:
        return process

    # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases

    process.HLTDoLocalPixelSequence = cms.Sequence()

    # Event Setup

    process.load(
        "CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load(
        "CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi"
    )  # this should be used only on GPUs, will crash otherwise
    process.load("RecoLocalTracker.SiPixelRecHits.PixelCPEFastESProducer_cfi")

    # Modules and EDAliases

    # referenced in HLTDoLocalPixelTask

    # transfer the beamspot to the gpu
    from RecoVertex.BeamSpotProducer.offlineBeamSpotToCUDA_cfi import offlineBeamSpotToCUDA as _offlineBeamSpotToCUDA
    process.hltOnlineBeamSpotToCUDA = _offlineBeamSpotToCUDA.clone(
        src="hltOnlineBeamSpot")

    # reconstruct the pixel digis and clusters on the gpu
    from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA
    if 'hltSiPixelClustersLegacy' in process.__dict__:
        process.hltSiPixelClustersCUDA = _siPixelRawToClusterCUDA.clone(
            # use the same thresholds as the legacy module
            clusterThreshold_layer1=process.hltSiPixelClustersLegacy.
            ClusterThreshold_L1,
            clusterThreshold_otherLayers=process.hltSiPixelClustersLegacy.
            ClusterThreshold)

    else:
        process.hltSiPixelClustersCUDA = _siPixelRawToClusterCUDA.clone(
            # use the same thresholds as the legacy module
            clusterThreshold_layer1=process.hltSiPixelClusters.
            ClusterThreshold_L1,
            clusterThreshold_otherLayers=process.hltSiPixelClusters.
            ClusterThreshold)

    # use the pixel channel calibrations scheme for Run 3
    run3_common.toModify(process.hltSiPixelClustersCUDA, isRun2=False)

    # copy the pixel digis errors to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA
    process.hltSiPixelDigiErrorsSoA = _siPixelDigiErrorsSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # copy the pixel digis (except errors) and clusters to the host
    from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA
    process.hltSiPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone(
        src="hltSiPixelClustersCUDA")

    # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors to the legacy format
    if not isinstance(process.hltSiPixelDigis, SwitchProducerCUDA):

        if 'hltSiPixelDigisLegacy' in process.__dict__:
            raise Exception(
                'unsupported configuration: "process.hltSiPixelDigis" is not a SwitchProducerCUDA, but "process.hltSiPixelDigisLegacy" already exists'
            )

        # reconstruct the pixel digis on the cpu
        process.hltSiPixelDigisLegacy = process.hltSiPixelDigis.clone()

        # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors to the legacy format
        process.hltSiPixelDigis = SwitchProducerCUDA(
            # legacy producer
            cpu=cms.EDAlias(hltSiPixelDigisLegacy=cms.VPSet(
                cms.PSet(type=cms.string("DetIdedmEDCollection")),
                cms.PSet(
                    type=cms.string("SiPixelRawDataErroredmDetSetVector")),
                cms.PSet(
                    type=cms.string("PixelFEDChanneledmNewDetSetVector")))))
    # conversion from SoA to legacy format
    from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA
    process.hltSiPixelDigis.cuda = _siPixelDigiErrorsFromSoA.clone(
        digiErrorSoASrc="hltSiPixelDigiErrorsSoA", UsePhase1=True)

    # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters to the legacy format
    if not isinstance(process.hltSiPixelClusters, SwitchProducerCUDA):

        if 'hltSiPixelClustersLegacy' in process.__dict__:
            raise Exception(
                'unsupported configuration: "process.hltSiPixelClusters" is not a SwitchProducerCUDA, but "process.hltSiPixelClustersLegacy" already exists'
            )

        # reconstruct the pixel clusters on the cpu
        process.hltSiPixelClustersLegacy = process.hltSiPixelClusters.clone(
            src="hltSiPixelDigisLegacy")

        process.hltSiPixelClusters = SwitchProducerCUDA(
            # legacy producer
            cpu=cms.EDAlias(hltSiPixelClustersLegacy=cms.VPSet(
                cms.PSet(
                    type=cms.string("SiPixelClusteredmNewDetSetVector")))))
    # conversion from SoA to legacy format
    from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA
    process.hltSiPixelClusters.cuda = _siPixelDigisClustersFromSoA.clone(
        src="hltSiPixelDigisSoA",
        produceDigis=False,
        storeDigis=False,
        # use the same thresholds as the legacy module
        clusterThreshold_layer1=process.hltSiPixelClustersLegacy.
        ClusterThreshold_L1,
        clusterThreshold_otherLayers=process.hltSiPixelClustersLegacy.
        ClusterThreshold)

    # reconstruct the pixel rechits on the gpu
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA
    process.hltSiPixelRecHitsCUDA = _siPixelRecHitCUDA.clone(
        src="hltSiPixelClustersCUDA", beamSpot="hltOnlineBeamSpotToCUDA")

    # cpu only: produce the pixel rechits in SoA and legacy format, from the legacy clusters
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy as _siPixelRecHitSoAFromLegacy
    process.hltSiPixelRecHitSoA = _siPixelRecHitSoAFromLegacy.clone(
        src="hltSiPixelClusters",
        beamSpot="hltOnlineBeamSpot",
        convertToLegacy=True)

    # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA
    process.hltSiPixelRecHits = SwitchProducerCUDA(
        # legacy producer
        cpu=cms.EDAlias(hltSiPixelRecHitSoA=cms.VPSet(
            cms.PSet(type=cms.string("SiPixelRecHitedmNewDetSetVector")),
            cms.PSet(type=cms.string("uintAsHostProduct")))),
        # conversion from SoA to legacy format
        cuda=_siPixelRecHitFromCUDA.clone(
            pixelRecHitSrc="hltSiPixelRecHitsCUDA", src="hltSiPixelClusters"))

    # Tasks and Sequences
    if 'HLTDoLocalPixelTask' in process.__dict__ and not isinstance(
            process.HLTDoLocalPixelTask, cms.Task):
        raise Exception(
            'unsupported configuration: "process.HLTDoLocalPixelTask" already exists, but it is not a Task'
        )

    process.HLTDoLocalPixelTask = cms.Task(
        process.hltOnlineBeamSpotToCUDA,  # transfer the beamspot to the gpu
        process.
        hltSiPixelClustersCUDA,  # reconstruct the pixel digis and clusters on the gpu
        process.
        hltSiPixelRecHitsCUDA,  # reconstruct the pixel rechits on the gpu
        process.
        hltSiPixelDigisSoA,  # copy the pixel digis (except errors) and clusters to the host
        process.
        hltSiPixelDigiErrorsSoA,  # copy the pixel digis errors to the host
        process.hltSiPixelDigisLegacy,  # legacy pixel digis producer
        process.
        hltSiPixelDigis,  # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors from SoA
        process.hltSiPixelClustersLegacy,  # legacy pixel cluster producer
        process.
        hltSiPixelClusters,  # SwitchProducer wrapping a subset of the legacy pixel cluster producer, or the conversion of the pixel digis (except errors) and clusters from SoA
        process.
        hltSiPixelClustersCache,  # legacy module, used by the legacy pixel quadruplet producer
        process.
        hltSiPixelRecHitSoA,  # pixel rechits on cpu, in SoA & legacy format
        process.hltSiPixelRecHits
    )  # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA

    process.HLTDoLocalPixelSequence = cms.Sequence(process.HLTDoLocalPixelTask)

    # workaround for old version of AlCa_LumiPixelsCounts paths
    for AlCaPathName in [
            'AlCa_LumiPixelsCounts_Random_v1',
            'AlCa_LumiPixelsCounts_ZeroBias_v1'
    ]:
        if AlCaPathName in process.__dict__:
            AlCaPath = getattr(process, AlCaPathName)
            # replace hltSiPixelDigis+hltSiPixelClusters with HLTDoLocalPixelSequence
            hasSiPixelDigis, hasSiPixelClusters = False, False
            for (itemLabel, itemName) in AlCaPath.directDependencies():
                if itemLabel != 'modules': continue
                if itemName == 'hltSiPixelDigis': hasSiPixelDigis = True
                elif itemName == 'hltSiPixelClusters':
                    hasSiPixelClusters = True
            if hasSiPixelDigis and hasSiPixelClusters:
                AlCaPath.remove(process.hltSiPixelClusters)
                AlCaPath.replace(process.hltSiPixelDigis,
                                 process.HLTDoLocalPixelSequence)

    # done
    return process