CMS 3D CMS Logo

customizeHLTforAlpaka.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import re
3 import itertools
4 
5 from FWCore.ParameterSet.MassReplace import massReplaceInputTag
8 
9 
11  '''Customization to introduce Particle Flow Reconstruction in Alpaka
12  '''
13 
14  if not hasattr(process, 'hltParticleFlowClusterHBHE'):
15  return process
16 
17  for prod in producers_by_type(process, 'HCALRecHitSoAProducer@alpaka'):
18  return process
19 
20  process.hltESSPFRecHitHCALParamsRecord = cms.ESSource('EmptyESSource',
21  recordName = cms.string('PFRecHitHCALParamsRecord'),
22  iovIsRunNotTime = cms.bool(True),
23  firstValid = cms.vuint32(1)
24  )
25 
26  process.hltESSPFRecHitHCALTopologyRecord = cms.ESSource('EmptyESSource',
27  recordName = cms.string('PFRecHitHCALTopologyRecord'),
28  iovIsRunNotTime = cms.bool(True),
29  firstValid = cms.vuint32(1)
30  )
31 
32  process.hltESSJobConfigurationGPURecord = cms.ESSource('EmptyESSource',
33  recordName = cms.string('JobConfigurationGPURecord'),
34  iovIsRunNotTime = cms.bool(True),
35  firstValid = cms.vuint32(1)
36  )
37 
38  process.hltHbheRecHitSoA = cms.EDProducer("HCALRecHitSoAProducer@alpaka",
39  src = cms.InputTag("hltHbhereco"),
40  synchronise = cms.untracked.bool(False),
41  # autoselect the alpaka backend
42  alpaka = cms.untracked.PSet(
43  backend = cms.untracked.string('')
44  )
45  )
46 
47  process.hltESPPFRecHitHCALTopology = cms.ESProducer('PFRecHitHCALTopologyESProducer@alpaka',
48  usePFThresholdsFromDB = cms.bool(True),
49  appendToDataLabel = cms.string(''),
50  # autoselect the alpaka backend
51  alpaka = cms.untracked.PSet(
52  backend = cms.untracked.string('')
53  )
54  )
55 
56  process.hltESPPFRecHitHCALParams = cms.ESProducer('PFRecHitHCALParamsESProducer@alpaka',
57  energyThresholdsHB = cms.vdouble(0.1, 0.2, 0.3, 0.3),
58  energyThresholdsHE = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2),
59  appendToDataLabel = cms.string(''),
60  # autoselect the alpaka backend
61  alpaka = cms.untracked.PSet(
62  backend = cms.untracked.string('')
63  )
64  )
65 
66  process.hltParticleFlowRecHitHBHESoA = cms.EDProducer("PFRecHitSoAProducerHCAL@alpaka",
67  producers = cms.VPSet(
68  cms.PSet(
69  src = cms.InputTag("hltHbheRecHitSoA"),
70  params = cms.ESInputTag("hltESPPFRecHitHCALParams:"),
71  )
72  ),
73  topology = cms.ESInputTag("hltESPPFRecHitHCALTopology:"),
74  synchronise = cms.untracked.bool(False),
75  # autoselect the alpaka backend
76  alpaka = cms.untracked.PSet(
77  backend = cms.untracked.string('')
78  )
79  )
80 
81  process.hltParticleFlowRecHitHBHE = cms.EDProducer("LegacyPFRecHitProducer",
82  src = cms.InputTag("hltParticleFlowRecHitHBHESoA")
83  )
84 
85  process.hltESPPFClusterParams = cms.ESProducer("PFClusterParamsESProducer@alpaka",
86  seedFinder = cms.PSet(
87  nNeighbours = cms.int32(4),
88  thresholdsByDetector = cms.VPSet(
89  cms.PSet(
90  detector = cms.string('HCAL_BARREL1'),
91  seedingThreshold = cms.vdouble(0.125, 0.25, 0.35, 0.35),
92  seedingThresholdPt = cms.double(0)
93  ),
94  cms.PSet(
95  detector = cms.string('HCAL_ENDCAP'),
96  seedingThreshold = cms.vdouble(0.1375, 0.275, 0.275, 0.275, 0.275, 0.275, 0.275),
97  seedingThresholdPt = cms.double(0)
98  )
99  )
100  ),
101  initialClusteringStep = cms.PSet(
102  thresholdsByDetector = cms.VPSet(
103  cms.PSet(
104  detector = cms.string('HCAL_BARREL1'),
105  gatheringThreshold = cms.vdouble(0.1, 0.2, 0.3, 0.3)
106  ),
107  cms.PSet(
108  detector = cms.string('HCAL_ENDCAP'),
109  gatheringThreshold = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
110  )
111  )
112  ),
113  pfClusterBuilder = cms.PSet(
114  maxIterations = cms.uint32(5),
115  minFracTot = cms.double(1e-20),
116  minFractionToKeep = cms.double(1e-07),
117  excludeOtherSeeds = cms.bool(True),
118  showerSigma = cms.double(10),
119  stoppingTolerance = cms.double(1e-08),
120  recHitEnergyNorms = cms.VPSet(
121  cms.PSet(
122  detector = cms.string('HCAL_BARREL1'),
123  recHitEnergyNorm = cms.vdouble(0.1, 0.2, 0.3, 0.3)
124  ),
125  cms.PSet(
126  detector = cms.string('HCAL_ENDCAP'),
127  recHitEnergyNorm = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
128  )
129  ),
130  positionCalc = cms.PSet(
131  minFractionInCalc = cms.double(1e-09),
132  minAllowedNormalization = cms.double(1e-09)
133  ),
134  timeResolutionCalcBarrel = cms.PSet(
135  corrTermLowE = cms.double(0),
136  threshLowE = cms.double(6),
137  noiseTerm = cms.double(21.86),
138  constantTermLowE = cms.double(4.24),
139  noiseTermLowE = cms.double(8),
140  threshHighE = cms.double(15),
141  constantTerm = cms.double(2.82)
142  ),
143  timeResolutionCalcEndcap = cms.PSet(
144  corrTermLowE = cms.double(0),
145  threshLowE = cms.double(6),
146  noiseTerm = cms.double(21.86),
147  constantTermLowE = cms.double(4.24),
148  noiseTermLowE = cms.double(8),
149  threshHighE = cms.double(15),
150  constantTerm = cms.double(2.82)
151  )
152  ),
153  # autoselect the alpaka backend
154  alpaka = cms.untracked.PSet(
155  backend = cms.untracked.string('')
156  )
157  )
158 
159  process.hltParticleFlowClusterHBHESoA = cms.EDProducer("PFClusterSoAProducer@alpaka",
160  pfRecHits = cms.InputTag("hltParticleFlowRecHitHBHESoA"),
161  topology = cms.ESInputTag("hltESPPFRecHitHCALTopology:"),
162  pfClusterParams = cms.ESInputTag("hltESPPFClusterParams:"),
163  synchronise = cms.bool(False),
164  # autoselect the alpaka backend
165  alpaka = cms.untracked.PSet(
166  backend = cms.untracked.string('')
167  )
168  )
169 
170  process.hltParticleFlowClusterHBHE = cms.EDProducer("LegacyPFClusterProducer",
171  src = cms.InputTag("hltParticleFlowClusterHBHESoA"),
172  pfClusterBuilder = process.hltParticleFlowClusterHBHE.pfClusterBuilder,
173  usePFThresholdsFromDB = cms.bool(True),
174  recHitsSource = cms.InputTag("hltParticleFlowRecHitHBHE"),
175  PFRecHitsLabelIn = cms.InputTag("hltParticleFlowRecHitHBHESoA")
176  )
177 
178  process.HLTPFHcalClustering = cms.Sequence(
179  process.hltHbheRecHitSoA +
180  process.hltParticleFlowRecHitHBHESoA +
181  process.hltParticleFlowRecHitHBHE +
182  process.hltParticleFlowClusterHBHESoA +
183  process.hltParticleFlowClusterHBHE +
184  process.hltParticleFlowClusterHCAL
185  )
186 
187  # Some Sequences contain all the modules of process.HLTPFHcalClustering Sequence instead of the Sequence itself
188  # find these Sequences and replace all the modules with the Sequence
189  def replaceItemsInSequence(process, seqNames, itemsToReplace, replacingSequence):
190  for seqName in seqNames:
191  if not hasattr(process, seqName):
192  continue
193  seq = getattr(process, seqName)
194  for item in itemsToReplace:
195  # remove items that will be replaced by replacingSequence
196  if (item != itemsToReplace[-1]):
197  seq.remove(item)
198  else:
199  # if last item, replace it with the Sequence
200  seq.replace(item, replacingSequence)
201  return process
202 
203  process = replaceItemsInSequence(
204  process, [
205  'HLTParticleFlowSequence',
206  'HLTParticleFlowSequenceForTaus',
207  'HLTParticleFlowSequenceForDisplTaus',
208  'HLTParticleFlowSequencePPOnAA',
209  'HLTPixelOnlyParticleFlowSequence',
210  ], [
211  process.hltParticleFlowRecHitHBHE,
212  process.hltParticleFlowClusterHBHE,
213  process.hltParticleFlowClusterHCAL
214  ],
215  process.HLTPFHcalClustering
216  )
217 
218  process.hltHbheRecHitSoACPUSerial = makeSerialClone(process.hltHbheRecHitSoA)
219 
220  process.hltParticleFlowRecHitHBHESoACPUSerial = makeSerialClone(process.hltParticleFlowRecHitHBHESoA)
221  process.hltParticleFlowRecHitHBHESoACPUSerial.producers[0].src = 'hltHbheRecHitSoACPUSerial'
222 
223  process.hltParticleFlowRecHitHBHECPUOnly = process.hltParticleFlowRecHitHBHE.clone(
224  src = 'hltParticleFlowRecHitHBHESoACPUSerial',
225  )
226 
227  process.hltParticleFlowClusterHBHESoACPUSerial = makeSerialClone(process.hltParticleFlowClusterHBHESoA,
228  pfRecHits = 'hltParticleFlowRecHitHBHESoACPUSerial',
229  )
230 
231  process.hltParticleFlowClusterHBHECPUOnly = process.hltParticleFlowClusterHBHE.clone(
232  src = 'hltParticleFlowClusterHBHESoACPUSerial',
233  recHitsSource = 'hltParticleFlowRecHitHBHECPUOnly',
234  PFRecHitsLabelIn = 'hltParticleFlowRecHitHBHESoACPUSerial',
235  )
236 
237  process.HLTPFHcalClusteringCPUOnly = cms.Sequence(
238  process.hltHbheRecHitSoACPUSerial +
239  process.hltParticleFlowRecHitHBHESoACPUSerial +
240  process.hltParticleFlowRecHitHBHECPUOnly +
241  process.hltParticleFlowClusterHBHESoACPUSerial +
242  process.hltParticleFlowClusterHBHECPUOnly +
243  process.hltParticleFlowClusterHCALCPUOnly
244  )
245 
246  process = replaceItemsInSequence(process, ['HLTParticleFlowCPUOnlySequence'],
247  [process.hltParticleFlowRecHitHBHECPUOnly, process.hltParticleFlowClusterHBHECPUOnly, process.hltParticleFlowClusterHCALCPUOnly],
248  process.HLTPFHcalClusteringCPUOnly)
249 
250  # modify EventContent of *DQMGPUvsCPU streams
251  for hltOutModMatch in ['hltOutputDQMGPUvsCPU', 'hltOutputHIDQMGPUvsCPU']:
252  if hasattr(process, hltOutModMatch):
253  outMod = getattr(process, hltOutModMatch)
254  outMod.outputCommands.extend([
255  'keep *_hltParticleFlowClusterHBHESoA_*_*',
256  'keep *_hltParticleFlowClusterHBHESoACPUSerial_*_*',
257  ])
258 
259  # Add PF sequences to DQM_*HcalReconstruction_v Path
260  for pathNameMatch in ['DQM_HcalReconstruction_v', 'DQM_HIHcalReconstruction_v']:
261  dqmHcalRecoPathName = None
262  for pathName in process.paths_():
263  if pathName.startswith(pathNameMatch):
264  dqmHcalRecoPathName = pathName
265  break
266  if dqmHcalRecoPathName == None:
267  continue
268  dqmHcalPath = getattr(process, dqmHcalRecoPathName)
269  dqmHcalRecoPathIndex = dqmHcalPath.index(process.hltHcalConsumerGPU) + 1
270  dqmHcalPath.insert(dqmHcalRecoPathIndex, process.HLTPFHcalClusteringCPUOnly)
271  dqmHcalPath.insert(dqmHcalRecoPathIndex, process.HLTPFHcalClustering)
272 
273  return process
274 
275 
276 
278  '''Ad-hoc changes to test HLT config containing only DQM_PixelReconstruction_v and DQMGPUvsCPU stream
279  only up to the Pixel Local Reconstruction
280  '''
281  dqmPixelRecoPathName = None
282  for pathName in process.paths_():
283  if pathName.startswith('DQM_PixelReconstruction_v'):
284  dqmPixelRecoPathName = pathName
285  break
286 
287  if dqmPixelRecoPathName == None:
288  return process
289 
290  for prod in producers_by_type(process, 'SiPixelPhase1MonitorRecHitsSoAAlpaka'):
291  return process
292 
293  # modify EventContent of DQMGPUvsCPU stream
294  try:
295  outCmds_new = [foo for foo in process.hltOutputDQMGPUvsCPU.outputCommands if 'Pixel' not in foo]
296  outCmds_new += [
297  'keep *Cluster*_hltSiPixelClusters_*_*',
298  'keep *Cluster*_hltSiPixelClustersSerialSync_*_*',
299  'keep *_hltSiPixelDigiErrors_*_*',
300  'keep *_hltSiPixelDigiErrorsSerialSync_*_*',
301  'keep *RecHit*_hltSiPixelRecHits_*_*',
302  'keep *RecHit*_hltSiPixelRecHitsSerialSync_*_*',
303  'keep *_hltPixelTracks_*_*',
304  'keep *_hltPixelTracksSerialSync_*_*',
305  'keep *_hltPixelVertices_*_*',
306  'keep *_hltPixelVerticesSerialSync_*_*',
307  ]
308  process.hltOutputDQMGPUvsCPU.outputCommands = outCmds_new[:]
309  except:
310  pass
311 
312  # PixelRecHits: monitor of SerialSync product (Alpaka backend: 'serial_sync')
313  process.hltPixelRecHitsSoAMonitorCPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka',
314  pixelHitsSrc = cms.InputTag('hltSiPixelRecHitsSoASerialSync'),
315  TopFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCPU')
316  )
317 
318  # PixelRecHits: monitor of GPU product (Alpaka backend: '')
319  process.hltPixelRecHitsSoAMonitorGPU = cms.EDProducer('SiPixelPhase1MonitorRecHitsSoAAlpaka',
320  pixelHitsSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
321  TopFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsGPU')
322  )
323 
324  # PixelRecHits: 'GPUvsCPU' comparisons
325  process.hltPixelRecHitsSoACompareGPUvsCPU = cms.EDProducer('SiPixelPhase1CompareRecHitsSoAAlpaka',
326  pixelHitsSrcHost = cms.InputTag('hltSiPixelRecHitsSoASerialSync'),
327  pixelHitsSrcDevice = cms.InputTag('hltSiPixelRecHitsSoA'),
328  topFolderName = cms.string('SiPixelHeterogeneous/PixelRecHitsCompareGPUvsCPU'),
329  minD2cut = cms.double(1.0e-4)
330  )
331 
332  process.hltPixelTracksSoAMonitorCPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka",
333  minQuality = cms.string('loose'),
334  pixelTrackSrc = cms.InputTag('hltPixelTracksSoASerialSync'),
335  topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCPU'),
336  useQualityCut = cms.bool(True)
337  )
338 
339  process.hltPixelTracksSoAMonitorGPU = cms.EDProducer("SiPixelPhase1MonitorTrackSoAAlpaka",
340  minQuality = cms.string('loose'),
341  pixelTrackSrc = cms.InputTag('hltPixelTracksSoA'),
342  topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackGPU'),
343  useQualityCut = cms.bool(True)
344  )
345 
346  process.hltPixelTracksSoACompareGPUvsCPU = cms.EDProducer("SiPixelPhase1CompareTrackSoAAlpaka",
347  deltaR2cut = cms.double(0.04),
348  minQuality = cms.string('loose'),
349  pixelTrackSrcHost = cms.InputTag("hltPixelTracksSoASerialSync"),
350  pixelTrackSrcDevice = cms.InputTag("hltPixelTracksSoA"),
351  topFolderName = cms.string('SiPixelHeterogeneous/PixelTrackCompareGPUvsCPU'),
352  useQualityCut = cms.bool(True)
353  )
354 
355  process.hltPixelVertexSoAMonitorCPU = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka",
356  beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
357  pixelVertexSrc = cms.InputTag("hltPixelVerticesSoASerialSync"),
358  topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCPU')
359  )
360 
361  process.hltPixelVertexSoAMonitorGPU = cms.EDProducer("SiPixelMonitorVertexSoAAlpaka",
362  beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
363  pixelVertexSrc = cms.InputTag("hltPixelVerticesSoA"),
364  topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexGPU')
365  )
366 
367  process.hltPixelVertexSoACompareGPUvsCPU = cms.EDProducer("SiPixelCompareVertexSoAAlpaka",
368  beamSpotSrc = cms.InputTag("hltOnlineBeamSpot"),
369  dzCut = cms.double(1),
370  pixelVertexSrcHost = cms.InputTag("hltPixelVerticesSoASerialSync"),
371  pixelVertexSrcDevice = cms.InputTag("hltPixelVerticesSoA"),
372  topFolderName = cms.string('SiPixelHeterogeneous/PixelVertexCompareGPUvsCPU')
373  )
374 
375  process.HLTDQMPixelReconstruction = cms.Sequence(
376  process.hltPixelRecHitsSoAMonitorCPU
377  + process.hltPixelRecHitsSoAMonitorGPU
378  + process.hltPixelRecHitsSoACompareGPUvsCPU
379  + process.hltPixelTracksSoAMonitorCPU
380  + process.hltPixelTracksSoAMonitorGPU
381  + process.hltPixelTracksSoACompareGPUvsCPU
382  + process.hltPixelVertexSoAMonitorCPU
383  + process.hltPixelVertexSoAMonitorGPU
384  + process.hltPixelVertexSoACompareGPUvsCPU
385  )
386 
387  for delMod in ['hltPixelConsumerCPU', 'hltPixelConsumerGPU']:
388  if hasattr(process, delMod):
389  process.__delattr__(delMod)
390 
391  return process
392 
393 
395  '''Customisation to introduce the Local Pixel Reconstruction in Alpaka
396  '''
397 
398  if not hasattr(process, 'HLTDoLocalPixelSequence'):
399  return process
400 
401  for prod in producers_by_type(process, 'SiPixelRawToClusterPhase1@alpaka'):
402  return process
403 
404  process.hltESPSiPixelCablingSoA = cms.ESProducer('SiPixelCablingSoAESProducer@alpaka',
405  CablingMapLabel = cms.string(''),
406  UseQualityInfo = cms.bool(False),
407  appendToDataLabel = cms.string(''),
408  alpaka = cms.untracked.PSet(
409  backend = cms.untracked.string('')
410  )
411  )
412 
413  process.hltESPSiPixelGainCalibrationForHLTSoA = cms.ESProducer('SiPixelGainCalibrationForHLTSoAESProducer@alpaka',
414  appendToDataLabel = cms.string(''),
415  alpaka = cms.untracked.PSet(
416  backend = cms.untracked.string('')
417  )
418  )
419 
420  process.hltESPPixelCPEFastParamsPhase1 = cms.ESProducer('PixelCPEFastParamsESProducerAlpakaPhase1@alpaka',
421  appendToDataLabel = cms.string(''),
422  alpaka = cms.untracked.PSet(
423  backend = cms.untracked.string('')
424  )
425  )
426 
427  if hasattr(process, 'hltESPPixelCPEFast'):
428  del process.hltESPPixelCPEFast
429 
430  # alpaka EDProducer
431  # consumes
432  # - reco::BeamSpot
433  # produces
434  # - BeamSpotDevice
435  process.hltOnlineBeamSpotDevice = cms.EDProducer('BeamSpotDeviceProducer@alpaka',
436  src = cms.InputTag('hltOnlineBeamSpot'),
437  alpaka = cms.untracked.PSet(
438  backend = cms.untracked.string('')
439  )
440  )
441 
442  if hasattr(process, 'hltOnlineBeamSpotToGPU'):
443  # hltOnlineBeamSpotToGPU is currently still used in HIon menu,
444  # remove it only if the relevant ConditionalTask of the HIon menu is not present
445  # (this check mainly applies to the HLT combined table)
446  if not (hasattr(process, 'HLTDoLocalPixelPPOnAATask') and process.HLTDoLocalPixelPPOnAATask.contains(process.hltOnlineBeamSpotToGPU)):
447  del process.hltOnlineBeamSpotToGPU
448 
449  # alpaka EDProducer
450  # consumes
451  # - FEDRawDataCollection
452  # produces (* optional)
453  # - SiPixelClustersSoA
454  # - SiPixelDigisSoACollection
455  # - SiPixelDigiErrorsSoACollection *
456  # - SiPixelFormatterErrors *
457  process.hltSiPixelClustersSoA = cms.EDProducer('SiPixelRawToClusterPhase1@alpaka',
458  IncludeErrors = cms.bool(True),
459  UseQualityInfo = cms.bool(False),
460  clusterThreshold_layer1 = cms.int32(4000),
461  clusterThreshold_otherLayers = cms.int32(4000),
462  VCaltoElectronGain = cms.double(1), # all gains=1, pedestals=0
463  VCaltoElectronGain_L1 = cms.double(1),
464  VCaltoElectronOffset = cms.double(0),
465  VCaltoElectronOffset_L1 = cms.double(0),
466  InputLabel = cms.InputTag('rawDataCollector'),
467  Regions = cms.PSet(),
468  CablingMapLabel = cms.string(''),
469  # autoselect the alpaka backend
470  alpaka = cms.untracked.PSet(
471  backend = cms.untracked.string('')
472  )
473  )
474 
475  if hasattr(process, 'hltSiPixelClustersGPU'):
476  del process.hltSiPixelClustersGPU
477 
478  process.hltSiPixelClusters = cms.EDProducer('SiPixelDigisClustersFromSoAAlpakaPhase1',
479  src = cms.InputTag('hltSiPixelClustersSoA'),
480  clusterThreshold_layer1 = cms.int32(4000),
481  clusterThreshold_otherLayers = cms.int32(4000),
482  produceDigis = cms.bool(False),
483  storeDigis = cms.bool(False)
484  )
485 
486  # used only in the PPRef menu for the legacy pixel track reconstruction
487  process.hltSiPixelClustersCache = cms.EDProducer('SiPixelClusterShapeCacheProducer',
488  src = cms.InputTag('hltSiPixelClusters'),
489  onDemand = cms.bool(False)
490  )
491 
492  # legacy EDProducer
493  # consumes
494  # - SiPixelDigiErrorsHost
495  # - SiPixelFormatterErrors
496  # produces
497  # - edm::DetSetVector<SiPixelRawDataError>
498  # - DetIdCollection
499  # - DetIdCollection, 'UserErrorModules'
500  # - edmNew::DetSetVector<PixelFEDChannel>
501  process.hltSiPixelDigiErrors = cms.EDProducer('SiPixelDigiErrorsFromSoAAlpaka',
502  digiErrorSoASrc = cms.InputTag('hltSiPixelClustersSoA'),
503  fmtErrorsSoASrc = cms.InputTag('hltSiPixelClustersSoA'),
504  CablingMapLabel = cms.string(''),
505  UsePhase1 = cms.bool(True),
506  ErrorList = cms.vint32(29),
507  UserErrorList = cms.vint32(40)
508  )
509 
510  if hasattr(process, 'hltSiPixelDigisSoA'):
511  del process.hltSiPixelDigisSoA
512  if hasattr(process, 'hltSiPixelDigiErrorsSoA'):
513  del process.hltSiPixelDigiErrorsSoA
514 
515  # alpaka EDProducer
516  # consumes
517  # - BeamSpotDevice
518  # - SiPixelClustersSoA
519  # - SiPixelDigisSoACollection
520  # produces
521  # - TrackingRecHitsSoACollection<TrackerTraits>
522  process.hltSiPixelRecHitsSoA = cms.EDProducer('SiPixelRecHitAlpakaPhase1@alpaka',
523  beamSpot = cms.InputTag('hltOnlineBeamSpotDevice'),
524  src = cms.InputTag('hltSiPixelClustersSoA'),
525  CPE = cms.string('PixelCPEFastParams'),
526  # autoselect the alpaka backend
527  alpaka = cms.untracked.PSet(
528  backend = cms.untracked.string('')
529  )
530  )
531 
532  if hasattr(process, 'hltSiPixelRecHitsGPU'):
533  del process.hltSiPixelRecHitsGPU
534  if hasattr(process, 'hltSiPixelRecHitsFromGPU'):
535  del process.hltSiPixelRecHitsFromGPU
536  if hasattr(process, 'hltSiPixelRecHitsSoAFromGPU'):
537  del process.hltSiPixelRecHitsSoAFromGPU
538 
539  process.hltSiPixelRecHits = cms.EDProducer('SiPixelRecHitFromSoAAlpakaPhase1',
540  pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
541  src = cms.InputTag('hltSiPixelClusters'),
542  )
543 
544 
547  process.HLTDoLocalPixelSequence = cms.Sequence(
548  process.hltOnlineBeamSpotDevice +
549  process.hltSiPixelClustersSoA +
550  process.hltSiPixelClusters +
551  process.hltSiPixelDigiErrors + # renamed from hltSiPixelDigis
552  process.hltSiPixelRecHitsSoA +
553  process.hltSiPixelRecHits
554  )
555 
556  # The module hltSiPixelClustersCache is only used in the PRef menu.
557  # Previously, it being included in the GRun menu had no effect
558  # because it was included in a ConditionalTask, which meant that
559  # it was not executed in the GRun menu, since no other modules
560  # in any Path of that menu were consuming it.
561  # Since this customisation effectively replaces ConditionalTasks in the HLT menus with Sequences,
562  # leaving hltSiPixelClustersCache in a Sequence of the GRun menu would lead to it being unnecessarily executed.
563  # On the other hand, hltSiPixelClustersCache must be kept in the PRef menu,
564  # as the latter does have reconstruction modules which consume it.
565  # The solution implemented here is
566  # (a) not to include hltSiPixelClustersCache in the Sequence HLTDoLocalPixelSequence used in the GRun menu, and
567  # (b) include hltSiPixelClustersCache in a separate Sequence to be used only as part of the PRef menu.
568  if hasattr(process, 'HLTPixelClusterSplittingForPFPPRefForDmeson') \
569  and not hasattr(process, 'HLTDoLocalPixelSequenceForPFPPRefForDmeson') \
570  and process.HLTPixelClusterSplittingForPFPPRefForDmeson.contains(process.HLTDoLocalPixelSequence):
571 
572  process.HLTDoLocalPixelSequenceForPFPPRefForDmeson = cms.Sequence(
573  process.HLTDoLocalPixelSequence +
574  process.hltSiPixelClustersCache
575  )
576 
577  process.HLTPixelClusterSplittingForPFPPRefForDmeson.insert(
578  process.HLTPixelClusterSplittingForPFPPRefForDmeson.index(process.HLTDoLocalPixelSequence),
579  process.HLTDoLocalPixelSequenceForPFPPRefForDmeson
580  )
581 
582  # remove HLTDoLocalPixelTask (not needed anymore)
583  if hasattr(process, 'HLTDoLocalPixelTask'):
584  del process.HLTDoLocalPixelTask
585 
586 
589  process.hltOnlineBeamSpotDeviceSerialSync = makeSerialClone(process.hltOnlineBeamSpotDevice)
590 
591  process.hltSiPixelClustersSoASerialSync = makeSerialClone(process.hltSiPixelClustersSoA)
592 
593  process.hltSiPixelClustersSerialSync = process.hltSiPixelClusters.clone(
594  src = 'hltSiPixelClustersSoASerialSync'
595  )
596 
597  process.hltSiPixelDigiErrorsSerialSync = process.hltSiPixelDigiErrors.clone(
598  digiErrorSoASrc = 'hltSiPixelClustersSoASerialSync',
599  fmtErrorsSoASrc = 'hltSiPixelClustersSoASerialSync',
600  )
601 
602  process.hltSiPixelRecHitsSoASerialSync = makeSerialClone(process.hltSiPixelRecHitsSoA,
603  beamSpot = 'hltOnlineBeamSpotDeviceSerialSync',
604  src = 'hltSiPixelClustersSoASerialSync',
605  )
606 
607  process.hltSiPixelRecHitsSerialSync = process.hltSiPixelRecHits.clone(
608  pixelRecHitSrc = 'hltSiPixelRecHitsSoASerialSync',
609  src = 'hltSiPixelClustersSerialSync',
610  )
611 
612  process.HLTDoLocalPixelCPUOnlySequence = cms.Sequence(
613  process.hltOnlineBeamSpotDeviceSerialSync +
614  process.hltSiPixelClustersSoASerialSync +
615  process.hltSiPixelClustersSerialSync +
616  process.hltSiPixelDigiErrorsSerialSync +
617  process.hltSiPixelRecHitsSoASerialSync +
618  process.hltSiPixelRecHitsSerialSync
619  )
620 
621  if hasattr(process, 'HLTDoLocalPixelCPUOnlyTask'):
622  del process.HLTDoLocalPixelCPUOnlyTask
623 
624  if hasattr(process, 'hltMeasurementTrackerEventCPUOnly'):
625  process.hltMeasurementTrackerEventCPUOnly.pixelClusterProducer = "hltSiPixelClustersSerialSync"
626  process.hltMeasurementTrackerEventCPUOnly.inactivePixelDetectorLabels = ["hltSiPixelDigiErrorsSerialSync"]
627  process.hltMeasurementTrackerEventCPUOnly.badPixelFEDChannelCollectionLabels = ["hltSiPixelDigiErrorsSerialSync"]
628 
629  if hasattr(process, 'hltDoubletRecoveryClustersRefRemovalCPUOnly'):
630  process.hltDoubletRecoveryClustersRefRemovalCPUOnly.pixelClusters = "hltSiPixelClustersSerialSync"
631 
632  if hasattr(process, 'hltDoubletRecoveryPFlowPixelClusterCheckCPUOnly'):
633  process.hltDoubletRecoveryPFlowPixelClusterCheckCPUOnly.PixelClusterCollectionLabel = "hltSiPixelClustersSerialSync"
634 
635  if hasattr(process, 'hltDoubletRecoveryPixelLayersAndRegionsCPUOnly'):
636  process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.inactivePixelDetectorLabels = ['hltSiPixelDigiErrorsSerialSync']
637  process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrorsSerialSync']
638  process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.BPix.HitProducer = "hltSiPixelRecHitsSerialSync"
639  process.hltDoubletRecoveryPixelLayersAndRegionsCPUOnly.FPix.HitProducer = "hltSiPixelRecHitsSerialSync"
640 
641  if hasattr(process, 'hltIter3IterL3FromL1MuonClustersRefRemovalCPUOnly'):
642  process.hltIter3IterL3FromL1MuonClustersRefRemovalCPUOnly.pixelClusters = "hltSiPixelClustersSerialSync"
643 
644  if hasattr(process, 'hltIter3IterL3FromL1MuonPixelClusterCheckCPUOnly'):
645  process.hltIter3IterL3FromL1MuonPixelClusterCheckCPUOnly.PixelClusterCollectionLabel = "hltSiPixelClustersSerialSync"
646 
647  if hasattr(process, 'hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly'):
648  process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.inactivePixelDetectorLabels = ['hltSiPixelDigiErrorsSerialSync']
649  process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrorsSerialSync']
650  process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.BPix.HitProducer = "hltSiPixelRecHitsSerialSync"
651  process.hltIter3IterL3FromL1MuonPixelLayersAndRegionsCPUOnly.FPix.HitProducer = "hltSiPixelRecHitsSerialSync"
652 
653  for modLabel in [
654  'hltDoubletRecoveryPixelLayersAndRegions',
655  'hltFullIter6PixelTrackingRegionSeedLayersBPPRef',
656  'hltIter3IterL3FromL1MuonPixelLayersAndRegions',
657  'hltMeasurementTrackerEvent',
658  ]:
659  if hasattr(process, modLabel):
660  mod = getattr(process, modLabel)
661  mod.inactivePixelDetectorLabels = ['hltSiPixelDigiErrors']
662  mod.badPixelFEDChannelCollectionLabels = ['hltSiPixelDigiErrors']
663 
664  return process
665 
666 
668  '''Customisation to introduce the Pixel-Track Reconstruction in Alpaka
669  '''
670 
671  if not hasattr(process, 'HLTRecoPixelTracksSequence'):
672  return process
673 
674  for prod in producers_by_type(process, 'CAHitNtupletAlpakaPhase1@alpaka'):
675  return process
676 
677  # alpaka EDProducer
678  # consumes
679  # - TrackingRecHitsSoACollection<TrackerTraits>
680  # produces
681  # - TkSoADevice
682  process.hltPixelTracksSoA = cms.EDProducer('CAHitNtupletAlpakaPhase1@alpaka',
683  pixelRecHitSrc = cms.InputTag('hltSiPixelRecHitsSoA'),
684  CPE = cms.string('PixelCPEFastParams'),
685  ptmin = cms.double(0.9),
686  CAThetaCutBarrel = cms.double(0.002),
687  CAThetaCutForward = cms.double(0.003),
688  hardCurvCut = cms.double(0.0328407225),
689  dcaCutInnerTriplet = cms.double(0.15),
690  dcaCutOuterTriplet = cms.double(0.25),
691  earlyFishbone = cms.bool(True),
692  lateFishbone = cms.bool(False),
693  fillStatistics = cms.bool(False),
694  minHitsPerNtuplet = cms.uint32(3),
695  phiCuts = cms.vint32(
696  522, 730, 730, 522, 626,
697  626, 522, 522, 626, 626,
698  626, 522, 522, 522, 522,
699  522, 522, 522, 522
700  ),
701  maxNumberOfDoublets = cms.uint32(524288),
702  minHitsForSharingCut = cms.uint32(10),
703  fitNas4 = cms.bool(False),
704  doClusterCut = cms.bool(True),
705  doZ0Cut = cms.bool(True),
706  doPtCut = cms.bool(True),
707  useRiemannFit = cms.bool(False),
708  doSharedHitCut = cms.bool(True),
709  dupPassThrough = cms.bool(False),
710  useSimpleTripletCleaner = cms.bool(True),
711  idealConditions = cms.bool(False),
712  includeJumpingForwardDoublets = cms.bool(True),
713  trackQualityCuts = cms.PSet(
714  chi2MaxPt = cms.double(10),
715  chi2Coeff = cms.vdouble(0.9, 1.8),
716  chi2Scale = cms.double(8),
717  tripletMinPt = cms.double(0.5),
718  tripletMaxTip = cms.double(0.3),
719  tripletMaxZip = cms.double(12),
720  quadrupletMinPt = cms.double(0.3),
721  quadrupletMaxTip = cms.double(0.5),
722  quadrupletMaxZip = cms.double(12)
723  ),
724  # autoselect the alpaka backend
725  alpaka = cms.untracked.PSet(
726  backend = cms.untracked.string('')
727  )
728  )
729 
730  if hasattr(process, 'hltL2TauTagNNProducer'):
731  process.hltL2TauTagNNProducer = cms.EDProducer("L2TauNNProducerAlpaka", **process.hltL2TauTagNNProducer.parameters_())
732 
733  process.hltPixelTracksSoASerialSync = makeSerialClone(process.hltPixelTracksSoA,
734  pixelRecHitSrc = 'hltSiPixelRecHitsSoASerialSync'
735  )
736 
737  process.hltPixelTracks = cms.EDProducer("PixelTrackProducerFromSoAAlpakaPhase1",
738  beamSpot = cms.InputTag("hltOnlineBeamSpot"),
739  minNumberOfHits = cms.int32(0),
740  minQuality = cms.string('loose'),
741  pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHits"),
742  trackSrc = cms.InputTag("hltPixelTracksSoA")
743  )
744 
745  if hasattr(process, 'hltPixelTracksCPU'):
746  del process.hltPixelTracksCPU
747  if hasattr(process, 'hltPixelTracksCPUOnly'):
748  del process.hltPixelTracksCPUOnly
749  if hasattr(process, 'hltPixelTracksFromGPU'):
750  del process.hltPixelTracksFromGPU
751  if hasattr(process, 'hltPixelTracksGPU'):
752  del process.hltPixelTracksGPU
753 
754  process.hltPixelTracksSerialSync = process.hltPixelTracks.clone(
755  pixelRecHitLegacySrc = cms.InputTag("hltSiPixelRecHitsSerialSync"),
756  trackSrc = cms.InputTag("hltPixelTracksSoASerialSync")
757  )
758 
759  process.HLTRecoPixelTracksSequence = cms.Sequence(
760  process.hltPixelTracksSoA +
761  process.hltPixelTracks
762  )
763 
764  if hasattr(process, 'HLTRecoPixelTracksTask'):
765  del process.HLTRecoPixelTracksTask
766 
767  process.HLTRecoPixelTracksSerialSyncSequence = cms.Sequence(
768  process.hltPixelTracksSoASerialSync +
769  process.hltPixelTracksSerialSync
770  )
771 
772  if hasattr(process, 'HLTRecoPixelTracksCPUOnlyTask'):
773  del process.HLTRecoPixelTracksCPUOnlyTask
774 
775  process.hltPixelTracksInRegionL2CPUOnly.tracks = "hltPixelTracksSerialSync"
776 
777  process.hltPixelTracksInRegionL1CPUOnly.tracks = "hltPixelTracksSerialSync"
778 
779  process.hltIter0PFLowPixelSeedsFromPixelTracksCPUOnly.InputCollection = "hltPixelTracksSerialSync"
780 
781  return process
782 
783 
785  '''Customisation to introduce the Pixel-Vertex Reconstruction in Alpaka
786  '''
787 
788  if not hasattr(process, 'HLTRecopixelvertexingSequence'):
789  return process
790 
791  # do not apply the customisation if the menu is already using the alpaka pixel reconstruction
792  for prod in producers_by_type(process, 'PixelVertexProducerAlpakaPhase1@alpaka'):
793  return process
794 
795  # alpaka EDProducer
796  # consumes
797  # - TkSoADevice
798  # produces
799  # - ZVertexDevice
800  process.hltPixelVerticesSoA = cms.EDProducer('PixelVertexProducerAlpakaPhase1@alpaka',
801  oneKernel = cms.bool(True),
802  useDensity = cms.bool(True),
803  useDBSCAN = cms.bool(False),
804  useIterative = cms.bool(False),
805  minT = cms.int32(2),
806  eps = cms.double(0.07),
807  errmax = cms.double(0.01),
808  chi2max = cms.double(9),
809  PtMin = cms.double(0.5),
810  PtMax = cms.double(75),
811  pixelTrackSrc = cms.InputTag('hltPixelTracksSoA'),
812  # autoselect the alpaka backend
813  alpaka = cms.untracked.PSet(
814  backend = cms.untracked.string('')
815  )
816  )
817 
818  process.hltPixelVerticesSoASerialSync = makeSerialClone(process.hltPixelVerticesSoA,
819  pixelTrackSrc = 'hltPixelTracksSoASerialSync'
820  )
821 
822  process.hltPixelVertices = cms.EDProducer("PixelVertexProducerFromSoAAlpaka",
823  TrackCollection = cms.InputTag("hltPixelTracks"),
824  beamSpot = cms.InputTag("hltOnlineBeamSpot"),
825  src = cms.InputTag("hltPixelVerticesSoA")
826  )
827 
828  process.hltPixelVerticesSerialSync = process.hltPixelVertices.clone(
829  TrackCollection = cms.InputTag("hltPixelTracksSerialSync"),
830  src = cms.InputTag("hltPixelVerticesSoASerialSync")
831  )
832 
833  if hasattr(process, 'hltPixelVerticesCPU'):
834  del process.hltPixelVerticesCPU
835  if hasattr(process, 'hltPixelVerticesCPUOnly'):
836  del process.hltPixelVerticesCPUOnly
837  if hasattr(process, 'hltPixelVerticesFromGPU'):
838  del process.hltPixelVerticesFromGPU
839  if hasattr(process, 'hltPixelVerticesGPU'):
840  del process.hltPixelVerticesGPU
841 
842 
843  if not hasattr(process, 'hltTrimmedPixelVertices'):
844  return process
845 
846  process.HLTRecopixelvertexingSequence = cms.Sequence(
847  process.HLTRecoPixelTracksSequence +
848  process.hltPixelVerticesSoA +
849  process.hltPixelVertices +
850  process.hltTrimmedPixelVertices
851  )
852 
853  if hasattr(process, 'HLTRecopixelvertexingTask'):
854  del process.HLTRecopixelvertexingTask
855 
856  process.HLTRecopixelvertexingCPUOnlySequence = cms.Sequence(
857  process.HLTRecoPixelTracksSerialSyncSequence +
858  process.hltPixelVerticesSoASerialSync +
859  process.hltPixelVerticesSerialSync +
860  process.hltTrimmedPixelVerticesCPUOnly
861  )
862 
863  if hasattr(process, 'HLTRecopixelvertexingCPUOnlyTask'):
864  del process.HLTRecopixelvertexingCPUOnlyTask
865 
866  process.hltTrimmedPixelVerticesCPUOnly.src = 'hltPixelVerticesSerialSync'
867  process.hltParticleFlowCPUOnly.vertexCollection = 'hltPixelVerticesSerialSync'
868  process.hltAK4PFJetsCPUOnly.srcPVs = 'hltPixelVerticesSerialSync'
869 
870  return process
871 
872 
874  '''Customisation to introduce the Pixel Local+Track+Vertex Reconstruction in Alpaka
875  '''
876  process = customizeHLTforAlpakaPixelRecoLocal(process)
877  process = customizeHLTforAlpakaPixelRecoTracking(process)
878  process = customizeHLTforAlpakaPixelRecoVertexing(process)
879  process = customizeHLTforDQMGPUvsCPUPixel(process)
880 
881  return process
882 
883 
884 
886 
887  if not hasattr(process, 'hltEcalDigisGPU'):
888  return process
889 
890  for prod in producers_by_type(process, 'EcalRawToDigiPortable@alpaka'):
891  return process
892 
893  # remove existing ECAL GPU-related ES modules
894  for foo in [foo for foo in process.es_producers_() if ('ecal' in foo and 'GPU' in foo)]:
895  process.__delattr__(foo)
896 
897  for foo in [foo for foo in process.es_sources_() if ('ecal' in foo and 'GPU' in foo)]:
898  process.__delattr__(foo)
899 
900  # redefine ECAL local reconstruction sequence
901  process.hltEcalDigisPortableSoA = cms.EDProducer("EcalRawToDigiPortable@alpaka",
902  FEDs = process.hltEcalDigisGPU.FEDs,
903  InputLabel = process.hltEcalDigisGPU.InputLabel,
904  digisLabelEB = process.hltEcalDigisGPU.digisLabelEB,
905  digisLabelEE = process.hltEcalDigisGPU.digisLabelEE,
906  maxChannelsEB = process.hltEcalDigisGPU.maxChannelsEB,
907  maxChannelsEE = process.hltEcalDigisGPU.maxChannelsEE,
908  # autoselect the alpaka backend
909  alpaka = cms.untracked.PSet(
910  backend = cms.untracked.string('')
911  )
912  )
913 
914  from EventFilter.EcalRawToDigi.ecalElectronicsMappingHostESProducer_cfi import ecalElectronicsMappingHostESProducer as _ecalElectronicsMappingHostESProducer
915  process.ecalElectronicsMappingHostESProducer = _ecalElectronicsMappingHostESProducer.clone()
916 
917  process.hltEcalDigis = cms.EDProducer("EcalDigisFromPortableProducer",
918  digisInLabelEB = cms.InputTag('hltEcalDigisPortableSoA', 'ebDigis'),
919  digisInLabelEE = cms.InputTag('hltEcalDigisPortableSoA', 'eeDigis'),
920  digisOutLabelEB = cms.string("ebDigis"),
921  digisOutLabelEE = cms.string("eeDigis"),
922  produceDummyIntegrityCollections = cms.bool(False)
923  )
924 
925  process.hltEcalUncalibRecHitPortableSoA = cms.EDProducer("EcalUncalibRecHitProducerPortable@alpaka",
926  EBtimeConstantTerm = process.hltEcalUncalibRecHitGPU.EBtimeConstantTerm,
927  EBtimeFitLimits_Lower = process.hltEcalUncalibRecHitGPU.EBtimeFitLimits_Lower,
928  EBtimeFitLimits_Upper = process.hltEcalUncalibRecHitGPU.EBtimeFitLimits_Upper,
929  EBtimeNconst = process.hltEcalUncalibRecHitGPU.EBtimeNconst,
930  EEtimeConstantTerm = process.hltEcalUncalibRecHitGPU.EEtimeConstantTerm,
931  EEtimeFitLimits_Lower = process.hltEcalUncalibRecHitGPU.EEtimeFitLimits_Lower,
932  EEtimeFitLimits_Upper = process.hltEcalUncalibRecHitGPU.EEtimeFitLimits_Upper,
933  EEtimeNconst = process.hltEcalUncalibRecHitGPU.EEtimeNconst,
934  amplitudeThresholdEB = process.hltEcalUncalibRecHitGPU.amplitudeThresholdEB,
935  amplitudeThresholdEE = process.hltEcalUncalibRecHitGPU.amplitudeThresholdEE,
936  digisLabelEB = cms.InputTag("hltEcalDigisPortableSoA", "ebDigis"),
937  digisLabelEE = cms.InputTag("hltEcalDigisPortableSoA", "eeDigis"),
938  kernelMinimizeThreads = process.hltEcalUncalibRecHitGPU.kernelMinimizeThreads,
939  outOfTimeThresholdGain12mEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12mEB,
940  outOfTimeThresholdGain12mEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12mEE,
941  outOfTimeThresholdGain12pEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12pEB,
942  outOfTimeThresholdGain12pEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain12pEE,
943  outOfTimeThresholdGain61mEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61mEB,
944  outOfTimeThresholdGain61mEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61mEE,
945  outOfTimeThresholdGain61pEB = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61pEB,
946  outOfTimeThresholdGain61pEE = process.hltEcalUncalibRecHitGPU.outOfTimeThresholdGain61pEE,
947  recHitsLabelEB = process.hltEcalUncalibRecHitGPU.recHitsLabelEB,
948  recHitsLabelEE = process.hltEcalUncalibRecHitGPU.recHitsLabelEE,
949  shouldRunTimingComputation = process.hltEcalUncalibRecHitGPU.shouldRunTimingComputation,
950  # autoselect the alpaka backend
951  alpaka = cms.untracked.PSet(
952  backend = cms.untracked.string('')
953  )
954  )
955 
956  if hasattr(process, 'hltEcalUncalibRecHitGPU'):
957  del process.hltEcalUncalibRecHitGPU
958 
959  process.ecalMultifitParametersSource = cms.ESSource("EmptyESSource",
960  firstValid = cms.vuint32(1),
961  iovIsRunNotTime = cms.bool(True),
962  recordName = cms.string('EcalMultifitParametersRcd')
963  )
964 
965  from RecoLocalCalo.EcalRecProducers.ecalMultifitConditionsHostESProducer_cfi import ecalMultifitConditionsHostESProducer as _ecalMultifitConditionsHostESProducer
966  process.ecalMultifitConditionsHostESProducer = _ecalMultifitConditionsHostESProducer.clone()
967 
968  from RecoLocalCalo.EcalRecProducers.ecalMultifitParametersHostESProducer_cfi import ecalMultifitParametersHostESProducer as _ecalMultifitParametersHostESProducer
969  process.ecalMultifitParametersHostESProducer = _ecalMultifitParametersHostESProducer.clone()
970 
971  process.hltEcalUncalibRecHit = cms.EDProducer("EcalUncalibRecHitSoAToLegacy",
972  isPhase2 = process.hltEcalUncalibRecHitFromSoA.isPhase2,
973  recHitsLabelCPUEB = process.hltEcalUncalibRecHitFromSoA.recHitsLabelCPUEB,
974  recHitsLabelCPUEE = process.hltEcalUncalibRecHitFromSoA.recHitsLabelCPUEE,
975  uncalibRecHitsPortableEB = cms.InputTag("hltEcalUncalibRecHitPortableSoA", "EcalUncalibRecHitsEB"),
976  uncalibRecHitsPortableEE = cms.InputTag("hltEcalUncalibRecHitPortableSoA", "EcalUncalibRecHitsEE")
977  )
978 
979  if hasattr(process, 'hltEcalUncalibRecHitSoA'):
980  delattr(process, 'hltEcalUncalibRecHitSoA')
981 
982  process.hltEcalDetIdToBeRecovered = cms.EDProducer("EcalDetIdToBeRecoveredProducer",
983  integrityBlockSizeErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityBlockSizeErrors'),
984  integrityTTIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityTTIdErrors'),
985 
986  ebIntegrityGainErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainErrors'),
987  eeIntegrityGainErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainErrors'),
988 
989  ebIntegrityGainSwitchErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainSwitchErrors'),
990  eeIntegrityGainSwitchErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityGainSwitchErrors'),
991 
992  ebIntegrityChIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityChIdErrors'),
993  eeIntegrityChIdErrors = cms.InputTag('hltEcalDigisLegacy', 'EcalIntegrityChIdErrors'),
994 
995  ebSrFlagCollection = cms.InputTag("hltEcalDigisLegacy"),
996  eeSrFlagCollection = cms.InputTag("hltEcalDigisLegacy"),
997 
998  ebDetIdToBeRecovered = cms.string("ebDetId"),
999  eeDetIdToBeRecovered = cms.string("eeDetId"),
1000 
1001  ebFEToBeRecovered = cms.string("ebFE"),
1002  eeFEToBeRecovered = cms.string("eeFE"),
1003  )
1004 
1005  process.hltEcalRecHit.triggerPrimitiveDigiCollection = 'hltEcalDigisLegacy:EcalTriggerPrimitives'
1006 
1007  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence = cms.Sequence(
1008  process.hltEcalDigisLegacy +
1009  process.hltEcalDigisPortableSoA +
1010  process.hltEcalDigis + # conversion of PortableSoA to legacy format
1011  process.hltEcalUncalibRecHitPortableSoA +
1012  process.hltEcalUncalibRecHit + # conversion of PortableSoA to legacy format
1013  process.hltEcalDetIdToBeRecovered +
1014  process.hltEcalRecHit
1015  )
1016 
1017  process.HLTPreshowerSequence = cms.Sequence(process.hltEcalPreshowerDigis + process.hltEcalPreshowerRecHit)
1018 
1019  process.HLTDoFullUnpackingEgammaEcalSequence = cms.Sequence(
1020  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerSequence +
1021  process.HLTPreshowerSequence
1022  )
1023 
1024  process.HLTDoFullUnpackingEgammaEcalMFSequence = cms.Sequence(process.HLTDoFullUnpackingEgammaEcalSequence)
1025 
1026  process.hltEcalDigisCPUSerialSoA = makeSerialClone(process.hltEcalDigisPortableSoA)
1027 
1028  process.hltEcalDigisCPUSerial = process.hltEcalDigis.clone(
1029  digisInLabelEB = 'hltEcalDigisCPUSerialSoA:ebDigis',
1030  digisInLabelEE = 'hltEcalDigisCPUSerialSoA:eeDigis',
1031  )
1032 
1033  process.hltEcalUncalibRecHitCPUSerialSoA = makeSerialClone(process.hltEcalUncalibRecHitPortableSoA,
1034  digisLabelEB = "hltEcalDigisCPUSerialSoA:ebDigis",
1035  digisLabelEE = "hltEcalDigisCPUSerialSoA:eeDigis",
1036  )
1037 
1038  process.hltEcalUncalibRecHitCPUSerial = process.hltEcalUncalibRecHit.clone(
1039  uncalibRecHitsPortableEB = "hltEcalUncalibRecHitCPUSerialSoA:EcalUncalibRecHitsEB",
1040  uncalibRecHitsPortableEE = "hltEcalUncalibRecHitCPUSerialSoA:EcalUncalibRecHitsEE",
1041  )
1042 
1043  process.hltEcalRecHitCPUOnly = process.hltEcalRecHit.clone(
1044  EBuncalibRecHitCollection = 'hltEcalUncalibRecHitCPUSerial:EcalUncalibRecHitsEB',
1045  EEuncalibRecHitCollection = 'hltEcalUncalibRecHitCPUSerial:EcalUncalibRecHitsEE',
1046  )
1047 
1048  process.HLTDoFullUnpackingEgammaEcalWithoutPreshowerCPUOnlySequence = cms.Sequence(
1049  process.hltEcalDigisLegacy +
1050  process.hltEcalDigisCPUSerialSoA +
1051  process.hltEcalDigisCPUSerial + # conversion of CPUSerialSoA to legacy format
1052  process.hltEcalUncalibRecHitCPUSerialSoA +
1053  process.hltEcalUncalibRecHitCPUSerial + # conversion of CPUSerialSoA to legacy format
1054  process.hltEcalDetIdToBeRecovered +
1055  process.hltEcalRecHitCPUOnly
1056  )
1057 
1058  for prod in producers_by_type(process, 'HLTRechitsToDigis'):
1059  prod.srFlagsIn = 'hltEcalDigisLegacy'
1060 
1061  for prod in producers_by_type(process, 'CorrectedECALPFClusterProducer'):
1062  try:
1063  prod.energyCorrector.ebSrFlagLabel = 'hltEcalDigisLegacy'
1064  prod.energyCorrector.eeSrFlagLabel = 'hltEcalDigisLegacy'
1065  except:
1066  pass
1067 
1068  for pathNameMatch in ['DQM_EcalReconstruction_v', 'DQM_HIEcalReconstruction_v']:
1069  dqmEcalRecoPathName = None
1070  for pathName in process.paths_():
1071  if pathName.startswith(pathNameMatch):
1072  dqmEcalRecoPath = getattr(process, pathName)
1073  dqmEcalRecoPath.insert(dqmEcalRecoPath.index(process.HLTEndSequence), getattr(process, 'HLTDoFullUnpackingEgammaEcalWithoutPreshowerCPUOnlySequence'))
1074  for delmod in ['hltEcalConsumerCPU', 'hltEcalConsumerGPU']:
1075  if hasattr(process, delmod):
1076  process.__delattr__(delmod)
1077 
1078  for hltOutModMatch in ['hltOutputDQMGPUvsCPU', 'hltOutputHIDQMGPUvsCPU']:
1079  if hasattr(process, hltOutModMatch):
1080  outMod = getattr(process, hltOutModMatch)
1081  outCmds_new = [foo for foo in outMod.outputCommands if 'Ecal' not in foo]
1082  outCmds_new += [
1083  'keep *_hltEcalDigis_*_*',
1084  'keep *_hltEcalDigisCPUSerial_*_*',
1085  'keep *_hltEcalUncalibRecHit_*_*',
1086  'keep *_hltEcalUncalibRecHitCPUSerial_*_*',
1087  ]
1088  outMod.outputCommands = outCmds_new[:]
1089 
1090  return process
1091 
1092 
1094 
1095  if not hasattr(process, 'statusOnGPU'):
1096  return process
1097 
1098  process.hltBackend = cms.EDProducer('AlpakaBackendProducer@alpaka')
1099 
1100  insert_modules_before(process, process.statusOnGPU, process.hltBackend)
1101 
1102  del process.statusOnGPU
1103 
1104  process.hltStatusOnGPUFilter = cms.EDFilter('AlpakaBackendFilter',
1105  producer = cms.InputTag('hltBackend', 'backend'),
1106  backends = cms.vstring('CudaAsync', 'ROCmAsync')
1107  )
1108 
1109  insert_modules_before(process, process.statusOnGPUFilter, process.hltStatusOnGPUFilter)
1110  insert_modules_before(process, ~process.statusOnGPUFilter, ~process.hltStatusOnGPUFilter)
1111 
1112  del process.statusOnGPUFilter
1113 
1114  return process
1115 
1116 
1117 def _replace_object(process, target, obj):
1118  for container in itertools.chain(
1119  process.sequences_().values(),
1120  process.paths_().values(),
1121  process.endpaths_().values()
1122  ):
1123  if target.label() in [bar for foo,bar in container.directDependencies()]:
1124  try:
1125  position = container.index(target)
1126  container.insert(position, obj)
1127  container.remove(target)
1128  except ValueError:
1129  container.associate(obj)
1130  container.remove(target)
1131 
1132  for container in itertools.chain(
1133  process.tasks_().values(),
1134  process.conditionaltasks_().values(),
1135  ):
1136  if target.label() in [bar for foo,bar in container.directDependencies()]:
1137  container.add(obj)
1138  container.remove(target)
1139 
1140  return process
1141 
1142 def _rename_edmodule(process, oldModuleLabel, newModuleLabel, typeBlackList):
1143  if not hasattr(process, oldModuleLabel) or hasattr(process, newModuleLabel) or oldModuleLabel == newModuleLabel:
1144  return process
1145  oldObj = getattr(process, oldModuleLabel)
1146  if oldObj.type_() in typeBlackList:
1147  return process
1148  setattr(process, newModuleLabel, oldObj.clone())
1149  newObj = getattr(process, newModuleLabel)
1150  process = _replace_object(process, oldObj, newObj)
1151  process.__delattr__(oldModuleLabel)
1152  process = massReplaceInputTag(process, oldModuleLabel, newModuleLabel, False, True, False)
1153  for outputModuleLabel in process.outputModules_():
1154  outputModule = getattr(process, outputModuleLabel)
1155  if not hasattr(outputModule, 'outputCommands'):
1156  continue
1157  for outputCmdIdx, outputCmd in enumerate(outputModule.outputCommands):
1158  outputModule.outputCommands[outputCmdIdx] = outputCmd.replace(f'_{oldModuleLabel}_', f'_{newModuleLabel}_')
1159  return process
1160 
1161 def _rename_edmodules(process, matchExpr, oldStr, newStr, typeBlackList):
1162  for moduleDict in [process.producers_(), process.filters_(), process.analyzers_()]:
1163  moduleLabels = list(moduleDict.keys())
1164  for moduleLabel in moduleLabels:
1165  if bool(re.match(matchExpr, moduleLabel)):
1166  moduleLabelNew = moduleLabel.replace(oldStr, '') + newStr
1167  process = _rename_edmodule(process, moduleLabel, moduleLabelNew, typeBlackList)
1168  return process
1169 
1170 def _rename_container(process, oldContainerLabel, newContainerLabel):
1171  if not hasattr(process, oldContainerLabel) or hasattr(process, newContainerLabel) or oldContainerLabel == newContainerLabel:
1172  return process
1173  oldObj = getattr(process, oldContainerLabel)
1174  setattr(process, newContainerLabel, oldObj.copy())
1175  newObj = getattr(process, newContainerLabel)
1176  process = _replace_object(process, oldObj, newObj)
1177  process.__delattr__(oldContainerLabel)
1178  return process
1179 
1180 def _rename_containers(process, matchExpr, oldStr, newStr):
1181  for containerName in itertools.chain(
1182  process.sequences_().keys(),
1183  process.tasks_().keys(),
1184  process.conditionaltasks_().keys()
1185  ):
1186  if bool(re.match(matchExpr, containerName)):
1187  containerNameNew = containerName.replace(oldStr, '') + newStr
1188  process = _rename_container(process, containerName, containerNameNew)
1189  return process
1190 
1192  # mass renaming of EDModules and Sequences:
1193  # if the label matches matchRegex, remove oldStr and append newStr
1194  for matchRegex, oldStr, newStr in [
1195  [".*Portable.*", "Portable", ""],
1196  [".*SerialSync.*", "SerialSync", "SerialSync"],
1197  [".*CPUSerial.*", "CPUSerial", "SerialSync"],
1198  [".*CPUOnly.*", "CPUOnly", "SerialSync"],
1199  ]:
1200  process = _rename_edmodules(process, matchRegex, oldStr, newStr, ['HLTPrescaler'])
1201  process = _rename_containers(process, matchRegex, oldStr, newStr)
1202 
1203  return process
1204 
1205 
1207  process.load('Configuration.StandardSequences.Accelerators_cff')
1208 
1209  process = customizeHLTforAlpakaStatus(process)
1210  process = customizeHLTforAlpakaPixelReco(process)
1211  process = customizeHLTforAlpakaEcalLocalReco(process)
1213  process = customizeHLTforAlpakaRename(process)
1214 
1215  return process
def customizeHLTforDQMGPUvsCPUPixel(process)
Pixel HLT in Alpaka.
def producers_by_type(process, types)
def customizeHLTforAlpakaPixelRecoVertexing(process)
def makeSerialClone(module, kwargs)
Definition: functions.py:1
def _rename_containers(process, matchExpr, oldStr, newStr)
def _replace_object(process, target, obj)
def insert_modules_before(process, target, modules)
Definition: common.py:34
def customizeHLTforAlpakaPixelRecoTracking(process)
def customizeHLTforAlpakaStatus(process)
def customizeHLTforAlpakaPixelRecoLocal(process)
def massReplaceInputTag(process, old="rawDataCollector", new="rawDataRepacker", verbose=False, moduleLabelOnly=False, skipLabelTest=False)
Definition: MassReplace.py:83
def customizeHLTforAlpakaPixelReco(process)
def customizeHLTforAlpakaEcalLocalReco(process)
ECAL HLT in Alpaka.
def customizeHLTforAlpakaRename(process)
def _rename_edmodules(process, matchExpr, oldStr, newStr, typeBlackList)
def customizeHLTforAlpakaParticleFlowClustering(process)
PF HLT in Alpaka.
def _rename_edmodule(process, oldModuleLabel, newModuleLabel, typeBlackList)
def _rename_container(process, oldContainerLabel, newContainerLabel)