CMS 3D CMS Logo

customizeHLTforPatatrack.py
Go to the documentation of this file.
1 import copy
2 import FWCore.ParameterSet.Config as cms
3 from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA
5 from Configuration.Eras.Modifier_run3_common_cff import run3_common
6 
7 
8 # force the SwitchProducerCUDA choice to pick a specific backend: True for offloading to a gpu, False for running on cpu
9 def forceGpuOffload(status = True):
10  import HeterogeneousCore.CUDACore.SwitchProducerCUDA
11  HeterogeneousCore.CUDACore.SwitchProducerCUDA._cuda_enabled_cached = bool(status)
12 
13 
14 # reset the SwitchProducerCUDA choice to pick a backend depending on the availability of a supported gpu
16  import HeterogeneousCore.CUDACore.SwitchProducerCUDA
17  HeterogeneousCore.CUDACore.SwitchProducerCUDA._cuda_enabled_cached = None
18  HeterogeneousCore.CUDACore.SwitchProducerCUDA._switch_cuda()
19 
20 
21 # customisation for running the Patatrack reconstruction, common parts
22 def customiseCommon(process):
23 
24  # Services
25 
26  process.load("HeterogeneousCore.CUDAServices.CUDAService_cfi")
27 
28  # NVProfilerService is broken in CMSSW 12.0,x and later
29  #process.load("HeterogeneousCore.CUDAServices.NVProfilerService_cfi")
30 
31 
32  # Paths and EndPaths
33 
34  # the hltGetConditions module would force gpu-specific ESProducers to run even if no supported gpu is present
35  if 'hltGetConditions' in process.__dict__:
36  del process.hltGetConditions
37 
38  # produce a boolean to track if the events ar being processed on gpu (true) or cpu (false)
39  process.statusOnGPU = SwitchProducerCUDA(
40  cpu = cms.EDProducer("BooleanProducer", value = cms.bool(False)),
41  cuda = cms.EDProducer("BooleanProducer", value = cms.bool(True))
42  )
43 
44  process.statusOnGPUFilter = cms.EDFilter("BooleanFilter",
45  src = cms.InputTag("statusOnGPU")
46  )
47 
48  if 'Status_OnCPU' in process.__dict__:
49  replace_with(process.Status_OnCPU, cms.Path(process.statusOnGPU + ~process.statusOnGPUFilter))
50  else:
51  process.Status_OnCPU = cms.Path(process.statusOnGPU + ~process.statusOnGPUFilter)
52  if 'HLTSchedule' in process.__dict__:
53  process.HLTSchedule.append(process.Status_OnCPU)
54  if process.schedule is not None:
55  process.schedule.append(process.Status_OnCPU)
56 
57  if 'Status_OnGPU' in process.__dict__:
58  replace_with(process.Status_OnGPU, cms.Path(process.statusOnGPU + process.statusOnGPUFilter))
59  else:
60  process.Status_OnGPU = cms.Path(process.statusOnGPU + process.statusOnGPUFilter)
61  if 'HLTSchedule' in process.__dict__:
62  process.HLTSchedule.append(process.Status_OnGPU)
63  if process.schedule is not None:
64  process.schedule.append(process.Status_OnGPU)
65 
66 
67  # make the ScoutingCaloMuonOutput endpath compatible with using Tasks in the Scouting paths
68  if 'hltOutputScoutingCaloMuon' in process.__dict__ and not 'hltPreScoutingCaloMuonOutputSmart' in process.__dict__:
69  process.hltPreScoutingCaloMuonOutputSmart = cms.EDFilter( "TriggerResultsFilter",
70  l1tIgnoreMaskAndPrescale = cms.bool( False ),
71  l1tResults = cms.InputTag( "" ),
72  hltResults = cms.InputTag( 'TriggerResults','','@currentProcess' ),
73  triggerConditions = process.hltOutputScoutingCaloMuon.SelectEvents.SelectEvents,
74  throw = cms.bool( True )
75  )
76  insert_modules_after(process, process.hltPreScoutingCaloMuonOutput, process.hltPreScoutingCaloMuonOutputSmart)
77 
78  # make the ScoutingPFOutput endpath compatible with using Tasks in the Scouting paths
79  if 'hltOutputScoutingPF' in process.__dict__ and not 'hltPreScoutingPFOutputSmart' in process.__dict__:
80  process.hltPreScoutingPFOutputSmart = cms.EDFilter( "TriggerResultsFilter",
81  l1tIgnoreMaskAndPrescale = cms.bool( False ),
82  l1tResults = cms.InputTag( "" ),
83  hltResults = cms.InputTag( 'TriggerResults','','@currentProcess' ),
84  triggerConditions = process.hltOutputScoutingPF.SelectEvents.SelectEvents,
85  throw = cms.bool( True )
86  )
87  insert_modules_after(process, process.hltPreScoutingPFOutput, process.hltPreScoutingPFOutputSmart)
88 
89 
90  # done
91  return process
92 
93 
94 # customisation for running the "Patatrack" pixel local reconstruction
96 
97  if not 'HLTDoLocalPixelSequence' in process.__dict__:
98  return process
99 
100  # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases
101 
102  process.HLTDoLocalPixelSequence = cms.Sequence()
103 
104 
105  # Event Setup
106 
107  process.load("CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi") # this should be used only on GPUs, will crash otherwise
108  process.load("CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi") # this should be used only on GPUs, will crash otherwise
109  process.load("RecoLocalTracker.SiPixelRecHits.PixelCPEFastESProducer_cfi")
110 
111 
112  # Modules and EDAliases
113 
114  # referenced in HLTDoLocalPixelTask
115 
116  # transfer the beamspot to the gpu
117  from RecoVertex.BeamSpotProducer.offlineBeamSpotToCUDA_cfi import offlineBeamSpotToCUDA as _offlineBeamSpotToCUDA
118  process.hltOnlineBeamSpotToCUDA = _offlineBeamSpotToCUDA.clone(
119  src = "hltOnlineBeamSpot"
120  )
121 
122  # reconstruct the pixel digis and clusters on the gpu
123  from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA
124  process.hltSiPixelClustersCUDA = _siPixelRawToClusterCUDA.clone(
125  # use the same thresholds as the legacy module
126  clusterThreshold_layer1 = process.hltSiPixelClusters.ClusterThreshold_L1,
127  clusterThreshold_otherLayers = process.hltSiPixelClusters.ClusterThreshold
128  )
129  # use the pixel channel calibrations scheme for Run 3
130  run3_common.toModify(process.hltSiPixelClustersCUDA, isRun2 = False)
131 
132  # copy the pixel digis errors to the host
133  from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA
134  process.hltSiPixelDigiErrorsSoA = _siPixelDigiErrorsSoAFromCUDA.clone(
135  src = "hltSiPixelClustersCUDA"
136  )
137 
138  # copy the pixel digis (except errors) and clusters to the host
139  from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA
140  process.hltSiPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone(
141  src = "hltSiPixelClustersCUDA"
142  )
143 
144  # reconstruct the pixel digis on the cpu
145  process.hltSiPixelDigisLegacy = process.hltSiPixelDigis.clone()
146 
147  # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors to the legacy format
148  from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA
149  process.hltSiPixelDigis = SwitchProducerCUDA(
150  # legacy producer
151  cpu = cms.EDAlias(
152  hltSiPixelDigisLegacy = cms.VPSet(
153  cms.PSet(type = cms.string("DetIdedmEDCollection")),
154  cms.PSet(type = cms.string("SiPixelRawDataErroredmDetSetVector")),
155  cms.PSet(type = cms.string("PixelFEDChanneledmNewDetSetVector"))
156  )
157  ),
158  # conversion from SoA to legacy format
159  cuda = _siPixelDigiErrorsFromSoA.clone(
160  digiErrorSoASrc = "hltSiPixelDigiErrorsSoA",
161  UsePhase1 = True
162  )
163  )
164 
165  # reconstruct the pixel clusters on the cpu
166  process.hltSiPixelClustersLegacy = process.hltSiPixelClusters.clone(
167  # update the threshold for compatibility with the gpu reconstruction
168  ChannelThreshold = 10
169  )
170 
171  # 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
172  from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA
173  process.hltSiPixelClusters = SwitchProducerCUDA(
174  # legacy producer
175  cpu = cms.EDAlias(
176  hltSiPixelClustersLegacy = cms.VPSet(
177  cms.PSet(type = cms.string("SiPixelClusteredmNewDetSetVector"))
178  )
179  ),
180  # conversion from SoA to legacy format
181  cuda = _siPixelDigisClustersFromSoA.clone(
182  src = "hltSiPixelDigisSoA",
183  produceDigis = False,
184  storeDigis = False,
185  # use the same thresholds as the legacy module
186  clusterThreshold_layer1 = process.hltSiPixelClusters.ClusterThreshold_L1,
187  clusterThreshold_otherLayers = process.hltSiPixelClusters.ClusterThreshold
188  )
189  )
190 
191  # reconstruct the pixel rechits on the gpu
192  from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA
193  process.hltSiPixelRecHitsCUDA = _siPixelRecHitCUDA.clone(
194  src = "hltSiPixelClustersCUDA",
195  beamSpot = "hltOnlineBeamSpotToCUDA"
196  )
197 
198  # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
199  from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA
200  process.hltSiPixelRecHits = SwitchProducerCUDA(
201  # legacy producer
202  cpu = process.hltSiPixelRecHits,
203  # conversion from SoA to legacy format
204  cuda = _siPixelRecHitFromCUDA.clone(
205  pixelRecHitSrc = "hltSiPixelRecHitsCUDA",
206  src = "hltSiPixelClusters"
207  )
208  )
209 
210 
211  # Tasks and Sequences
212 
213  process.HLTDoLocalPixelTask = cms.Task(
214  process.hltOnlineBeamSpotToCUDA, # transfer the beamspot to the gpu
215  process.hltSiPixelClustersCUDA, # reconstruct the pixel digis and clusters on the gpu
216  process.hltSiPixelRecHitsCUDA, # reconstruct the pixel rechits on the gpu
217  process.hltSiPixelDigisSoA, # copy the pixel digis (except errors) and clusters to the host
218  process.hltSiPixelDigiErrorsSoA, # copy the pixel digis errors to the host
219  process.hltSiPixelDigisLegacy, # legacy pixel digis producer
220  process.hltSiPixelDigis, # SwitchProducer wrapping a subset of the legacy pixel digis producer, or the conversion of the pixel digis errors from SoA
221  process.hltSiPixelClustersLegacy, # legacy pixel cluster producer
222  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
223  process.hltSiPixelClustersCache, # legacy module, used by the legacy pixel quadruplet producer
224  process.hltSiPixelRecHits) # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA
225 
226  process.HLTDoLocalPixelSequence = cms.Sequence(process.HLTDoLocalPixelTask)
227 
228 
229  # workaround for AlCa paths
230 
231  if 'AlCa_LumiPixelsCounts_Random_v1' in process.__dict__:
232  # redefine the path to use the HLTDoLocalPixelSequence
233  process.AlCa_LumiPixelsCounts_Random_v1 = cms.Path(
234  process.HLTBeginSequenceRandom +
235  process.hltScalersRawToDigi +
236  process.hltPreAlCaLumiPixelsCountsRandom +
237  process.hltPixelTrackerHVOn +
238  process.HLTDoLocalPixelSequence +
239  process.hltAlcaPixelClusterCounts +
240  process.HLTEndSequence )
241 
242  if 'AlCa_LumiPixelsCounts_ZeroBias_v1' in process.__dict__:
243  # redefine the path to use the HLTDoLocalPixelSequence
244  process.AlCa_LumiPixelsCounts_ZeroBias_v1 = cms.Path(
245  process.HLTBeginSequence +
246  process.hltScalersRawToDigi +
247  process.hltL1sZeroBias +
248  process.hltPreAlCaLumiPixelsCountsZeroBias +
249  process.hltPixelTrackerHVOn +
250  process.HLTDoLocalPixelSequence +
251  process.hltAlcaPixelClusterCounts +
252  process.HLTEndSequence )
253 
254 
255  # done
256  return process
257 
258 
259 # customisation for running the "Patatrack" pixel track reconstruction
261 
262  if not 'HLTRecoPixelTracksSequence' in process.__dict__:
263  return process
264 
265  hasHLTPixelVertexReco = 'HLTRecopixelvertexingSequence' in process.__dict__
266 
267  # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases
268 
269  process.HLTRecoPixelTracksSequence = cms.Sequence()
270  if hasHLTPixelVertexReco:
271  process.HLTRecopixelvertexingSequence = cms.Sequence()
272 
273 
274  # Modules and EDAliases
275 
276  # referenced in process.HLTRecoPixelTracksTask
277 
278  # cpu only: convert the pixel rechits from legacy to SoA format
279  from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy as _siPixelRecHitSoAFromLegacy
280  process.hltSiPixelRecHitSoA = _siPixelRecHitSoAFromLegacy.clone(
281  src = "hltSiPixelClusters",
282  beamSpot = "hltOnlineBeamSpot",
283  convertToLegacy = True
284  )
285 
286  # build pixel ntuplets and pixel tracks in SoA format on gpu
287  from RecoPixelVertexing.PixelTriplets.pixelTracksCUDA_cfi import pixelTracksCUDA as _pixelTracksCUDA
288  process.hltPixelTracksCUDA = _pixelTracksCUDA.clone(
289  idealConditions = False,
290  pixelRecHitSrc = "hltSiPixelRecHitsCUDA",
291  onGPU = True
292  )
293  # use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows
294  run3_common.toModify(process.hltPixelTracksCUDA, idealConditions = True)
295 
296  # SwitchProducer providing the pixel tracks in SoA format on cpu
297  from RecoPixelVertexing.PixelTrackFitting.pixelTracksSoA_cfi import pixelTracksSoA as _pixelTracksSoA
298  process.hltPixelTracksSoA = SwitchProducerCUDA(
299  # build pixel ntuplets and pixel tracks in SoA format on cpu
300  cpu = _pixelTracksCUDA.clone(
301  idealConditions = False,
302  pixelRecHitSrc = "hltSiPixelRecHitSoA",
303  onGPU = False
304  ),
305  # transfer the pixel tracks in SoA format to the host
306  cuda = _pixelTracksSoA.clone(
307  src = "hltPixelTracksCUDA"
308  )
309  )
310  # use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows
311  run3_common.toModify(process.hltPixelTracksSoA.cpu, idealConditions = True)
312 
313  # convert the pixel tracks from SoA to legacy format
314  from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as _pixelTrackProducerFromSoA
315  process.hltPixelTracks = _pixelTrackProducerFromSoA.clone(
316  beamSpot = "hltOnlineBeamSpot",
317  pixelRecHitLegacySrc = "hltSiPixelRecHits",
318  trackSrc = "hltPixelTracksSoA"
319  )
320 
321 
322  # referenced in process.HLTRecopixelvertexingTask
323  if hasHLTPixelVertexReco:
324 
325  # build pixel vertices in SoA format on gpu
326  from RecoPixelVertexing.PixelVertexFinding.pixelVerticesCUDA_cfi import pixelVerticesCUDA as _pixelVerticesCUDA
327  process.hltPixelVerticesCUDA = _pixelVerticesCUDA.clone(
328  pixelTrackSrc = "hltPixelTracksCUDA",
329  onGPU = True
330  )
331 
332  # build or transfer pixel vertices in SoA format on cpu
333  from RecoPixelVertexing.PixelVertexFinding.pixelVerticesSoA_cfi import pixelVerticesSoA as _pixelVerticesSoA
334  process.hltPixelVerticesSoA = SwitchProducerCUDA(
335  # build pixel vertices in SoA format on cpu
336  cpu = _pixelVerticesCUDA.clone(
337  pixelTrackSrc = "hltPixelTracksSoA",
338  onGPU = False
339  ),
340  # transfer the pixel vertices in SoA format to cpu
341  cuda = _pixelVerticesSoA.clone(
342  src = "hltPixelVerticesCUDA"
343  )
344  )
345 
346  # convert the pixel vertices from SoA to legacy format
347  from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA
348  process.hltPixelVertices = _pixelVertexFromSoA.clone(
349  src = "hltPixelVerticesSoA",
350  TrackCollection = "hltPixelTracks",
351  beamSpot = "hltOnlineBeamSpot"
352  )
353 
354 
355  # Tasks and Sequences
356 
357  process.HLTRecoPixelTracksTask = cms.Task(
358  process.hltPixelTracksTrackingRegions, # from the original sequence
359  process.hltSiPixelRecHitSoA, # pixel rechits on cpu, converted to SoA
360  process.hltPixelTracksCUDA, # pixel ntuplets on gpu, in SoA format
361  process.hltPixelTracksSoA, # pixel ntuplets on cpu, in SoA format
362  process.hltPixelTracks) # pixel tracks on cpu, in legacy format
363 
364 
365  process.HLTRecoPixelTracksSequence = cms.Sequence(process.HLTRecoPixelTracksTask)
366 
367  if hasHLTPixelVertexReco:
368  process.HLTRecopixelvertexingTask = cms.Task(
369  process.HLTRecoPixelTracksTask,
370  process.hltPixelVerticesCUDA, # pixel vertices on gpu, in SoA format
371  process.hltPixelVerticesSoA, # pixel vertices on cpu, in SoA format
372  process.hltPixelVertices, # pixel vertices on cpu, in legacy format
373  process.hltTrimmedPixelVertices) # from the original sequence
374 
375  process.HLTRecopixelvertexingSequence = cms.Sequence(
376  process.hltPixelTracksFitter + # not used here, kept for compatibility with legacy sequences
377  process.hltPixelTracksFilter, # not used here, kept for compatibility with legacy sequences
378  process.HLTRecopixelvertexingTask)
379 
380 
381  # done
382  return process
383 
384 
385 # customisation for offloading the ECAL local reconstruction via CUDA if a supported gpu is present
387 
388  hasHLTEcalPreshowerSeq = any(seq in process.__dict__ for seq in ['HLTDoFullUnpackingEgammaEcalMFSequence', 'HLTDoFullUnpackingEgammaEcalSequence'])
389  if not (hasHLTEcalPreshowerSeq or 'HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence' in process.__dict__):
390  return process
391 
392  # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases
393 
394  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence()
395  if hasHLTEcalPreshowerSeq:
396  process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence()
397  process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence()
398 
399 
400  # Event Setup
401 
402  process.load("EventFilter.EcalRawToDigi.ecalElectronicsMappingGPUESProducer_cfi")
403  process.load("RecoLocalCalo.EcalRecProducers.ecalGainRatiosGPUESProducer_cfi")
404  process.load("RecoLocalCalo.EcalRecProducers.ecalPedestalsGPUESProducer_cfi")
405  process.load("RecoLocalCalo.EcalRecProducers.ecalPulseCovariancesGPUESProducer_cfi")
406  process.load("RecoLocalCalo.EcalRecProducers.ecalPulseShapesGPUESProducer_cfi")
407  process.load("RecoLocalCalo.EcalRecProducers.ecalSamplesCorrelationGPUESProducer_cfi")
408  process.load("RecoLocalCalo.EcalRecProducers.ecalTimeBiasCorrectionsGPUESProducer_cfi")
409  process.load("RecoLocalCalo.EcalRecProducers.ecalTimeCalibConstantsGPUESProducer_cfi")
410  process.load("RecoLocalCalo.EcalRecProducers.ecalMultifitParametersGPUESProducer_cfi")
411 
412  process.load("RecoLocalCalo.EcalRecProducers.ecalRechitADCToGeVConstantGPUESProducer_cfi")
413  process.load("RecoLocalCalo.EcalRecProducers.ecalRechitChannelStatusGPUESProducer_cfi")
414  process.load("RecoLocalCalo.EcalRecProducers.ecalIntercalibConstantsGPUESProducer_cfi")
415  process.load("RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosGPUESProducer_cfi")
416  process.load("RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosRefGPUESProducer_cfi")
417  process.load("RecoLocalCalo.EcalRecProducers.ecalLaserAlphasGPUESProducer_cfi")
418  process.load("RecoLocalCalo.EcalRecProducers.ecalLinearCorrectionsGPUESProducer_cfi")
419  process.load("RecoLocalCalo.EcalRecProducers.ecalRecHitParametersGPUESProducer_cfi")
420 
421 
422  # Modules and EDAliases
423 
424  # ECAL unpacker running on gpu
425  from EventFilter.EcalRawToDigi.ecalRawToDigiGPU_cfi import ecalRawToDigiGPU as _ecalRawToDigiGPU
426  process.hltEcalDigisGPU = _ecalRawToDigiGPU.clone()
427 
428  # SwitchProducer wrapping the legacy ECAL unpacker or the ECAL digi converter from SoA format on gpu to legacy format on cpu
429  process.hltEcalDigisLegacy = process.hltEcalDigis.clone()
430  from EventFilter.EcalRawToDigi.ecalCPUDigisProducer_cfi import ecalCPUDigisProducer as _ecalCPUDigisProducer
431 
432  process.hltEcalDigis = SwitchProducerCUDA(
433  # legacy producer
434  cpu = cms.EDAlias(
435  hltEcalDigisLegacy = cms.VPSet(
436  cms.PSet(type = cms.string("EBDigiCollection")),
437  cms.PSet(type = cms.string("EEDigiCollection")),
438  cms.PSet(type = cms.string("EBDetIdedmEDCollection")),
439  cms.PSet(type = cms.string("EEDetIdedmEDCollection")),
440  cms.PSet(type = cms.string("EBSrFlagsSorted")),
441  cms.PSet(type = cms.string("EESrFlagsSorted")),
442  cms.PSet(type = cms.string("EcalElectronicsIdedmEDCollection"), fromProductInstance = cms.string("EcalIntegrityBlockSizeErrors")),
443  cms.PSet(type = cms.string("EcalElectronicsIdedmEDCollection"), fromProductInstance = cms.string("EcalIntegrityTTIdErrors")),
444  cms.PSet(type = cms.string("EcalElectronicsIdedmEDCollection"), fromProductInstance = cms.string("EcalIntegrityZSXtalIdErrors")),
445  cms.PSet(type = cms.string("EcalPnDiodeDigisSorted")),
446  cms.PSet(type = cms.string("EcalPseudoStripInputDigisSorted"), fromProductInstance = cms.string("EcalPseudoStripInputs")),
447  cms.PSet(type = cms.string("EcalTriggerPrimitiveDigisSorted"), fromProductInstance = cms.string("EcalTriggerPrimitives")),
448  )
449  ),
450  # convert ECAL digis from SoA format on gpu to legacy format on cpu
451  cuda = _ecalCPUDigisProducer.clone(
452  digisInLabelEB = ("hltEcalDigisGPU", "ebDigis"),
453  digisInLabelEE = ("hltEcalDigisGPU", "eeDigis"),
454  produceDummyIntegrityCollections = cms.bool(True)
455  )
456  )
457 
458  # ECAL multifit running on gpu
459  from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitProducerGPU_cfi import ecalUncalibRecHitProducerGPU as _ecalUncalibRecHitProducerGPU
460  process.hltEcalUncalibRecHitGPU = _ecalUncalibRecHitProducerGPU.clone(
461  digisLabelEB = ("hltEcalDigisGPU", "ebDigis"),
462  digisLabelEE = ("hltEcalDigisGPU", "eeDigis"),
463  shouldRunTimingComputation = False
464  )
465 
466  # copy the ECAL uncalibrated rechits from gpu to cpu in SoA format
467  from RecoLocalCalo.EcalRecProducers.ecalCPUUncalibRecHitProducer_cfi import ecalCPUUncalibRecHitProducer as _ecalCPUUncalibRecHitProducer
468  process.hltEcalUncalibRecHitSoA = _ecalCPUUncalibRecHitProducer.clone(
469  recHitsInLabelEB = ("hltEcalUncalibRecHitGPU", "EcalUncalibRecHitsEB"),
470  recHitsInLabelEE = ("hltEcalUncalibRecHitGPU", "EcalUncalibRecHitsEE"),
471  )
472 
473  # SwitchProducer wrapping the legacy ECAL uncalibrated rechits producer or a converter from SoA to legacy format
474  from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitConvertGPU2CPUFormat_cfi import ecalUncalibRecHitConvertGPU2CPUFormat as _ecalUncalibRecHitConvertGPU2CPUFormat
475  process.hltEcalUncalibRecHit = SwitchProducerCUDA(
476  # legacy producer
477  cpu = process.hltEcalUncalibRecHit,
478  # convert the ECAL uncalibrated rechits from SoA to legacy format
479  cuda = _ecalUncalibRecHitConvertGPU2CPUFormat.clone(
480  recHitsLabelGPUEB = ("hltEcalUncalibRecHitSoA", "EcalUncalibRecHitsEB"),
481  recHitsLabelGPUEE = ("hltEcalUncalibRecHitSoA", "EcalUncalibRecHitsEE"),
482  )
483  )
484 
485  # Reconstructing the ECAL calibrated rechits on gpu works, but is extremely slow.
486  # Disable it for the time being, until the performance has been addressed.
487  """
488  from RecoLocalCalo.EcalRecProducers.ecalRecHitGPU_cfi import ecalRecHitGPU as _ecalRecHitGPU
489  process.hltEcalRecHitGPU = _ecalRecHitGPU.clone(
490  uncalibrecHitsInLabelEB = ("hltEcalUncalibRecHitGPU","EcalUncalibRecHitsEB"),
491  uncalibrecHitsInLabelEE = ("hltEcalUncalibRecHitGPU","EcalUncalibRecHitsEE"),
492  )
493 
494  from RecoLocalCalo.EcalRecProducers.ecalCPURecHitProducer_cfi import ecalCPURecHitProducer as _ecalCPURecHitProducer
495  process.hltEcalRecHitSoA = _ecalCPURecHitProducer.clone(
496  recHitsInLabelEB = ("hltEcalRecHitGPU", "EcalRecHitsEB"),
497  recHitsInLabelEE = ("hltEcalRecHitGPU", "EcalRecHitsEE"),
498  )
499 
500  # SwitchProducer wrapping the legacy ECAL calibrated rechits producer or a converter from SoA to legacy format
501  from RecoLocalCalo.EcalRecProducers.ecalRecHitConvertGPU2CPUFormat_cfi import ecalRecHitConvertGPU2CPUFormat as _ecalRecHitConvertGPU2CPUFormat
502  process.hltEcalRecHit = SwitchProducerCUDA(
503  # legacy producer
504  cpu = process.hltEcalRecHit,
505  # convert the ECAL calibrated rechits from SoA to legacy format
506  cuda = _ecalRecHitConvertGPU2CPUFormat.clone(
507  recHitsLabelGPUEB = ("hltEcalRecHitSoA", "EcalRecHitsEB"),
508  recHitsLabelGPUEE = ("hltEcalRecHitSoA", "EcalRecHitsEE"),
509  )
510  )
511  """
512 
513  # SwitchProducer wrapping the legacy ECAL rechits producer
514  # the gpu unpacker does not produce the TPs used for the recovery, so the SwitchProducer alias does not provide them:
515  # - the cpu uncalibrated rechit producer may mark them for recovery, read the TPs explicitly from the legacy unpacker
516  # - the gpu uncalibrated rechit producer does not flag them for recovery, so the TPs are not necessary
517  process.hltEcalRecHit = SwitchProducerCUDA(
518  cpu = process.hltEcalRecHit.clone(
519  triggerPrimitiveDigiCollection = ('hltEcalDigisLegacy', 'EcalTriggerPrimitives')
520  ),
521  cuda = process.hltEcalRecHit.clone(
522  triggerPrimitiveDigiCollection = 'unused'
523  )
524  )
525 
526  # Tasks and Sequences
527 
528  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask = cms.Task(
529  process.hltEcalDigisGPU, # unpack ECAL digis on gpu
530  process.hltEcalDigisLegacy, # legacy producer, referenced in the SwitchProducer
531  process.hltEcalDigis, # SwitchProducer
532  process.hltEcalUncalibRecHitGPU, # run ECAL local reconstruction and multifit on gpu
533  process.hltEcalUncalibRecHitSoA, # needed by hltEcalPhiSymFilter - copy to host
534  process.hltEcalUncalibRecHit, # needed by hltEcalPhiSymFilter - convert to legacy format
535  # process.hltEcalRecHitGPU, # make ECAL calibrated rechits on gpu
536  # process.hltEcalRecHitSoA, # copy to host
537  process.hltEcalDetIdToBeRecovered, # legacy producer
538  process.hltEcalRecHit) # legacy producer
539 
540  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence(
541  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask)
542 
543  if hasHLTEcalPreshowerSeq:
544  process.HLTPreshowerTask = cms.Task(
545  process.hltEcalPreshowerDigis, # unpack ECAL preshower digis on the host
546  process.hltEcalPreshowerRecHit) # build ECAL preshower rechits on the host
547 
548  process.HLTPreshowerSequence = cms.Sequence(process.HLTPreshowerTask)
549 
550  process.HLTDoFullUnpackingEgammaEcalTask = cms.Task(
551  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerTask,
552  process.HLTPreshowerTask)
553 
554  process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence(
555  process.HLTDoFullUnpackingEgammaEcalTask)
556 
557  process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence(
558  process.HLTDoFullUnpackingEgammaEcalTask)
559 
560  # done
561  return process
562 
563 # customisation for offloading the HCAL local reconstruction via CUDA if a supported gpu is present
565 
566  hasHLTDoLocalHcalSeq = 'HLTDoLocalHcalSequence' in process.__dict__
567  if not (hasHLTDoLocalHcalSeq or 'HLTStoppedHSCPLocalHcalReco' in process.__dict__):
568  return process
569 
570  # FIXME replace the Sequences with empty ones to avoid expanding them during the (re)definition of Modules and EDAliases
571 
572  if hasHLTDoLocalHcalSeq:
573  process.HLTDoLocalHcalSequence = cms.Sequence()
574  process.HLTStoppedHSCPLocalHcalReco = cms.Sequence()
575 
576 
577  # Event Setup
578 
579  process.load("EventFilter.HcalRawToDigi.hcalElectronicsMappingGPUESProducer_cfi")
580 
581  process.load("RecoLocalCalo.HcalRecProducers.hcalChannelQualityGPUESProducer_cfi")
582  process.load("RecoLocalCalo.HcalRecProducers.hcalGainsGPUESProducer_cfi")
583  process.load("RecoLocalCalo.HcalRecProducers.hcalGainWidthsGPUESProducer_cfi")
584  process.load("RecoLocalCalo.HcalRecProducers.hcalLUTCorrsGPUESProducer_cfi")
585  process.load("RecoLocalCalo.HcalRecProducers.hcalConvertedPedestalsGPUESProducer_cfi")
586  process.load("RecoLocalCalo.HcalRecProducers.hcalConvertedEffectivePedestalsGPUESProducer_cfi")
587  process.hcalConvertedEffectivePedestalsGPUESProducer.label0 = "withTopoEff"
588  process.load("RecoLocalCalo.HcalRecProducers.hcalConvertedPedestalWidthsGPUESProducer_cfi")
589  process.load("RecoLocalCalo.HcalRecProducers.hcalConvertedEffectivePedestalWidthsGPUESProducer_cfi")
590  process.hcalConvertedEffectivePedestalWidthsGPUESProducer.label0 = "withTopoEff"
591  process.hcalConvertedEffectivePedestalWidthsGPUESProducer.label1 = "withTopoEff"
592  process.load("RecoLocalCalo.HcalRecProducers.hcalQIECodersGPUESProducer_cfi")
593  process.load("RecoLocalCalo.HcalRecProducers.hcalRecoParamsWithPulseShapesGPUESProducer_cfi")
594  process.load("RecoLocalCalo.HcalRecProducers.hcalRespCorrsGPUESProducer_cfi")
595  process.load("RecoLocalCalo.HcalRecProducers.hcalTimeCorrsGPUESProducer_cfi")
596  process.load("RecoLocalCalo.HcalRecProducers.hcalQIETypesGPUESProducer_cfi")
597  process.load("RecoLocalCalo.HcalRecProducers.hcalSiPMParametersGPUESProducer_cfi")
598  process.load("RecoLocalCalo.HcalRecProducers.hcalSiPMCharacteristicsGPUESProducer_cfi")
599  process.load("RecoLocalCalo.HcalRecProducers.hcalMahiPulseOffsetsGPUESProducer_cfi")
600 
601 
602  # Modules and EDAliases
603 
604  # The HCAL unpacker running on the gpu supports only the HB and HE digis.
605  # So, run the legacy unacker on the cpu, then convert the HB and HE digis
606  # to SoA format and copy them to the gpu.
607  from EventFilter.HcalRawToDigi.hcalDigisProducerGPU_cfi import hcalDigisProducerGPU as _hcalDigisProducerGPU
608  process.hltHcalDigisGPU = _hcalDigisProducerGPU.clone(
609  hbheDigisLabel = "hltHcalDigis",
610  qie11DigiLabel = "hltHcalDigis",
611  digisLabelF01HE = "",
612  digisLabelF5HB = "",
613  digisLabelF3HB = ""
614  )
615 
616  # run the HCAL local reconstruction (including Method 0 and MAHI) on gpu
617  from RecoLocalCalo.HcalRecProducers.hbheRecHitProducerGPU_cfi import hbheRecHitProducerGPU as _hbheRecHitProducerGPU
618  process.hltHbherecoGPU = _hbheRecHitProducerGPU.clone(
619  digisLabelF01HE = "hltHcalDigisGPU",
620  digisLabelF5HB = "hltHcalDigisGPU",
621  digisLabelF3HB = "hltHcalDigisGPU",
622  recHitsLabelM0HBHE = ""
623  )
624 
625  # transfer the HCAL rechits to the cpu, and convert them to the legacy format
626  from RecoLocalCalo.HcalRecProducers.hcalCPURecHitsProducer_cfi import hcalCPURecHitsProducer as _hcalCPURecHitsProducer
627  process.hltHbherecoFromGPU = _hcalCPURecHitsProducer.clone(
628  recHitsM0LabelIn = "hltHbherecoGPU",
629  recHitsM0LabelOut = "",
630  recHitsLegacyLabelOut = ""
631  )
632 
633  # SwitchProducer between the legacy producer and the copy from gpu with conversion
634  process.hltHbhereco = SwitchProducerCUDA(
635  # legacy producer
636  cpu = process.hltHbhereco.clone(),
637  # alias to the rechits converted to legacy format
638  cuda = cms.EDAlias(
639  hltHbherecoFromGPU = cms.VPSet(
640  cms.PSet(type = cms.string("HBHERecHitsSorted"))
641  )
642  )
643  )
644 
645 
646  # Tasks and Sequences
647  if hasHLTDoLocalHcalSeq:
648  process.HLTDoLocalHcalTask = cms.Task(
649  process.hltHcalDigis, # legacy producer, unpack HCAL digis on cpu
650  process.hltHcalDigisGPU, # copy to gpu and convert to SoA format
651  process.hltHbherecoGPU, # run the HCAL local reconstruction (including Method 0 and MAHI) on gpu
652  process.hltHbherecoFromGPU, # transfer the HCAL rechits to the cpu, and convert them to the legacy format
653  process.hltHbhereco, # SwitchProducer between the legacy producer and the copy from gpu with conversion
654  process.hltHfprereco, # legacy producer
655  process.hltHfreco, # legacy producer
656  process.hltHoreco) # legacy producer
657 
658  process.HLTDoLocalHcalSequence = cms.Sequence(
659  process.HLTDoLocalHcalTask)
660 
661  process.HLTStoppedHSCPLocalHcalRecoTask = cms.Task(
662  process.hltHcalDigis, # legacy producer, unpack HCAL digis on cpu
663  process.hltHcalDigisGPU, # copy to gpu and convert to SoA format
664  process.hltHbherecoGPU, # run the HCAL local reconstruction (including Method 0 and MAHI) on gpu
665  process.hltHbherecoFromGPU, # transfer the HCAL rechits to the cpu, and convert them to the legacy format
666  process.hltHbhereco) # SwitchProducer between the legacy producer and the copy from gpu with conversion
667 
668  process.HLTStoppedHSCPLocalHcalReco = cms.Sequence(
669  process.HLTStoppedHSCPLocalHcalRecoTask)
670 
671 
672  # done
673  return process
674 
675 
676 # customisation to enable pixel triplets instead of quadruplets
678 
679  if 'hltPixelTracksCUDA' in process.__dict__:
680  # configure GPU pixel tracks for triplets
681  process.hltPixelTracksCUDA.minHitsPerNtuplet = 3
682  process.hltPixelTracksCUDA.includeJumpingForwardDoublets = True
683 
684  if 'hltPixelTracksSoA' in process.__dict__:
685  # configure CPU pixel tracks for triplets
686  process.hltPixelTracksSoA.cpu.minHitsPerNtuplet = 3
687  process.hltPixelTracksSoA.cpu.includeJumpingForwardDoublets = True
688 
689  # done
690  return process
691 
692 
693 # customisation for running the Patatrack reconstruction, with automatic offload via CUDA when a supported gpu is available
695  process = customiseCommon(process)
696  process = customisePixelLocalReconstruction(process)
697  process = customisePixelTrackReconstruction(process)
698  process = customiseEcalLocalReconstruction(process)
699  process = customiseHcalLocalReconstruction(process)
700  return process
701 
702 
703 # customisation for running the Patatrack triplets reconstruction, with automatic offload via CUDA when a supported gpu is available
705  process = customiseCommon(process)
706  process = customisePixelLocalReconstruction(process)
707  process = customisePixelTrackReconstruction(process)
708  process = customiseEcalLocalReconstruction(process)
709  process = customiseHcalLocalReconstruction(process)
710  process = enablePatatrackPixelTriplets(process)
711  return process
712 
713 
714 def _addConsumerPath(process):
715  # add to a path all consumers and the tasks that define the producers
716  process.Consumer = cms.Path(
717  process.HLTBeginSequence +
718  process.hltPixelConsumer +
719  process.hltEcalConsumer +
720  process.hltHbheConsumer,
721  process.HLTDoLocalPixelTask,
722  process.HLTRecoPixelTracksTask,
723  process.HLTRecopixelvertexingTask,
724  process.HLTDoFullUnpackingEgammaEcalTask,
725  process.HLTDoLocalHcalTask,
726  )
727 
728  if 'HLTSchedule' in process.__dict__:
729  process.HLTSchedule.append(process.Consumer)
730  if process.schedule is not None:
731  process.schedule.append(process.Consumer)
732 
733  # done
734  return process
735 
736 
738  # consume the Pixel tracks and vertices on the GPU in SoA format
739  process.hltPixelConsumer = cms.EDAnalyzer("GenericConsumer",
740  eventProducts = cms.untracked.vstring( 'hltPixelTracksCUDA', 'hltPixelVerticesCUDA' )
741  )
742 
743  # consume the ECAL uncalibrated rechits on the GPU in SoA format
744  process.hltEcalConsumer = cms.EDAnalyzer("GenericConsumer",
745  eventProducts = cms.untracked.vstring( 'hltEcalUncalibRecHitGPU' )
746  )
747 
748  # consume the HCAL rechits on the GPU in SoA format
749  process.hltHbheConsumer = cms.EDAnalyzer("GenericConsumer",
750  eventProducts = cms.untracked.vstring( 'hltHbherecoGPU' )
751  )
752 
753  # add to a path all consumers and the tasks that define the producers
754  process = _addConsumerPath(process)
755 
756  # done
757  return process
758 
759 
761  # consume the Pixel tracks and vertices on the CPU in SoA format
762  process.hltPixelConsumer = cms.EDAnalyzer("GenericConsumer",
763  eventProducts = cms.untracked.vstring( 'hltPixelTracksSoA', 'hltPixelVerticesSoA' )
764  )
765 
766  # consume the ECAL uncalibrated rechits on the CPU in SoA format
767  process.hltEcalConsumer = cms.EDAnalyzer("GenericConsumer",
768  eventProducts = cms.untracked.vstring( 'hltEcalUncalibRecHitSoA' )
769  )
770 
771  # consume the HCAL rechits on the CPU in legacy format
772  process.hltHbheConsumer = cms.EDAnalyzer("GenericConsumer",
773  eventProducts = cms.untracked.vstring( 'hltHbhereco' )
774  )
775 
776  # add to a path all consumers and the tasks that define the producers
777  process = _addConsumerPath(process)
778 
779  # done
780  return process
781 
783  # consume the Pixel tracks and vertices on the CPU in legacy format
784  process.hltPixelConsumer = cms.EDAnalyzer("GenericConsumer",
785  eventProducts = cms.untracked.vstring( 'hltPixelTracks', 'hltPixelVertices' )
786  )
787 
788  # consume the ECAL runcalibrated echits on the CPU in legacy format
789  process.hltEcalConsumer = cms.EDAnalyzer("GenericConsumer",
790  eventProducts = cms.untracked.vstring( 'hltEcalUncalibRecHit' )
791  )
792 
793  # consume the HCAL rechits on the CPU in legacy format
794  process.hltHbheConsumer = cms.EDAnalyzer("GenericConsumer",
795  eventProducts = cms.untracked.vstring( 'hltHbhereco' )
796  )
797 
798  # add to a path all consumers and the tasks that define the producers
799  process = _addConsumerPath(process)
800 
801  # done
802  return process
customizeHLTforPatatrack.customisePixelTrackReconstruction
def customisePixelTrackReconstruction(process)
Definition: customizeHLTforPatatrack.py:260
electrons_cff.bool
bool
Definition: electrons_cff.py:366
common
customizeHLTforPatatrack.enablePatatrackPixelTriplets
def enablePatatrackPixelTriplets(process)
Definition: customizeHLTforPatatrack.py:677
customizeHLTforPatatrack.customiseHcalLocalReconstruction
def customiseHcalLocalReconstruction(process)
Definition: customizeHLTforPatatrack.py:564
customizeHLTforPatatrack.customiseEcalLocalReconstruction
def customiseEcalLocalReconstruction(process)
Definition: customizeHLTforPatatrack.py:386
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
common.replace_with
def replace_with(fromObj, toObj)
Definition: common.py:67
customizeHLTforPatatrack.customiseCommon
def customiseCommon(process)
Definition: customizeHLTforPatatrack.py:22
customizeHLTforPatatrack._addConsumerPath
def _addConsumerPath(process)
Definition: customizeHLTforPatatrack.py:714
customizeHLTforPatatrack.consumeCPULegacyProducts
def consumeCPULegacyProducts(process)
Definition: customizeHLTforPatatrack.py:782
customizeHLTforPatatrack.consumeGPUSoAProducts
def consumeGPUSoAProducts(process)
Definition: customizeHLTforPatatrack.py:737
customizeHLTforPatatrack.customizeHLTforPatatrack
def customizeHLTforPatatrack(process)
Definition: customizeHLTforPatatrack.py:694
customizeHLTforPatatrack.resetGpuOffload
def resetGpuOffload()
Definition: customizeHLTforPatatrack.py:15
customizeHLTforPatatrack.consumeCPUSoAProducts
def consumeCPUSoAProducts(process)
Definition: customizeHLTforPatatrack.py:760
customizeHLTforPatatrack.customizeHLTforPatatrackTriplets
def customizeHLTforPatatrackTriplets(process)
Definition: customizeHLTforPatatrack.py:704
customizeHLTforPatatrack.customisePixelLocalReconstruction
def customisePixelLocalReconstruction(process)
Definition: customizeHLTforPatatrack.py:95
common.insert_modules_after
def insert_modules_after(process, target, *modules)
Definition: common.py:50
customizeHLTforPatatrack.forceGpuOffload
def forceGpuOffload(status=True)
Definition: customizeHLTforPatatrack.py:9
SwitchProducerCUDA
Definition: SwitchProducerCUDA.py:1