Ejemplo n.º 1
0
def customisePixelTrackReconstruction(process):

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

    hasHLTPixelVertexReco = 'HLTRecopixelvertexingSequence' in process.__dict__

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

    process.HLTRecoPixelTracksSequence = cms.Sequence()
    if hasHLTPixelVertexReco:
        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.pixelTracksCUDA_cfi import pixelTracksCUDA as _pixelTracksCUDA
    process.hltPixelTracksCUDA = _pixelTracksCUDA.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
    from RecoPixelVertexing.PixelTrackFitting.pixelTracksSoA_cfi import pixelTracksSoA as _pixelTracksSoA
    process.hltPixelTracksSoA = SwitchProducerCUDA(
        # build pixel ntuplets and pixel tracks in SoA format on cpu
        cpu=_pixelTracksCUDA.clone(idealConditions=False,
                                   pixelRecHitSrc="hltSiPixelRecHitSoA",
                                   onGPU=False),
        # transfer the pixel tracks in SoA format to the host
        cuda=_pixelTracksSoA.clone(src="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
    if hasHLTPixelVertexReco:

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

        # build or transfer pixel vertices in SoA format on cpu
        from RecoPixelVertexing.PixelVertexFinding.pixelVerticesSoA_cfi import pixelVerticesSoA as _pixelVerticesSoA
        process.hltPixelVerticesSoA = SwitchProducerCUDA(
            # build pixel vertices in SoA format on cpu
            cpu=_pixelVerticesCUDA.clone(pixelTrackSrc="hltPixelTracksSoA",
                                         onGPU=False),
            # transfer the pixel vertices in SoA format to cpu
            cuda=_pixelVerticesSoA.clone(src="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)

    if hasHLTPixelVertexReco:
        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
Ejemplo n.º 2
0
        pixelVerticesSoA,
        # convert the pixel vertices from SoA to legacy format
        pixelVertices))

# "Patatrack" sequence running on the GPU
from Configuration.ProcessModifiers.gpu_cff import gpu

# build pixel vertices in SoA format on the GPU
pixelVerticesCUDA = _pixelVerticesCUDA.clone(pixelTrackSrc="pixelTracksCUDA",
                                             onGPU=True)

# transfer the pixel vertices in SoA format to the CPU
from RecoPixelVertexing.PixelVertexFinding.pixelVerticesSoA_cfi import pixelVerticesSoA as _pixelVerticesSoA
gpu.toModify(
    pixelVerticesSoA,
    cuda=_pixelVerticesSoA.clone(src=cms.InputTag("pixelVerticesCUDA")))

## GPU vs CPU validation
# force CPU vertexing to use track SoA from CPU chain and not the converted one from GPU chain
from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel
(pixelNtupletFit & gpu & gpuValidationPixel).toModify(
    pixelVerticesSoA.cpu, pixelTrackSrc="pixelTracksSoA@cpu")

(pixelNtupletFit & gpu).toReplaceWith(
    pixelVerticesTask,
    cms.Task(
        # build pixel vertices in SoA format on the GPU
        pixelVerticesCUDA,
        # transfer the pixel vertices in SoA format to the CPU and convert them to legacy format
        pixelVerticesTask.copy()))