CMS 3D CMS Logo

RecoPixelVertexing_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
4 
7 
8 # legacy pixel vertex reconsruction using the divisive vertex finder
9 pixelVerticesTask = cms.Task(
10  pixelVertices
11 )
12 
13 # "Patatrack" pixel ntuplets, fishbone cleaning, Broken Line fit, and density-based vertex reconstruction
14 from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit
15 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
16 
17 # HIon modifiers
18 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
19 
20 # build the pixel vertices in SoA format on the CPU
21 from RecoTracker.PixelVertexFinding.pixelVertexProducerCUDAPhase1_cfi import pixelVertexProducerCUDAPhase1 as _pixelVerticesCUDA
22 from RecoTracker.PixelVertexFinding.pixelVertexProducerCUDAPhase2_cfi import pixelVertexProducerCUDAPhase2 as _pixelVerticesCUDAPhase2
23 from RecoTracker.PixelVertexFinding.pixelVertexProducerCUDAHIonPhase1_cfi import pixelVertexProducerCUDAHIonPhase1 as _pixelVerticesCUDAHIonPhase1
24 
25 pixelVerticesSoA = SwitchProducerCUDA(
26  cpu = _pixelVerticesCUDA.clone(
27  pixelTrackSrc = "pixelTracksSoA",
28  onGPU = False
29  )
30 )
31 
32 phase2_tracker.toModify(pixelVerticesSoA,cpu = _pixelVerticesCUDAPhase2.clone(
33  pixelTrackSrc = "pixelTracksSoA",
34  onGPU = False,
35  PtMin = 2.0
36 ))
37 
38 (pp_on_AA & ~phase2_tracker).toModify(pixelVerticesSoA,cpu = _pixelVerticesCUDAHIonPhase1.clone(
39  pixelTrackSrc = "pixelTracksSoA",
40  doSplitting = False,
41  onGPU = False,
42 ))
43 
44 # convert the pixel vertices from SoA to legacy format
45 from RecoTracker.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
46 
47 (pixelNtupletFit).toReplaceWith(pixelVertices, _pixelVertexFromSoA.clone(
48  src = "pixelVerticesSoA"
49 ))
50 
51 (pixelNtupletFit).toReplaceWith(pixelVerticesTask, cms.Task(
52  # build the pixel vertices in SoA format on the CPU
53  pixelVerticesSoA,
54  # convert the pixel vertices from SoA to legacy format
55  pixelVertices
56 ))
57 
58 
59 # "Patatrack" sequence running on the GPU
61 
62 # build pixel vertices in SoA format on the GPU
63 pixelVerticesCUDA = _pixelVerticesCUDA.clone(
64  pixelTrackSrc = "pixelTracksCUDA",
65  onGPU = True
66 )
67 
68 phase2_tracker.toReplaceWith(pixelVerticesCUDA,_pixelVerticesCUDAPhase2.clone(
69  pixelTrackSrc = "pixelTracksCUDA",
70  onGPU = True,
71  PtMin = 2.0
72 ))
73 
74 (pp_on_AA & ~phase2_tracker).toReplaceWith(pixelVerticesCUDA,_pixelVerticesCUDAHIonPhase1.clone(
75  pixelTrackSrc = "pixelTracksCUDA",
76  doSplitting = False,
77  onGPU = True
78 ))
79 
80 # transfer the pixel vertices in SoA format to the CPU
81 from RecoTracker.PixelVertexFinding.pixelVerticesSoA_cfi import pixelVerticesSoA as _pixelVerticesSoA
82 gpu.toModify(pixelVerticesSoA,
83  cuda = _pixelVerticesSoA.clone(
84  src = cms.InputTag("pixelVerticesCUDA")
85  )
86 )
87 
88 
90 from Configuration.ProcessModifiers.gpuValidationPixel_cff import gpuValidationPixel
91 (pixelNtupletFit & gpu & gpuValidationPixel).toModify(pixelVerticesSoA.cpu,
92  pixelTrackSrc = "pixelTracksSoA@cpu"
93 )
94 
95 (pixelNtupletFit & gpu).toReplaceWith(pixelVerticesTask, cms.Task(
96  # build pixel vertices in SoA format on the GPU
97  pixelVerticesCUDA,
98  # transfer the pixel vertices in SoA format to the CPU and convert them to legacy format
99  pixelVerticesTask.copy()
100 ))
101 
102 
103 
104 # pixel vertex SoA producer with alpaka on the device
105 from RecoTracker.PixelVertexFinding.pixelVertexProducerAlpakaPhase1_cfi import pixelVertexProducerAlpakaPhase1 as _pixelVerticesAlpakaPhase1
106 from RecoTracker.PixelVertexFinding.pixelVertexProducerAlpakaPhase2_cfi import pixelVertexProducerAlpakaPhase2 as _pixelVerticesAlpakaPhase2
107 pixelVerticesAlpaka = _pixelVerticesAlpakaPhase1.clone()
108 phase2_tracker.toReplaceWith(pixelVerticesAlpaka,_pixelVerticesAlpakaPhase2.clone())
109 
110 from RecoTracker.PixelVertexFinding.pixelVertexFromSoAAlpaka_cfi import pixelVertexFromSoAAlpaka as _pixelVertexFromSoAAlpaka
111 alpaka.toReplaceWith(pixelVertices, _pixelVertexFromSoAAlpaka.clone())
112 
113 # pixel vertex SoA producer with alpaka on the cpu, for validation
114 pixelVerticesAlpakaSerial = makeSerialClone(pixelVerticesAlpaka,
115  pixelTrackSrc = 'pixelTracksAlpakaSerial'
116 )
117 
118 alpaka.toReplaceWith(pixelVerticesTask, cms.Task(
119  # Build the pixel vertices in SoA format with alpaka on the device
120  pixelVerticesAlpaka,
121  # Build the pixel vertices in SoA format with alpaka on the cpu (if requested by the validation)
122  pixelVerticesAlpakaSerial,
123  # Convert the pixel vertices from SoA format (on the host) to the legacy format
124  pixelVertices
125 ))
126 
127 # Tasks and Sequences
128 recopixelvertexingTask = cms.Task(
129  pixelTracksTask,
130  pixelVerticesTask
131 )
132 recopixelvertexing = cms.Sequence(recopixelvertexingTask)
def makeSerialClone(module, kwargs)
Definition: functions.py:1