Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-13 22:52:46

0001 import FWCore.ParameterSet.Config as cms
0002 from HeterogeneousCore.AlpakaCore.functions import *
0003 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
0004 
0005 from RecoTracker.PixelTrackFitting.PixelTracks_cff import *
0006 from RecoVertex.PixelVertexFinding.PixelVertices_cff import *
0007 
0008 # legacy pixel vertex reconsruction using the divisive vertex finder
0009 pixelVerticesTask = cms.Task(
0010     pixelVertices
0011 )
0012 
0013 # "Patatrack" pixel ntuplets, fishbone cleaning, Broken Line fit, and density-based vertex reconstruction
0014 from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit
0015 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
0016 
0017 # HIon modifiers
0018 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
0019 
0020 # build the pixel vertices in SoA format on the CPU
0021 from RecoVertex.PixelVertexFinding.pixelVertexProducerCUDAPhase1_cfi import pixelVertexProducerCUDAPhase1 as _pixelVerticesCUDA
0022 from RecoVertex.PixelVertexFinding.pixelVertexProducerCUDAPhase2_cfi import pixelVertexProducerCUDAPhase2 as _pixelVerticesCUDAPhase2
0023 from RecoVertex.PixelVertexFinding.pixelVertexProducerCUDAHIonPhase1_cfi import pixelVertexProducerCUDAHIonPhase1 as _pixelVerticesCUDAHIonPhase1
0024 
0025 pixelVerticesSoA = SwitchProducerCUDA(
0026     cpu = _pixelVerticesCUDA.clone(
0027         pixelTrackSrc = "pixelTracksSoA",
0028         onGPU = False
0029     )
0030 )
0031 
0032 phase2_tracker.toModify(pixelVerticesSoA,cpu = _pixelVerticesCUDAPhase2.clone(
0033     pixelTrackSrc = "pixelTracksSoA",
0034     onGPU = False,
0035     PtMin = 2.0
0036 ))
0037 
0038 (pp_on_AA & ~phase2_tracker).toModify(pixelVerticesSoA,cpu = _pixelVerticesCUDAHIonPhase1.clone(
0039     pixelTrackSrc = "pixelTracksSoA",
0040     doSplitting = False,
0041     onGPU = False,
0042 ))
0043 
0044 # convert the pixel vertices from SoA to legacy format
0045 from RecoVertex.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
0046 
0047 (pixelNtupletFit).toReplaceWith(pixelVertices, _pixelVertexFromSoA.clone(
0048     src = "pixelVerticesSoA"
0049 ))
0050 
0051 (pixelNtupletFit).toReplaceWith(pixelVerticesTask, cms.Task(
0052     # build the pixel vertices in SoA format on the CPU
0053     pixelVerticesSoA,
0054     # convert the pixel vertices from SoA to legacy format
0055     pixelVertices
0056 ))
0057 
0058 
0059 # "Patatrack" sequence running on the GPU
0060 from Configuration.ProcessModifiers.gpu_cff import gpu
0061 
0062 # build pixel vertices in SoA format on the GPU
0063 pixelVerticesCUDA = _pixelVerticesCUDA.clone(
0064     pixelTrackSrc = "pixelTracksCUDA",
0065     onGPU = True
0066 )
0067 
0068 phase2_tracker.toReplaceWith(pixelVerticesCUDA,_pixelVerticesCUDAPhase2.clone(
0069     pixelTrackSrc = "pixelTracksCUDA",
0070     onGPU = True,
0071     PtMin = 2.0
0072 ))
0073 
0074 (pp_on_AA & ~phase2_tracker).toReplaceWith(pixelVerticesCUDA,_pixelVerticesCUDAHIonPhase1.clone(
0075     pixelTrackSrc = "pixelTracksCUDA",
0076     doSplitting = False,
0077     onGPU = True
0078 ))
0079 
0080 # transfer the pixel vertices in SoA format to the CPU
0081 from RecoVertex.PixelVertexFinding.pixelVerticesSoA_cfi import pixelVerticesSoA as _pixelVerticesSoA
0082 gpu.toModify(pixelVerticesSoA,
0083     cuda = _pixelVerticesSoA.clone(
0084         src = cms.InputTag("pixelVerticesCUDA")
0085     )
0086 )
0087 
0088 ## GPU vs CPU validation
0089 # force CPU vertexing to use track SoA from CPU chain and not the converted one from GPU chain
0090 from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel
0091 (pixelNtupletFit & gpu & gpuValidationPixel).toModify(pixelVerticesSoA.cpu,
0092     pixelTrackSrc = "pixelTracksSoA@cpu"
0093 )
0094 
0095 (pixelNtupletFit & gpu).toReplaceWith(pixelVerticesTask, cms.Task(
0096     # build pixel vertices in SoA format on the GPU
0097     pixelVerticesCUDA,
0098     # transfer the pixel vertices in SoA format to the CPU and convert them to legacy format
0099     pixelVerticesTask.copy()
0100 ))
0101 
0102 ## pixel vertex reconstruction with Alpaka
0103 
0104 # pixel vertex SoA producer with alpaka on the device
0105 from RecoVertex.PixelVertexFinding.pixelVertexProducerAlpakaPhase1_cfi import pixelVertexProducerAlpakaPhase1 as _pixelVerticesAlpakaPhase1
0106 from RecoVertex.PixelVertexFinding.pixelVertexProducerAlpakaPhase2_cfi import pixelVertexProducerAlpakaPhase2 as _pixelVerticesAlpakaPhase2
0107 from RecoVertex.PixelVertexFinding.pixelVertexProducerAlpakaHIonPhase1_cfi import pixelVertexProducerAlpakaHIonPhase1 as _pixelVerticesAlpakaHIonPhase1
0108 pixelVerticesAlpaka = _pixelVerticesAlpakaPhase1.clone()
0109 phase2_tracker.toReplaceWith(pixelVerticesAlpaka,_pixelVerticesAlpakaPhase2.clone( maxVertices = 512))
0110 (pp_on_AA & ~phase2_tracker).toReplaceWith(pixelVerticesAlpaka,_pixelVerticesAlpakaHIonPhase1.clone(doSplitting = False, maxVertices = 32))
0111 
0112 from RecoVertex.PixelVertexFinding.pixelVertexFromSoAAlpaka_cfi import pixelVertexFromSoAAlpaka as _pixelVertexFromSoAAlpaka
0113 alpaka.toReplaceWith(pixelVertices, _pixelVertexFromSoAAlpaka.clone())
0114 
0115 # pixel vertex SoA producer with alpaka on the cpu, for validation
0116 pixelVerticesAlpakaSerial = makeSerialClone(pixelVerticesAlpaka,
0117     pixelTrackSrc = 'pixelTracksAlpakaSerial'
0118 )
0119 
0120 alpaka.toReplaceWith(pixelVerticesTask, cms.Task(
0121     # Build the pixel vertices in SoA format with alpaka on the device
0122     pixelVerticesAlpaka,
0123     # Build the pixel vertices in SoA format with alpaka on the cpu (if requested by the validation)
0124     pixelVerticesAlpakaSerial,
0125     # Convert the pixel vertices from SoA format (on the host) to the legacy format
0126     pixelVertices
0127 ))
0128 
0129 # Tasks and Sequences
0130 recopixelvertexingTask = cms.Task(
0131     pixelTracksTask,
0132     pixelVerticesTask
0133 )
0134 recopixelvertexing = cms.Sequence(recopixelvertexingTask)