def customizePixelTracksSoAonCPU(process):

    process.CUDAService = cms.Service('CUDAService',
                                      enabled=cms.untracked.bool(False))

    # ensure the same results when running on GPU (which supports only the 'HLT' payload) and CPU
    process.siPixelClustersPreSplitting.cpu.payloadType = cms.string('HLT')

    from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy
    process.siPixelRecHitsPreSplitting = siPixelRecHitSoAFromLegacy.clone(
        convertToLegacy=True)

    from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA
    process.pixelTrackSoA = caHitNtupletCUDA.clone(
        onGPU=False, pixelRecHitSrc='siPixelRecHitsPreSplitting')

    from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA
    process.pixelVertexSoA = pixelVertexCUDA.clone(
        onGPU=False, pixelTrackSrc='pixelTrackSoA')

    from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA
    process.pixelTracks = pixelTrackProducerFromSoA.clone(
        pixelRecHitLegacySrc='siPixelRecHitsPreSplitting')

    from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA
    process.pixelVertices = pixelVertexFromSoA.clone()

    process.reconstruction_step += process.siPixelRecHitsPreSplitting + process.pixelTrackSoA + process.pixelVertexSoA

    return process
Пример #2
0
def customisePixelTrackReconstruction(process):

    if not 'HLTRecoPixelTracksSequence' 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.HLTRecoPixelTracksSequence = cms.Sequence()
    process.HLTRecopixelvertexingSequence = cms.Sequence()

    # Modules and EDAliases

    # referenced in process.HLTRecoPixelTracksTask

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

    # build pixel ntuplets and pixel tracks in SoA format on gpu
    from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA as _caHitNtupletCUDA
    process.hltPixelTracksCUDA = _caHitNtupletCUDA.clone(
        idealConditions=False,
        pixelRecHitSrc="hltSiPixelRecHitsCUDA",
        onGPU=True)
    # use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows
    run3_common.toModify(process.hltPixelTracksCUDA, idealConditions=True)

    # SwitchProducer providing the pixel tracks in SoA format on cpu
    process.hltPixelTracksSoA = SwitchProducerCUDA(
        # build pixel ntuplets and pixel tracks in SoA format on cpu
        cpu=_caHitNtupletCUDA.clone(idealConditions=False,
                                    pixelRecHitSrc="hltSiPixelRecHitSoA",
                                    onGPU=False),
        # transfer the pixel tracks in SoA format to the host
        cuda=cms.EDProducer("PixelTrackSoAFromCUDA",
                            src=cms.InputTag("hltPixelTracksCUDA")))
    # use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows
    run3_common.toModify(process.hltPixelTracksSoA.cpu, idealConditions=True)

    # convert the pixel tracks from SoA to legacy format
    from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as _pixelTrackProducerFromSoA
    process.hltPixelTracks = _pixelTrackProducerFromSoA.clone(
        beamSpot="hltOnlineBeamSpot",
        pixelRecHitLegacySrc="hltSiPixelRecHits",
        trackSrc="hltPixelTracksSoA")

    # referenced in process.HLTRecopixelvertexingTask

    # build pixel vertices in SoA format on gpu
    from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA as _pixelVertexCUDA
    process.hltPixelVerticesCUDA = _pixelVertexCUDA.clone(
        pixelTrackSrc="hltPixelTracksCUDA", onGPU=True)

    # build or transfer pixel vertices in SoA format on cpu
    process.hltPixelVerticesSoA = SwitchProducerCUDA(
        # build pixel vertices in SoA format on cpu
        cpu=_pixelVertexCUDA.clone(pixelTrackSrc="hltPixelTracksSoA",
                                   onGPU=False),
        # transfer the pixel vertices in SoA format to cpu
        cuda=cms.EDProducer("PixelVertexSoAFromCUDA",
                            src=cms.InputTag("hltPixelVerticesCUDA")))

    # convert the pixel vertices from SoA to legacy format
    from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
    process.hltPixelVertices = _pixelVertexFromSoA.clone(
        src="hltPixelVerticesSoA",
        TrackCollection="hltPixelTracks",
        beamSpot="hltOnlineBeamSpot")

    # Tasks and Sequences

    process.HLTRecoPixelTracksTask = cms.Task(
        process.hltPixelTracksTrackingRegions,  # from the original sequence
        process.hltSiPixelRecHitSoA,  # pixel rechits on cpu, converted to SoA
        process.hltPixelTracksCUDA,  # pixel ntuplets on gpu, in SoA format
        process.hltPixelTracksSoA,  # pixel ntuplets on cpu, in SoA format
        process.hltPixelTracks)  # pixel tracks on cpu, in legacy format

    process.HLTRecoPixelTracksSequence = cms.Sequence(
        process.HLTRecoPixelTracksTask)

    process.HLTRecopixelvertexingTask = cms.Task(
        process.HLTRecoPixelTracksTask,
        process.hltPixelVerticesCUDA,  # pixel vertices on gpu, in SoA format
        process.hltPixelVerticesSoA,  # pixel vertices on cpu, in SoA format
        process.hltPixelVertices,  # pixel vertices on cpu, in legacy format
        process.hltTrimmedPixelVertices)  # from the original sequence

    process.HLTRecopixelvertexingSequence = cms.Sequence(
        process.hltPixelTracksFitter
        +  # not used here, kept for compatibility with legacy sequences
        process.
        hltPixelTracksFilter,  # not used here, kept for compatibility with legacy sequences
        process.HLTRecopixelvertexingTask)

    # done
    return process
Пример #3
0
# legacy pixel rechit producer
siPixelRecHits = cms.EDProducer("SiPixelRecHitConverter",
                                src=cms.InputTag("siPixelClusters"),
                                CPE=cms.string('PixelCPEGeneric'),
                                VerboseLevel=cms.untracked.int32(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
from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromCUDA_cfi import siPixelRecHitSoAFromCUDA as _siPixelRecHitSoAFromCUDA

siPixelRecHitsPreSplittingCPU = _siPixelRecHitsPreSplittingSoA.clone(
    convertToLegacy=True)

# phase 2 tracker modifier
from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase2_tracker.toModify(siPixelRecHitsPreSplittingCPU, isPhase2=True)

# modifier used to prompt patatrack pixel tracks reconstruction on cpu
from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit
pixelNtupletFit.toModify(
    siPixelRecHitsPreSplitting,
    cpu=cms.EDAlias(siPixelRecHitsPreSplittingCPU=cms.VPSet(
        cms.PSet(type=cms.string("SiPixelRecHitedmNewDetSetVector")),
        cms.PSet(type=cms.string("uintAsHostProduct")))))

siPixelRecHitsPreSplittingTask = cms.Task(
    # SwitchProducer wrapping the legacy pixel rechit producer or the cpu SoA producer
Пример #4
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
Пример #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
    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")

    # 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

    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 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