CMS 3D CMS Logo

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