From 436e9220fa15db7302274aa581ccccec6382576c Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 13 Apr 2021 19:31:11 +0200 Subject: [PATCH 01/11] Remove an unused modifier from the test files --- .../EcalRecProducers/test/testEcalRechitProducer_cfg.py | 1 - .../EcalRecProducers/test/testEcalUncalibRechitProducer_cfg.py | 1 - .../HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py | 1 - 3 files changed, 3 deletions(-) diff --git a/RecoLocalCalo/EcalRecProducers/test/testEcalRechitProducer_cfg.py b/RecoLocalCalo/EcalRecProducers/test/testEcalRechitProducer_cfg.py index c70572ff3b89d..a9e3d5c1af7b3 100644 --- a/RecoLocalCalo/EcalRecProducers/test/testEcalRechitProducer_cfg.py +++ b/RecoLocalCalo/EcalRecProducers/test/testEcalRechitProducer_cfg.py @@ -1,7 +1,6 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -#from Configuration.ProcessModifiers.gpu_cff import gpu process = cms.Process('RECO', eras.Run2_2018) diff --git a/RecoLocalCalo/EcalRecProducers/test/testEcalUncalibRechitProducer_cfg.py b/RecoLocalCalo/EcalRecProducers/test/testEcalUncalibRechitProducer_cfg.py index ffb665d7bc96a..5684e30e330b8 100644 --- a/RecoLocalCalo/EcalRecProducers/test/testEcalUncalibRechitProducer_cfg.py +++ b/RecoLocalCalo/EcalRecProducers/test/testEcalUncalibRechitProducer_cfg.py @@ -1,7 +1,6 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -#from Configuration.ProcessModifiers.gpu_cff import gpu process = cms.Process('RECO', eras.Run2_2018) diff --git a/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py b/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py index 32d4104a842ef..8c7162bc076c4 100644 --- a/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py +++ b/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py @@ -1,7 +1,6 @@ import FWCore.ParameterSet.Config as cms from Configuration.StandardSequences.Eras import eras -#from Configuration.ProcessModifiers.gpu_cff import gpu process = cms.Process('RECOgpu', eras.Run2_2018) From 32ea55258e3a79426f87c207f7a514b466ff09ca Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 13 Apr 2021 23:24:26 +0200 Subject: [PATCH 02/11] Simplify the definition of the "Patatrack" workflows --- .../python/upgradeWorkflowComponents.py | 322 ++++++------------ 1 file changed, 113 insertions(+), 209 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 8b7ccd217e6c2..ff88d3b0c0546 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -1,4 +1,4 @@ -from copy import deepcopy +from copy import copy, deepcopy from collections import OrderedDict import six from .MatrixUtil import merge, Kby @@ -392,246 +392,150 @@ def condition(self, fragment, stepList, key, hasHarvest): '--procModifiers': 'mlpf' } -# Patatrack workflows -class UpgradeWorkflowPatatrack(UpgradeWorkflow): +# Patatrack workflows: +# - 2018 conditions, TTbar +# - 2018 conditions, Z->mumu, +# - 2021 conditions, TTbar +# - 2021 conditions, Z->mumu, +class PatatrackWorkflow(UpgradeWorkflow): + def __init__(self, reco, harvest, **kwargs): + # adapt the parameters for the UpgradeWorkflow init method + super(PatatrackWorkflow, self).__init__( + steps = [ + 'Reco', + 'HARVEST', + 'RecoFakeHLT', + 'HARVESTFakeHLT', + 'RecoGlobal', + 'HARVESTGlobal', + ], + PU = [], + **kwargs) + self.__reco = reco + self.__reco.update({ + '--datatier': 'GEN-SIM-RECO,DQMIO', + '--eventcontent': 'RECOSIM,DQM' + }) + self.__harvest = harvest + def condition(self, fragment, stepList, key, hasHarvest): - is_2018_ttbar = ('2018' in key and fragment=="TTbar_13") - is_2021_ttbar = ('2021' in key and fragment=="TTbar_14TeV") - is_2018_zmumu = ('2018' in key and fragment=="ZMM_13") - is_2021_zmumu = ('2021' in key and fragment=="ZMM_14") - result = any((is_2018_ttbar, is_2021_ttbar, is_2018_zmumu, is_2021_zmumu)) and hasHarvest and self.condition_(fragment, stepList, key, hasHarvest) - if result: - # skip ALCA and Nano - skipList = [s for s in stepList if (("ALCA" in s) or ("Nano" in s))] - for skip in skipList: + # select only a subset of the workflows + selected = [ + ('2018' in key and fragment == "TTbar_13"), + ('2021' in key and fragment == "TTbar_14TeV"), + ('2018' in key and fragment == "ZMM_13"), + ('2021' in key and fragment == "ZMM_14"), + ] + result = any(selected) and hasHarvest + + # skip ALCA and Nano steps + for skip in copy(stepList): + if ("ALCA" in skip) or ("Nano" in skip): stepList.remove(skip) return result - def condition_(self, fragment, stepList, key, hasHarvest): - return True -class UpgradeWorkflowPatatrack_PixelOnlyCPU(UpgradeWorkflowPatatrack): def setup_(self, step, stepName, stepDict, k, properties): if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) + stepDict[stepName][k] = merge([self.__reco, stepDict[step][k]]) elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM'}, stepDict[step][k]]) + stepDict[stepName][k] = merge([self.__harvest, stepDict[step][k]]) - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key -upgradeWFs['PatatrackPixelOnlyCPU'] = UpgradeWorkflowPatatrack_PixelOnlyCPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackPixelOnlyCPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', + '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU' + }, + harvest = { + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + }, suffix = 'Patatrack_PixelOnlyCPU', offset = 0.501, ) -upgradeWFs['PatatrackPixelOnlyCPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU' -} - -upgradeWFs['PatatrackPixelOnlyTripletsCPU'] = UpgradeWorkflowPatatrack_PixelOnlyCPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], - suffix = 'Patatrack_PixelOnlyTripletsCPU', - offset = 0.505, -) - -upgradeWFs['PatatrackPixelOnlyTripletsCPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU,RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' -} - -class UpgradeWorkflowPatatrack_PixelOnlyGPU(UpgradeWorkflowPatatrack): - def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) - elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM'}, stepDict[step][k]]) - - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key - -upgradeWFs['PatatrackPixelOnlyGPU'] = UpgradeWorkflowPatatrack_PixelOnlyGPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackPixelOnlyGPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', + '--procModifiers': 'gpu' + }, + harvest = { + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + }, suffix = 'Patatrack_PixelOnlyGPU', offset = 0.502, ) -upgradeWFs['PatatrackPixelOnlyGPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--procModifiers': 'gpu' -} +upgradeWFs['PatatrackPixelOnlyTripletsCPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', + '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU,RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' + }, + harvest = { + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + }, + suffix = 'Patatrack_PixelOnlyTripletsCPU', + offset = 0.505, +) -upgradeWFs['PatatrackPixelOnlyTripletsGPU'] = UpgradeWorkflowPatatrack_PixelOnlyGPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackPixelOnlyTripletsGPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', + '--procModifiers': 'gpu', + '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' + }, + harvest = { + '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' + }, suffix = 'Patatrack_PixelOnlyTripletsGPU', offset = 0.506, ) -upgradeWFs['PatatrackPixelOnlyTripletsGPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--procModifiers': 'gpu', - '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' -} - -class UpgradeWorkflowPatatrack_ECALOnlyCPU(UpgradeWorkflowPatatrack): - def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) - elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@ecalOnlyValidation+@ecal'}, stepDict[step][k]]) - - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key - -upgradeWFs['PatatrackECALOnlyCPU'] = UpgradeWorkflowPatatrack_ECALOnlyCPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackECALOnlyCPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,VALIDATION:@ecalOnlyValidation,DQM:@ecalOnly', + }, + harvest = { + '-s': 'HARVESTING:@ecalOnlyValidation+@ecal' + }, suffix = 'Patatrack_ECALOnlyCPU', offset = 0.511, ) -upgradeWFs['PatatrackECALOnlyCPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,VALIDATION:@ecalOnlyValidation,DQM:@ecalOnly', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', -} - -class UpgradeWorkflowPatatrack_ECALOnlyGPU(UpgradeWorkflowPatatrack): - def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) - elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@ecalOnlyValidation+@ecal'}, stepDict[step][k]]) - - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key - -upgradeWFs['PatatrackECALOnlyGPU'] = UpgradeWorkflowPatatrack_ECALOnlyGPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackECALOnlyGPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,VALIDATION:@ecalOnlyValidation,DQM:@ecalOnly', + '--procModifiers': 'gpu' + }, + harvest = { + '-s': 'HARVESTING:@ecalOnlyValidation+@ecal' + }, suffix = 'Patatrack_ECALOnlyGPU', offset = 0.512, ) -upgradeWFs['PatatrackECALOnlyGPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,VALIDATION:@ecalOnlyValidation,DQM:@ecalOnly', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--procModifiers': 'gpu' -} - -class UpgradeWorkflowPatatrack_HCALOnlyCPU(UpgradeWorkflowPatatrack): - def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) - elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@hcalOnlyValidation+@hcalOnly+@hcal2Only'}, stepDict[step][k]]) - - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key - -upgradeWFs['PatatrackHCALOnlyCPU'] = UpgradeWorkflowPatatrack_HCALOnlyCPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackHCALOnlyCPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_hcalOnly,RECO:reconstruction_hcalOnly,VALIDATION:@hcalOnlyValidation,DQM:@hcalOnly+@hcal2Only', + }, + harvest = { + '-s': 'HARVESTING:@hcalOnlyValidation+@hcalOnly+@hcal2Only' + }, suffix = 'Patatrack_HCALOnlyCPU', offset = 0.521, ) -upgradeWFs['PatatrackHCALOnlyCPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_hcalOnly,RECO:reconstruction_hcalOnly,VALIDATION:@hcalOnlyValidation,DQM:@hcalOnly+@hcal2Only', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', -} - -class UpgradeWorkflowPatatrack_HCALOnlyGPU(UpgradeWorkflowPatatrack): - def setup_(self, step, stepName, stepDict, k, properties): - if 'Reco' in step: - stepDict[stepName][k] = merge([self.step3, stepDict[step][k]]) - elif 'HARVEST' in step: - stepDict[stepName][k] = merge([{'-s': 'HARVESTING:@hcalOnlyValidation+@hcalOnly+@hcal2Only'}, stepDict[step][k]]) - - def condition_(self, fragment, stepList, key, hasHarvest): - return '2018' in key or '2021' in key - -upgradeWFs['PatatrackHCALOnlyGPU'] = UpgradeWorkflowPatatrack_HCALOnlyGPU( - steps = [ - 'Reco', - 'HARVEST', - 'RecoFakeHLT', - 'HARVESTFakeHLT', - 'RecoGlobal', - 'HARVESTGlobal', - ], - PU = [], +upgradeWFs['PatatrackHCALOnlyGPU'] = PatatrackWorkflow( + reco = { + '-s': 'RAW2DIGI:RawToDigi_hcalOnly,RECO:reconstruction_hcalOnly,VALIDATION:@hcalOnlyValidation,DQM:@hcalOnly+@hcal2Only', + '--procModifiers': 'gpu' + }, + harvest = { + '-s': 'HARVESTING:@hcalOnlyValidation+@hcalOnly+@hcal2Only' + }, suffix = 'Patatrack_HCALOnlyGPU', offset = 0.522, ) -upgradeWFs['PatatrackHCALOnlyGPU'].step3 = { - '-s': 'RAW2DIGI:RawToDigi_hcalOnly,RECO:reconstruction_hcalOnly,VALIDATION:@hcalOnlyValidation,DQM:@hcalOnly+@hcal2Only', - '--datatier': 'GEN-SIM-RECO,DQMIO', - '--eventcontent': 'RECOSIM,DQM', - '--procModifiers': 'gpu' -} - # end of Patatrack workflows class UpgradeWorkflow_ProdLike(UpgradeWorkflow): @@ -1398,14 +1302,14 @@ def __init__(self, howMuch, dataset): ('FlatRandomPtAndDxyGunProducer_MuPt2To10_cfi', UpgradeFragment(Kby(9,100),'DisplacedMuPt2To10')), ('FlatRandomPtAndDxyGunProducer_MuPt10To30_cfi', UpgradeFragment(Kby(9,100),'DisplacedMuPt10To30')), ('FlatRandomPtAndDxyGunProducer_MuPt30To100_cfi', UpgradeFragment(Kby(9,100),'DisplacedMuPt30To100')), - ('B0ToKstarMuMu_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(304,3030),'B0ToKstarMuMu_14TeV')), # 3.3% - ('BsToEleEle_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(223,2222),'BsToEleEle_14TeV')), # 4.5% - ('BsToJpsiGamma_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(2500,25000),'BsToJpsiGamma_14TeV')), # 0.4% + ('B0ToKstarMuMu_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(304,3030),'B0ToKstarMuMu_14TeV')), # 3.3% + ('BsToEleEle_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(223,2222),'BsToEleEle_14TeV')), # 4.5% + ('BsToJpsiGamma_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(2500,25000),'BsToJpsiGamma_14TeV')), # 0.4% ('BsToJpsiPhi_mumuKK_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(910,9090),'BsToJpsiPhi_mumuKK_14TeV')), # 1.1% - ('BsToMuMu_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(313,3125),'BsToMuMu_14TeV')), # 3.2% - ('BsToPhiPhi_KKKK_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(556,5555),'BsToPhiPhi_KKKK_14TeV')), # 1.8% + ('BsToMuMu_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(313,3125),'BsToMuMu_14TeV')), # 3.2% + ('BsToPhiPhi_KKKK_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(556,5555),'BsToPhiPhi_KKKK_14TeV')), # 1.8% ('TauToMuMuMu_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(18939,189393),'TauToMuMuMu_14TeV')), # effi = 5.280e-04 - ('BdToKstarEleEle_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(206,2061),'BdToKstarEleEle_14TeV')), #effi = 4.850e-02 + ('BdToKstarEleEle_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(206,2061),'BdToKstarEleEle_14TeV')), #effi = 4.850e-02 ('ZpTT_1500_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(9,50),'ZpTT_1500_14')), ('BuMixing_BMuonFilter_forSTEAM_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(900,10000),'BuMixing_14')), ('Upsilon1SToMuMu_forSTEAM_14TeV_TuneCP5_cfi', UpgradeFragment(Kby(9,50),'Upsilon1SToMuMu_14')), From db8f341b070fa55b67b37f897d701a481b5b27a5 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 13 Apr 2021 23:42:40 +0200 Subject: [PATCH 03/11] Make the Pixel 'gpu' workflow use a GPU if available, and fall-back to CPU otherwise --- .../python/RecoPixelVertexing_cff.py | 21 +++++++----- .../python/PixelTracks_cff.py | 34 ++++++++++++------- .../python/PixelVertexes_cff.py | 7 ++-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py b/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py index 424ac13a43627..4b32839e21b0e 100644 --- a/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py +++ b/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py @@ -6,19 +6,24 @@ # from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cff import * #from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import * -recopixelvertexingTask = cms.Task(pixelTracksTask,pixelVertices) -recopixelvertexing = cms.Sequence(recopixelvertexingTask) +recopixelvertexingTask = cms.Task(pixelTracksTask, pixelVertices) from Configuration.ProcessModifiers.gpu_cff import gpu +_recopixelvertexingTask_gpu = recopixelvertexingTask.copy() from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA +_recopixelvertexingTask_gpu.add(pixelVertexCUDA) + from RecoPixelVertexing.PixelVertexFinding.pixelVertexSoA_cfi import pixelVertexSoA -from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA +_recopixelvertexingTask_gpu.add(pixelVertexSoA) -_pixelVertexingCUDATask = cms.Task(pixelTracksTask,pixelVertexCUDA,pixelVertexSoA,pixelVertices) +from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA +# this is needed because the 'pixelTrack' EDAlias does not contain the 'ushorts' collections +_pixelVertexFromSoA.TrackCollection = 'pixelTrackFromSoA' +gpu.toModify(pixelVertices, + cuda = _pixelVertexFromSoA +) -# pixelVertexSoAonCPU = pixelVertexCUDA.clone() -# pixelVertexSoAonCPU.onGPU = False; +gpu.toReplaceWith(recopixelvertexingTask, _recopixelvertexingTask_gpu) -gpu.toReplaceWith(pixelVertices,_pixelVertexFromSoA) -gpu.toReplaceWith(recopixelvertexingTask,_pixelVertexingCUDATask) +recopixelvertexing = cms.Sequence(recopixelvertexingTask) diff --git a/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py b/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py index 5ff404cb603d4..244e68faba8b6 100644 --- a/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py +++ b/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py @@ -1,4 +1,5 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA from RecoLocalTracker.SiStripRecHitConverter.StripCPEfromTrackAngle_cfi import * from RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitMatcher_cfi import * @@ -59,10 +60,12 @@ ) ) -pixelTracks = _pixelTracks.clone( - SeedingHitSets = "pixelTracksHitQuadruplets" +pixelTracks = SwitchProducerCUDA( + cpu = _pixelTracks.clone( + SeedingHitSets = "pixelTracksHitQuadruplets" + ) ) -trackingLowPU.toModify(pixelTracks, SeedingHitSets = "pixelTracksHitTriplets") +trackingLowPU.toModify(pixelTracks.cpu, SeedingHitSets = "pixelTracksHitTriplets") pixelTracksTask = cms.Task( pixelTracksTrackingRegions, @@ -79,7 +82,7 @@ # Use ntuple fit and substitute previous Fitter producer with the ntuple one from Configuration.ProcessModifiers.pixelNtupleFit_cff import pixelNtupleFit as ntupleFit -ntupleFit.toModify(pixelTracks, Fitter = "pixelNtupletsFitter") +ntupleFit.toModify(pixelTracks.cpu, Fitter = "pixelNtupletsFitter") _pixelTracksTask_ntupleFit = pixelTracksTask.copy() _pixelTracksTask_ntupleFit.replace(pixelFitterByHelixProjections, pixelNtupletsFitter) ntupleFit.toReplaceWith(pixelTracksTask, _pixelTracksTask_ntupleFit) @@ -88,15 +91,20 @@ from Configuration.ProcessModifiers.gpu_cff import gpu from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA from RecoPixelVertexing.PixelTrackFitting.pixelTrackSoA_cfi import pixelTrackSoA -from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as _pixelTrackFromSoA -_pixelTracksGPUTask = cms.Task( - caHitNtupletCUDA, - pixelTrackSoA, - pixelTracks # FromSoA +from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as pixelTrackFromSoA +_pixelTracksTask_gpu = pixelTracksTask.copy() +_pixelTracksTask_gpu.add(caHitNtupletCUDA, pixelTrackSoA, pixelTrackFromSoA) +# this is needed (instead of simply using pixelTracks.cuda = pixelTrackFromSoA.clone()) because +# the PixelTrackProducerFromSoA produces an additional 'ushorts' collection +gpu.toModify(pixelTracks, + cuda = cms.EDAlias( + pixelTrackFromSoA = cms.VPSet( + cms.PSet(type = cms.string("recoTracks")), + cms.PSet(type = cms.string("recoTrackExtras")), + cms.PSet(type = cms.string("TrackingRecHitsOwned")) + ) + ) ) - -gpu.toReplaceWith(pixelTracksTask, _pixelTracksGPUTask) -gpu.toReplaceWith(pixelTracks,_pixelTrackFromSoA) - +gpu.toReplaceWith(pixelTracksTask, _pixelTracksTask_gpu) pixelTracksSequence = cms.Sequence(pixelTracksTask) diff --git a/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py b/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py index 6f74899c00f03..a33d5c14af751 100644 --- a/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py +++ b/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py @@ -1,4 +1,7 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA -from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import * - +from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import pvClusterComparer, pixelVertices as _pixelVertices +pixelVertices = SwitchProducerCUDA( + cpu = _pixelVertices.clone() +) From 9e5d3abf4c8b094ea4a1e05fe594f00db5c518d5 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 15 Apr 2021 14:28:56 +0200 Subject: [PATCH 04/11] Remove obsolete configuration file --- .../ecalMultiFitUncalibRecHit_gpu_new_cfi.py | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_gpu_new_cfi.py diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_gpu_new_cfi.py b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_gpu_new_cfi.py deleted file mode 100644 index 84a0c6f9cbe8a..0000000000000 --- a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_gpu_new_cfi.py +++ /dev/null @@ -1,83 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from RecoLocalCalo.EcalRecProducers.ecalPulseShapeParameters_cff import * - -ecalMultiFitUncalibRecHitgpu = cms.EDProducer("EcalUncalibRecHitProducerGPUNew", - EBdigiCollection = cms.InputTag("ecalDigis","ebDigis"), - EEdigiCollection = cms.InputTag("ecalDigis","eeDigis"), - EBhitCollection = cms.string("EcalUncalibRecHitsEBgpunew"), - EBhitCollection_soa = cms.string("EcalUncalibRecHitsEBgpunew"), - EEhitCollection = cms.string('EcalUncalibRecHitsEEgpunew'), - EEhitCollection_soa = cms.string('EcalUncalibRecHitsEEgpunew'), - algo = cms.string("EcalUncalibRecHitWorkerMultiFitGPUNew"), - algoPSet = cms.PSet( - # for multifit method - EcalPulseShapeParameters = cms.PSet( ecal_pulse_shape_parameters ), - activeBXs = cms.vint32(-5,-4,-3,-2,-1,0,1,2,3,4), - ampErrorCalculation = cms.bool(True), - useLumiInfoRunHeader = cms.bool(True), - - doPrefitEB = cms.bool(False), - doPrefitEE = cms.bool(False), - prefitMaxChiSqEB = cms.double(25.), - prefitMaxChiSqEE = cms.double(10.), - - dynamicPedestalsEB = cms.bool(False), - dynamicPedestalsEE = cms.bool(False), - mitigateBadSamplesEB = cms.bool(False), - mitigateBadSamplesEE = cms.bool(False), - gainSwitchUseMaxSampleEB = cms.bool(True), - gainSwitchUseMaxSampleEE = cms.bool(False), - selectiveBadSampleCriteriaEB = cms.bool(False), - selectiveBadSampleCriteriaEE = cms.bool(False), - simplifiedNoiseModelForGainSwitch = cms.bool(True), - addPedestalUncertaintyEB = cms.double(0.), - addPedestalUncertaintyEE = cms.double(0.), - - # decide which algorithm to be use to calculate the jitter - timealgo = cms.string("RatioMethod"), - - # for ratio method - EBtimeFitParameters = cms.vdouble(-2.015452e+00, 3.130702e+00, -1.234730e+01, 4.188921e+01, -8.283944e+01, 9.101147e+01, -5.035761e+01, 1.105621e+01), - EEtimeFitParameters = cms.vdouble(-2.390548e+00, 3.553628e+00, -1.762341e+01, 6.767538e+01, -1.332130e+02, 1.407432e+02, -7.541106e+01, 1.620277e+01), - EBamplitudeFitParameters = cms.vdouble(1.138,1.652), - EEamplitudeFitParameters = cms.vdouble(1.890,1.400), - EBtimeFitLimits_Lower = cms.double(0.2), - EBtimeFitLimits_Upper = cms.double(1.4), - EEtimeFitLimits_Lower = cms.double(0.2), - EEtimeFitLimits_Upper = cms.double(1.4), - # for time error - EBtimeConstantTerm= cms.double(.6), - EEtimeConstantTerm= cms.double(1.0), - - # for kOutOfTime flag - EBtimeNconst = cms.double(28.5), - EEtimeNconst = cms.double(31.8), - outOfTimeThresholdGain12pEB = cms.double(5), # times estimated precision - outOfTimeThresholdGain12mEB = cms.double(5), # times estimated precision - outOfTimeThresholdGain61pEB = cms.double(5), # times estimated precision - outOfTimeThresholdGain61mEB = cms.double(5), # times estimated precision - outOfTimeThresholdGain12pEE = cms.double(1000), # times estimated precision - outOfTimeThresholdGain12mEE = cms.double(1000), # times estimated precision - outOfTimeThresholdGain61pEE = cms.double(1000), # times estimated precision - outOfTimeThresholdGain61mEE = cms.double(1000), # times estimated precision - amplitudeThresholdEB = cms.double(10), - amplitudeThresholdEE = cms.double(10), - - ebSpikeThreshold = cms.double(1.042), - - # these are now taken from DB. Here the MC parameters for backward compatibility - ebPulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - eePulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - - # for kPoorReco flag - kPoorRecoFlagEB = cms.bool(True), - kPoorRecoFlagEE = cms.bool(False), - chi2ThreshEB_ = cms.double(65.0), - chi2ThreshEE_ = cms.double(50.0), - - # threads/blocks config - threads = cms.vint32(256, 1, 1), - runV1 = cms.bool(True), - ) -) From 887df186c434178ce41e036239c8f764dea8722a Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Fri, 16 Apr 2021 00:42:56 +0200 Subject: [PATCH 05/11] Make the ECAL 'gpu' workflow use a GPU if available, and fall-back to CPU otherwise EcalRawToDigi: do not declare to produce the collections that will not be put in the event. EcalCPUDigisProducer: add more dummy collections. --- .../python/RawToDigi_Repacked_cff.py | 22 ++++- .../StandardSequences/python/RawToDigi_cff.py | 2 +- .../python/SimL1EmulatorRepack_GCTGT_cff.py | 2 +- .../plugins/EcalCPUDigisProducer.cc | 82 +++++++++++-------- .../EcalRawToDigi/plugins/EcalRawToDigi.cc | 71 +++++++++------- .../EcalRawToDigi/python/ecalDigis_cff.py | 45 +++++++--- .../ecalLocalRecoSequenceCosmics_cff.py | 23 ++++-- .../python/ecalLocalRecoSequence_cff.py | 60 +------------- .../python/ecalLocalCustom.py | 13 ++- .../python/ecalMultiFitUncalibRecHit_cff.py | 24 ++++-- .../EcalRecProducers/python/ecalRecHit_cff.py | 67 +++++++++++++++ Validation/Configuration/python/ECALHCAL.py | 16 ++-- 12 files changed, 260 insertions(+), 167 deletions(-) create mode 100644 RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py diff --git a/Configuration/StandardSequences/python/RawToDigi_Repacked_cff.py b/Configuration/StandardSequences/python/RawToDigi_Repacked_cff.py index 1e6cf30d8c917..3d64a8c1c4912 100644 --- a/Configuration/StandardSequences/python/RawToDigi_Repacked_cff.py +++ b/Configuration/StandardSequences/python/RawToDigi_Repacked_cff.py @@ -8,9 +8,9 @@ gctDigis.inputLabel = 'rawDataRepacker' gtDigis.DaqGtInputTag = 'rawDataRepacker' gtEvmDigis.EvmGtInputTag = 'rawDataRepacker' -siPixelDigis.InputLabel = 'rawDataRepacker' +siPixelDigis.cpu.InputLabel = 'rawDataRepacker' siStripDigis.ProductLabel = 'rawDataRepacker' -ecalDigis.InputLabel = 'rawDataRepacker' +ecalDigis.cpu.InputLabel = 'rawDataRepacker' ecalPreshowerDigis.sourceTag = 'rawDataRepacker' hcalDigis.InputLabel = 'rawDataRepacker' muonCSCDigis.InputObjects = 'rawDataRepacker' @@ -18,7 +18,23 @@ muonRPCDigis.InputLabel = 'rawDataRepacker' castorDigis.InputLabel = 'rawDataRepacker' -RawToDigiTask = cms.Task(csctfDigis,dttfDigis,gctDigis,gtDigis,gtEvmDigis,siPixelDigis,siStripDigis,ecalDigis,ecalPreshowerDigis,hcalDigis,muonCSCDigis,muonDTDigis,muonRPCDigis,castorDigis,scalersRawToDigi) +RawToDigiTask = cms.Task( + csctfDigis, + dttfDigis, + gctDigis, + gtDigis, + gtEvmDigis, + siPixelDigis, + siStripDigis, + ecalDigis, + ecalPreshowerDigis, + hcalDigis, + muonCSCDigis, + muonDTDigis, + muonRPCDigis, + castorDigis, + scalersRawToDigi) + RawToDigi = cms.Sequence(RawToDigiTask) RawToDigiTask_woGCT = RawToDigiTask.copyAndExclude([gctDigis]) diff --git a/Configuration/StandardSequences/python/RawToDigi_cff.py b/Configuration/StandardSequences/python/RawToDigi_cff.py index 42fa09bd30c62..60ed421a6205f 100644 --- a/Configuration/StandardSequences/python/RawToDigi_cff.py +++ b/Configuration/StandardSequences/python/RawToDigi_cff.py @@ -75,7 +75,7 @@ scalersRawToDigi.scalersInputTag = 'rawDataCollector' siPixelDigis.cpu.InputLabel = 'rawDataCollector' -(~gpu).toModify(ecalDigis, InputLabel='rawDataCollector') +ecalDigis.cpu.InputLabel = 'rawDataCollector' ecalPreshowerDigis.sourceTag = 'rawDataCollector' hcalDigis.InputLabel = 'rawDataCollector' muonCSCDigis.InputObjects = 'rawDataCollector' diff --git a/Configuration/StandardSequences/python/SimL1EmulatorRepack_GCTGT_cff.py b/Configuration/StandardSequences/python/SimL1EmulatorRepack_GCTGT_cff.py index 834b4249888f3..dbcc43f08352c 100644 --- a/Configuration/StandardSequences/python/SimL1EmulatorRepack_GCTGT_cff.py +++ b/Configuration/StandardSequences/python/SimL1EmulatorRepack_GCTGT_cff.py @@ -27,7 +27,7 @@ ## from L1Trigger.L1TCalorimeter.L1TCaloStage1_PPFromRaw_cff import * -ecalDigis.InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()) +ecalDigis.cpu.InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()) hcalDigis.InputLabel = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()) simHcalTriggerPrimitiveDigis.InputTagFEDRaw = cms.InputTag( 'rawDataCollector', processName=cms.InputTag.skipCurrentProcess()) diff --git a/EventFilter/EcalRawToDigi/plugins/EcalCPUDigisProducer.cc b/EventFilter/EcalRawToDigi/plugins/EcalCPUDigisProducer.cc index 97f9828e9f5ec..d9a8b35ebb89e 100644 --- a/EventFilter/EcalRawToDigi/plugins/EcalCPUDigisProducer.cc +++ b/EventFilter/EcalRawToDigi/plugins/EcalCPUDigisProducer.cc @@ -1,4 +1,5 @@ #include +#include #include "CUDADataFormats/EcalDigi/interface/DigisCollection.h" #include "CondFormats/DataRecord/interface/EcalMappingElectronicsRcd.h" @@ -23,13 +24,19 @@ class EcalCPUDigisProducer : public edm::stream::EDProducer { public: explicit EcalCPUDigisProducer(edm::ParameterSet const& ps); - ~EcalCPUDigisProducer() override; + ~EcalCPUDigisProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions&); private: void acquire(edm::Event const&, edm::EventSetup const&, edm::WaitingTaskWithArenaHolder) override; void produce(edm::Event&, edm::EventSetup const&) override; + template + edm::EDPutTokenT dummyProduces(ARGS&&... args) { + return (produceDummyIntegrityCollections_) ? produces(std::forward(args)...) + : edm::EDPutTokenT{}; + } + private: // input digi collections in GPU-friendly format using InputProduct = cms::cuda::Product>; @@ -43,7 +50,7 @@ class EcalCPUDigisProducer : public edm::stream::EDProducer { // whether to produce dummy integrity collections bool produceDummyIntegrityCollections_; - // dummy SRP collections + // dummy producer collections edm::EDPutTokenT ebSrFlagToken_; edm::EDPutTokenT eeSrFlagToken_; @@ -59,8 +66,15 @@ class EcalCPUDigisProducer : public edm::stream::EDProducer { // dummy integrity errors edm::EDPutTokenT integrityTTIdErrorsToken_; + edm::EDPutTokenT integrityZSXtalIdErrorsToken_; edm::EDPutTokenT integrityBlockSizeErrorsToken_; + edm::EDPutTokenT pnDiodeDigisToken_; + + // dummy TCC collections + edm::EDPutTokenT ecalTriggerPrimitivesToken_; + edm::EDPutTokenT ecalPseudoStripInputsToken_; + // FIXME better way to pass pointers from acquire to produce? std::vector> idsebtmp, idseetmp; std::vector> dataebtmp, dataeetmp; @@ -84,45 +98,41 @@ EcalCPUDigisProducer::EcalCPUDigisProducer(const edm::ParameterSet& ps) : // input digi collections in GPU-friendly format digisInEBToken_{consumes(ps.getParameter("digisInLabelEB"))}, digisInEEToken_{consumes(ps.getParameter("digisInLabelEE"))}, + // output digi collections in legacy format digisOutEBToken_{produces(ps.getParameter("digisOutLabelEB"))}, digisOutEEToken_{produces(ps.getParameter("digisOutLabelEE"))}, + // whether to produce dummy integrity collections produceDummyIntegrityCollections_{ps.getParameter("produceDummyIntegrityCollections")}, - // dummy SRP collections - ebSrFlagToken_{produceDummyIntegrityCollections_ ? produces() - : edm::EDPutTokenT{}}, - eeSrFlagToken_{produceDummyIntegrityCollections_ ? produces() - : edm::EDPutTokenT{}}, + + // dummy collections + ebSrFlagToken_{dummyProduces()}, + eeSrFlagToken_{dummyProduces()}, + // dummy integrity for xtal data - ebIntegrityGainErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityGainErrors") - : edm::EDPutTokenT{}}, - ebIntegrityGainSwitchErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityGainSwitchErrors") - : edm::EDPutTokenT{}}, - ebIntegrityChIdErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityChIdErrors") - : edm::EDPutTokenT{}}, + ebIntegrityGainErrorsToken_{dummyProduces("EcalIntegrityGainErrors")}, + ebIntegrityGainSwitchErrorsToken_{dummyProduces("EcalIntegrityGainSwitchErrors")}, + ebIntegrityChIdErrorsToken_{dummyProduces("EcalIntegrityChIdErrors")}, + // dummy integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection) - eeIntegrityGainErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityGainErrors") - : edm::EDPutTokenT{}}, - eeIntegrityGainSwitchErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityGainSwitchErrors") - : edm::EDPutTokenT{}}, - eeIntegrityChIdErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityChIdErrors") - : edm::EDPutTokenT{}}, + eeIntegrityGainErrorsToken_{dummyProduces("EcalIntegrityGainErrors")}, + eeIntegrityGainSwitchErrorsToken_{dummyProduces("EcalIntegrityGainSwitchErrors")}, + eeIntegrityChIdErrorsToken_{dummyProduces("EcalIntegrityChIdErrors")}, + // dummy integrity errors - integrityTTIdErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityTTIdErrors") - : edm::EDPutTokenT{}}, - integrityBlockSizeErrorsToken_{produceDummyIntegrityCollections_ - ? produces("EcalIntegrityBlockSizeErrors") - : edm::EDPutTokenT{}} {} + integrityTTIdErrorsToken_{dummyProduces("EcalIntegrityTTIdErrors")}, + integrityZSXtalIdErrorsToken_{dummyProduces("EcalIntegrityZSXtalIdErrors")}, + integrityBlockSizeErrorsToken_{dummyProduces("EcalIntegrityBlockSizeErrors")}, + + // + pnDiodeDigisToken_{dummyProduces()}, -EcalCPUDigisProducer::~EcalCPUDigisProducer() {} + // dummy TCC collections + ecalTriggerPrimitivesToken_{dummyProduces("EcalTriggerPrimitives")}, + ecalPseudoStripInputsToken_{dummyProduces("EcalPseudoStripInputs")} +// constructor body +{} void EcalCPUDigisProducer::acquire(edm::Event const& event, edm::EventSetup const& setup, @@ -176,7 +186,7 @@ void EcalCPUDigisProducer::produce(edm::Event& event, edm::EventSetup const& set event.put(digisOutEEToken_, std::move(digisEE)); if (produceDummyIntegrityCollections_) { - // dummy SRP collections + // dummy collections event.emplace(ebSrFlagToken_); event.emplace(eeSrFlagToken_); // dummy integrity for xtal data @@ -189,7 +199,13 @@ void EcalCPUDigisProducer::produce(edm::Event& event, edm::EventSetup const& set event.emplace(eeIntegrityChIdErrorsToken_); // dummy integrity errors event.emplace(integrityTTIdErrorsToken_); + event.emplace(integrityZSXtalIdErrorsToken_); event.emplace(integrityBlockSizeErrorsToken_); + // + event.emplace(pnDiodeDigisToken_); + // dummy TCC collections + event.emplace(ecalTriggerPrimitivesToken_); + event.emplace(ecalPseudoStripInputsToken_); } } diff --git a/EventFilter/EcalRawToDigi/plugins/EcalRawToDigi.cc b/EventFilter/EcalRawToDigi/plugins/EcalRawToDigi.cc index b1c4c2aee087f..650e0e1911cfb 100644 --- a/EventFilter/EcalRawToDigi/plugins/EcalRawToDigi.cc +++ b/EventFilter/EcalRawToDigi/plugins/EcalRawToDigi.cc @@ -110,36 +110,51 @@ EcalRawToDigi::EcalRawToDigi(edm::ParameterSet const& conf) edm::InputTag dataLabel = conf.getParameter("InputLabel"); edm::InputTag fedsLabel = conf.getParameter("FedLabel"); - // Producer products : - produces("ebDigis"); - produces("eeDigis"); - produces(); - produces(); - produces(); - produces(); - produces("EcalTriggerPrimitives"); - produces("EcalPseudoStripInputs"); - - // Integrity for xtal data - produces("EcalIntegrityGainErrors"); - produces("EcalIntegrityGainSwitchErrors"); - produces("EcalIntegrityChIdErrors"); - - // Integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection) - produces("EcalIntegrityGainErrors"); - produces("EcalIntegrityGainSwitchErrors"); - produces("EcalIntegrityChIdErrors"); - - // Integrity Errors - produces("EcalIntegrityTTIdErrors"); - produces("EcalIntegrityZSXtalIdErrors"); - produces("EcalIntegrityBlockSizeErrors"); + // Producer products + if (headerUnpacking_) { + produces(); + } + + if (feUnpacking_) { + produces("ebDigis"); + produces("eeDigis"); + + // Integrity for xtal data + produces("EcalIntegrityGainErrors"); + produces("EcalIntegrityGainSwitchErrors"); + produces("EcalIntegrityChIdErrors"); + + // Integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection) + produces("EcalIntegrityGainErrors"); + produces("EcalIntegrityGainSwitchErrors"); + produces("EcalIntegrityChIdErrors"); + + // Integrity Errors + produces("EcalIntegrityTTIdErrors"); + produces("EcalIntegrityZSXtalIdErrors"); + produces("EcalIntegrityBlockSizeErrors"); + + // + produces(); + } + + if (srpUnpacking_) { + produces(); + produces(); + } + + if (tccUnpacking_) { + produces("EcalTriggerPrimitives"); + produces("EcalPseudoStripInputs"); + } // Mem channels' integrity - produces("EcalIntegrityMemTtIdErrors"); - produces("EcalIntegrityMemBlockSizeErrors"); - produces("EcalIntegrityMemChIdErrors"); - produces("EcalIntegrityMemGainErrors"); + if (memUnpacking_) { + produces("EcalIntegrityMemTtIdErrors"); + produces("EcalIntegrityMemBlockSizeErrors"); + produces("EcalIntegrityMemChIdErrors"); + produces("EcalIntegrityMemGainErrors"); + } dataToken_ = consumes(dataLabel); if (REGIONAL_) { diff --git a/EventFilter/EcalRawToDigi/python/ecalDigis_cff.py b/EventFilter/EcalRawToDigi/python/ecalDigis_cff.py index 00a54ad56c128..0238a62f34568 100644 --- a/EventFilter/EcalRawToDigi/python/ecalDigis_cff.py +++ b/EventFilter/EcalRawToDigi/python/ecalDigis_cff.py @@ -1,28 +1,49 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA -# legacy raw to digi on the CPU +# ECAL unpacker running on CPU from EventFilter.EcalRawToDigi.EcalUnpackerData_cfi import ecalEBunpacker as _ecalEBunpacker -ecalDigis = _ecalEBunpacker.clone() +ecalDigis = SwitchProducerCUDA( + cpu = _ecalEBunpacker.clone() +) -ecalDigisTask = cms.Task(ecalDigis) +ecalDigisTask = cms.Task( + # ECAL unpacker running on CPU + ecalDigis +) # process modifier to run on GPUs from Configuration.ProcessModifiers.gpu_cff import gpu -# GPU-friendly EventSetup modules +# ECAL conditions used by the unpacker running on GPU from EventFilter.EcalRawToDigi.ecalElectronicsMappingGPUESProducer_cfi import ecalElectronicsMappingGPUESProducer -# raw to digi on GPUs +# ECAL unpacker running on GPU from EventFilter.EcalRawToDigi.ecalRawToDigiGPU_cfi import ecalRawToDigiGPU as _ecalRawToDigiGPU ecalDigisGPU = _ecalRawToDigiGPU.clone() -# copy the digi from the GPU to the CPU and convert to legacy format +# disable the ECAL unpacker collections that are not available in the GPU unpacker +gpu.toModify(ecalDigis.cpu, + headerUnpacking = False, + memUnpacking = False +) + +# extend the SwitchProducer to add a case to copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format from EventFilter.EcalRawToDigi.ecalCPUDigisProducer_cfi import ecalCPUDigisProducer as _ecalCPUDigisProducer -_ecalDigis_gpu = _ecalCPUDigisProducer.clone( - digisInLabelEB = ('ecalDigisGPU', 'ebDigis'), - digisInLabelEE = ('ecalDigisGPU', 'eeDigis'), - produceDummyIntegrityCollections = True +gpu.toModify(ecalDigis, + # copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format + cuda = _ecalCPUDigisProducer.clone( + digisInLabelEB = ('ecalDigisGPU', 'ebDigis'), + digisInLabelEE = ('ecalDigisGPU', 'eeDigis'), + produceDummyIntegrityCollections = True + ) ) -gpu.toReplaceWith(ecalDigis, _ecalDigis_gpu) -gpu.toReplaceWith(ecalDigisTask, cms.Task(ecalElectronicsMappingGPUESProducer, ecalDigisGPU, ecalDigis)) +gpu.toReplaceWith(ecalDigisTask, cms.Task( + # ECAL conditions used by the unpacker running on GPU + ecalElectronicsMappingGPUESProducer, + # run the ECAL unpacker on GPU + ecalDigisGPU, + # run the ECAL unpacker on CPU, or copy the ECAL digis from GPU to CPU and covert them from SoA to legacy format + ecalDigis +)) diff --git a/RecoLocalCalo/Configuration/python/ecalLocalRecoSequenceCosmics_cff.py b/RecoLocalCalo/Configuration/python/ecalLocalRecoSequenceCosmics_cff.py index ce74351bc8c33..bf6c8896b3823 100644 --- a/RecoLocalCalo/Configuration/python/ecalLocalRecoSequenceCosmics_cff.py +++ b/RecoLocalCalo/Configuration/python/ecalLocalRecoSequenceCosmics_cff.py @@ -12,14 +12,10 @@ #ECAL reconstruction from RecoLocalCalo.EcalRecProducers.ecalWeightUncalibRecHit_cfi import * from RecoLocalCalo.EcalRecProducers.ecalFixedAlphaBetaFitUncalibRecHit_cfi import * -from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import * -from RecoLocalCalo.EcalRecProducers.ecalPreshowerRecHit_cfi import * -from RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi import * -ecalLocalRecoTaskCosmics = cms.Task(ecalFixedAlphaBetaFitUncalibRecHit,ecalWeightUncalibRecHit,ecalDetIdToBeRecovered,ecalRecHit,ecalPreshowerRecHit) -ecalLocalRecoSequenceCosmics = cms.Sequence(ecalLocalRecoTaskCosmics) -ecalRecHit.EBuncalibRecHitCollection = 'ecalFixedAlphaBetaFitUncalibRecHit:EcalUncalibRecHitsEB' -ecalRecHit.EEuncalibRecHitCollection = 'ecalFixedAlphaBetaFitUncalibRecHit:EcalUncalibRecHitsEE' -ecalRecHit.ChannelStatusToBeExcluded = [ +from RecoLocalCalo.EcalRecProducers.ecalRecHit_cff import * +ecalRecHit.cpu.EBuncalibRecHitCollection = 'ecalFixedAlphaBetaFitUncalibRecHit:EcalUncalibRecHitsEB' +ecalRecHit.cpu.EEuncalibRecHitCollection = 'ecalFixedAlphaBetaFitUncalibRecHit:EcalUncalibRecHitsEE' +ecalRecHit.cpu.ChannelStatusToBeExcluded = [ 'kDAC', 'kNoLaser', 'kNoisy', @@ -32,3 +28,14 @@ 'kDeadFE', 'kNoDataNoTP' ] +from RecoLocalCalo.EcalRecProducers.ecalPreshowerRecHit_cfi import * +from RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi import * + +ecalLocalRecoTaskCosmics = cms.Task( + ecalFixedAlphaBetaFitUncalibRecHit, + ecalWeightUncalibRecHit, + ecalDetIdToBeRecovered, + ecalCalibratedRecHitTask, + ecalPreshowerRecHit +) +ecalLocalRecoSequenceCosmics = cms.Sequence(ecalLocalRecoTaskCosmics) diff --git a/RecoLocalCalo/Configuration/python/ecalLocalRecoSequence_cff.py b/RecoLocalCalo/Configuration/python/ecalLocalRecoSequence_cff.py index 75ae5fc0c202f..e49aae13d365b 100644 --- a/RecoLocalCalo/Configuration/python/ecalLocalRecoSequence_cff.py +++ b/RecoLocalCalo/Configuration/python/ecalLocalRecoSequence_cff.py @@ -1,12 +1,11 @@ import FWCore.ParameterSet.Config as cms -from Configuration.ProcessModifiers.gpu_cff import gpu # TPG condition needed by ecalRecHit producer if TT recovery is ON from RecoLocalCalo.EcalRecProducers.ecalRecHitTPGConditions_cff import * # ECAL reconstruction from RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cff import * -from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import * +from RecoLocalCalo.EcalRecProducers.ecalRecHit_cff import * from RecoLocalCalo.EcalRecProducers.ecalPreshowerRecHit_cfi import * from RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi import * from RecoLocalCalo.EcalRecProducers.ecalCompactTrigPrim_cfi import * @@ -20,7 +19,7 @@ ecalUncalibRecHitSequence = cms.Sequence(ecalUncalibRecHitTask) ecalRecHitNoTPTask = cms.Task( - ecalRecHit, + ecalCalibratedRecHitTask, ecalPreshowerRecHit) ecalRecHitNoTPSequence = cms.Sequence(ecalRecHitNoTPTask) @@ -44,61 +43,6 @@ ecalOnlyLocalRecoSequence = cms.Sequence(ecalOnlyLocalRecoTask) -# ECAL rechit calibrations on GPU -from RecoLocalCalo.EcalRecProducers.ecalRechitADCToGeVConstantGPUESProducer_cfi import ecalRechitADCToGeVConstantGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalRechitChannelStatusGPUESProducer_cfi import ecalRechitChannelStatusGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalIntercalibConstantsGPUESProducer_cfi import ecalIntercalibConstantsGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosGPUESProducer_cfi import ecalLaserAPDPNRatiosGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosRefGPUESProducer_cfi import ecalLaserAPDPNRatiosRefGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalLaserAlphasGPUESProducer_cfi import ecalLaserAlphasGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalLinearCorrectionsGPUESProducer_cfi import ecalLinearCorrectionsGPUESProducer -from RecoLocalCalo.EcalRecProducers.ecalRecHitParametersGPUESProducer_cfi import ecalRecHitParametersGPUESProducer - -# ECAL rechits running on GPU -from RecoLocalCalo.EcalRecProducers.ecalRecHitGPU_cfi import ecalRecHitGPU as _ecalRecHitGPU -ecalRecHitGPU = _ecalRecHitGPU.clone( - uncalibrecHitsInLabelEB = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEB'), - uncalibrecHitsInLabelEE = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEE') -) - -# copy the rechits from GPU to CPU -from RecoLocalCalo.EcalRecProducers.ecalCPURecHitProducer_cfi import ecalCPURecHitProducer as _ecalCPURecHitProducer -ecalRecHitSoA = _ecalCPURecHitProducer.clone( - recHitsInLabelEB = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEB'), - recHitsInLabelEE = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEE') -) - -# convert the rechits from SoA to legacy format -from RecoLocalCalo.EcalRecProducers.ecalRecHitConvertGPU2CPUFormat_cfi import ecalRecHitConvertGPU2CPUFormat as _ecalRecHitConvertGPU2CPUFormat -_ecalRecHit_gpu = _ecalRecHitConvertGPU2CPUFormat.clone( - recHitsLabelGPUEB = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEB'), - recHitsLabelGPUEE = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEE') -) -# TODO: the ECAL calibrated rechits produced on the GPU are not correct, yet. -# When they are working and validated, remove this comment and uncomment the next line: -#gpu.toReplaceWith(ecalRecHit, _ecalRecHit_gpu) - -# ECAL reconstruction on GPU -gpu.toReplaceWith(ecalRecHitNoTPTask, cms.Task( - # ECAL rechit calibrations on GPU - ecalRechitADCToGeVConstantGPUESProducer, - ecalRechitChannelStatusGPUESProducer, - ecalIntercalibConstantsGPUESProducer, - ecalLaserAPDPNRatiosGPUESProducer, - ecalLaserAPDPNRatiosRefGPUESProducer, - ecalLaserAlphasGPUESProducer, - ecalLinearCorrectionsGPUESProducer, - ecalRecHitParametersGPUESProducer, - # ECAL rechits running on GPU - ecalRecHitGPU, - # copy the rechits from GPU to CPU - ecalRecHitSoA, - # convert the rechits from SoA to legacy format - ecalRecHit, - # ECAL preshower rechit legacy module - ecalPreshowerRecHit -)) - # Phase 2 modifications from RecoLocalCalo.EcalRecProducers.ecalDetailedTimeRecHit_cfi import * _phase2_timing_ecalRecHitTask = cms.Task( ecalRecHitTask.copy() , ecalDetailedTimeRecHit ) diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalLocalCustom.py b/RecoLocalCalo/EcalRecProducers/python/ecalLocalCustom.py index ba84f7779a0d9..137c97ac7765a 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalLocalCustom.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalLocalCustom.py @@ -1,17 +1,16 @@ - import FWCore.ParameterSet.Config as cms def configureEcalLocal25ns(process): - process.ecalMultiFitUncalibRecHit.activeBXs = [-5,-4,-3,-2,-1,0,1,2,3,4], - process.ecalMultiFitUncalibRecHit.useLumiInfoRunHeader = False + process.ecalMultiFitUncalibRecHit.cpu.activeBXs = [-5,-4,-3,-2,-1,0,1,2,3,4], + process.ecalMultiFitUncalibRecHit.cpu.useLumiInfoRunHeader = False return process def configureEcalLocal50ns(process): - process.ecalMultiFitUncalibRecHit.activeBXs = [-4,-2,0,2,4] - process.ecalMultiFitUncalibRecHit.useLumiInfoRunHeader = False + process.ecalMultiFitUncalibRecHit.cpu.activeBXs = [-4,-2,0,2,4] + process.ecalMultiFitUncalibRecHit.cpu.useLumiInfoRunHeader = False return process def configureEcalLocalNoOOTPU(process): - process.ecalMultiFitUncalibRecHit.activeBXs = [0] - process.ecalMultiFitUncalibRecHit.useLumiInfoRunHeader = False + process.ecalMultiFitUncalibRecHit.cpu.activeBXs = [0] + process.ecalMultiFitUncalibRecHit.cpu.useLumiInfoRunHeader = False return process diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py index 72a3efaae38ba..fb285456a053f 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py @@ -1,10 +1,17 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA from Configuration.ProcessModifiers.gpu_cff import gpu # ECAL multifit running on CPU -from RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi import ecalMultiFitUncalibRecHit +from RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi import ecalMultiFitUncalibRecHit as _ecalMultiFitUncalibRecHit +ecalMultiFitUncalibRecHit = SwitchProducerCUDA( + cpu = _ecalMultiFitUncalibRecHit +) -ecalMultiFitUncalibRecHitTask = cms.Task(ecalMultiFitUncalibRecHit) +ecalMultiFitUncalibRecHitTask = cms.Task( + # ECAL multifit running on CPU + ecalMultiFitUncalibRecHit +) # ECAL conditions used by the multifit running on GPU from RecoLocalCalo.EcalRecProducers.ecalPedestalsGPUESProducer_cfi import ecalPedestalsGPUESProducer @@ -32,11 +39,12 @@ # convert the uncalibrated rechits from SoA to legacy format from RecoLocalCalo.EcalRecProducers.ecalUncalibRecHitConvertGPU2CPUFormat_cfi import ecalUncalibRecHitConvertGPU2CPUFormat as _ecalUncalibRecHitConvertGPU2CPUFormat -_ecalMultiFitUncalibRecHit_gpu = _ecalUncalibRecHitConvertGPU2CPUFormat.clone( - recHitsLabelGPUEB = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEB'), - recHitsLabelGPUEE = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEE'), +gpu.toModify(ecalMultiFitUncalibRecHit, + cuda = _ecalUncalibRecHitConvertGPU2CPUFormat.clone( + recHitsLabelGPUEB = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEB'), + recHitsLabelGPUEE = cms.InputTag('ecalMultiFitUncalibRecHitSoA', 'EcalUncalibRecHitsEE'), + ) ) -gpu.toReplaceWith(ecalMultiFitUncalibRecHit, _ecalMultiFitUncalibRecHit_gpu) gpu.toReplaceWith(ecalMultiFitUncalibRecHitTask, cms.Task( # ECAL conditions used by the multifit running on GPU @@ -48,10 +56,10 @@ ecalTimeBiasCorrectionsGPUESProducer, ecalTimeCalibConstantsGPUESProducer, ecalMultifitParametersGPUESProducer, - # ECAL multifit running on GP + # ECAL multifit running on GPU ecalMultiFitUncalibRecHitGPU, # copy the uncalibrated rechits from GPU to CPU ecalMultiFitUncalibRecHitSoA, - # convert the uncalibrated rechits legacy format + # ECAL multifit running on CPU, or convert the uncalibrated rechits from SoA to legacy format ecalMultiFitUncalibRecHit, )) diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py b/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py new file mode 100644 index 0000000000000..44420e9600690 --- /dev/null +++ b/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py @@ -0,0 +1,67 @@ +import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA +from Configuration.ProcessModifiers.gpu_cff import gpu + +# ECAL calibrated rechit reconstruction on CPU +from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import ecalRecHit as _ecalRecHit +ecalRecHit = SwitchProducerCUDA( + cpu = _ecalRecHit +) + +ecalCalibratedRecHitTask = cms.Task( + ecalRecHit +) + +# ECAL rechit calibrations on GPU +from RecoLocalCalo.EcalRecProducers.ecalRechitADCToGeVConstantGPUESProducer_cfi import ecalRechitADCToGeVConstantGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalRechitChannelStatusGPUESProducer_cfi import ecalRechitChannelStatusGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalIntercalibConstantsGPUESProducer_cfi import ecalIntercalibConstantsGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosGPUESProducer_cfi import ecalLaserAPDPNRatiosGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalLaserAPDPNRatiosRefGPUESProducer_cfi import ecalLaserAPDPNRatiosRefGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalLaserAlphasGPUESProducer_cfi import ecalLaserAlphasGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalLinearCorrectionsGPUESProducer_cfi import ecalLinearCorrectionsGPUESProducer +from RecoLocalCalo.EcalRecProducers.ecalRecHitParametersGPUESProducer_cfi import ecalRecHitParametersGPUESProducer + +# ECAL rechits running on GPU +from RecoLocalCalo.EcalRecProducers.ecalRecHitGPU_cfi import ecalRecHitGPU as _ecalRecHitGPU +ecalRecHitGPU = _ecalRecHitGPU.clone( + uncalibrecHitsInLabelEB = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEB'), + uncalibrecHitsInLabelEE = cms.InputTag('ecalMultiFitUncalibRecHitGPU', 'EcalUncalibRecHitsEE') +) + +# copy the rechits from GPU to CPU +from RecoLocalCalo.EcalRecProducers.ecalCPURecHitProducer_cfi import ecalCPURecHitProducer as _ecalCPURecHitProducer +ecalRecHitSoA = _ecalCPURecHitProducer.clone( + recHitsInLabelEB = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEB'), + recHitsInLabelEE = cms.InputTag('ecalRecHitGPU', 'EcalRecHitsEE') +) + +# TODO: the ECAL calibrated rechits produced on the GPU are not correct, yet. +# When they are working and validated, remove this comment and uncomment the next lines: +# convert the rechits from SoA to legacy format +#from RecoLocalCalo.EcalRecProducers.ecalRecHitConvertGPU2CPUFormat_cfi import ecalRecHitConvertGPU2CPUFormat as _ecalRecHitFromSoA +#gpu.toModify(ecalRecHit, +# cuda = _ecalRecHitFromSoA.clone( +# recHitsLabelGPUEB = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEB'), +# recHitsLabelGPUEE = cms.InputTag('ecalRecHitSoA', 'EcalRecHitsEE') +# ) +#) + +# ECAL calibrated rechit reconstruction on GPU +gpu.toReplaceWith(ecalCalibratedRecHitTask, cms.Task( + # ECAL rechit calibrations on GPU + ecalRechitADCToGeVConstantGPUESProducer, + ecalRechitChannelStatusGPUESProducer, + ecalIntercalibConstantsGPUESProducer, + ecalLaserAPDPNRatiosGPUESProducer, + ecalLaserAPDPNRatiosRefGPUESProducer, + ecalLaserAlphasGPUESProducer, + ecalLinearCorrectionsGPUESProducer, + ecalRecHitParametersGPUESProducer, + # ECAL rechits running on GPU + ecalRecHitGPU, + # copy the rechits from GPU to CPU + ecalRecHitSoA, + # convert the rechits from SoA to legacy format + ecalRecHit +)) diff --git a/Validation/Configuration/python/ECALHCAL.py b/Validation/Configuration/python/ECALHCAL.py index 50013e0859c30..1c4e18046144b 100644 --- a/Validation/Configuration/python/ECALHCAL.py +++ b/Validation/Configuration/python/ECALHCAL.py @@ -39,21 +39,21 @@ def customise(process): process.schedule.append(process.generation_step) process.schedule.append(process.simulation_step) - process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("simEcalDigis","ebDigis") - process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("simEcalDigis","eeDigis") + process.ecalMultiFitUncalibRecHit.cpu.EBdigiCollection = cms.InputTag("simEcalDigis","ebDigis") + process.ecalMultiFitUncalibRecHit.cpu.EEdigiCollection = cms.InputTag("simEcalDigis","eeDigis") process.ecalPreshowerRecHit.ESdigiCollection = cms.InputTag("simEcalPreshowerDigis") delattr(process,"hbhereco") process.hbhereco = process.hbheprereco.clone() process.hcalLocalRecoSequence.replace(process.hbheprereco,process.hbhereco) - process.hbhereco.digiLabelQIE8 = cms.InputTag("simHcalUnsuppressedDigis") - process.hbhereco.digiLabelQIE11 = cms.InputTag("simHcalUnsuppressedDigis","HBHEQIE11DigiCollection") + process.hbhereco.cpu.digiLabelQIE8 = cms.InputTag("simHcalUnsuppressedDigis") + process.hbhereco.cpu.digiLabelQIE11 = cms.InputTag("simHcalUnsuppressedDigis","HBHEQIE11DigiCollection") process.horeco.digiLabel = cms.InputTag("simHcalUnsuppressedDigis") process.hfreco.digiLabel = cms.InputTag("simHcalUnsuppressedDigis") - process.ecalRecHit.recoverEBIsolatedChannels = cms.bool(False) - process.ecalRecHit.recoverEEIsolatedChannels = cms.bool(False) - process.ecalRecHit.recoverEBFE = cms.bool(False) - process.ecalRecHit.recoverEEFE = cms.bool(False) + process.ecalRecHit.cpu.recoverEBIsolatedChannels = cms.bool(False) + process.ecalRecHit.cpu.recoverEEIsolatedChannels = cms.bool(False) + process.ecalRecHit.cpu.recoverEBFE = cms.bool(False) + process.ecalRecHit.cpu.recoverEEFE = cms.bool(False) # process.local_digireco = cms.Path(process.mix * process.calDigi * process.ecalLocalRecoSequence * process.hbhereco * process.hfreco * process.horeco * (process.ecalClusters+process.caloTowersRec) * process.reducedEcalRecHitsSequence ) From a929ca9a9d78bf816c4a79b41245d78f6f613a5c Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 20 Apr 2021 12:01:35 +0200 Subject: [PATCH 06/11] Update the DQM clients workflows for ecalDigis being a SwitchProducer --- .../python/clients/beam_dqm_sourceclient-live_cfg.py | 2 +- .../python/clients/beamfake_dqm_sourceclient-live_cfg.py | 2 +- .../python/clients/beampixel_dqm_sourceclient-live_cfg.py | 4 ++-- .../python/clients/csc_dqm_sourceclient-live_cfg.py | 4 ++-- .../python/clients/ecal_dqm_sourceclient-live_cfg.py | 2 +- .../python/clients/l1t_dqm_sourceclient-live_cfg.py | 4 ++-- .../python/clients/l1temulator_dqm_sourceclient-live_cfg.py | 4 ++-- .../python/clients/l1tstage1_dqm_sourceclient-live_cfg.py | 4 ++-- .../clients/l1tstage1emulator_dqm_sourceclient-live_cfg.py | 4 ++-- .../python/clients/l1tstage2_dqm_sourceclient-live_cfg.py | 2 +- .../clients/l1tstage2emulator_dqm_sourceclient-live_cfg.py | 2 +- .../python/clients/scal_dqm_sourceclient-live_cfg.py | 2 +- .../python/clients/sistrip_dqm_sourceclient-live_cfg.py | 4 ++-- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DQM/Integration/python/clients/beam_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/beam_dqm_sourceclient-live_cfg.py index 316b4cf91c64d..ba5c96c796e57 100644 --- a/DQM/Integration/python/clients/beam_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/beam_dqm_sourceclient-live_cfg.py @@ -287,7 +287,7 @@ process.castorDigis.InputLabel = rawDataInputTag process.csctfDigis.producer = rawDataInputTag process.dttfDigis.DTTF_FED_Source = rawDataInputTag -process.ecalDigis.InputLabel = rawDataInputTag +process.ecalDigis.cpu.InputLabel = rawDataInputTag process.ecalPreshowerDigis.sourceTag = rawDataInputTag process.gctDigis.inputLabel = rawDataInputTag process.gtDigis.DaqGtInputTag = rawDataInputTag diff --git a/DQM/Integration/python/clients/beamfake_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/beamfake_dqm_sourceclient-live_cfg.py index 3765c52e57290..8b6fe3516f0ac 100644 --- a/DQM/Integration/python/clients/beamfake_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/beamfake_dqm_sourceclient-live_cfg.py @@ -115,7 +115,7 @@ """ process.castorDigis.InputLabel = rawDataInputTag process.csctfDigis.producer = rawDataInputTag process.dttfDigis.DTTF_FED_Source = rawDataInputTag -process.ecalDigis.InputLabel = rawDataInputTag +process.ecalDigis.cpu.InputLabel = rawDataInputTag process.ecalPreshowerDigis.sourceTag = rawDataInputTag process.gctDigis.inputLabel = rawDataInputTag process.gtDigis.DaqGtInputTag = rawDataInputTag diff --git a/DQM/Integration/python/clients/beampixel_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/beampixel_dqm_sourceclient-live_cfg.py index ba03f7f75f2d6..cd21b498d7f9c 100644 --- a/DQM/Integration/python/clients/beampixel_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/beampixel_dqm_sourceclient-live_cfg.py @@ -115,7 +115,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") - process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -168,7 +168,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/csc_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/csc_dqm_sourceclient-live_cfg.py index 747ec4d01b07a..2aa8f0fc32dfe 100644 --- a/DQM/Integration/python/clients/csc_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/csc_dqm_sourceclient-live_cfg.py @@ -179,7 +179,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -204,7 +204,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/ecal_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/ecal_dqm_sourceclient-live_cfg.py index 0c692470fc983..a68733cef810a 100644 --- a/DQM/Integration/python/clients/ecal_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/ecal_dqm_sourceclient-live_cfg.py @@ -162,7 +162,7 @@ process.ecalMonitorTask.workerParameters.PresampleTask.params.doPulseMaxCheck = False elif runTypeName == 'hi_run': process.ecalMonitorTask.collectionTags.Source = "rawDataRepacker" - process.ecalDigis.InputLabel = cms.InputTag('rawDataRepacker') + process.ecalDigis.cpu.InputLabel = cms.InputTag('rawDataRepacker') elif runTypeName == 'hpu_run': if not unitTest: process.source.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('*')) diff --git a/DQM/Integration/python/clients/l1t_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1t_dqm_sourceclient-live_cfg.py index b2358e79a1bb6..3887c06b60772 100644 --- a/DQM/Integration/python/clients/l1t_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1t_dqm_sourceclient-live_cfg.py @@ -172,7 +172,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -191,7 +191,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/l1temulator_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1temulator_dqm_sourceclient-live_cfg.py index e2c9f057f04b1..c995051a63b2e 100644 --- a/DQM/Integration/python/clients/l1temulator_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1temulator_dqm_sourceclient-live_cfg.py @@ -185,7 +185,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -207,7 +207,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/l1tstage1_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1tstage1_dqm_sourceclient-live_cfg.py index 93df769c2dfe4..b5b25b9fc318a 100644 --- a/DQM/Integration/python/clients/l1tstage1_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1tstage1_dqm_sourceclient-live_cfg.py @@ -182,7 +182,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -201,7 +201,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/l1tstage1emulator_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1tstage1emulator_dqm_sourceclient-live_cfg.py index 4ed9c5e298890..0cb164bf2c0b4 100644 --- a/DQM/Integration/python/clients/l1tstage1emulator_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1tstage1emulator_dqm_sourceclient-live_cfg.py @@ -194,7 +194,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -216,7 +216,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/l1tstage2_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1tstage2_dqm_sourceclient-live_cfg.py index 0c7f4707b6d8b..e1e87d866dcc4 100644 --- a/DQM/Integration/python/clients/l1tstage2_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1tstage2_dqm_sourceclient-live_cfg.py @@ -130,7 +130,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.ctppsDiamondRawToDigi.rawDataTag = cms.InputTag("rawDataRepacker") process.ctppsPixelDigis.inputLabel = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.hcalDigis.InputLabel = cms.InputTag("rawDataRepacker") process.muonCSCDigis.InputObjects = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/l1tstage2emulator_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/l1tstage2emulator_dqm_sourceclient-live_cfg.py index d2d4ecb4f630d..222cebbf0e1d1 100644 --- a/DQM/Integration/python/clients/l1tstage2emulator_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/l1tstage2emulator_dqm_sourceclient-live_cfg.py @@ -128,7 +128,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.ctppsDiamondRawToDigi.rawDataTag = cms.InputTag("rawDataRepacker") process.ctppsPixelDigis.inputLabel = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.hcalDigis.InputLabel = cms.InputTag("rawDataRepacker") process.muonCSCDigis.InputObjects = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py index 2decc1b774251..433f9f3510d15 100644 --- a/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/scal_dqm_sourceclient-live_cfg.py @@ -90,7 +90,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataRepacker") diff --git a/DQM/Integration/python/clients/sistrip_dqm_sourceclient-live_cfg.py b/DQM/Integration/python/clients/sistrip_dqm_sourceclient-live_cfg.py index 889fc8a978d22..3004cb47ef80b 100644 --- a/DQM/Integration/python/clients/sistrip_dqm_sourceclient-live_cfg.py +++ b/DQM/Integration/python/clients/sistrip_dqm_sourceclient-live_cfg.py @@ -493,7 +493,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataCollector") process.csctfDigis.producer = cms.InputTag("rawDataCollector") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataCollector") -process.ecalDigis.InputLabel = cms.InputTag("rawDataCollector") +process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataCollector") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataCollector") process.gctDigis.inputLabel = cms.InputTag("rawDataCollector") process.gtDigis.DaqGtInputTag = cms.InputTag("rawDataCollector") @@ -515,7 +515,7 @@ process.castorDigis.InputLabel = cms.InputTag("rawDataRepacker") process.csctfDigis.producer = cms.InputTag("rawDataRepacker") process.dttfDigis.DTTF_FED_Source = cms.InputTag("rawDataRepacker") - process.ecalDigis.InputLabel = cms.InputTag("rawDataRepacker") + process.ecalDigis.cpu.InputLabel = cms.InputTag("rawDataRepacker") process.ecalPreshowerDigis.sourceTag = cms.InputTag("rawDataRepacker") process.gctDigis.inputLabel = cms.InputTag("rawDataRepacker") process.hcalDigis.InputLabel = cms.InputTag("rawDataRepacker") From 90a90a6448dd4f83c3b281b644deee8bc8e95043 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Wed, 21 Apr 2021 00:29:45 +0200 Subject: [PATCH 07/11] Make the SoA and/or legacy collections optional --- .../src/HcalCPURecHitsProducer.cc | 77 +++++++++++-------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/RecoLocalCalo/HcalRecProducers/src/HcalCPURecHitsProducer.cc b/RecoLocalCalo/HcalRecProducers/src/HcalCPURecHitsProducer.cc index 714ec8b7de5af..742662eac2dd9 100644 --- a/RecoLocalCalo/HcalRecProducers/src/HcalCPURecHitsProducer.cc +++ b/RecoLocalCalo/HcalRecProducers/src/HcalCPURecHitsProducer.cc @@ -15,7 +15,8 @@ class HcalCPURecHitsProducer : public edm::stream::EDProducer { public: explicit HcalCPURecHitsProducer(edm::ParameterSet const& ps); - ~HcalCPURecHitsProducer() override; + ~HcalCPURecHitsProducer() override = default; + static void fillDescriptions(edm::ConfigurationDescriptions&); private: @@ -23,11 +24,15 @@ class HcalCPURecHitsProducer : public edm::stream::EDProducer void produce(edm::Event&, edm::EventSetup const&) override; private: + const bool produceSoA_; + const bool produceLegacy_; + using IProductType = cms::cuda::Product>; - edm::EDGetTokenT recHitsM0TokenIn_; + const edm::EDGetTokenT recHitsM0TokenIn_; + using OProductType = hcal::RecHitCollection>; - edm::EDPutTokenT recHitsM0TokenOut_; - edm::EDPutTokenT recHitsLegacyTokenOut_; + const edm::EDPutTokenT recHitsM0TokenOut_; + const edm::EDPutTokenT recHitsLegacyTokenOut_; // to pass from acquire to produce OProductType tmpRecHits_; @@ -36,19 +41,25 @@ class HcalCPURecHitsProducer : public edm::stream::EDProducer void HcalCPURecHitsProducer::fillDescriptions(edm::ConfigurationDescriptions& confDesc) { edm::ParameterSetDescription desc; - desc.add("recHitsM0LabelIn", edm::InputTag{"hbheRecHitProducerGPU", "recHitsM0HBHE"}); - desc.add("recHitsM0LabelOut", "recHitsM0HBHE"); - desc.add("recHitsLegacyLabelOut", "recHitsLegacyHBHE"); + desc.add("recHitsM0LabelIn", edm::InputTag{"hbheRecHitProducerGPU"}); + desc.add("recHitsM0LabelOut", ""); + desc.add("recHitsLegacyLabelOut", ""); + desc.add("produceSoA", true); + desc.add("produceLegacy", true); confDesc.addWithDefaultLabel(desc); } HcalCPURecHitsProducer::HcalCPURecHitsProducer(const edm::ParameterSet& ps) - : recHitsM0TokenIn_{consumes(ps.getParameter("recHitsM0LabelIn"))}, - recHitsM0TokenOut_{produces(ps.getParameter("recHitsM0LabelOut"))}, - recHitsLegacyTokenOut_{produces(ps.getParameter("recHitsLegacyLabelOut"))} {} - -HcalCPURecHitsProducer::~HcalCPURecHitsProducer() {} + : produceSoA_{ps.getParameter("produceSoA")}, + produceLegacy_{ps.getParameter("produceLegacy")}, + recHitsM0TokenIn_{consumes(ps.getParameter("recHitsM0LabelIn"))}, + recHitsM0TokenOut_{produceSoA_ ? produces(ps.getParameter("recHitsM0LabelOut")) + : edm::EDPutTokenT{}}, // empty token if disabled + recHitsLegacyTokenOut_{produceLegacy_ + ? produces(ps.getParameter("recHitsLegacyLabelOut")) + : edm::EDPutTokenT{}} // empty token if disabled +{} void HcalCPURecHitsProducer::acquire(edm::Event const& event, edm::EventSetup const& setup, @@ -81,26 +92,32 @@ void HcalCPURecHitsProducer::acquire(edm::Event const& event, } void HcalCPURecHitsProducer::produce(edm::Event& event, edm::EventSetup const& setup) { - // populate the legacy collection - auto recHitsLegacy = std::make_unique(); - // did not set size with ctor as there is no setter for did - recHitsLegacy->reserve(tmpRecHits_.did.size()); - for (uint32_t i = 0; i < tmpRecHits_.did.size(); i++) { - recHitsLegacy->emplace_back(HcalDetId{tmpRecHits_.did[i]}, - tmpRecHits_.energy[i], - 0 // timeRising - ); - - // update newly pushed guy - (*recHitsLegacy)[i].setChiSquared(tmpRecHits_.chi2[i]); - (*recHitsLegacy)[i].setRawEnergy(tmpRecHits_.energyM0[i]); + if (produceLegacy_) { + // populate the legacy collection + auto recHitsLegacy = std::make_unique(); + // did not set size with ctor as there is no setter for did + recHitsLegacy->reserve(tmpRecHits_.did.size()); + for (uint32_t i = 0; i < tmpRecHits_.did.size(); i++) { + recHitsLegacy->emplace_back(HcalDetId{tmpRecHits_.did[i]}, + tmpRecHits_.energy[i], + 0 // timeRising + ); + + // update newly pushed guy + (*recHitsLegacy)[i].setChiSquared(tmpRecHits_.chi2[i]); + (*recHitsLegacy)[i].setRawEnergy(tmpRecHits_.energyM0[i]); + } + + // put the legacy collection + event.put(recHitsLegacyTokenOut_, std::move(recHitsLegacy)); } - // put a legacy format - event.put(recHitsLegacyTokenOut_, std::move(recHitsLegacy)); - - // put a new format - event.emplace(recHitsM0TokenOut_, std::move(tmpRecHits_)); + if (produceSoA_) { + // put the SoA collection + event.emplace(recHitsM0TokenOut_, std::move(tmpRecHits_)); + } + // clear the temporary collection for the next event + tmpRecHits_.resize(0); } DEFINE_FWK_MODULE(HcalCPURecHitsProducer); From 33ef05739ed403d4af6ba915a406905080dbc5ca Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Wed, 21 Apr 2021 00:32:12 +0200 Subject: [PATCH 08/11] Make the HCAL 'gpu' workflow use a GPU if available, and fall-back to CPU otherwise --- .../python/Reconstruction_cff.py | 1 + .../python/OfflineSourceSequence_pp.py | 29 +++++++------ .../python/RecoLocalCalo_Cosmics_cff.py | 31 +++++++------- .../python/hcalGlobalReco_cff.py | 25 +++++++---- .../Configuration/python/hcalLocalReco_cff.py | 42 +++++++++---------- .../python/HBHE_custom_25nsMethod.py | 4 +- .../test/make_GPUvsCPU_HCAL_rechits.py | 22 +++++----- .../python/particleFlowRecHitHBHE_cfi.py | 5 ++- 8 files changed, 85 insertions(+), 74 deletions(-) diff --git a/Configuration/StandardSequences/python/Reconstruction_cff.py b/Configuration/StandardSequences/python/Reconstruction_cff.py index e03d228a857fb..62d03776be5de 100644 --- a/Configuration/StandardSequences/python/Reconstruction_cff.py +++ b/Configuration/StandardSequences/python/Reconstruction_cff.py @@ -235,6 +235,7 @@ bunchSpacingProducer, offlineBeamSpot, hcalOnlyLocalRecoTask, + hcalOnlyGlobalRecoTask, pfClusteringHBHEHFOnlyTask ) diff --git a/DQM/HcalTasks/python/OfflineSourceSequence_pp.py b/DQM/HcalTasks/python/OfflineSourceSequence_pp.py index 0543cf3aae84d..65172a4180be0 100644 --- a/DQM/HcalTasks/python/OfflineSourceSequence_pp.py +++ b/DQM/HcalTasks/python/OfflineSourceSequence_pp.py @@ -1,36 +1,41 @@ import FWCore.ParameterSet.Config as cms #----------------- -# HCAL DQM Offline Source Sequence Definition for pp -# To be used for Offline DQM importing +# HCAL DQM Offline Source Sequence Definition for pp +# To be used for Offline DQM importing #----------------- -# import the tasks +# import the tasks from DQM.HcalTasks.DigiTask import digiTask from DQM.HcalTasks.RawTask import rawTask from DQM.HcalTasks.TPTask import tpTask from DQM.HcalTasks.RecHitTask import recHitTask, recHitPreRecoTask -# set processing type to Offine +# set processing type to Offine digiTask.ptype = cms.untracked.int32(1) tpTask.ptype = cms.untracked.int32(1) recHitTask.ptype = cms.untracked.int32(1) rawTask.ptype = cms.untracked.int32(1) recHitPreRecoTask.ptype = cms.untracked.int32(1) -# set the label for Emulator TP Task +# set the label for Emulator TP Task tpTask.tagEmul = cms.untracked.InputTag("valHcalTriggerPrimitiveDigis") hcalOfflineSourceSequence = cms.Sequence( - digiTask - +tpTask - +recHitTask - +rawTask) + digiTask + + tpTask + + recHitTask + + rawTask ) hcalOnlyOfflineSourceSequence = cms.Sequence( - digiTask - +recHitPreRecoTask - +rawTask) + digiTask + + recHitPreRecoTask + + rawTask ) + +from Configuration.Eras.Modifier_run3_HB_cff import run3_HB +_phase1_hcalOnlyOfflineSourceSequence = hcalOnlyOfflineSourceSequence.copy() +_phase1_hcalOnlyOfflineSourceSequence.replace(recHitPreRecoTask, recHitTask) +run3_HB.toReplaceWith(hcalOnlyOfflineSourceSequence, _phase1_hcalOnlyOfflineSourceSequence) from Configuration.Eras.Modifier_phase2_hcal_cff import phase2_hcal _phase2_hcalOfflineSourceSequence = hcalOfflineSourceSequence.copyAndExclude([tpTask,rawTask]) diff --git a/RecoLocalCalo/Configuration/python/RecoLocalCalo_Cosmics_cff.py b/RecoLocalCalo/Configuration/python/RecoLocalCalo_Cosmics_cff.py index 40718749c65db..25b8fed436ae2 100644 --- a/RecoLocalCalo/Configuration/python/RecoLocalCalo_Cosmics_cff.py +++ b/RecoLocalCalo/Configuration/python/RecoLocalCalo_Cosmics_cff.py @@ -19,23 +19,20 @@ # sequence CaloLocalReco # -def hbheCosmic(module): - return module.clone( - tsFromDB = False, - recoParamsFromDB = False, - algorithm = dict( - useMahi = False, - useM2 = False, - useM3 = False, - firstSampleShift = -1000, - samplesToAdd = 10, - correctForPhaseContainment = False, - ), - sipmQTSShift = -100, - sipmQNTStoSum = 200, - ) - -hbhereco = hbheCosmic(_hcalLocalReco_cff.hbheprereco) +hbhereco = _hcalLocalReco_cff.hbheprereco.cpu.clone( + tsFromDB = False, + recoParamsFromDB = False, + algorithm = dict( + useMahi = False, + useM2 = False, + useM3 = False, + firstSampleShift = -1000, + samplesToAdd = 10, + correctForPhaseContainment = False, + ), + sipmQTSShift = -100, + sipmQNTStoSum = 200, +) hfreco = _hcalLocalReco_cff._default_hfreco.clone( firstSample = 0, samplesToAdd = 10, ### min(10,size) in the algo diff --git a/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py b/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py index fbb4c53f9f28b..30b7927d5753a 100644 --- a/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py @@ -1,21 +1,30 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA -from RecoLocalCalo.HcalRecProducers.HBHEIsolatedNoiseReflagger_cfi import * +#--- for Run 1 and Run 2 +from RecoLocalCalo.HcalRecProducers.HBHEIsolatedNoiseReflagger_cfi import hbhereco as _phase0_hbhereco +hbhereco = SwitchProducerCUDA( + cpu = _phase0_hbhereco +) hcalGlobalRecoTask = cms.Task(hbhereco) hcalGlobalRecoSequence = cms.Sequence(hcalGlobalRecoTask) +hcalOnlyGlobalRecoTask = cms.Task() +hcalOnlyGlobalRecoSequence = cms.Sequence(hcalOnlyGlobalRecoTask) + #--- for Run 3 and later from Configuration.Eras.Modifier_run3_HB_cff import run3_HB from RecoLocalCalo.HcalRecProducers.HBHEPhase1Reconstructor_cfi import hbheprereco as _phase1_hbheprereco -run3_HB.toReplaceWith(hbhereco, _phase1_hbheprereco) +run3_HB.toReplaceWith(hbhereco.cpu, _phase1_hbheprereco) +run3_HB.toReplaceWith(hcalOnlyGlobalRecoTask, cms.Task(hbhereco)) #--- for Run 3 on GPU from Configuration.ProcessModifiers.gpu_cff import gpu -from RecoLocalCalo.HcalRecProducers.hcalCPURecHitsProducer_cfi import hcalCPURecHitsProducer as _hcalCPURecHitsProducer -gpu.toReplaceWith(hbhereco, _hcalCPURecHitsProducer.clone( - recHitsM0LabelIn = "hbheRecHitProducerGPU", - recHitsM0LabelOut = "", - recHitsLegacyLabelOut = "" -)) +from RecoLocalCalo.HcalRecProducers.hcalCPURecHitsProducer_cfi import hcalCPURecHitsProducer as _hbherecoFromCUDA +(run3_HB & gpu).toModify(hbhereco, + cuda = _hbherecoFromCUDA.clone( + produceSoA = False + ) +) diff --git a/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py b/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py index a7bdce3b916af..4c68380d686ac 100644 --- a/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py @@ -1,15 +1,18 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA from RecoLocalCalo.HcalRecAlgos.hcalRecAlgoESProd_cfi import * from RecoLocalCalo.HcalRecAlgos.hcalChannelPropertiesESProd_cfi import * hcalOOTPileupESProducer = cms.ESProducer('OOTPileupDBCompatibilityESProducer') from RecoLocalCalo.HcalRecProducers.HBHEPhase1Reconstructor_cfi import hbheprereco as _phase1_hbheprereco -hbheprereco = _phase1_hbheprereco.clone( - processQIE11 = False, - tsFromDB = True, - pulseShapeParametersQIE8 = dict( - TrianglePeakTS = 4, +hbheprereco = SwitchProducerCUDA( + cpu = _phase1_hbheprereco.clone( + processQIE11 = False, + tsFromDB = True, + pulseShapeParametersQIE8 = dict( + TrianglePeakTS = 4, + ) ) ) @@ -34,7 +37,7 @@ run2_HF_2017.toReplaceWith( hcalLocalRecoTask, _phase1_hcalLocalRecoTask ) run2_HF_2017.toReplaceWith( hfreco, _phase1_hfreco ) from Configuration.Eras.Modifier_run2_HCAL_2017_cff import run2_HCAL_2017 -run2_HCAL_2017.toReplaceWith(hbheprereco, _phase1_hbheprereco) +run2_HCAL_2017.toReplaceWith(hbheprereco.cpu, _phase1_hbheprereco) _plan1_hcalLocalRecoTask = _phase1_hcalLocalRecoTask.copy() _plan1_hcalLocalRecoTask.add(hbheplan1) @@ -57,27 +60,20 @@ from Configuration.ProcessModifiers.gpu_cff import gpu from RecoLocalCalo.HcalRecProducers.hbheRecHitProducerGPUTask_cff import * -_run3_hcalLocalRecoGPUTask = _run3_hcalLocalRecoTask.copy() +_run3_hcalLocalRecoGPUTask = hcalLocalRecoTask.copy() _run3_hcalLocalRecoGPUTask.add(hbheRecHitProducerGPUTask) gpu.toReplaceWith(hcalLocalRecoTask, _run3_hcalLocalRecoGPUTask) -#--- HCAL-only workflow for Run 3 -# FIXME rename `hbheprereco` to `hbhereco` and use it from hcalGlobalRecoTask -hcalOnlyLocalRecoTask = cms.Task(hbheprereco, hfprereco, hfreco, horeco) +#--- HCAL-only workflow +hcalOnlyLocalRecoTask = hcalLocalRecoTask.copyAndExclude([zdcreco]) -#--- HCAL-only workflow for Run 3 on GPU -from Configuration.ProcessModifiers.gpu_cff import gpu - -_hcalOnlyLocalRecoGPUTask = hcalOnlyLocalRecoTask.copy() -_hcalOnlyLocalRecoGPUTask.add(hbheRecHitProducerGPUTask) -gpu.toReplaceWith(hcalOnlyLocalRecoTask, _hcalOnlyLocalRecoGPUTask) - -from RecoLocalCalo.HcalRecProducers.hcalCPURecHitsProducer_cfi import hcalCPURecHitsProducer as _hcalCPURecHitsProducer -gpu.toReplaceWith(hbheprereco, _hcalCPURecHitsProducer.clone( - recHitsM0LabelIn = "hbheRecHitProducerGPU", - recHitsM0LabelOut = "", - recHitsLegacyLabelOut = "" -)) +#--- HCAL-only workflow for Run 2 on GPU +from RecoLocalCalo.HcalRecProducers.hcalCPURecHitsProducer_cfi import hcalCPURecHitsProducer as _hbheprerecoFromCUDA +(gpu & ~run3_HB).toModify(hbheprereco, + cuda = _hbheprerecoFromCUDA.clone( + produceSoA = False + ) +) #--- for FastSim _fastSim_hcalLocalRecoTask = hcalLocalRecoTask.copyAndExclude([zdcreco]) diff --git a/RecoLocalCalo/HcalRecProducers/python/HBHE_custom_25nsMethod.py b/RecoLocalCalo/HcalRecProducers/python/HBHE_custom_25nsMethod.py index 455f3df9178f2..988a4b4a2b3cc 100644 --- a/RecoLocalCalo/HcalRecProducers/python/HBHE_custom_25nsMethod.py +++ b/RecoLocalCalo/HcalRecProducers/python/HBHE_custom_25nsMethod.py @@ -2,11 +2,11 @@ def customise_HBHE_Method1(process): if hasattr(process,'hbheprereco'): - process.hbheprereco.puCorrMethod = cms.int32(1) + process.hbheprereco.cpu.puCorrMethod = cms.int32(1) return process def customise_HBHE_Method0(process): if hasattr(process,'hbheprereco'): - process.hbheprereco.puCorrMethod = cms.int32(0) + process.hbheprereco.cpu.puCorrMethod = cms.int32(0) return process diff --git a/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py b/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py index 8c7162bc076c4..0ce9caf13fa88 100644 --- a/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py +++ b/RecoLocalCalo/HcalRecProducers/test/make_GPUvsCPU_HCAL_rechits.py @@ -59,32 +59,32 @@ #process.hbheprereco.algorithm.correctForPhaseContainment = cms.bool(False) ## do always 8 pulse -process.hbheprereco.algorithm.chiSqSwitch = cms.double(-1) +process.hbheprereco.cpu.algorithm.chiSqSwitch = cms.double(-1) ## to match hard coded setting (will be fixed on CPU) -process.hbheprereco.algorithm.nMaxItersMin = cms.int32(50) +process.hbheprereco.cpu.algorithm.nMaxItersMin = cms.int32(50) #----------------------------------------- # Final Custmization for Run3 #----------------------------------------- # we will not run arrival Time at HLT -process.hbheprereco.algorithm.calculateArrivalTime = cms.bool(False) +process.hbheprereco.cpu.algorithm.calculateArrivalTime = cms.bool(False) ## we do not need this -process.hbheprereco.algorithm.applyLegacyHBMCorrection = cms.bool(False) +process.hbheprereco.cpu.algorithm.applyLegacyHBMCorrection = cms.bool(False) # we only run Mahi at HLT -process.hbheprereco.algorithm.useM3 = cms.bool(False) +process.hbheprereco.cpu.algorithm.useM3 = cms.bool(False) # we will not have the HPD noise flags in Run3, as will be all siPM -process.hbheprereco.setLegacyFlagsQIE8 = cms.bool(False) -process.hbheprereco.setNegativeFlagsQIE8 = cms.bool(False) -process.hbheprereco.setNoiseFlagsQIE8 = cms.bool(False) -process.hbheprereco.setPulseShapeFlagsQIE8 = cms.bool(False) +process.hbheprereco.cpu.setLegacyFlagsQIE8 = cms.bool(False) +process.hbheprereco.cpu.setNegativeFlagsQIE8 = cms.bool(False) +process.hbheprereco.cpu.setNoiseFlagsQIE8 = cms.bool(False) +process.hbheprereco.cpu.setPulseShapeFlagsQIE8 = cms.bool(False) # for testing M0 only -##process.hbheprereco.algorithm.useMahi = cms.bool(False) +##process.hbheprereco.cpu.algorithm.useMahi = cms.bool(False) #----------------------------------------- # OUTPUT @@ -148,4 +148,4 @@ # report CUDAService messages process.MessageLogger.cerr.FwkReport.reportEvery = 100 -process.MessageLogger.categories.append("CUDAService") +process.MessageLogger.CUDAService = cms.untracked.PSet() diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py index c8939961bd36e..815e60d3c2b5a 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py @@ -56,5 +56,8 @@ # HCALonly WF particleFlowRecHitHBHEOnly = particleFlowRecHitHBHE.clone( - producers = { 0: dict(src = "hbheprereco:") } + producers = { 0: dict(src = "hbheprereco") } +) +run3_HB.toModify(particleFlowRecHitHBHEOnly, + producers = { 0: dict(src = "hbhereco") } ) From 3ead0e533a54c595cc7ff82a3fded9b7c37b597e Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Fri, 23 Apr 2021 00:07:21 +0200 Subject: [PATCH 09/11] Rework the definition of the Patatrack pixel workflows Drop the obsolete pixelNtupleFit modifier, and replace the customizePixelTracksSoAonCPU function with the pixelNtupletFit modifier. Make the "gpu" workflows autodetect if a GPU is a present, and fall back to running only on CPU otherwise. Update the name of the modules for better consistency. --- .../python/Reconstruction_cff.py | 18 +-- .../python/pixelNtupleFit_cff.py | 5 - .../python/pixelNtupletFit_cff.py | 7 + .../python/relval_steps.py | 11 +- .../python/upgradeWorkflowComponents.py | 11 +- .../StandardSequences/python/RawToDigi_cff.py | 2 +- .../StandardSequences/python/Services_cff.py | 5 +- .../python/SiPixelRawToDigiRegional_cfi.py | 2 +- .../python/SiPixelRawToDigi_cfi.py | 13 +- .../python/siPixelDigis_cff.py | 39 ++++-- .../python/RecoLocalTracker_cff.py | 20 ++- .../SiPixelClusterizerPreSplitting_cfi.py | 10 +- .../python/siPixelClustersPreSplitting_cff.py | 42 ++++-- .../python/SiPixelRecHits_cfi.py | 50 +++---- .../python/RecoPixelVertexing_cff.py | 70 +++++++--- .../python/customizePixelTracksForTriplets.py | 10 ++ .../python/customizePixelTracksSoAonCPU.py | 62 --------- .../plugins/PixelTrackDumpCUDA.cc | 2 +- .../plugins/PixelTrackProducerFromSoA.cc | 2 +- .../plugins/PixelTrackSoAFromCUDA.cc | 4 +- .../python/PixelTracks_cff.py | 124 ++++++++++++------ .../PixelTriplets/plugins/CAHitNtupletCUDA.cc | 2 +- .../plugins/PixelVertexProducerCUDA.cc | 2 +- .../python/PixelVertexes_cff.py | 6 +- .../python/customizePixelOnlyForProfiling.py | 4 +- 25 files changed, 304 insertions(+), 219 deletions(-) delete mode 100644 Configuration/ProcessModifiers/python/pixelNtupleFit_cff.py create mode 100644 Configuration/ProcessModifiers/python/pixelNtupletFit_cff.py create mode 100644 RecoPixelVertexing/Configuration/python/customizePixelTracksForTriplets.py delete mode 100644 RecoPixelVertexing/Configuration/python/customizePixelTracksSoAonCPU.py diff --git a/CalibTracker/Configuration/python/Reconstruction_cff.py b/CalibTracker/Configuration/python/Reconstruction_cff.py index f6cafe076db9e..5e20b01ceb9a2 100644 --- a/CalibTracker/Configuration/python/Reconstruction_cff.py +++ b/CalibTracker/Configuration/python/Reconstruction_cff.py @@ -1,24 +1,24 @@ import FWCore.ParameterSet.Config as cms -#local reconstruction +# local reconstruction from EventFilter.SiPixelRawToDigi.SiPixelRawToDigi_cfi import * from EventFilter.SiStripRawToDigi.SiStripDigis_cfi import * from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizerPreSplitting_cfi import * from RecoLocalTracker.SiStripZeroSuppression.SiStripZeroSuppression_cfi import * from RecoLocalTracker.SiStripClusterizer.SiStripClusterizer_cfi import * -recolocal = cms.Sequence( siPixelDigis*siPixelClustersPreSplitting*siStripDigis*siStripZeroSuppression*siStripClusters) -siPixelDigis.InputLabel = 'rawDataCollector' +recolocal = cms.Sequence(siPixelDigis + siPixelClustersPreSplitting + siStripDigis + siStripZeroSuppression + siStripClusters) +siPixelDigis.cpu.InputLabel = 'rawDataCollector' -#tracking +# tracking from RecoVertex.BeamSpotProducer.BeamSpot_cff import * from RecoLocalTracker.SiPixelRecHits.SiPixelRecHits_cfi import * from RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitConverter_cfi import * from RecoTracker.Configuration.RecoTracker_cff import * from RecoTracker.Configuration.RecoTrackerP5_cff import * from RecoPixelVertexing.Configuration.RecoPixelVertexing_cff import * -recotrack = cms.Sequence( offlineBeamSpot + siPixelRecHitsPreSplitting*siStripMatchedRecHits*recopixelvertexing*ckftracks) -recotrackP5 = cms.Sequence( offlineBeamSpot + siPixelRecHitsPreSplitting*siStripMatchedRecHits*recopixelvertexing*ctftracksP5) +recotrack = cms.Sequence(offlineBeamSpot + siPixelRecHitsPreSplitting + siStripMatchedRecHits + recopixelvertexing + ckftracks) +recotrackP5 = cms.Sequence(offlineBeamSpot + siPixelRecHitsPreSplitting + siStripMatchedRecHits + recopixelvertexing + ctftracksP5) -#Schedule -reconstruction_step = cms.Path( recolocal + recotrack ) -reconstructionP5_step = cms.Path( recolocal + recotrackP5 ) +# Schedule +reconstruction_step = cms.Path(recolocal + recotrack) +reconstructionP5_step = cms.Path(recolocal + recotrackP5) diff --git a/Configuration/ProcessModifiers/python/pixelNtupleFit_cff.py b/Configuration/ProcessModifiers/python/pixelNtupleFit_cff.py deleted file mode 100644 index db8a2ac229a02..0000000000000 --- a/Configuration/ProcessModifiers/python/pixelNtupleFit_cff.py +++ /dev/null @@ -1,5 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -# This modifier is for replacing the default pixel track "fitting" with eihter Riemann or BrokenLine fit - -pixelNtupleFit = cms.Modifier() diff --git a/Configuration/ProcessModifiers/python/pixelNtupletFit_cff.py b/Configuration/ProcessModifiers/python/pixelNtupletFit_cff.py new file mode 100644 index 0000000000000..94b14a4f5a6e3 --- /dev/null +++ b/Configuration/ProcessModifiers/python/pixelNtupletFit_cff.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +# This modifier is for replacing the legacy pixel tracks with the "Patatrack" pixel ntuplets, +# fishbone cleaning, and either the Broken Line fit (by default) or the Riemann fit. +# It also replaces the "gap" pixel vertices with a density-based vertex reconstruction algorithm. + +pixelNtupletFit = cms.Modifier() diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 97235248c83b6..f25b5178c1fd8 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -2187,10 +2187,13 @@ def gen2021HiMix(fragment,howMuch): } step3_pixel_ntuplet_cpu = { - '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU' + '--procModifiers': 'pixelNtupletFit' +} +step3_pixel_ntuplet_gpu = { + '--procModifiers': 'pixelNtupletFit,gpu' } step3_pixel_triplets = { - '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' + '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksForTriplets.customizePixelTracksForTriplets' } step3_gpu = { '--procModifiers': 'gpu', @@ -2324,9 +2327,9 @@ def gen2021HiMix(fragment,howMuch): steps['RECODR2_2018reHLT_ZBPrompt']=merge([{'--conditions':'auto:run2_data','-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,ALCA:SiStripCalZeroBias+SiStripCalMinBias+TkAlMinBias+EcalESAlign,DQM:@rerecoZeroBias+@ExtraHLT+@miniAODDQM'},steps['RECODR2_2018reHLT']]) steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']=merge([{'-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,DQM:@pixelTrackingOnlyDQM'},steps['RECODR2_2018reHLT_Prompt']]) steps['RECODR2_2018reHLT_Patatrack_PixelOnlyCPU']=merge([step3_pixel_ntuplet_cpu, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) -steps['RECODR2_2018reHLT_Patatrack_PixelOnlyGPU']=merge([step3_gpu, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) +steps['RECODR2_2018reHLT_Patatrack_PixelOnlyGPU']=merge([step3_pixel_ntuplet_gpu, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) steps['RECODR2_2018reHLT_Patatrack_PixelOnlyTripletsCPU']=merge([step3_pixel_ntuplet_cpu, step3_pixel_triplets, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) -steps['RECODR2_2018reHLT_Patatrack_PixelOnlyTripletsGPU']=merge([step3_gpu, step3_pixel_triplets, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) +steps['RECODR2_2018reHLT_Patatrack_PixelOnlyTripletsGPU']=merge([step3_pixel_ntuplet_gpu, step3_pixel_triplets, steps['RECODR2_2018reHLT_Prompt_pixelTrackingOnly']]) steps['RECODR2_2018reHLT_ECALOnlyCPU']=merge([{'-s': 'RAW2DIGI:RawToDigi_ecalOnly,RECO:reconstruction_ecalOnly,DQM:@ecalOnly'},steps['RECODR2_2018reHLT_Prompt']]) steps['RECODR2_2018reHLT_ECALOnlyGPU']=merge([step3_gpu, steps['RECODR2_2018reHLT_ECALOnlyCPU']]) diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index ff88d3b0c0546..492ff70c2c91c 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -444,7 +444,7 @@ def setup_(self, step, stepName, stepDict, k, properties): upgradeWFs['PatatrackPixelOnlyCPU'] = PatatrackWorkflow( reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU' + '--procModifiers': 'pixelNtupletFit' }, harvest = { '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' @@ -456,7 +456,7 @@ def setup_(self, step, stepName, stepDict, k, properties): upgradeWFs['PatatrackPixelOnlyGPU'] = PatatrackWorkflow( reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--procModifiers': 'gpu' + '--procModifiers': 'pixelNtupletFit,gpu' }, harvest = { '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' @@ -468,7 +468,8 @@ def setup_(self, step, stepName, stepDict, k, properties): upgradeWFs['PatatrackPixelOnlyTripletsCPU'] = PatatrackWorkflow( reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksSoAonCPU,RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' + '--procModifiers': 'pixelNtupletFit', + '--customise' : 'RecoPixelVertexing/Configuration/customizePixelTracksForTriplets.customizePixelTracksForTriplets' }, harvest = { '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' @@ -480,8 +481,8 @@ def setup_(self, step, stepName, stepDict, k, properties): upgradeWFs['PatatrackPixelOnlyTripletsGPU'] = PatatrackWorkflow( reco = { '-s': 'RAW2DIGI:RawToDigi_pixelOnly,RECO:reconstruction_pixelTrackingOnly,VALIDATION:@pixelTrackingOnlyValidation,DQM:@pixelTrackingOnlyDQM', - '--procModifiers': 'gpu', - '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksSoAonCPU.customizePixelTracksForTriplets' + '--procModifiers': 'pixelNtupletFit,gpu', + '--customise': 'RecoPixelVertexing/Configuration/customizePixelTracksForTriplets.customizePixelTracksForTriplets' }, harvest = { '-s': 'HARVESTING:@trackingOnlyValidation+@pixelTrackingOnlyDQM' diff --git a/Configuration/StandardSequences/python/RawToDigi_cff.py b/Configuration/StandardSequences/python/RawToDigi_cff.py index 60ed421a6205f..ef77578a7775d 100644 --- a/Configuration/StandardSequences/python/RawToDigi_cff.py +++ b/Configuration/StandardSequences/python/RawToDigi_cff.py @@ -87,7 +87,7 @@ run3_common.toReplaceWith(RawToDigiTask, RawToDigiTask.copyAndExclude([castorDigis])) from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker -# Remove siPixelDigis until we have phase1 pixel digis +# Remove siPixelDigis until we have Phase 2 pixel digis phase2_tracker.toReplaceWith(RawToDigiTask, RawToDigiTask.copyAndExclude([siPixelDigis])) # FIXME diff --git a/Configuration/StandardSequences/python/Services_cff.py b/Configuration/StandardSequences/python/Services_cff.py index ef1da8dec1d59..0949c7b8d4972 100644 --- a/Configuration/StandardSequences/python/Services_cff.py +++ b/Configuration/StandardSequences/python/Services_cff.py @@ -8,12 +8,13 @@ # DQM store service from DQMServices.Core.DQMStore_cfi import * -# load CUDA services when the "gpu" modifier is enabled +# load CUDA services when the "gpu" or "pixelNtupletFit" modifiers are enabled def _addCUDAServices(process): process.load("HeterogeneousCore.CUDAServices.CUDAService_cfi") from Configuration.ProcessModifiers.gpu_cff import gpu -modifyConfigurationStandardSequencesServicesAddCUDAServices_ = gpu.makeProcessModifier(_addCUDAServices) +from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit +modifyConfigurationStandardSequencesServicesAddCUDAServices_ = (gpu | pixelNtupletFit).makeProcessModifier(_addCUDAServices) # load TritonService when SONIC workflow is enabled def _addTritonService(process): diff --git a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigiRegional_cfi.py b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigiRegional_cfi.py index 34897891cd323..81622b3b9d1e1 100644 --- a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigiRegional_cfi.py +++ b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigiRegional_cfi.py @@ -3,7 +3,7 @@ from EventFilter.SiPixelRawToDigi.SiPixelRawToDigi_cfi import * ## regional seeded unpacking for specialized HLT paths -siPixelDigisRegional = siPixelDigis.clone() +siPixelDigisRegional = siPixelDigis.cpu.clone() siPixelDigisRegional.Regions = cms.PSet( inputs = cms.VInputTag( "hltL2EtCutDoublePFIsoTau45Trk5" ), deltaPhi = cms.vdouble( 0.5 ), diff --git a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py index 50c8f0fcabd3c..13fff5e0e1600 100644 --- a/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py +++ b/EventFilter/SiPixelRawToDigi/python/SiPixelRawToDigi_cfi.py @@ -1,15 +1,20 @@ import FWCore.ParameterSet.Config as cms -from EventFilter.SiPixelRawToDigi.siPixelRawToDigi_cfi import siPixelRawToDigi as _siPixelRawToDigi - from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA +from Configuration.ProcessModifiers.gpu_cff import gpu + +# legacy pixel unpacker +from EventFilter.SiPixelRawToDigi.siPixelRawToDigi_cfi import siPixelRawToDigi as _siPixelRawToDigi siPixelDigis = SwitchProducerCUDA( cpu = _siPixelRawToDigi.clone() ) +# use the Phase 1 settings from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel -phase1Pixel.toModify(siPixelDigis.cpu, UsePhase1=True) +phase1Pixel.toModify(siPixelDigis.cpu, + UsePhase1 = True +) -from Configuration.ProcessModifiers.gpu_cff import gpu +# SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA gpu.toModify(siPixelDigis, cuda = cms.EDAlias( siPixelDigiErrors = cms.VPSet( diff --git a/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py b/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py index 5c1ff74be9c69..8a84ba90b5ac0 100644 --- a/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py +++ b/EventFilter/SiPixelRawToDigi/python/siPixelDigis_cff.py @@ -1,30 +1,43 @@ import FWCore.ParameterSet.Config as cms from EventFilter.SiPixelRawToDigi.SiPixelRawToDigi_cfi import siPixelDigis -from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA -from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA -from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA -siPixelDigisTask = cms.Task(siPixelDigis) +siPixelDigisTask = cms.Task( + # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA + siPixelDigis +) +# copy the pixel digis (except errors) and clusters to the host +from EventFilter.SiPixelRawToDigi.siPixelDigisSoAFromCUDA_cfi import siPixelDigisSoAFromCUDA as _siPixelDigisSoAFromCUDA siPixelDigisSoA = _siPixelDigisSoAFromCUDA.clone( src = "siPixelClustersPreSplittingCUDA" ) + +# copy the pixel digis errors to the host +from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsSoAFromCUDA_cfi import siPixelDigiErrorsSoAFromCUDA as _siPixelDigiErrorsSoAFromCUDA siPixelDigiErrorsSoA = _siPixelDigiErrorsSoAFromCUDA.clone( src = "siPixelClustersPreSplittingCUDA" ) + +# convert the pixel digis errors to the legacy format +from EventFilter.SiPixelRawToDigi.siPixelDigiErrorsFromSoA_cfi import siPixelDigiErrorsFromSoA as _siPixelDigiErrorsFromSoA siPixelDigiErrors = _siPixelDigiErrorsFromSoA.clone() +# use the Phase 1 settings from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel -phase1Pixel.toModify(siPixelDigiErrors, UsePhase1=True) - -siPixelDigisTaskCUDA = cms.Task( - siPixelDigisSoA, - siPixelDigiErrorsSoA, - siPixelDigiErrors +phase1Pixel.toModify(siPixelDigiErrors, + UsePhase1 = True ) + from Configuration.ProcessModifiers.gpu_cff import gpu -_siPixelDigisTask_gpu = siPixelDigisTask.copy() -_siPixelDigisTask_gpu.add(siPixelDigisTaskCUDA) -gpu.toReplaceWith(siPixelDigisTask, _siPixelDigisTask_gpu) +gpu.toReplaceWith(siPixelDigisTask, cms.Task( + # copy the pixel digis (except errors) and clusters to the host + siPixelDigisSoA, + # copy the pixel digis errors to the host + siPixelDigiErrorsSoA, + # convert the pixel digis errors to the legacy format + siPixelDigiErrors, + # SwitchProducer wrapping the legacy pixel digis producer or an alias combining the pixel digis information converted from SoA + siPixelDigisTask.copy() +)) diff --git a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py index 35a72f0edb08f..809c440effb53 100644 --- a/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py +++ b/RecoLocalTracker/Configuration/python/RecoLocalTracker_cff.py @@ -1,9 +1,7 @@ import FWCore.ParameterSet.Config as cms -# # Tracker Local Reco -# Initialize magnetic field -# + from RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitConverter_cfi import * from RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitMatcher_cfi import * from RecoLocalTracker.SiStripRecHitConverter.StripCPEfromTrackAngle_cfi import * @@ -13,9 +11,19 @@ from RecoLocalTracker.SiPixelRecHits.SiPixelRecHits_cfi import * from RecoLocalTracker.SubCollectionProducers.clustersummaryproducer_cfi import * -pixeltrackerlocalrecoTask = cms.Task(siPixelClustersPreSplittingTask,siPixelRecHitsPreSplittingTask) -striptrackerlocalrecoTask = cms.Task(siStripZeroSuppression,siStripClusters,siStripMatchedRecHits) -trackerlocalrecoTask = cms.Task(pixeltrackerlocalrecoTask,striptrackerlocalrecoTask,clusterSummaryProducer) +pixeltrackerlocalrecoTask = cms.Task( + siPixelClustersPreSplittingTask, + siPixelRecHitsPreSplittingTask) + +striptrackerlocalrecoTask = cms.Task( + siStripZeroSuppression, + siStripClusters, + siStripMatchedRecHits) + +trackerlocalrecoTask = cms.Task( + pixeltrackerlocalrecoTask, + striptrackerlocalrecoTask, + clusterSummaryProducer) pixeltrackerlocalreco = cms.Sequence(pixeltrackerlocalrecoTask) striptrackerlocalreco = cms.Sequence(striptrackerlocalrecoTask) diff --git a/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py b/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py index b9c6862b015bf..f3675134fb84d 100644 --- a/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py +++ b/RecoLocalTracker/SiPixelClusterizer/python/SiPixelClusterizerPreSplitting_cfi.py @@ -1,14 +1,22 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA +# SiPixelGainCalibrationServiceParameters from CondTools.SiPixel.SiPixelGainCalibrationService_cfi import * + +# legacy pixel cluster producer from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizer_cfi import siPixelClusters as _siPixelClusters -from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA siPixelClustersPreSplitting = SwitchProducerCUDA( cpu = _siPixelClusters.clone() ) from Configuration.ProcessModifiers.gpu_cff import gpu +# SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA gpu.toModify(siPixelClustersPreSplitting, + # ensure the same results when running on GPU (which supports only the 'HLT' payload) and CPU + cpu = dict( + payloadType = 'HLT' + ), cuda = cms.EDAlias( siPixelDigisClustersPreSplitting = cms.VPSet( cms.PSet(type = cms.string("SiPixelClusteredmNewDetSetVector")) diff --git a/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py b/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py index 8bbf47e9ebf90..50e47edbcce26 100644 --- a/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py +++ b/RecoLocalTracker/SiPixelClusterizer/python/siPixelClustersPreSplitting_cff.py @@ -1,26 +1,40 @@ import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Modifier_run3_common_cff import run3_common +from Configuration.ProcessModifiers.gpu_cff import gpu +# conditions used *only* by the modules running on GPU +from CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi import siPixelROCsStatusAndMappingWrapperESProducer +from CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi import siPixelGainCalibrationForHLTGPU + +# SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizerPreSplitting_cfi import siPixelClustersPreSplitting -from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA -from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA -from CalibTracker.SiPixelESProducers.siPixelROCsStatusAndMappingWrapperESProducer_cfi import * -from CalibTracker.SiPixelESProducers.siPixelGainCalibrationForHLTGPU_cfi import * -siPixelClustersPreSplittingTask = cms.Task(siPixelClustersPreSplitting) +siPixelClustersPreSplittingTask = cms.Task( + # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA + siPixelClustersPreSplitting +) +# reconstruct the pixel digis and clusters on the gpu +from RecoLocalTracker.SiPixelClusterizer.siPixelRawToClusterCUDA_cfi import siPixelRawToClusterCUDA as _siPixelRawToClusterCUDA siPixelClustersPreSplittingCUDA = _siPixelRawToClusterCUDA.clone() -from Configuration.Eras.Modifier_run3_common_cff import run3_common + run3_common.toModify(siPixelClustersPreSplittingCUDA, - isRun2=False + # use the pixel channel calibrations scheme for Run 3 + isRun2 = False ) +# convert the pixel digis (except errors) and clusters to the legacy format +from RecoLocalTracker.SiPixelClusterizer.siPixelDigisClustersFromSoA_cfi import siPixelDigisClustersFromSoA as _siPixelDigisClustersFromSoA siPixelDigisClustersPreSplitting = _siPixelDigisClustersFromSoA.clone() -siPixelClustersPreSplittingTaskCUDA = cms.Task( + +gpu.toReplaceWith(siPixelClustersPreSplittingTask, cms.Task( + # conditions used *only* by the modules running on GPU + siPixelROCsStatusAndMappingWrapperESProducer, + siPixelGainCalibrationForHLTGPU, + # reconstruct the pixel digis and clusters on the gpu siPixelClustersPreSplittingCUDA, + # convert the pixel digis (except errors) and clusters to the legacy format siPixelDigisClustersPreSplitting, -) - -from Configuration.ProcessModifiers.gpu_cff import gpu -_siPixelClustersPreSplittingTask_gpu = siPixelClustersPreSplittingTask.copy() -_siPixelClustersPreSplittingTask_gpu.add(siPixelClustersPreSplittingTaskCUDA) -gpu.toReplaceWith(siPixelClustersPreSplittingTask, _siPixelClustersPreSplittingTask_gpu) + # SwitchProducer wrapping the legacy pixel cluster producer or an alias for the pixel clusters information converted from SoA + siPixelClustersPreSplittingTask.copy() +)) diff --git a/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py b/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py index eb9dbad4934cd..8430b19f1e9be 100644 --- a/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py +++ b/RecoLocalTracker/SiPixelRecHits/python/SiPixelRecHits_cfi.py @@ -1,44 +1,46 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA +from Configuration.ProcessModifiers.gpu_cff import gpu +# legacy pixel rechit producer siPixelRecHits = cms.EDProducer("SiPixelRecHitConverter", src = cms.InputTag("siPixelClusters"), CPE = cms.string('PixelCPEGeneric'), VerboseLevel = cms.untracked.int32(0) ) -_siPixelRecHitsPreSplitting = siPixelRecHits.clone( - src = 'siPixelClustersPreSplitting' -) - -from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA +# SwitchProducer wrapping the legacy pixel rechit producer siPixelRecHitsPreSplitting = SwitchProducerCUDA( - cpu = _siPixelRecHitsPreSplitting.clone() + cpu = siPixelRecHits.clone( + src = 'siPixelClustersPreSplitting' + ) ) +# convert the pixel rechits from legacy to SoA format +from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy as siPixelRecHitsPreSplittingSoA - -from Configuration.ProcessModifiers.gpu_cff import gpu -from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA -from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA - -gpu.toModify(siPixelRecHitsPreSplitting, - cuda = _siPixelRecHitFromCUDA.clone() +siPixelRecHitsPreSplittingTask = cms.Task( + # SwitchProducer wrapping the legacy pixel rechit producer + siPixelRecHitsPreSplitting, + # convert the pixel rechits from legacy to SoA format + siPixelRecHitsPreSplittingSoA ) - -siPixelRecHitsPreSplittingTask = cms.Task(siPixelRecHitsPreSplitting) - +# reconstruct the pixel rechits on the gpu +from RecoLocalTracker.SiPixelRecHits.siPixelRecHitCUDA_cfi import siPixelRecHitCUDA as _siPixelRecHitCUDA siPixelRecHitsPreSplittingCUDA = _siPixelRecHitCUDA.clone( beamSpot = "offlineBeamSpotToCUDA" ) -siPixelRecHitsPreSplittingLegacy = _siPixelRecHitFromCUDA.clone() -siPixelRecHitsPreSplittingTaskCUDA = cms.Task( - siPixelRecHitsPreSplittingCUDA, - siPixelRecHitsPreSplittingLegacy, +# transfer the pixel rechits to the host and convert them from SoA +from RecoLocalTracker.SiPixelRecHits.siPixelRecHitFromCUDA_cfi import siPixelRecHitFromCUDA as _siPixelRecHitFromCUDA +gpu.toModify(siPixelRecHitsPreSplitting, + cuda = _siPixelRecHitFromCUDA.clone() ) -from Configuration.ProcessModifiers.gpu_cff import gpu -_siPixelRecHitsPreSplittingTask_gpu = siPixelRecHitsPreSplittingTask.copy() -_siPixelRecHitsPreSplittingTask_gpu.add(siPixelRecHitsPreSplittingTaskCUDA) -gpu.toReplaceWith(siPixelRecHitsPreSplittingTask, _siPixelRecHitsPreSplittingTask_gpu) +gpu.toReplaceWith(siPixelRecHitsPreSplittingTask, cms.Task( + # reconstruct the pixel rechits on the gpu + siPixelRecHitsPreSplittingCUDA, + # SwitchProducer wrapping the legacy pixel rechit producer or the transfer of the pixel rechits to the host and the conversion from SoA + siPixelRecHitsPreSplittingTask.copy() +)) diff --git a/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py b/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py index 4b32839e21b0e..391055bd870e8 100644 --- a/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py +++ b/RecoPixelVertexing/Configuration/python/RecoPixelVertexing_cff.py @@ -1,29 +1,67 @@ import FWCore.ParameterSet.Config as cms +from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA from RecoPixelVertexing.PixelTrackFitting.PixelTracks_cff import * -# -# for STARTUP ONLY use try and use Offline 3D PV from pixelTracks, with adaptive vertex -# from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cff import * -#from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import * -recopixelvertexingTask = cms.Task(pixelTracksTask, pixelVertices) -from Configuration.ProcessModifiers.gpu_cff import gpu -_recopixelvertexingTask_gpu = recopixelvertexingTask.copy() +# legacy pixel vertex reconsruction using the divisive vertex finder +pixelVerticesTask = cms.Task( + pixelVertices +) -from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA -_recopixelvertexingTask_gpu.add(pixelVertexCUDA) +# "Patatrack" pixel ntuplets, fishbone cleaning, Broken Line fit, and density-based vertex reconstruction +from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit -from RecoPixelVertexing.PixelVertexFinding.pixelVertexSoA_cfi import pixelVertexSoA -_recopixelvertexingTask_gpu.add(pixelVertexSoA) +# build the pixel vertices in SoA format on the CPU +from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA as _pixelVertexCUDA +pixelVerticesSoA = SwitchProducerCUDA( + cpu = _pixelVertexCUDA.clone( + pixelTrackSrc = "pixelTracksSoA", + onGPU = False + ) +) +# convert the pixel vertices from SoA to legacy format from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA as _pixelVertexFromSoA -# this is needed because the 'pixelTrack' EDAlias does not contain the 'ushorts' collections -_pixelVertexFromSoA.TrackCollection = 'pixelTrackFromSoA' -gpu.toModify(pixelVertices, - cuda = _pixelVertexFromSoA +pixelNtupletFit.toReplaceWith(pixelVertices, _pixelVertexFromSoA.clone( + src = "pixelVerticesSoA" +)) + +pixelNtupletFit.toReplaceWith(pixelVerticesTask, cms.Task( + # build the pixel vertices in SoA format on the CPU + pixelVerticesSoA, + # convert the pixel vertices from SoA to legacy format + pixelVertices +)) + + +# "Patatrack" sequence running on the GPU +from Configuration.ProcessModifiers.gpu_cff import gpu + +# build pixel vertices in SoA format on the GPU +pixelVerticesCUDA = _pixelVertexCUDA.clone( + pixelTrackSrc = "pixelTracksCUDA", + onGPU = True ) -gpu.toReplaceWith(recopixelvertexingTask, _recopixelvertexingTask_gpu) +# transfer the pixel vertices in SoA format to the CPU +from RecoPixelVertexing.PixelVertexFinding.pixelVertexSoA_cfi import pixelVertexSoA as _pixelVertexSoA +gpu.toModify(pixelVerticesSoA, + cuda = _pixelVertexSoA.clone( + src = cms.InputTag("pixelVerticesCUDA") + ) +) +(pixelNtupletFit & gpu).toReplaceWith(pixelVerticesTask, cms.Task( + # build pixel vertices in SoA format on the GPU + pixelVerticesCUDA, + # transfer the pixel vertices in SoA format to the CPU and convert them to legacy format + pixelVerticesTask.copy() +)) + +# Tasks and Sequences +recopixelvertexingTask = cms.Task( + pixelTracksTask, + pixelVerticesTask +) recopixelvertexing = cms.Sequence(recopixelvertexingTask) diff --git a/RecoPixelVertexing/Configuration/python/customizePixelTracksForTriplets.py b/RecoPixelVertexing/Configuration/python/customizePixelTracksForTriplets.py new file mode 100644 index 0000000000000..51abcd3ea7982 --- /dev/null +++ b/RecoPixelVertexing/Configuration/python/customizePixelTracksForTriplets.py @@ -0,0 +1,10 @@ +import FWCore.ParameterSet.Config as cms + +def customizePixelTracksForTriplets(process): + + from HLTrigger.Configuration.common import producers_by_type + for producer in producers_by_type(process, 'CAHitNtupletCUDA'): + producer.includeJumpingForwardDoublets = True + producer.minHitsPerNtuplet = 3 + + return process diff --git a/RecoPixelVertexing/Configuration/python/customizePixelTracksSoAonCPU.py b/RecoPixelVertexing/Configuration/python/customizePixelTracksSoAonCPU.py deleted file mode 100644 index 1661cac832b8b..0000000000000 --- a/RecoPixelVertexing/Configuration/python/customizePixelTracksSoAonCPU.py +++ /dev/null @@ -1,62 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -def customizePixelTracksSoAonCPU(process): - - process.CUDAService = cms.Service('CUDAService', - enabled = cms.untracked.bool(False) - ) - - # ensure the same results when running on GPU (which supports only the 'HLT' payload) and CPU - process.siPixelClustersPreSplitting.cpu.payloadType = cms.string('HLT') - - from RecoLocalTracker.SiPixelRecHits.siPixelRecHitSoAFromLegacy_cfi import siPixelRecHitSoAFromLegacy - process.siPixelRecHitsPreSplitting = siPixelRecHitSoAFromLegacy.clone( - convertToLegacy = True - ) - - from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA - process.pixelTrackSoA = caHitNtupletCUDA.clone( - onGPU = False, - pixelRecHitSrc = 'siPixelRecHitsPreSplitting' - ) - - from RecoPixelVertexing.PixelVertexFinding.pixelVertexCUDA_cfi import pixelVertexCUDA - process.pixelVertexSoA = pixelVertexCUDA.clone( - onGPU = False, - pixelTrackSrc = 'pixelTrackSoA' - ) - - from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA - process.pixelTracks = pixelTrackProducerFromSoA.clone( - pixelRecHitLegacySrc = 'siPixelRecHitsPreSplitting' - ) - - from RecoPixelVertexing.PixelVertexFinding.pixelVertexFromSoA_cfi import pixelVertexFromSoA - process.pixelVertices = pixelVertexFromSoA.clone() - - process.reconstruction_step += process.siPixelRecHitsPreSplitting + process.pixelTrackSoA + process.pixelVertexSoA - - return process - - -def customizePixelTracksForTriplets(process): - - from HLTrigger.Configuration.common import producers_by_type - for producer in producers_by_type(process, 'CAHitNtupletCUDA'): - producer.includeJumpingForwardDoublets = True - producer.minHitsPerNtuplet = 3 - - return process - - -def customizePixelTracksSoAonCPUForProfiling(process): - - process = customizePixelTracksSoAonCPU(process) - - process.siPixelRecHitSoAFromLegacy.convertToLegacy = False - - process.TkSoA = cms.Path(process.offlineBeamSpot + process.siPixelDigis + process.siPixelClustersPreSplitting + process.siPixelRecHitSoAFromLegacy + process.pixelTrackSoA + process.pixelVertexSoA) - - process.schedule = cms.Schedule(process.TkSoA) - - return process diff --git a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackDumpCUDA.cc b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackDumpCUDA.cc index 2f0965be50eb8..04cc57db5876c 100644 --- a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackDumpCUDA.cc +++ b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackDumpCUDA.cc @@ -54,7 +54,7 @@ void PixelTrackDumpCUDA::fillDescriptions(edm::ConfigurationDescriptions& descri edm::ParameterSetDescription desc; desc.add("onGPU", true); - desc.add("pixelTrackSrc", edm::InputTag("caHitNtupletCUDA")); + desc.add("pixelTrackSrc", edm::InputTag("pixelTracksCUDA")); desc.add("pixelVertexSrc", edm::InputTag("pixelVertexCUDA")); descriptions.add("pixelTrackDumpCUDA", desc); } diff --git a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackProducerFromSoA.cc b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackProducerFromSoA.cc index 94c490e948575..60225eceebc00 100644 --- a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackProducerFromSoA.cc +++ b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackProducerFromSoA.cc @@ -82,7 +82,7 @@ PixelTrackProducerFromSoA::PixelTrackProducerFromSoA(const edm::ParameterSet &iC void PixelTrackProducerFromSoA::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; desc.add("beamSpot", edm::InputTag("offlineBeamSpot")); - desc.add("trackSrc", edm::InputTag("pixelTrackSoA")); + desc.add("trackSrc", edm::InputTag("pixelTracksSoA")); desc.add("pixelRecHitLegacySrc", edm::InputTag("siPixelRecHitsPreSplittingLegacy")); desc.add("minNumberOfHits", 0); diff --git a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackSoAFromCUDA.cc b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackSoAFromCUDA.cc index 2de8ec6c335b5..ad2da317e8ba6 100644 --- a/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackSoAFromCUDA.cc +++ b/RecoPixelVertexing/PixelTrackFitting/plugins/PixelTrackSoAFromCUDA.cc @@ -46,8 +46,8 @@ PixelTrackSoAFromCUDA::PixelTrackSoAFromCUDA(const edm::ParameterSet& iConfig) void PixelTrackSoAFromCUDA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.add("src", edm::InputTag("caHitNtupletCUDA")); - descriptions.add("pixelTrackSoA", desc); + desc.add("src", edm::InputTag("pixelTracksCUDA")); + descriptions.add("pixelTracksSoA", desc); } void PixelTrackSoAFromCUDA::acquire(edm::Event const& iEvent, diff --git a/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py b/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py index 244e68faba8b6..ec9bb133a6c58 100644 --- a/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py +++ b/RecoPixelVertexing/PixelTrackFitting/python/PixelTracks_cff.py @@ -24,9 +24,11 @@ import RecoPixelVertexing.PixelLowPtUtilities.LowPtClusterShapeSeedComparitor_cfi from RecoTracker.FinalTrackSelectors.trackAlgoPriorityOrder_cfi import trackAlgoPriorityOrder +# Eras from Configuration.Eras.Modifier_trackingLowPU_cff import trackingLowPU +from Configuration.Eras.Modifier_run3_common_cff import run3_common -# SEEDING LAYERS +# seeding layers from RecoTracker.IterativeTracking.InitialStep_cff import initialStepSeedLayers, initialStepHitDoublets, _initialStepCAHitQuadruplets # TrackingRegion @@ -34,7 +36,7 @@ trackingLowPU.toReplaceWith(pixelTracksTrackingRegions, _globalTrackingRegionFromBeamSpot.clone()) -# Pixel Quadruplets Tracking +# Pixel quadruplets tracking pixelTracksSeedLayers = initialStepSeedLayers.clone( BPix = dict(HitProducer = "siPixelRecHitsPreSplitting"), FPix = dict(HitProducer = "siPixelRecHitsPreSplitting") @@ -51,22 +53,10 @@ SeedComparitorPSet = dict(clusterShapeCacheSrc = 'siPixelClusterShapeCachePreSplitting') ) -# for trackingLowPU -pixelTracksHitTriplets = _pixelTripletHLTEDProducer.clone( - doublets = "pixelTracksHitDoublets", - produceSeedingHitSets = True, - SeedComparitorPSet = RecoPixelVertexing.PixelLowPtUtilities.LowPtClusterShapeSeedComparitor_cfi.LowPtClusterShapeSeedComparitor.clone( - clusterShapeCacheSrc = "siPixelClusterShapeCachePreSplitting" - ) +pixelTracks = _pixelTracks.clone( + SeedingHitSets = "pixelTracksHitQuadruplets" ) -pixelTracks = SwitchProducerCUDA( - cpu = _pixelTracks.clone( - SeedingHitSets = "pixelTracksHitQuadruplets" - ) -) -trackingLowPU.toModify(pixelTracks.cpu, SeedingHitSets = "pixelTracksHitTriplets") - pixelTracksTask = cms.Task( pixelTracksTrackingRegions, pixelFitterByHelixProjections, @@ -76,35 +66,91 @@ pixelTracksHitQuadruplets, pixelTracks ) + +pixelTracksSequence = cms.Sequence(pixelTracksTask) + + +# Pixel triplets for trackingLowPU +pixelTracksHitTriplets = _pixelTripletHLTEDProducer.clone( + doublets = "pixelTracksHitDoublets", + produceSeedingHitSets = True, + SeedComparitorPSet = RecoPixelVertexing.PixelLowPtUtilities.LowPtClusterShapeSeedComparitor_cfi.LowPtClusterShapeSeedComparitor.clone( + clusterShapeCacheSrc = "siPixelClusterShapeCachePreSplitting" + ) +) + +trackingLowPU.toModify(pixelTracks, + SeedingHitSets = "pixelTracksHitTriplets" +) + _pixelTracksTask_lowPU = pixelTracksTask.copy() _pixelTracksTask_lowPU.replace(pixelTracksHitQuadruplets, pixelTracksHitTriplets) trackingLowPU.toReplaceWith(pixelTracksTask, _pixelTracksTask_lowPU) -# Use ntuple fit and substitute previous Fitter producer with the ntuple one -from Configuration.ProcessModifiers.pixelNtupleFit_cff import pixelNtupleFit as ntupleFit -ntupleFit.toModify(pixelTracks.cpu, Fitter = "pixelNtupletsFitter") -_pixelTracksTask_ntupleFit = pixelTracksTask.copy() -_pixelTracksTask_ntupleFit.replace(pixelFitterByHelixProjections, pixelNtupletsFitter) -ntupleFit.toReplaceWith(pixelTracksTask, _pixelTracksTask_ntupleFit) +# "Patatrack" pixel ntuplets, fishbone cleaning, Broken Line fit, and density-based vertex reconstruction +from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit -from Configuration.ProcessModifiers.gpu_cff import gpu -from RecoPixelVertexing.PixelTriplets.caHitNtupletCUDA_cfi import caHitNtupletCUDA -from RecoPixelVertexing.PixelTrackFitting.pixelTrackSoA_cfi import pixelTrackSoA -from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as pixelTrackFromSoA -_pixelTracksTask_gpu = pixelTracksTask.copy() -_pixelTracksTask_gpu.add(caHitNtupletCUDA, pixelTrackSoA, pixelTrackFromSoA) -# this is needed (instead of simply using pixelTracks.cuda = pixelTrackFromSoA.clone()) because -# the PixelTrackProducerFromSoA produces an additional 'ushorts' collection -gpu.toModify(pixelTracks, - cuda = cms.EDAlias( - pixelTrackFromSoA = cms.VPSet( - cms.PSet(type = cms.string("recoTracks")), - cms.PSet(type = cms.string("recoTrackExtras")), - cms.PSet(type = cms.string("TrackingRecHitsOwned")) - ) +from RecoPixelVertexing.PixelTriplets.pixelTracksCUDA_cfi import pixelTracksCUDA as _pixelTracksCUDA + +# SwitchProducer providing the pixel tracks in SoA format on the CPU +pixelTracksSoA = SwitchProducerCUDA( + # build pixel ntuplets and pixel tracks in SoA format on the CPU + cpu = _pixelTracksCUDA.clone( + pixelRecHitSrc = "siPixelRecHitsPreSplittingSoA", + idealConditions = False, + onGPU = False ) ) -gpu.toReplaceWith(pixelTracksTask, _pixelTracksTask_gpu) +# use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows +run3_common.toModify(pixelTracksSoA.cpu, + idealConditions = True +) -pixelTracksSequence = cms.Sequence(pixelTracksTask) +# convert the pixel tracks from SoA to legacy format +from RecoPixelVertexing.PixelTrackFitting.pixelTrackProducerFromSoA_cfi import pixelTrackProducerFromSoA as _pixelTrackProducerFromSoA +pixelNtupletFit.toReplaceWith(pixelTracks, _pixelTrackProducerFromSoA.clone( + pixelRecHitLegacySrc = "siPixelRecHitsPreSplitting", +)) + +pixelNtupletFit.toReplaceWith(pixelTracksTask, cms.Task( + #pixelTracksTrackingRegions, + #pixelFitterByHelixProjections, + #pixelTrackFilterByKinematics, + #pixelTracksSeedLayers, + #pixelTracksHitDoublets, + #pixelTracksHitQuadruplets, + # build the pixel ntuplets and the pixel tracks in SoA format on the GPU + pixelTracksSoA, + # convert the pixel tracks from SoA to legacy format + pixelTracks +)) + + +# "Patatrack" sequence running on GPU +from Configuration.ProcessModifiers.gpu_cff import gpu + +# build the pixel ntuplets and pixel tracks in SoA format on the GPU +pixelTracksCUDA = _pixelTracksCUDA.clone( + pixelRecHitSrc = "siPixelRecHitsPreSplittingCUDA", + idealConditions = False, + onGPU = True +) +# use quality cuts tuned for Run 2 ideal conditions for all Run 3 workflows +run3_common.toModify(pixelTracksCUDA, + idealConditions = True +) + +# SwitchProducer providing the pixel tracks in SoA format on the CPU +from RecoPixelVertexing.PixelTrackFitting.pixelTracksSoA_cfi import pixelTracksSoA as _pixelTracksSoA +gpu.toModify(pixelTracksSoA, + # transfer the pixel tracks in SoA format to the host + cuda = _pixelTracksSoA.clone() +) + +(pixelNtupletFit & gpu).toReplaceWith(pixelTracksTask, cms.Task( + # build the pixel ntuplets and pixel tracks in SoA format on the GPU + pixelTracksCUDA, + # transfer the pixel tracks in SoA format to the CPU, and convert them to legacy format + pixelTracksTask.copy() +)) diff --git a/RecoPixelVertexing/PixelTriplets/plugins/CAHitNtupletCUDA.cc b/RecoPixelVertexing/PixelTriplets/plugins/CAHitNtupletCUDA.cc index beba54c33f513..ee295d8f5253c 100644 --- a/RecoPixelVertexing/PixelTriplets/plugins/CAHitNtupletCUDA.cc +++ b/RecoPixelVertexing/PixelTriplets/plugins/CAHitNtupletCUDA.cc @@ -61,7 +61,7 @@ void CAHitNtupletCUDA::fillDescriptions(edm::ConfigurationDescriptions& descript desc.add("pixelRecHitSrc", edm::InputTag("siPixelRecHitsPreSplittingCUDA")); CAHitNtupletGeneratorOnGPU::fillDescriptions(desc); - descriptions.add("caHitNtupletCUDA", desc); + descriptions.add("pixelTracksCUDA", desc); } void CAHitNtupletCUDA::produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& es) const { diff --git a/RecoPixelVertexing/PixelVertexFinding/plugins/PixelVertexProducerCUDA.cc b/RecoPixelVertexing/PixelVertexFinding/plugins/PixelVertexProducerCUDA.cc index e2c2bc76c8612..2989403fa4214 100644 --- a/RecoPixelVertexing/PixelVertexFinding/plugins/PixelVertexProducerCUDA.cc +++ b/RecoPixelVertexing/PixelVertexFinding/plugins/PixelVertexProducerCUDA.cc @@ -85,7 +85,7 @@ void PixelVertexProducerCUDA::fillDescriptions(edm::ConfigurationDescriptions& d desc.add("chi2max", 9.); // max normalized distance to cluster desc.add("PtMin", 0.5); - desc.add("pixelTrackSrc", edm::InputTag("caHitNtupletCUDA")); + desc.add("pixelTrackSrc", edm::InputTag("pixelTracksCUDA")); auto label = "pixelVertexCUDA"; descriptions.add(label, desc); diff --git a/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py b/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py index a33d5c14af751..d47ce2eb339b4 100644 --- a/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py +++ b/RecoPixelVertexing/PixelVertexFinding/python/PixelVertexes_cff.py @@ -1,7 +1,3 @@ import FWCore.ParameterSet.Config as cms -from HeterogeneousCore.CUDACore.SwitchProducerCUDA import SwitchProducerCUDA -from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import pvClusterComparer, pixelVertices as _pixelVertices -pixelVertices = SwitchProducerCUDA( - cpu = _pixelVertices.clone() -) +from RecoPixelVertexing.PixelVertexFinding.PixelVertexes_cfi import * diff --git a/RecoTracker/Configuration/python/customizePixelOnlyForProfiling.py b/RecoTracker/Configuration/python/customizePixelOnlyForProfiling.py index 24774bbda649c..045738b37dde1 100644 --- a/RecoTracker/Configuration/python/customizePixelOnlyForProfiling.py +++ b/RecoTracker/Configuration/python/customizePixelOnlyForProfiling.py @@ -6,7 +6,7 @@ def customizePixelOnlyForProfilingGPUOnly(process): process.consumer = cms.EDAnalyzer("GenericConsumer", - eventProducts = cms.untracked.vstring('caHitNtupletCUDA', 'pixelVertexCUDA') + eventProducts = cms.untracked.vstring('pixelTracksCUDA', 'pixelVertexCUDA') ) process.consume_step = cms.EndPath(process.consumer) @@ -28,7 +28,7 @@ def customizePixelOnlyForProfilingGPUWithHostCopy(process): #? process.siPixelRecHitSoAFromLegacy.convertToLegacy = False process.consumer = cms.EDAnalyzer("GenericConsumer", - eventProducts = cms.untracked.vstring('pixelTrackSoA', 'pixelVertexSoA') + eventProducts = cms.untracked.vstring('pixelTracksSoA', 'pixelVertexSoA') ) process.consume_step = cms.EndPath(process.consumer) From 109fbc4e79c5d3b36f374508365c144d6ae49311 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 27 Apr 2021 17:45:10 +0200 Subject: [PATCH 10/11] Always clone() a module used in a SwitchProducer --- RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py | 2 +- RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py | 8 +++++--- .../python/ecalMultiFitUncalibRecHit_cff.py | 2 +- RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py b/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py index 30b7927d5753a..c876f79eb5422 100644 --- a/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hcalGlobalReco_cff.py @@ -4,7 +4,7 @@ #--- for Run 1 and Run 2 from RecoLocalCalo.HcalRecProducers.HBHEIsolatedNoiseReflagger_cfi import hbhereco as _phase0_hbhereco hbhereco = SwitchProducerCUDA( - cpu = _phase0_hbhereco + cpu = _phase0_hbhereco.clone() ) hcalGlobalRecoTask = cms.Task(hbhereco) hcalGlobalRecoSequence = cms.Sequence(hcalGlobalRecoTask) diff --git a/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py b/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py index 4c68380d686ac..45b3e511c6874 100644 --- a/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py +++ b/RecoLocalCalo/Configuration/python/hcalLocalReco_cff.py @@ -34,10 +34,12 @@ _phase1_hcalLocalRecoTask.add(hfprereco) from Configuration.Eras.Modifier_run2_HF_2017_cff import run2_HF_2017 -run2_HF_2017.toReplaceWith( hcalLocalRecoTask, _phase1_hcalLocalRecoTask ) -run2_HF_2017.toReplaceWith( hfreco, _phase1_hfreco ) +run2_HF_2017.toReplaceWith(hcalLocalRecoTask, _phase1_hcalLocalRecoTask) +run2_HF_2017.toReplaceWith(hfreco, _phase1_hfreco) from Configuration.Eras.Modifier_run2_HCAL_2017_cff import run2_HCAL_2017 -run2_HCAL_2017.toReplaceWith(hbheprereco.cpu, _phase1_hbheprereco) +run2_HCAL_2017.toModify(hbheprereco, + cpu = _phase1_hbheprereco.clone() +) _plan1_hcalLocalRecoTask = _phase1_hcalLocalRecoTask.copy() _plan1_hcalLocalRecoTask.add(hbheplan1) diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py index fb285456a053f..81c0a71986c78 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cff.py @@ -5,7 +5,7 @@ # ECAL multifit running on CPU from RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi import ecalMultiFitUncalibRecHit as _ecalMultiFitUncalibRecHit ecalMultiFitUncalibRecHit = SwitchProducerCUDA( - cpu = _ecalMultiFitUncalibRecHit + cpu = _ecalMultiFitUncalibRecHit.clone() ) ecalMultiFitUncalibRecHitTask = cms.Task( diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py b/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py index 44420e9600690..71247d33d6063 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalRecHit_cff.py @@ -5,7 +5,7 @@ # ECAL calibrated rechit reconstruction on CPU from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import ecalRecHit as _ecalRecHit ecalRecHit = SwitchProducerCUDA( - cpu = _ecalRecHit + cpu = _ecalRecHit.clone() ) ecalCalibratedRecHitTask = cms.Task( From ad06d7898affbe9dd78964f046eb2dd04d8309b9 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Tue, 27 Apr 2021 18:39:26 +0200 Subject: [PATCH 11/11] Move the implementation of the gpuVertexFinder kernels to gpuVertexFinder.cc --- .../plugins/gpuVertexFinder.cc | 193 +++++++++++++++++- .../plugins/gpuVertexFinder.cu | 2 +- .../plugins/gpuVertexFinderImpl.h | 192 ----------------- 3 files changed, 193 insertions(+), 194 deletions(-) delete mode 100644 RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinderImpl.h diff --git a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cc b/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cc index 084763385bdb4..d685ced488233 100644 --- a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cc +++ b/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cc @@ -1 +1,192 @@ -#include "gpuVertexFinderImpl.h" +#ifndef RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h +#define RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h + +#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" + +#include "gpuClusterTracksByDensity.h" +#include "gpuClusterTracksDBSCAN.h" +#include "gpuClusterTracksIterative.h" +#include "gpuFitVertices.h" +#include "gpuSortByPt2.h" +#include "gpuSplitVertices.h" + +#undef PIXVERTEX_DEBUG_PRODUCE + +namespace gpuVertexFinder { + + // reject outlier tracks that contribute more than this to the chi2 of the vertex fit + constexpr float maxChi2ForFirstFit = 50.f; + constexpr float maxChi2ForFinalFit = 5000.f; + + // split vertices with a chi2/NDoF greater than this + constexpr float maxChi2ForSplit = 9.f; + + __global__ void loadTracks(TkSoA const* ptracks, ZVertexSoA* soa, WorkSpace* pws, float ptMin) { + assert(ptracks); + assert(soa); + auto const& tracks = *ptracks; + auto const& fit = tracks.stateAtBS; + auto const* quality = tracks.qualityData(); + + auto first = blockIdx.x * blockDim.x + threadIdx.x; + for (int idx = first, nt = TkSoA::stride(); idx < nt; idx += gridDim.x * blockDim.x) { + auto nHits = tracks.nHits(idx); + if (nHits == 0) + break; // this is a guard: maybe we need to move to nTracks... + + // initialize soa... + soa->idv[idx] = -1; + + if (nHits < 4) + continue; // no triplets + if (quality[idx] != pixelTrack::Quality::loose) + continue; + + auto pt = tracks.pt(idx); + + if (pt < ptMin) + continue; + + auto& data = *pws; + auto it = atomicAdd(&data.ntrks, 1); + data.itrk[it] = idx; + data.zt[it] = tracks.zip(idx); + data.ezt2[it] = fit.covariance(idx)(14); + data.ptt2[it] = pt * pt; + } + } + +// #define THREE_KERNELS +#ifndef THREE_KERNELS + __global__ void vertexFinderOneKernel(gpuVertexFinder::ZVertices* pdata, + gpuVertexFinder::WorkSpace* pws, + int minT, // min number of neighbours to be "seed" + float eps, // max absolute distance to cluster + float errmax, // max error to be "seed" + float chi2max // max normalized distance to cluster, + ) { + clusterTracksByDensity(pdata, pws, minT, eps, errmax, chi2max); + __syncthreads(); + fitVertices(pdata, pws, maxChi2ForFirstFit); + __syncthreads(); + splitVertices(pdata, pws, maxChi2ForSplit); + __syncthreads(); + fitVertices(pdata, pws, maxChi2ForFinalFit); + __syncthreads(); + sortByPt2(pdata, pws); + } +#else + __global__ void vertexFinderKernel1(gpuVertexFinder::ZVertices* pdata, + gpuVertexFinder::WorkSpace* pws, + int minT, // min number of neighbours to be "seed" + float eps, // max absolute distance to cluster + float errmax, // max error to be "seed" + float chi2max // max normalized distance to cluster, + ) { + clusterTracksByDensity(pdata, pws, minT, eps, errmax, chi2max); + __syncthreads(); + fitVertices(pdata, pws, maxChi2ForFirstFit); + } + + __global__ void vertexFinderKernel2(gpuVertexFinder::ZVertices* pdata, gpuVertexFinder::WorkSpace* pws) { + fitVertices(pdata, pws, maxChi2ForFinalFit); + __syncthreads(); + sortByPt2(pdata, pws); + } +#endif + +#ifdef __CUDACC__ + ZVertexHeterogeneous Producer::makeAsync(cudaStream_t stream, TkSoA const* tksoa, float ptMin) const { +#ifdef PIXVERTEX_DEBUG_PRODUCE + std::cout << "producing Vertices on GPU" << std::endl; +#endif // PIXVERTEX_DEBUG_PRODUCE + ZVertexHeterogeneous vertices(cms::cuda::make_device_unique(stream)); +#else + ZVertexHeterogeneous Producer::make(TkSoA const* tksoa, float ptMin) const { +#ifdef PIXVERTEX_DEBUG_PRODUCE + std::cout << "producing Vertices on CPU" << std::endl; +#endif // PIXVERTEX_DEBUG_PRODUCE + ZVertexHeterogeneous vertices(std::make_unique()); +#endif + assert(tksoa); + auto* soa = vertices.get(); + assert(soa); + +#ifdef __CUDACC__ + auto ws_d = cms::cuda::make_device_unique(stream); +#else + auto ws_d = std::make_unique(); +#endif + +#ifdef __CUDACC__ + init<<<1, 1, 0, stream>>>(soa, ws_d.get()); + auto blockSize = 128; + auto numberOfBlocks = (TkSoA::stride() + blockSize - 1) / blockSize; + loadTracks<<>>(tksoa, soa, ws_d.get(), ptMin); + cudaCheck(cudaGetLastError()); +#else + init(soa, ws_d.get()); + loadTracks(tksoa, soa, ws_d.get(), ptMin); +#endif + +#ifdef __CUDACC__ + // Running too many thread lead to problems when printf is enabled. + constexpr int maxThreadsForPrint = 1024 - 256; + constexpr int numBlocks = 1024; + constexpr int threadsPerBlock = 128; + + if (oneKernel_) { + // implemented only for density clustesrs +#ifndef THREE_KERNELS + vertexFinderOneKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); +#else + vertexFinderKernel1<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); + cudaCheck(cudaGetLastError()); + // one block per vertex... + splitVerticesKernel<<>>(soa, ws_d.get(), maxChi2ForSplit); + cudaCheck(cudaGetLastError()); + vertexFinderKernel2<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get()); +#endif + } else { // five kernels + if (useDensity_) { + clusterTracksByDensityKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); + } else if (useDBSCAN_) { + clusterTracksDBSCAN<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); + } else if (useIterative_) { + clusterTracksIterative<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); + } + cudaCheck(cudaGetLastError()); + fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFirstFit); + cudaCheck(cudaGetLastError()); + // one block per vertex... + splitVerticesKernel<<>>(soa, ws_d.get(), maxChi2ForSplit); + cudaCheck(cudaGetLastError()); + fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFinalFit); + cudaCheck(cudaGetLastError()); + sortByPt2Kernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get()); + } + cudaCheck(cudaGetLastError()); +#else // __CUDACC__ + if (useDensity_) { + clusterTracksByDensity(soa, ws_d.get(), minT, eps, errmax, chi2max); + } else if (useDBSCAN_) { + clusterTracksDBSCAN(soa, ws_d.get(), minT, eps, errmax, chi2max); + } else if (useIterative_) { + clusterTracksIterative(soa, ws_d.get(), minT, eps, errmax, chi2max); + } +#ifdef PIXVERTEX_DEBUG_PRODUCE + std::cout << "found " << (*ws_d).nvIntermediate << " vertices " << std::endl; +#endif // PIXVERTEX_DEBUG_PRODUCE + fitVertices(soa, ws_d.get(), maxChi2ForFirstFit); + // one block per vertex! + splitVertices(soa, ws_d.get(), maxChi2ForSplit); + fitVertices(soa, ws_d.get(), maxChi2ForFinalFit); + sortByPt2(soa, ws_d.get()); +#endif + + return vertices; + } + +} // namespace gpuVertexFinder + +#endif // RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h diff --git a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cu b/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cu index 084763385bdb4..9674eac7d8784 100644 --- a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cu +++ b/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinder.cu @@ -1 +1 @@ -#include "gpuVertexFinderImpl.h" +#include "gpuVertexFinder.cc" diff --git a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinderImpl.h b/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinderImpl.h deleted file mode 100644 index d685ced488233..0000000000000 --- a/RecoPixelVertexing/PixelVertexFinding/plugins/gpuVertexFinderImpl.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h -#define RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h - -#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" - -#include "gpuClusterTracksByDensity.h" -#include "gpuClusterTracksDBSCAN.h" -#include "gpuClusterTracksIterative.h" -#include "gpuFitVertices.h" -#include "gpuSortByPt2.h" -#include "gpuSplitVertices.h" - -#undef PIXVERTEX_DEBUG_PRODUCE - -namespace gpuVertexFinder { - - // reject outlier tracks that contribute more than this to the chi2 of the vertex fit - constexpr float maxChi2ForFirstFit = 50.f; - constexpr float maxChi2ForFinalFit = 5000.f; - - // split vertices with a chi2/NDoF greater than this - constexpr float maxChi2ForSplit = 9.f; - - __global__ void loadTracks(TkSoA const* ptracks, ZVertexSoA* soa, WorkSpace* pws, float ptMin) { - assert(ptracks); - assert(soa); - auto const& tracks = *ptracks; - auto const& fit = tracks.stateAtBS; - auto const* quality = tracks.qualityData(); - - auto first = blockIdx.x * blockDim.x + threadIdx.x; - for (int idx = first, nt = TkSoA::stride(); idx < nt; idx += gridDim.x * blockDim.x) { - auto nHits = tracks.nHits(idx); - if (nHits == 0) - break; // this is a guard: maybe we need to move to nTracks... - - // initialize soa... - soa->idv[idx] = -1; - - if (nHits < 4) - continue; // no triplets - if (quality[idx] != pixelTrack::Quality::loose) - continue; - - auto pt = tracks.pt(idx); - - if (pt < ptMin) - continue; - - auto& data = *pws; - auto it = atomicAdd(&data.ntrks, 1); - data.itrk[it] = idx; - data.zt[it] = tracks.zip(idx); - data.ezt2[it] = fit.covariance(idx)(14); - data.ptt2[it] = pt * pt; - } - } - -// #define THREE_KERNELS -#ifndef THREE_KERNELS - __global__ void vertexFinderOneKernel(gpuVertexFinder::ZVertices* pdata, - gpuVertexFinder::WorkSpace* pws, - int minT, // min number of neighbours to be "seed" - float eps, // max absolute distance to cluster - float errmax, // max error to be "seed" - float chi2max // max normalized distance to cluster, - ) { - clusterTracksByDensity(pdata, pws, minT, eps, errmax, chi2max); - __syncthreads(); - fitVertices(pdata, pws, maxChi2ForFirstFit); - __syncthreads(); - splitVertices(pdata, pws, maxChi2ForSplit); - __syncthreads(); - fitVertices(pdata, pws, maxChi2ForFinalFit); - __syncthreads(); - sortByPt2(pdata, pws); - } -#else - __global__ void vertexFinderKernel1(gpuVertexFinder::ZVertices* pdata, - gpuVertexFinder::WorkSpace* pws, - int minT, // min number of neighbours to be "seed" - float eps, // max absolute distance to cluster - float errmax, // max error to be "seed" - float chi2max // max normalized distance to cluster, - ) { - clusterTracksByDensity(pdata, pws, minT, eps, errmax, chi2max); - __syncthreads(); - fitVertices(pdata, pws, maxChi2ForFirstFit); - } - - __global__ void vertexFinderKernel2(gpuVertexFinder::ZVertices* pdata, gpuVertexFinder::WorkSpace* pws) { - fitVertices(pdata, pws, maxChi2ForFinalFit); - __syncthreads(); - sortByPt2(pdata, pws); - } -#endif - -#ifdef __CUDACC__ - ZVertexHeterogeneous Producer::makeAsync(cudaStream_t stream, TkSoA const* tksoa, float ptMin) const { -#ifdef PIXVERTEX_DEBUG_PRODUCE - std::cout << "producing Vertices on GPU" << std::endl; -#endif // PIXVERTEX_DEBUG_PRODUCE - ZVertexHeterogeneous vertices(cms::cuda::make_device_unique(stream)); -#else - ZVertexHeterogeneous Producer::make(TkSoA const* tksoa, float ptMin) const { -#ifdef PIXVERTEX_DEBUG_PRODUCE - std::cout << "producing Vertices on CPU" << std::endl; -#endif // PIXVERTEX_DEBUG_PRODUCE - ZVertexHeterogeneous vertices(std::make_unique()); -#endif - assert(tksoa); - auto* soa = vertices.get(); - assert(soa); - -#ifdef __CUDACC__ - auto ws_d = cms::cuda::make_device_unique(stream); -#else - auto ws_d = std::make_unique(); -#endif - -#ifdef __CUDACC__ - init<<<1, 1, 0, stream>>>(soa, ws_d.get()); - auto blockSize = 128; - auto numberOfBlocks = (TkSoA::stride() + blockSize - 1) / blockSize; - loadTracks<<>>(tksoa, soa, ws_d.get(), ptMin); - cudaCheck(cudaGetLastError()); -#else - init(soa, ws_d.get()); - loadTracks(tksoa, soa, ws_d.get(), ptMin); -#endif - -#ifdef __CUDACC__ - // Running too many thread lead to problems when printf is enabled. - constexpr int maxThreadsForPrint = 1024 - 256; - constexpr int numBlocks = 1024; - constexpr int threadsPerBlock = 128; - - if (oneKernel_) { - // implemented only for density clustesrs -#ifndef THREE_KERNELS - vertexFinderOneKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); -#else - vertexFinderKernel1<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); - cudaCheck(cudaGetLastError()); - // one block per vertex... - splitVerticesKernel<<>>(soa, ws_d.get(), maxChi2ForSplit); - cudaCheck(cudaGetLastError()); - vertexFinderKernel2<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get()); -#endif - } else { // five kernels - if (useDensity_) { - clusterTracksByDensityKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); - } else if (useDBSCAN_) { - clusterTracksDBSCAN<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); - } else if (useIterative_) { - clusterTracksIterative<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), minT, eps, errmax, chi2max); - } - cudaCheck(cudaGetLastError()); - fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFirstFit); - cudaCheck(cudaGetLastError()); - // one block per vertex... - splitVerticesKernel<<>>(soa, ws_d.get(), maxChi2ForSplit); - cudaCheck(cudaGetLastError()); - fitVerticesKernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get(), maxChi2ForFinalFit); - cudaCheck(cudaGetLastError()); - sortByPt2Kernel<<<1, maxThreadsForPrint, 0, stream>>>(soa, ws_d.get()); - } - cudaCheck(cudaGetLastError()); -#else // __CUDACC__ - if (useDensity_) { - clusterTracksByDensity(soa, ws_d.get(), minT, eps, errmax, chi2max); - } else if (useDBSCAN_) { - clusterTracksDBSCAN(soa, ws_d.get(), minT, eps, errmax, chi2max); - } else if (useIterative_) { - clusterTracksIterative(soa, ws_d.get(), minT, eps, errmax, chi2max); - } -#ifdef PIXVERTEX_DEBUG_PRODUCE - std::cout << "found " << (*ws_d).nvIntermediate << " vertices " << std::endl; -#endif // PIXVERTEX_DEBUG_PRODUCE - fitVertices(soa, ws_d.get(), maxChi2ForFirstFit); - // one block per vertex! - splitVertices(soa, ws_d.get(), maxChi2ForSplit); - fitVertices(soa, ws_d.get(), maxChi2ForFinalFit); - sortByPt2(soa, ws_d.get()); -#endif - - return vertices; - } - -} // namespace gpuVertexFinder - -#endif // RecoPixelVertexing_PixelVertexFinding_plugins_gpuVertexFinderImpl_h