diff --git a/Configuration/ProcessModifiers/python/fastSimPU_cff.py b/Configuration/ProcessModifiers/python/fastSimPU_cff.py new file mode 100644 index 0000000000000..97bfd16180c54 --- /dev/null +++ b/Configuration/ProcessModifiers/python/fastSimPU_cff.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +fastSimPU = cms.Modifier() diff --git a/Configuration/PyReleaseValidation/README.md b/Configuration/PyReleaseValidation/README.md index ef50a51ea34d4..4d3fd058d9373 100644 --- a/Configuration/PyReleaseValidation/README.md +++ b/Configuration/PyReleaseValidation/README.md @@ -101,6 +101,8 @@ The offsets currently in use are: * 0.634: ECAL phase2 Trigger Primitive + component-method based digis * 0.635: ECAL phase2 Trigger Primitive + component-method based finely-sampled waveforms * 0.91: Track DNN modifier +* 0.95: Hybrid PU (FullSim signal + FastSim PU) stage2 +* 0.96: Hybrid PU (FullSim signal + FastSim PU) stage1+stage2 * 0.97: Premixing stage1 * 0.98: Premixing stage2 * 0.99: Premixing stage1+stage2 diff --git a/Configuration/PyReleaseValidation/python/WorkFlowRunner.py b/Configuration/PyReleaseValidation/python/WorkFlowRunner.py index 2925e6507afed..971b8421d2743 100644 --- a/Configuration/PyReleaseValidation/python/WorkFlowRunner.py +++ b/Configuration/PyReleaseValidation/python/WorkFlowRunner.py @@ -232,8 +232,9 @@ def closeCmd(i,ID): if self.noRun: cmd +=' --no_exec' # in case previous step used DAS query (either filelist of das:) - # not to be applied for premixing stage1 to allow combiend stage1+stage2 workflow - if inFile and not 'premix_stage1' in cmd: + # not to be applied for premixing stage1 to allow combined stage1+stage2 workflow + # & similar for HybridPU combined workflow + if inFile and not 'premix_stage1' in cmd and not 'FASTSIM' in cmd: cmd += ' --filein '+inFile inFile=None if lumiRangeFile: #DAS query can also restrict lumi range @@ -246,12 +247,13 @@ def closeCmd(i,ID): else: # Disable input for premix stage1 to allow combined stage1+stage2 workflow # Disable input for premix stage2 in FastSim to allow combined stage1+stage2 workflow (in FS, stage2 does also GEN) + # & similar for HybridPU combined workflow # Ugly hack but works extension = '.root' if '--rntuple_out' in cmd: extension = '.rntpl' outputExtensionForStep[istep] = extension - if istep!=1 and not '--filein' in cmd and not 'premix_stage1' in cmd and not ("--fast" in cmd and "premix_stage2" in cmd): + if istep!=1 and not '--filein' in cmd and not 'premix_stage1' in cmd and not ("--fast" in cmd and "premix_stage2" in cmd) and not 'FASTSIM' in cmd: steps = cmd.split("-s ")[1].split(" ")[0] ## relying on the syntax: cmsDriver -s STEPS --otherFlags if "ALCA" not in steps: cmd+=' --filein file:step%s%s '%(istep-1,outputExtensionForStep[istep-1]) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 2ce206190dcdb..9cba23c9769fe 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -5237,6 +5237,14 @@ def gen2024HiMix(fragment,howMuch): # else: #For FastSim to recycle GEN # steps[k+'INPUT']={'INPUT':InputInfo(dataSet='/RelVal'+info.dataset+'/%s/GEN'%(baseDataSetReleaseBetter[s],),location='STD')} # end COMMENT: reads old format file + # this condition is checked here to avoid skipping the creation of default steps for other fragments + if 'HybridPU' in step: + # minbias fastsim for PU mixing + if not 'MinBias_14TeV' in frag: + continue + stepKey = 'HYBRID_'+key+'_'+step + howMuch = Kby(100,100) + steps[stepKey]=merge([ {'--evt_type':frag},howMuch,upgradeStepDict[step][key]]) else: for key in [key for year in upgradeKeys for key in upgradeKeys[year]]: k=step+'_'+key diff --git a/Configuration/PyReleaseValidation/python/relval_upgrade.py b/Configuration/PyReleaseValidation/python/relval_upgrade.py index 53dea45e63aa0..57907606f90b4 100644 --- a/Configuration/PyReleaseValidation/python/relval_upgrade.py +++ b/Configuration/PyReleaseValidation/python/relval_upgrade.py @@ -80,6 +80,14 @@ def notForGenOnly(key,specialType): if 'S2' in specialType: stepList[specialType].append(stepMade) # replace for s1 else: stepList[specialType][-1] = stepMade + # similar hack for fastpu + if 'HybridPU' in specialType: + if 'GenSim' in step: + s = step.replace('GenSim','GenSimFS')+'PU' # later processing requires to have PU here + if step in specialWF.PU: + stepMade = stepMaker(key,'HYBRID',s,specialWF.suffix) + # append for combined + if 'S2' in specialType: stepList[specialType].append(stepMade) else: stepList[specialType].append(stepMaker(key,frag[:-4],step,'')) for specialType,specialWF in upgradeWFs.items(): diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index 1887169482d37..b6ccd3b23bbde 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -3171,6 +3171,82 @@ def condition(self, fragment, stepList, key, hasHarvest): offset = 0.9921, ) +class UpgradeWorkflowHybridPU(UpgradeWorkflow): + def setup_(self, step, stepName, stepDict, k, properties): + # just copy steps + stepDict[stepName][k] = merge([stepDict[step][k]]) + def setupPU_(self, step, stepName, stepDict, k, properties): + # make new step for S1 + # this gets inserted in relval_upgrade.py + if "GenSim" in stepName: + # go back to non-PU step version + d = merge([stepDict[self.getStepName(step)][k]]) + stepNameS1 = stepName.replace('GenSim','GenSimFS') + if not stepNameS1 in stepDict: stepDict[stepNameS1] = {} + stepDict[stepNameS1][k] = merge([{ + '--fast': '', + '--era': stepDict[stepName][k]['--era']+'_FastSim', + '--eventcontent': 'FASTPU', + '--processName': 'FASTSIM', + }, d]) + else: + # include modifier in all subsequent steps in case any of them use PU replay + if "--procModifiers" in stepDict[stepName][k]: + stepDict[stepName][k]["--procModifiers"] += ",fastSimPU" + else: + stepDict[stepName][k]["--procModifiers"] = "fastSimPU" + + if "Digi" in stepName: + stepDict[stepName][k] = merge([digiPremixLocalPileup, stepDict[stepName][k]]) + elif 'S1S2' in self.suffix: + # increment inputs for subsequent steps in combined case + # also reset pileup input + digiPremixLocalPileupTmp = deepcopy(digiPremixLocalPileup) + filein = stepDict[stepName][k].get("--filein","") + m = re.search("step(?P\\d+)", filein) + if m: + digiPremixLocalPileupTmp['--filein'] = filein.replace(m.group(), "step%d"%(int(m.group("ind"))+1)) + else: + digiPremixLocalPileupTmp.pop('--filein') + stepDict[stepName][k] = merge([digiPremixLocalPileupTmp, stepDict[stepName][k]]) + def condition(self, fragment, stepList, key, hasHarvest): + return (fragment=='TTbar_14TeV' and 'PU' in key and key.startswith('202') and not 'FS' in key) +# stage1 is just FastSim MinBias, no separate workflow needed +# HybridPU stage2 +upgradeWFs['HybridPUS2'] = UpgradeWorkflowHybridPU( + steps = [], + PU = [ + 'Digi', + 'DigiTrigger', + ], + suffix = '_HybridPUS2', + offset = 0.95, +) +# HybridPU combined stage1+stage2 +upgradeWFs['HybridPUS1S2'] = UpgradeWorkflowHybridPU( + steps = [], + PU = [ + 'GenSim', + 'GenSimHLBeamSpot', + 'GenSimHLBeamSpot14', + 'Digi', + 'DigiTrigger', + 'RecoLocal', + 'Reco', + 'RecoFakeHLT', + 'RecoGlobal', + 'RecoGlobalFakeHLT', + 'RecoNano', + 'RecoNanoFakeHLT', + 'Nano', + 'HARVESTNano', + 'HARVESTNanoFakeHLT', + 'ALCA', + ], + suffix = '_HybridPUS1S2', + offset = 0.96, +) + class UpgradeWorkflow_Run3FStrackingOnly(UpgradeWorkflow): def setup_(self, step, stepName, stepDict, k, properties): if 'HARVESTFastRun3' in step: diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeedTracksLST_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeedTracksLST_cfi.py deleted file mode 100644 index b803257685b64..0000000000000 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeedTracksLST_cfi.py +++ /dev/null @@ -1,8 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -hltInitialStepSeedTracksLST = cms.EDProducer( - "TrackFromSeedProducer", - src = cms.InputTag("hltInitialStepSeeds"), - beamSpot = cms.InputTag("hltOnlineBeamSpot"), - TTRHBuilder = cms.string("hltESPTTRHBuilderWithoutRefit") -) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeeds_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeeds_cfi.py index dda1fa1234ce3..f3d6f6d9b7472 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeeds_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepSeeds_cfi.py @@ -6,14 +6,16 @@ SeedCreatorPSet = cms.PSet( refToPSet_ = cms.string('seedFromProtoTracks') ), - TTRHBuilder = cms.string('WithTrackAngle'), originHalfLength = cms.double(0.3), originRadius = cms.double(0.1), + useProtoTrackKinematics = cms.bool(False), + sortAndFilterProtoTracks = cms.bool(False), useEventsWithNoVertex = cms.bool(True), + TTRHBuilder = cms.string('WithTrackAngle'), usePV = cms.bool(False), - useProtoTrackKinematics = cms.bool(False), includeFourthHit = cms.bool(True), - removeOTRechits = cms.bool(True) + removeOTRechits = cms.bool(True), + produceComplement = cms.bool(False) ) from Configuration.ProcessModifiers.hltPhase2LegacyTracking_cff import hltPhase2LegacyTracking diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackCandidates_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackCandidates_cfi.py index f2787b3a4f3a0..8f766e6b0df4e 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackCandidates_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackCandidates_cfi.py @@ -64,6 +64,8 @@ lstPixelSeeds = cms.InputTag('hltInputLST'), includeT5s = cms.bool(True), includeNonpLSTSs = cms.bool(False), + produceSeeds = cms.bool(False), + produceTrackCandidates = cms.bool(True), propagatorAlong = cms.ESInputTag('', 'PropagatorWithMaterial'), propagatorOpposite = cms.ESInputTag('', 'PropagatorWithMaterialOpposite'), SeedCreatorPSet = cms.PSet( diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrajectorySeedsLST_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrajectorySeedsLST_cfi.py index c3585a5b85511..82e2085f7c263 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrajectorySeedsLST_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrajectorySeedsLST_cfi.py @@ -6,6 +6,8 @@ lstPixelSeeds = cms.InputTag('hltInputLST'), includeT5s = cms.bool(True), includeNonpLSTSs = cms.bool(True), + produceSeeds = cms.bool(True), + produceTrackCandidates = cms.bool(False), propagatorAlong = cms.ESInputTag('', 'PropagatorWithMaterial'), propagatorOpposite = cms.ESInputTag('', 'PropagatorWithMaterialOpposite'), SeedCreatorPSet = cms.PSet( diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInputLST_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInputLST_cfi.py index 93750cbe91ab4..1489e8c232fb6 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltInputLST_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltInputLST_cfi.py @@ -4,7 +4,7 @@ ptCut = cms.double(0.8), phase2OTRecHits = cms.InputTag('hltSiPhase2RecHits'), beamSpot = cms.InputTag('hltOnlineBeamSpot'), - seedTracks = cms.VInputTag('hltInitialStepSeedTracksLST'), + pixelSeeds = cms.VInputTag('hltInitialStepSeeds'), alpaka = cms.untracked.PSet( backend = cms.untracked.string('') ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltIter0Phase2L3FromL1TkMuonPixelSeedsFromPixelTracks_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltIter0Phase2L3FromL1TkMuonPixelSeedsFromPixelTracks_cfi.py index 66fcf98329587..968e7393d91b8 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltIter0Phase2L3FromL1TkMuonPixelSeedsFromPixelTracks_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltIter0Phase2L3FromL1TkMuonPixelSeedsFromPixelTracks_cfi.py @@ -6,10 +6,14 @@ SeedCreatorPSet = cms.PSet( refToPSet_ = cms.string('hltPhase2SeedFromProtoTracks') ), - TTRHBuilder = cms.string('WithTrackAngle'), originHalfLength = cms.double(0.3), originRadius = cms.double(0.1), + useProtoTrackKinematics = cms.bool(False), + sortAndFilterProtoTracks = cms.bool(False), useEventsWithNoVertex = cms.bool(True), + TTRHBuilder = cms.string('WithTrackAngle'), usePV = cms.bool(False), - useProtoTrackKinematics = cms.bool(False) + includeFourthHit = cms.bool(False), + removeOTRechits = cms.bool(False), + produceComplement = cms.bool(False) ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltPhase2L3MuonInitialStepSeeds_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltPhase2L3MuonInitialStepSeeds_cfi.py index e070e1e12253b..e4444da71f4df 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltPhase2L3MuonInitialStepSeeds_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltPhase2L3MuonInitialStepSeeds_cfi.py @@ -6,10 +6,14 @@ SeedCreatorPSet = cms.PSet( refToPSet_ = cms.string('hltPhase2L3MuonSeedFromProtoTracks') ), - TTRHBuilder = cms.string('WithTrackAngle'), originHalfLength = cms.double(0.3), originRadius = cms.double(0.1), + useProtoTrackKinematics = cms.bool(False), + sortAndFilterProtoTracks = cms.bool(False), useEventsWithNoVertex = cms.bool(True), + TTRHBuilder = cms.string('WithTrackAngle'), usePV = cms.bool(True), - useProtoTrackKinematics = cms.bool(False) + includeFourthHit = cms.bool(False), + removeOTRechits = cms.bool(False), + produceComplement = cms.bool(False) ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/paths/DST_HeterogeneousReco_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/paths/DST_HeterogeneousReco_cfi.py index 669b8acae40b7..2fdb8fa8b92cf 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/paths/DST_HeterogeneousReco_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/paths/DST_HeterogeneousReco_cfi.py @@ -7,7 +7,6 @@ from ..modules.hltHgcalSoARecHitsLayerClustersProducer_cfi import hltHgcalSoARecHitsLayerClustersProducer from ..modules.hltHgcalSoARecHitsProducer_cfi import hltHgcalSoARecHitsProducer from ..modules.hltInputLST_cfi import hltInputLST -from ..modules.hltInitialStepSeedTracksLST_cfi import hltInitialStepSeedTracksLST from ..modules.hltInitialStepSeeds_cfi import hltInitialStepSeeds from ..modules.hltInitialStepTrajectorySeedsLST_cfi import hltInitialStepTrajectorySeedsLST from ..modules.hltL1GTAcceptFilter_cfi import hltL1GTAcceptFilter @@ -54,7 +53,6 @@ HLTLSTSequence = cms.Sequence( hltInitialStepSeeds - + hltInitialStepSeedTracksLST + hltInputLST + hltLST ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTDoLocalPixelSequence_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTDoLocalPixelSequence_cfi.py index 4858df733ff5a..c0dd136fa5c86 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTDoLocalPixelSequence_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTDoLocalPixelSequence_cfi.py @@ -9,7 +9,7 @@ HLTDoLocalPixelSequence = cms.Sequence( hltPhase2SiPixelClustersSoA +hltSiPixelClusters - +hltSiPixelClusterShapeCache # should we disable this? Still needed by tracker muons + +hltSiPixelClusterShapeCache # Currently needed by tracker muons +hltPhase2SiPixelRecHitsSoA +hltSiPixelRecHits ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTInitialStepSequence_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTInitialStepSequence_cfi.py index 3796ff867fb39..574c199b9714c 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTInitialStepSequence_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTInitialStepSequence_cfi.py @@ -3,7 +3,6 @@ from ..modules.hltInputLST_cfi import * from ..modules.hltInitialStepMkFitSeeds_cfi import * -from ..modules.hltInitialStepSeedTracksLST_cfi import * from ..modules.hltInitialStepSeeds_cfi import * from ..modules.hltInitialStepTrackCandidates_cfi import * from ..modules.hltInitialStepTrackCandidatesMkFit_cfi import * @@ -13,13 +12,10 @@ from ..modules.hltInitialStepTrajectorySeedsLST_cfi import * from ..modules.hltInitialStepTrajectorySeedsLSTTracks_cfi import * from ..modules.hltLST_cfi import * -from ..modules.hltSiPhase2RecHits_cfi import * from ..sequences.HLTMkFitInputSequence_cfi import * HLTInitialStepSequence = cms.Sequence( hltInitialStepSeeds - +hltInitialStepSeedTracksLST - +hltSiPhase2RecHits +hltInputLST +hltLST +hltInitialStepTrajectorySeedsLST @@ -39,9 +35,6 @@ hltInitialStepSeedsSerialSync = hltInitialStepSeeds.clone( InputCollection = "hltPhase2PixelTracksSerialSync" ) -hltInitialStepSeedTracksLSTSerialSync = hltInitialStepSeedTracksLST.clone( - src = "hltInitialStepSeedsSerialSync" -) hltInputLSTSerialSync = makeSerialClone(hltInputLST) hltLSTSerialSync = makeSerialClone(hltLST, lstInput = "hltInputLSTSerialSync" @@ -60,8 +53,6 @@ from Configuration.ProcessModifiers.alpakaValidationHLT_cff import alpakaValidationHLT alpakaValidationHLT.toReplaceWith(HLTInitialStepSequenceSerialSync, cms.Sequence( hltInitialStepSeedsSerialSync - +hltInitialStepSeedTracksLSTSerialSync - +hltSiPhase2RecHits +hltInputLSTSerialSync +hltLSTSerialSync +hltInitialStepTrajectorySeedsLSTSerialSync @@ -77,8 +68,6 @@ from Configuration.ProcessModifiers.hltPhase2LegacyTracking_cff import hltPhase2LegacyTracking hltPhase2LegacyTracking.toReplaceWith(HLTInitialStepSequence, HLTInitialStepSequence.copyAndExclude([ - hltInitialStepSeedTracksLST, - hltSiPhase2RecHits, hltInputLST, hltLST, hltInitialStepTrajectorySeedsLST, @@ -91,8 +80,6 @@ _HLTInitialStepSequenceLST = cms.Sequence( hltInitialStepSeeds - +hltInitialStepSeedTracksLST - +hltSiPhase2RecHits # Probably need to move elsewhere in the final setup +hltInputLST +hltLST +hltInitialStepTrackCandidates @@ -108,8 +95,6 @@ from ..modules.hltInitialStepTracksT4T5TCLST_cfi import * _HLTInitialStepSequenceNGTScouting = cms.Sequence( hltInitialStepSeeds - +hltInitialStepSeedTracksLST - +hltSiPhase2RecHits +hltInputLST +hltLST +hltInitialStepTrackCandidates @@ -123,8 +108,6 @@ from ..modules.hltInitialStepTrackCandidatesMkFitFit_cfi import * _HLTInitialStepSequenceMkFitFit = cms.Sequence( hltInitialStepSeeds - +hltInitialStepSeedTracksLST - +hltSiPhase2RecHits +hltInputLST +hltLST +hltInitialStepTrajectorySeedsLST diff --git a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTPhase2PixelTracksAndVerticesSequence_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTPhase2PixelTracksAndVerticesSequence_cfi.py index 6c695d127a8bf..c3f76e2b91d7a 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTPhase2PixelTracksAndVerticesSequence_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTPhase2PixelTracksAndVerticesSequence_cfi.py @@ -19,9 +19,8 @@ HLTPhase2PixelTracksAndVerticesSequence = cms.Sequence( HLTBeamSpotSequence - +hltPhase2PixelTracksAndHighPtStepTrackingRegions # needed by highPtTripletStep iteration - +hltPhase2PixelFitterByHelixProjections # needed by tracker muons - +hltPhase2PixelTrackFilterByKinematics # needed by tracker muons + +hltPhase2PixelFitterByHelixProjections # Currently needed by tracker muons + +hltPhase2PixelTrackFilterByKinematics # Currently needed by tracker muons +hltPhase2OtRecHitsSoA +hltPhase2PixelRecHitsExtendedSoA +hltPhase2PixelTracksSoA @@ -70,7 +69,6 @@ from ..modules.hltPhase2TrimmedPixelVertices_cfi import hltPhase2TrimmedPixelVertices _HLTPhase2PixelTracksAndVerticesSequenceTrimming = cms.Sequence( HLTBeamSpotSequence - +hltPhase2PixelTracksAndHighPtStepTrackingRegions +hltPhase2PixelFitterByHelixProjections +hltPhase2PixelTrackFilterByKinematics +hltPhase2OtRecHitsSoA diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc index 43e1cf861541e..35eab715a20b6 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.cc @@ -14,6 +14,7 @@ #include "oneapi/tbb.h" #include #include +#include #include "DataFormats/DetId/interface/DetId.h" using namespace hgcal_clustering; @@ -171,7 +172,7 @@ std::vector HGCalCLUEAlgoT::getClusters(bool) { int maxEnergyCellIndex = -1; DetId maxEnergyDetId; float energy = 0.f; - int seedDetId = -1; + std::optional seedDetId; float x = 0.f; float y = 0.f; float z = cellsOnLayer.layerDim3; @@ -188,17 +189,27 @@ std::vector HGCalCLUEAlgoT::getClusters(bool) { seedDetId = cellsOnLayer.detid[cellIdx]; } } - + assert(seedDetId); float total_weight_log = 0.f; float total_weight = energy; if constexpr (std::is_same_v) { auto thick = rhtools_.getSiThickIndex(maxEnergyDetId); + assert(std::cmp_less(thick, thresholdW0_.size())); for (auto cellIdx : cl) { + assert(cellIdx >= 0); + assert(std::cmp_less(cellIdx, cellsOnLayer.dim1.size())); + assert(std::cmp_less(cellIdx, cellsOnLayer.dim2.size())); + assert(std::cmp_less(cellIdx, cellsOnLayer.weight.size())); const float d1 = cellsOnLayer.dim1[cellIdx] - cellsOnLayer.dim1[maxEnergyCellIndex]; const float d2 = cellsOnLayer.dim2[cellIdx] - cellsOnLayer.dim2[maxEnergyCellIndex]; if ((d1 * d1 + d2 * d2) < positionDeltaRho2_) { float Wi = std::max(thresholdW0_[thick] + std::log(cellsOnLayer.weight[cellIdx] / energy), 0.); + if (std::isnan(Wi)) { + throw cms::Exception("HGCalClusterNan") + << "The weight for cell " << cellIdx << " is a nan. The values in the calculation are weight " + << cellsOnLayer.weight[cellIdx] << " energy " << energy; + } x += cellsOnLayer.dim1[cellIdx] * Wi; y += cellsOnLayer.dim2[cellIdx] * Wi; total_weight_log += Wi; @@ -226,8 +237,9 @@ std::vector HGCalCLUEAlgoT::getClusters(bool) { } if (std::isnan(x) or std::isnan(y)) { - throw cms::Exception("HGCalClusterNan") << "while calculating the position of cluster seeded by " << seedDetId - << " we got x = " << x << " y = " << y << " z = " << z; + throw cms::Exception("HGCalClusterNan") + << "while calculating the position of cluster seeded by " << seedDetId->rawId() << " we got x = " << x + << " y = " << y << " z = " << z; } math::XYZPoint position = math::XYZPoint(x, y, z); @@ -235,7 +247,7 @@ std::vector HGCalCLUEAlgoT::getClusters(bool) { clusters_v_[globalClusterIndex] = reco::BasicCluster(energy, position, reco::CaloID::DET_HGCAL_ENDCAP, thisCluster, algoId_); - clusters_v_[globalClusterIndex].setSeed(seedDetId); + clusters_v_[globalClusterIndex].setSeed(*seedDetId); thisCluster.clear(); } diff --git a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py index 77f4e2f779a4d..b61ea28fd2385 100644 --- a/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py +++ b/RecoTracker/IterativeTracking/python/HighPtTripletStep_cff.py @@ -399,11 +399,10 @@ _HighPtTripletStepTask_LST = HighPtTripletStepTask.copy() from RecoLocalTracker.Phase2TrackerRecHits.Phase2TrackerRecHits_cfi import siPhase2RecHits -from RecoTracker.LST.lstSeedTracks_cff import lstInitialStepSeedTracks,lstHighPtTripletStepSeedTracks from RecoTracker.LST.lstInputProducer_cfi import lstInputProducer from RecoTracker.LST.lstProducerTask_cff import * -_HighPtTripletStepTask_LST.add(siPhase2RecHits, lstInitialStepSeedTracks, lstHighPtTripletStepSeedTracks, lstInputProducer, lstProducerTask) +_HighPtTripletStepTask_LST.add(siPhase2RecHits, lstInputProducer, lstProducerTask) (trackingPhase2PU140 & trackingLST).toReplaceWith(HighPtTripletStepTask, _HighPtTripletStepTask_LST) from Configuration.ProcessModifiers.alpakaValidationLST_cff import alpakaValidationLST @@ -422,8 +421,9 @@ highPtTripletStepSelectorSerialSync = highPtTripletStepSelector.clone() (trackingPhase2PU140 & alpakaValidationLST & trackingLST).toModify(highPtTripletStepSelectorSerialSync, src = "highPtTripletStepTracksSerialSync" ) _HighPtTripletStepTask_LSTSerialSync = HighPtTripletStepTask.copy() -_HighPtTripletStepTask_LSTSerialSync.add(siPhase2RecHits, lstInitialStepSeedTracks, lstHighPtTripletStepSeedTracks, lstInputProducerSerialSync, lstProducerSerialSync, - highPtTripletStepTrackCandidatesSerialSync, highPtTripletStepTracksSerialSync, highPtTripletStepSelectorSerialSync +_HighPtTripletStepTask_LSTSerialSync.add(siPhase2RecHits, lstInputProducerSerialSync, + lstProducerSerialSync, highPtTripletStepTrackCandidatesSerialSync, + highPtTripletStepTracksSerialSync, highPtTripletStepSelectorSerialSync ) HighPtTripletStepTaskSerialSync = cms.Task() (trackingPhase2PU140 & alpakaValidationLST & trackingLST).toReplaceWith(HighPtTripletStepTaskSerialSync, _HighPtTripletStepTask_LSTSerialSync) diff --git a/RecoTracker/LST/plugins/BuildFile.xml b/RecoTracker/LST/plugins/BuildFile.xml index b987ef730c0f9..3fe944bf9af9a 100644 --- a/RecoTracker/LST/plugins/BuildFile.xml +++ b/RecoTracker/LST/plugins/BuildFile.xml @@ -26,7 +26,9 @@ + + diff --git a/RecoTracker/LST/plugins/LSTOutputConverter.cc b/RecoTracker/LST/plugins/LSTOutputConverter.cc index 58b8be19a77f8..2f1ff99541c2e 100644 --- a/RecoTracker/LST/plugins/LSTOutputConverter.cc +++ b/RecoTracker/LST/plugins/LSTOutputConverter.cc @@ -40,6 +40,8 @@ class LSTOutputConverter : public edm::stream::EDProducer<> { const edm::EDGetTokenT lstPixelSeedToken_; const bool includeT5s_; const bool includeNonpLSTSs_; + const bool produceSeeds_; + const bool produceTrackCandidates_; const edm::ESGetToken mfToken_; const edm::ESGetToken propagatorAlongToken_; const edm::ESGetToken propagatorOppositeToken_; @@ -66,6 +68,8 @@ LSTOutputConverter::LSTOutputConverter(edm::ParameterSet const& iConfig) lstPixelSeedToken_{consumes(iConfig.getParameter("lstPixelSeeds"))}, includeT5s_(iConfig.getParameter("includeT5s")), includeNonpLSTSs_(iConfig.getParameter("includeNonpLSTSs")), + produceSeeds_(iConfig.getParameter("produceSeeds")), + produceTrackCandidates_(iConfig.getParameter("produceTrackCandidates")), mfToken_(esConsumes()), propagatorAlongToken_{esConsumes(iConfig.getParameter("propagatorAlong"))}, propagatorOppositeToken_{esConsumes(iConfig.getParameter("propagatorOpposite"))}, @@ -74,24 +78,29 @@ LSTOutputConverter::LSTOutputConverter(edm::ParameterSet const& iConfig) seedCreator_(SeedCreatorFactory::get()->create("SeedFromConsecutiveHitsCreator", iConfig.getParameter("SeedCreatorPSet"), consumesCollector())), - // FIXME: need to make creation configurable: - // - A toggle to not produce TSs at all could be useful to save memory; - // it won't affect speed though - // - The minimal set for TCs is t5TCsLST, pTTCsLST and pLSTCsLST. - // That would complicate the handling of collections though, - // so it is deferred to when we have a clearer picture of what's needed. - trajectorySeedPutToken_(produces("")), - trajectorySeedpLSPutToken_(produces("pLSTSsLST")), - trackCandidatePutToken_(produces("")), - trackCandidatepTCPutToken_(produces("pTCsLST")), - trackCandidateT4T5TCPutToken_(produces("t4t5TCsLST")), - trackCandidateNopLSTCPutToken_(produces("nopLSTCsLST")), - trackCandidatepTTCPutToken_(produces("pTTCsLST")), - trackCandidatepLSTCPutToken_(produces("pLSTCsLST")), - seedStopInfoPutToken_(produces("")), - pTCsSeedStopInfoPutToken_(produces("pTCsLST")), - t4t5TCsSeedStopInfoPutToken_(produces("t4t5TCsLST")), - pTTCsSeedStopInfoPutToken_(produces("pTTCsLST")) {} + trajectorySeedPutToken_(produces("")), + trajectorySeedpLSPutToken_(produceSeeds_ ? produces("pLSTSsLST") + : edm::EDPutTokenT{}), + trackCandidatePutToken_(produceTrackCandidates_ ? produces("") + : edm::EDPutTokenT{}), + trackCandidatepTCPutToken_(produceTrackCandidates_ ? produces("pTCsLST") + : edm::EDPutTokenT{}), + trackCandidateT4T5TCPutToken_(produceTrackCandidates_ ? produces("t4t5TCsLST") + : edm::EDPutTokenT{}), + trackCandidateNopLSTCPutToken_(produceTrackCandidates_ ? produces("nopLSTCsLST") + : edm::EDPutTokenT{}), + trackCandidatepTTCPutToken_(produceTrackCandidates_ ? produces("pTTCsLST") + : edm::EDPutTokenT{}), + trackCandidatepLSTCPutToken_(produceTrackCandidates_ ? produces("pLSTCsLST") + : edm::EDPutTokenT{}), + seedStopInfoPutToken_(produceTrackCandidates_ ? produces>("") + : edm::EDPutTokenT>{}), + pTCsSeedStopInfoPutToken_(produceTrackCandidates_ ? produces>("pTCsLST") + : edm::EDPutTokenT>{}), + t4t5TCsSeedStopInfoPutToken_(produceTrackCandidates_ ? produces>("t4t5TCsLST") + : edm::EDPutTokenT>{}), + pTTCsSeedStopInfoPutToken_(produceTrackCandidates_ ? produces>("pTTCsLST") + : edm::EDPutTokenT>{}) {} void LSTOutputConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -101,6 +110,8 @@ void LSTOutputConverter::fillDescriptions(edm::ConfigurationDescriptions& descri desc.add("lstPixelSeeds", edm::InputTag("lstInputProducer")); desc.add("includeT5s", true); desc.add("includeNonpLSTSs", false); + desc.add("produceSeeds", true); + desc.add("produceTrackCandidates", true); desc.add("propagatorAlong", edm::ESInputTag{"", "PropagatorWithMaterial"}); desc.add("propagatorOpposite", edm::ESInputTag{"", "PropagatorWithMaterialOpposite"}); @@ -148,60 +159,68 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet auto OTHits = lstInputHC.const_view().hits().hits(); + TrajectorySeedCollection seeds; + using Hit = SeedingHitSet::ConstRecHitPointer; + std::vector hitsForSeed; + LogDebug("LSTOutputConverter") << "nTrackCandidates " << nTrackCandidates; for (unsigned int i = 0; i < nTrackCandidates; i++) { auto iType = lstOutput_view.trackCandidateType()[i]; + bool const isT5orT4 = (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4); LogDebug("LSTOutputConverter") << " cand " << i << " " << iType << " " << lstOutput_view.pixelSeedIndex()[i]; TrajectorySeed seed; edm::RefToBase seedRef; - if (iType != lst::LSTObjType::T5 && iType != lst::LSTObjType::T4) { + if (!isT5orT4) { seed = pixelSeeds[lstOutput_view.pixelSeedIndex()[i]]; seedRef = {pixelSeedsRBP, lstOutput_view.pixelSeedIndex()[i]}; } edm::OwnVector recHits; - if (iType != lst::LSTObjType::T5 && iType != lst::LSTObjType::T4) { + if (!isT5orT4) { for (auto const& hit : seed.recHits()) recHits.push_back(hit.clone()); } - // The pixel hits are packed into first kPixelLayerSlots layer slots. - for (unsigned int layerSlot = lst::Params_TC::kPixelLayerSlots; layerSlot < lst::Params_TC::kLayers; ++layerSlot) { - for (unsigned int hitSlot = 0; hitSlot < lst::Params_TC::kHitsPerLayer; ++hitSlot) { - unsigned int hitIdx = lstOutput_view.hitIndices()[i][layerSlot][hitSlot]; - if (hitIdx == lst::kTCEmptyHitIdx) - continue; - recHits.push_back(OTHits[hitIdx]->clone()); + if (iType != lst::LSTObjType::pLS) { + // The pixel hits are packed into first kPixelLayerSlots layer slots. + for (unsigned int layerSlot = lst::Params_TC::kPixelLayerSlots; layerSlot < lst::Params_TC::kLayers; + ++layerSlot) { + for (unsigned int hitSlot = 0; hitSlot < lst::Params_TC::kHitsPerLayer; ++hitSlot) { + unsigned int hitIdx = lstOutput_view.hitIndices()[i][layerSlot][hitSlot]; + if (hitIdx == lst::kTCEmptyHitIdx) + continue; + recHits.push_back(OTHits[hitIdx]->clone()); + } } - } - recHits.sort([](const auto& a, const auto& b) { - const auto asub = a.det()->subDetector(); - const auto bsub = b.det()->subDetector(); - if (GeomDetEnumerators::isInnerTracker(asub) && GeomDetEnumerators::isOuterTracker(bsub)) { - return true; - } else if (GeomDetEnumerators::isOuterTracker(asub) && GeomDetEnumerators::isInnerTracker(bsub)) { - return false; - } else if (asub != bsub) { - return asub < bsub; - } else { - const auto& apos = a.surface(); - const auto& bpos = b.surface(); - if (GeomDetEnumerators::isBarrel(asub)) { - return apos->rSpan().first < bpos->rSpan().first; + recHits.sort([](const auto& a, const auto& b) { + const auto asub = a.det()->subDetector(); + const auto bsub = b.det()->subDetector(); + if (GeomDetEnumerators::isInnerTracker(asub) && GeomDetEnumerators::isOuterTracker(bsub)) { + return true; + } else if (GeomDetEnumerators::isOuterTracker(asub) && GeomDetEnumerators::isInnerTracker(bsub)) { + return false; + } else if (asub != bsub) { + return asub < bsub; } else { - return std::abs(apos->zSpan().first) < std::abs(bpos->zSpan().first); + const auto& apos = a.surface(); + const auto& bpos = b.surface(); + if (GeomDetEnumerators::isBarrel(asub)) { + return apos->rSpan().first < bpos->rSpan().first; + } else { + return std::abs(apos->zSpan().first) < std::abs(bpos->zSpan().first); + } } - } - }); + }); + } - TrajectorySeedCollection seeds; if (iType != lst::LSTObjType::pLS) { - // Construct a full-length TrajectorySeed always for T5s, - // only when required by a flag for other pT objects. - if (includeNonpLSTSs_ || (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4)) { - using Hit = SeedingHitSet::ConstRecHitPointer; - std::vector hitsForSeed; + // For T5/T4: makeSeed is needed whenever seeds or TCs are produced, since the resulting + // seed is the only source of initial state for T5/T4 track candidates. + // For other pT objects: makeSeed is only needed for seed output. + if ((isT5orT4 && (produceSeeds_ || produceTrackCandidates_)) || + (!isT5orT4 && produceSeeds_ && includeNonpLSTSs_)) { + hitsForSeed.clear(); hitsForSeed.reserve(recHits.size()); int n = 0; unsigned int firstLayer; @@ -226,14 +245,15 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet } GlobalTrackingRegion region; seedCreator_->init(region, iSetup, nullptr); + seeds.clear(); seedCreator_->makeSeed(seeds, hitsForSeed); if (seeds.empty()) { edm::LogInfo("LSTOutputConverter") << "failed to convert a LST object to a seed" << i << " " << iType << " " << lstOutput_view.pixelSeedIndex()[i]; - if (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4) + if (isT5orT4) continue; } - if (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4) { + if (isT5orT4) { seed = seeds[0]; seedRef = edm::RefToBase(edm::Ref(outputTSRP, outputTS.size())); } @@ -245,10 +265,15 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet << ss.pt() << " " << ss.parameters().vector() << " " << ss.error(0); } } else { - outputTS.emplace_back(seed); - outputpLSTS.emplace_back(seed); + if (produceSeeds_) { + outputTS.emplace_back(seed); + outputpLSTS.emplace_back(seed); + } } + if (!produceTrackCandidates_) + continue; + TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(seed.startingState(), (seed.recHits().end() - 1)->surface(), &mf); tsos.rescaleError(100.); @@ -261,12 +286,12 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet PTrajectoryStateOnDet st = trajectoryStateTransform::persistentState(tsosPair.first, recHits[0].det()->geographicalId().rawId()); - if (!includeT5s_ && (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4)) + if (!includeT5s_ && isT5orT4) continue; auto tc = TrackCandidate(recHits, seed, st, seedRef); outputTC.emplace_back(tc); - if (iType == lst::LSTObjType::T5 || iType == lst::LSTObjType::T4) { + if (isT5orT4) { outputT4T5TC.emplace_back(tc); outputNopLSTC.emplace_back(tc); } else { @@ -289,24 +314,23 @@ void LSTOutputConverter::produce(edm::Event& iEvent, const edm::EventSetup& iSet LogDebug("LSTOutputConverter") << "done with conversion: Track candidate output size = " << outputpTC.size() << " (p* objects) + " << outputT4T5TC.size() << " (T5 objects)"; - //dummy (for now) stop infos: one per used kind of candidates - std::vector seedStopInfo(pixelSeeds.size()); - iEvent.emplace(seedStopInfoPutToken_, std::move(seedStopInfo)); - std::vector pTCsSeedStopInfo(pixelSeeds.size()); - iEvent.emplace(pTCsSeedStopInfoPutToken_, std::move(pTCsSeedStopInfo)); - std::vector t4t5TCsSeedStopInfo(outputTS.size()); - iEvent.emplace(t4t5TCsSeedStopInfoPutToken_, std::move(t4t5TCsSeedStopInfo)); - std::vector pTTCsSeedStopInfo(pixelSeeds.size()); - iEvent.emplace(pTTCsSeedStopInfoPutToken_, std::move(pTTCsSeedStopInfo)); iEvent.emplace(trajectorySeedPutToken_, std::move(outputTS)); - iEvent.emplace(trajectorySeedpLSPutToken_, std::move(outputpLSTS)); - iEvent.emplace(trackCandidatePutToken_, std::move(outputTC)); - iEvent.emplace(trackCandidatepTCPutToken_, std::move(outputpTC)); - iEvent.emplace(trackCandidateT4T5TCPutToken_, std::move(outputT4T5TC)); - iEvent.emplace(trackCandidateNopLSTCPutToken_, std::move(outputNopLSTC)); - iEvent.emplace(trackCandidatepTTCPutToken_, std::move(outputpTTC)); - iEvent.emplace(trackCandidatepLSTCPutToken_, std::move(outputpLSTC)); + if (produceSeeds_) + iEvent.emplace(trajectorySeedpLSPutToken_, std::move(outputpLSTS)); + if (produceTrackCandidates_) { + //dummy (for now) stop infos: one per used kind of candidates + iEvent.emplace(seedStopInfoPutToken_, std::vector(pixelSeeds.size())); + iEvent.emplace(pTCsSeedStopInfoPutToken_, std::vector(pixelSeeds.size())); + iEvent.emplace(t4t5TCsSeedStopInfoPutToken_, std::vector(outputT4T5TC.size())); + iEvent.emplace(pTTCsSeedStopInfoPutToken_, std::vector(pixelSeeds.size())); + iEvent.emplace(trackCandidatePutToken_, std::move(outputTC)); + iEvent.emplace(trackCandidatepTCPutToken_, std::move(outputpTC)); + iEvent.emplace(trackCandidateT4T5TCPutToken_, std::move(outputT4T5TC)); + iEvent.emplace(trackCandidateNopLSTCPutToken_, std::move(outputNopLSTC)); + iEvent.emplace(trackCandidatepTTCPutToken_, std::move(outputpTTC)); + iEvent.emplace(trackCandidatepLSTCPutToken_, std::move(outputpLSTC)); + } } DEFINE_FWK_MODULE(LSTOutputConverter); diff --git a/RecoTracker/LST/plugins/alpaka/LSTInputProducer.cc b/RecoTracker/LST/plugins/alpaka/LSTInputProducer.cc index 600a0d929624a..0f5bbd4dfac32 100644 --- a/RecoTracker/LST/plugins/alpaka/LSTInputProducer.cc +++ b/RecoTracker/LST/plugins/alpaka/LSTInputProducer.cc @@ -10,16 +10,17 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "DataFormats/TrackerRecHit2D/interface/Phase2TrackerRecHit1D.h" +#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" #include "FWCore/Utilities/interface/transform.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" -#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" -#include "DataFormats/TrackReco/interface/trackFromSeedFitFailed.h" #include "TrackingTools/Records/interface/TransientRecHitRecord.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h" +#include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h" +#include "TrackingTools/TrajectoryState/interface/PerigeeConversions.h" #include "RecoTracker/LSTCore/interface/LSTInputHostCollection.h" #include "RecoTracker/LSTCore/interface/LSTPrepareInput.h" @@ -42,7 +43,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { const edm::ESGetToken mfToken_; const edm::EDGetTokenT beamSpotToken_; - const std::vector>> seedTokens_; + const std::vector> seedTokens_; const edm::EDPutTokenT lstPixelSeedsPutToken_; const edm::EDPutTokenT lstInputPutToken_; @@ -55,8 +56,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { mfToken_(esConsumes()), beamSpotToken_(consumes(iConfig.getParameter("beamSpot"))), seedTokens_( - edm::vector_transform(iConfig.getParameter>("seedTracks"), - [&](const edm::InputTag& tag) { return consumes>(tag); })), + edm::vector_transform(iConfig.getParameter>("pixelSeeds"), + [&](const edm::InputTag& tag) { return consumes(tag); })), lstPixelSeedsPutToken_(produces()), lstInputPutToken_(produces()) {} @@ -68,9 +69,9 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { desc.add("phase2OTRecHits", edm::InputTag("siPhase2RecHits")); desc.add("beamSpot", edm::InputTag("offlineBeamSpot")); - desc.add>("seedTracks", - std::vector{edm::InputTag("lstInitialStepSeedTracks"), - edm::InputTag("lstHighPtTripletStepSeedTracks")}); + desc.add>( + "pixelSeeds", + std::vector{edm::InputTag("initialStepSeeds"), edm::InputTag("highPtTripletStepSeeds")}); descriptions.addWithDefaultLabel(desc); } @@ -108,6 +109,8 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { auto const& mf = iSetup.getData(mfToken_); auto const& bs = iEvent.get(beamSpotToken_); + TSCBLBuilderNoMaterial tscblBuilder; + // Vector definitions std::vector see_px; std::vector see_py; @@ -128,38 +131,53 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { TrajectorySeedCollection see_seeds; for (auto const& seedToken : seedTokens_) { - auto const& seedTracks = iEvent.get(seedToken); + auto const& seeds = iEvent.get(seedToken); - if (seedTracks.empty()) + if (seeds.empty()) continue; - // Get seed track refs - edm::RefToBaseVector seedTrackRefs; - for (edm::View::size_type i = 0; i < seedTracks.size(); ++i) { - seedTrackRefs.push_back(seedTracks.refAt(i)); - } - - edm::ProductID id = seedTracks[0].seedRef().id(); - - for (size_t iSeed = 0; iSeed < seedTrackRefs.size(); ++iSeed) { - auto const& seedTrackRef = seedTrackRefs[iSeed]; - auto const& seedTrack = *seedTrackRef; - auto const& seedRef = seedTrack.seedRef(); - auto const& seed = *seedRef; - - if (seedRef.id() != id) - throw cms::Exception("LogicError") - << "All tracks in 'TracksFromSeeds' collection should point to seeds in the same collection. Now the " - "element 0 had ProductID " - << id << " while the element " << seedTrackRef.key() << " had " << seedTrackRef.id() << "."; - - const bool seedFitOk = !trackFromSeedFitFailed(seedTrack); - + for (auto const& seed : seeds) { const TrackingRecHit* lastRecHit = &*(seed.recHits().end() - 1); TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), &mf); auto const& stateGlobal = tsos.globalParameters(); + // Propagate to beam line to get perigee parameters (replicates TrackFromSeedProducer) + TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(tsos.freeState()), bs); + const bool tscblValid = tscbl.isValid(); + + float px = 0, py = 0, pz = 0, dxy = 0, dz = 0, ptErr = 0, etaErr = 0; + int charge = tscblValid ? tsos.charge() : 0; + + if (tscblValid) { + auto const& fts = tscbl.trackStateAtPCA(); + auto const& mom = fts.momentum(); + auto const& pos = fts.position(); + auto const& bsPos = bs.position(); + px = mom.x(); + py = mom.y(); + pz = mom.z(); + dxy = (-(pos.x() - bsPos.x()) * mom.y() + (pos.y() - bsPos.y()) * mom.x()) / mom.perp(); + dz = (pos.z() - bsPos.z()) - ((pos.x() - bsPos.x()) * mom.x() + (pos.y() - bsPos.y()) * mom.y()) / + mom.perp() * (mom.z() / mom.perp()); + + // Compute ptErr and etaErr replicating reco::TrackBase::ptError() and etaError() + PerigeeTrajectoryError periErr = PerigeeConversions::ftsToPerigeeError(fts); + auto const& errMat = periErr.covarianceMatrix(); + double pt = mom.perp(); + double p = mom.mag(); + double pz = mom.z(); + double q = static_cast(charge); + // Full error propagation matching reco::TrackBase::ptError2(): + // pt2*p2/q2 * cov(qoverp,qoverp) + 2*sqrt(p2*pt2)/q * pz * cov(qoverp,lambda) + pz2 * cov(lambda,lambda) + double pt2 = pt * pt; + double p2 = p * p; + ptErr = std::sqrt(pt2 * p2 / (q * q) * errMat(0, 0) + 2.0 * std::sqrt(p2 * pt2) / q * pz * errMat(0, 1) + + pz * pz * errMat(1, 1)); + // etaError() = sqrt(cov(lambda,lambda)) * p/pt + etaErr = std::sqrt(errMat(1, 1)) * p / pt; + } + std::vector hitIdx; std::vector hitType; for (auto const& hit : seed.recHits()) { @@ -181,20 +199,20 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { } // Fill output - see_px.push_back(seedFitOk ? seedTrack.px() : 0); - see_py.push_back(seedFitOk ? seedTrack.py() : 0); - see_pz.push_back(seedFitOk ? seedTrack.pz() : 0); - see_dxy.push_back(seedFitOk ? seedTrack.dxy(bs.position()) : 0); - see_dz.push_back(seedFitOk ? seedTrack.dz(bs.position()) : 0); - see_ptErr.push_back(seedFitOk ? seedTrack.ptError() : 0); - see_etaErr.push_back(seedFitOk ? seedTrack.etaError() : 0); + see_px.push_back(px); + see_py.push_back(py); + see_pz.push_back(pz); + see_dxy.push_back(dxy); + see_dz.push_back(dz); + see_ptErr.push_back(ptErr); + see_etaErr.push_back(etaErr); see_stateTrajGlbX.push_back(stateGlobal.position().x()); see_stateTrajGlbY.push_back(stateGlobal.position().y()); see_stateTrajGlbZ.push_back(stateGlobal.position().z()); see_stateTrajGlbPx.push_back(stateGlobal.momentum().x()); see_stateTrajGlbPy.push_back(stateGlobal.momentum().y()); see_stateTrajGlbPz.push_back(stateGlobal.momentum().z()); - see_q.push_back(seedTrack.charge()); + see_q.push_back(charge); see_hitIdx.emplace_back(std::move(hitIdx)); see_hitType.emplace_back(std::move(hitType)); see_seeds.push_back(seed); diff --git a/RecoTracker/LST/python/lstSeedTracks_cff.py b/RecoTracker/LST/python/lstSeedTracks_cff.py deleted file mode 100644 index 7046c616b0054..0000000000000 --- a/RecoTracker/LST/python/lstSeedTracks_cff.py +++ /dev/null @@ -1,15 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -lstInitialStepSeedTracks = cms.EDProducer( - "TrackFromSeedProducer", - src = cms.InputTag("initialStepSeeds"), - beamSpot = cms.InputTag("offlineBeamSpot"), - TTRHBuilder = cms.string("WithoutRefit") -) - -lstHighPtTripletStepSeedTracks = cms.EDProducer( - "TrackFromSeedProducer", - src = cms.InputTag("highPtTripletStepSeeds"), - beamSpot = cms.InputTag("offlineBeamSpot"), - TTRHBuilder = cms.string("WithoutRefit") -) diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.cc index f300665353477..9f9c2541c2049 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.cc @@ -41,6 +41,7 @@ void SeedGeneratorFromProtoTracksEDProducer::fillDescriptions(edm::Configuration desc.add("originHalfLength", 1E9); desc.add("originRadius", 1E9); desc.add("useProtoTrackKinematics", false); + desc.add("sortAndFilterProtoTracks", false); desc.add("useEventsWithNoVertex", true); desc.add("TTRHBuilder", "TTRHBuilderWithoutAngle4PixelTriplets"); desc.add("usePV", false); @@ -66,6 +67,7 @@ SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer(c : originHalfLength(cfg.getParameter("originHalfLength")), originRadius(cfg.getParameter("originRadius")), useProtoTrackKinematics(cfg.getParameter("useProtoTrackKinematics")), + sortAndFilterProtoTracks_(cfg.getParameter("sortAndFilterProtoTracks")), useEventsWithNoVertex(cfg.getParameter("useEventsWithNoVertex")), usePV_(cfg.getParameter("usePV")), removeOTRechits_(cfg.getParameter("removeOTRechits")), @@ -131,9 +133,47 @@ void SeedGeneratorFromProtoTracksEDProducer::produce(edm::Event& ev, const edm:: continue; if (useProtoTrackKinematics) { - SeedFromProtoTrack seedFromProtoTrack(config_, proto, es); - if (seedFromProtoTrack.isValid()) - (*result).push_back(seedFromProtoTrack.trajectorySeed()); + if (removeOTRechits_) { + std::vector hits; + for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) { + TrackingRecHitRef refHit = proto.recHit(iHit); + if (refHit->isValid()) + hits.push_back((Hit) & (*refHit)); + } + sort(hits.begin(), hits.end(), HitLessByRadius()); + hits.erase(std::remove_if(hits.begin(), + hits.end(), + [](const Hit& hit) { + unsigned int subdetId = hit->geographicalId().subdetId(); + return subdetId != PixelSubdetector::PixelBarrel && + subdetId != PixelSubdetector::PixelEndcap; + }), + hits.end()); + if (hits.size() > 2) { + SeedFromProtoTrack seedFromProtoTrack(config_, proto, SeedingHitSet(hits), es); + if (seedFromProtoTrack.isValid()) + (*result).push_back(seedFromProtoTrack.trajectorySeed()); + } + } else { + if (sortAndFilterProtoTracks_) { + std::vector hits; + for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) { + TrackingRecHitRef refHit = proto.recHit(iHit); + if (refHit->isValid()) + hits.push_back((Hit) & (*refHit)); + } + sort(hits.begin(), hits.end(), HitLessByRadius()); + if (hits.size() > 2) { + SeedFromProtoTrack seedFromProtoTrack(config_, proto, SeedingHitSet(hits), es); + if (seedFromProtoTrack.isValid()) + (*result).push_back(seedFromProtoTrack.trajectorySeed()); + } + } else { + SeedFromProtoTrack seedFromProtoTrack(config_, proto, es); + if (seedFromProtoTrack.isValid()) + (*result).push_back(seedFromProtoTrack.trajectorySeed()); + } + } } else { std::vector hits; for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) { diff --git a/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.h b/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.h index df42650e5cdad..633282c74a2f5 100644 --- a/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.h +++ b/RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromProtoTracksEDProducer.h @@ -19,6 +19,7 @@ class dso_hidden SeedGeneratorFromProtoTracksEDProducer : public edm::stream::ED const double originHalfLength; const double originRadius; const bool useProtoTrackKinematics; + const bool sortAndFilterProtoTracks_; const bool useEventsWithNoVertex; const bool usePV_; const bool removeOTRechits_; diff --git a/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h index 12337b541367a..868e2bee4f380 100644 --- a/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h +++ b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h @@ -46,9 +46,9 @@ #include "SimDataFormats/CaloHit/interface/PCaloHit.h" #include -typedef EcalTDigitizer EBDigitizer; -typedef EcalTDigitizer EEDigitizer; -typedef CaloTDigitizer ESOldDigitizer; +using EBDigitizer = EcalTDigitizer; +using EEDigitizer = EcalTDigitizer; +using ESOldDigitizer = CaloTDigitizer; class ESDigitizer; @@ -99,7 +99,7 @@ class EcalDigiProducer : public DigiAccumulatorMixMod { virtual void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const {} virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const {} - typedef edm::Handle> HitsHandle; + using HitsHandle = edm::Handle>; void accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, HitsHandle const &esHandle, @@ -121,10 +121,10 @@ class EcalDigiProducer : public DigiAccumulatorMixMod { const std::string m_EEdigiCollection; const std::string m_ESdigiCollection; const std::string m_hitsProducerTag; - - const edm::EDGetTokenT> m_HitsEBToken_; - const edm::EDGetTokenT> m_HitsEEToken_; - const edm::EDGetTokenT> m_HitsESToken_; + const std::string m_hitsProducerTagPU; + edm::EDGetTokenT> m_HitsEBToken_; + edm::EDGetTokenT> m_HitsEEToken_; + edm::EDGetTokenT> m_HitsESToken_; const edm::ESGetToken m_pedestalsToken; const edm::ESGetToken m_icalToken; @@ -188,9 +188,9 @@ class EcalDigiProducer : public DigiAccumulatorMixMod { std::unique_ptr m_BarrelDigitizer; std::unique_ptr m_EndcapDigitizer; - typedef CaloTSamples EcalSamples; + using EcalSamples = CaloTSamples; - typedef EcalElectronicsSim EcalElectronicsSim_Ph1; + using EcalElectronicsSim_Ph1 = EcalElectronicsSim; std::unique_ptr m_ElectronicsSim; std::unique_ptr m_Coder; diff --git a/SimCalorimetry/EcalSimProducers/src/EcalDigiProducer.cc b/SimCalorimetry/EcalSimProducers/src/EcalDigiProducer.cc index 586399a9c19d8..26959c508397b 100644 --- a/SimCalorimetry/EcalSimProducers/src/EcalDigiProducer.cc +++ b/SimCalorimetry/EcalSimProducers/src/EcalDigiProducer.cc @@ -60,9 +60,7 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume m_EEdigiCollection(params.getParameter("EEdigiCollection")), m_ESdigiCollection(params.getParameter("ESdigiCollection")), m_hitsProducerTag(params.getParameter("hitsProducer")), - m_HitsEBToken_(iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEB"))), - m_HitsEEToken_(iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEE"))), - m_HitsESToken_(iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsES"))), + m_hitsProducerTagPU(params.getParameter("hitsProducerPU")), m_pedestalsToken(iC.esConsumes()), m_icalToken(iC.esConsumes()), m_laserToken(iC.esConsumes()), @@ -77,27 +75,27 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume m_EEs25notCont(params.getParameter("EEs25notContainment")), m_readoutFrameSize(ecalPh1::sampleSize), - m_ParameterMap(new EcalSimParameterMap(params.getParameter("simHitToPhotoelectronsBarrel"), - params.getParameter("simHitToPhotoelectronsEndcap"), - params.getParameter("photoelectronsToAnalogBarrel"), - params.getParameter("photoelectronsToAnalogEndcap"), - params.getParameter("samplingFactor"), - params.getParameter("timePhase"), - m_readoutFrameSize, - params.getParameter("binOfMaximum"), - params.getParameter("doPhotostatistics"), - params.getParameter("syncPhase"))), + m_ParameterMap(std::make_unique(params.getParameter("simHitToPhotoelectronsBarrel"), + params.getParameter("simHitToPhotoelectronsEndcap"), + params.getParameter("photoelectronsToAnalogBarrel"), + params.getParameter("photoelectronsToAnalogEndcap"), + params.getParameter("samplingFactor"), + params.getParameter("timePhase"), + m_readoutFrameSize, + params.getParameter("binOfMaximum"), + params.getParameter("doPhotostatistics"), + params.getParameter("syncPhase"))), m_apdDigiTag(params.getParameter("apdDigiTag")), - m_apdParameters(new APDSimParameters(params.getParameter("apdAddToBarrel"), - m_apdSeparateDigi, - params.getParameter("apdSimToPELow"), - params.getParameter("apdSimToPEHigh"), - params.getParameter("apdTimeOffset"), - params.getParameter("apdTimeOffWidth"), - params.getParameter("apdDoPEStats"), - m_apdDigiTag, - params.getParameter>("apdNonlParms"))), + m_apdParameters(std::make_unique(params.getParameter("apdAddToBarrel"), + m_apdSeparateDigi, + params.getParameter("apdSimToPELow"), + params.getParameter("apdSimToPEHigh"), + params.getParameter("apdTimeOffset"), + params.getParameter("apdTimeOffWidth"), + params.getParameter("apdDoPEStats"), + m_apdDigiTag, + params.getParameter>("apdNonlParms"))), m_componentDigiTag(params.getParameter("componentDigiTag")), m_componentParameters( @@ -115,14 +113,14 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume params.getParameter("syncPhase"))), m_APDResponse(!m_apdSeparateDigi ? nullptr - : new EBHitResponse(m_ParameterMap.get(), - &m_EBShape, - true, - false, - m_apdParameters.get(), - &m_APDShape, - m_componentParameters.get(), - &m_ComponentShapes)), + : std::make_unique(m_ParameterMap.get(), + &m_EBShape, + true, + false, + m_apdParameters.get(), + &m_APDShape, + m_componentParameters.get(), + &m_ComponentShapes)), m_ComponentResponse(!m_componentSeparateDigi ? nullptr @@ -136,18 +134,18 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume m_componentParameters.get(), &m_ComponentShapes)), // check if that false is correct // TODO HERE JCH - m_EBResponse(new EBHitResponse(m_ParameterMap.get(), - &m_EBShape, - false, // barrel - false, // normal non-component shape based - m_apdParameters.get(), - &m_APDShape, - m_componentParameters.get(), - &m_ComponentShapes)), + m_EBResponse(std::make_unique(m_ParameterMap.get(), + &m_EBShape, + false, // barrel + false, // normal non-component shape based + m_apdParameters.get(), + &m_APDShape, + m_componentParameters.get(), + &m_ComponentShapes)), - m_EEResponse(new EEHitResponse(m_ParameterMap.get(), &m_EEShape)), - m_ESResponse(new ESHitResponse(m_ParameterMap.get(), &m_ESShape)), - m_ESOldResponse(new CaloHitResponse(m_ParameterMap.get(), &m_ESShape)), + m_EEResponse(std::make_unique(m_ParameterMap.get(), &m_EEShape)), + m_ESResponse(std::make_unique(m_ParameterMap.get(), &m_ESShape)), + m_ESOldResponse(std::make_unique(m_ParameterMap.get(), &m_ESShape)), m_addESNoise(params.getParameter("doESNoise")), m_PreMix1(params.getParameter("EcalPreMixStage1")), @@ -159,15 +157,17 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume m_doEE(params.getParameter("doEE")), m_doES(params.getParameter("doES")), - m_ESElectronicsSim(m_doFastES ? nullptr : new ESElectronicsSim(m_addESNoise)), + m_ESElectronicsSim(m_doFastES ? nullptr : std::make_unique(m_addESNoise)), - m_ESOldDigitizer(m_doFastES ? nullptr - : new ESOldDigitizer(m_ESOldResponse.get(), m_ESElectronicsSim.get(), m_addESNoise)), + m_ESOldDigitizer( + m_doFastES ? nullptr + : std::make_unique(m_ESOldResponse.get(), m_ESElectronicsSim.get(), m_addESNoise)), - m_ESElectronicsSimFast(!m_doFastES ? nullptr : new ESElectronicsSimFast(m_addESNoise, m_PreMix1)), + m_ESElectronicsSimFast(!m_doFastES ? nullptr : std::make_unique(m_addESNoise, m_PreMix1)), - m_ESDigitizer(!m_doFastES ? nullptr - : new ESDigitizer(m_ESResponse.get(), m_ESElectronicsSimFast.get(), m_addESNoise)), + m_ESDigitizer( + !m_doFastES ? nullptr + : std::make_unique(m_ESResponse.get(), m_ESElectronicsSimFast.get(), m_addESNoise)), m_APDDigitizer(nullptr), m_ComponentDigitizer(nullptr), @@ -185,12 +185,16 @@ EcalDigiProducer::EcalDigiProducer(const edm::ParameterSet ¶ms, edm::Consume // mixMod.produces(m_EBdigiCollection); // mixMod.produces(m_EEdigiCollection); // mixMod.produces(m_ESdigiCollection); + + // Get the tokens for signal if (m_doEB) - iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEB")); + m_HitsEBToken_ = iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEB")); if (m_doEE) - iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEE")); + m_HitsEEToken_ = iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsEE")); + if (m_doES) + m_HitsESToken_ = iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsES")); + if (m_doES) { - iC.consumes>(edm::InputTag(m_hitsProducerTag, "EcalHitsES")); m_esGainToken = iC.esConsumes(); m_esMIPToGeVToken = iC.esConsumes(); m_esPedestalsToken = iC.esConsumes(); @@ -373,20 +377,27 @@ void EcalDigiProducer::accumulateCaloHits(HitsHandle const &ebHandle, void EcalDigiProducer::accumulate(edm::Event const &e, edm::EventSetup const &eventSetup) { // Step A: Get Inputs - const edm::Handle> &ebHandle = e.getHandle(m_HitsEBToken_); + edm::Handle> ebHandle; if (m_doEB) { + ebHandle = e.getHandle(m_HitsEBToken_); m_EBShape.setEventSetup(eventSetup); m_APDShape.setEventSetup(eventSetup); m_ComponentShapes.setEventSetup(eventSetup); } - const edm::Handle> &eeHandle = e.getHandle(m_HitsEEToken_); + edm::Handle> eeHandle; if (m_doEE) { + eeHandle = e.getHandle(m_HitsEEToken_); m_EEShape.setEventSetup(eventSetup); } - const edm::Handle> &esHandle = e.getHandle(m_HitsESToken_); - + edm::Handle> esHandle; + if (m_doES) { + esHandle = e.getHandle(m_HitsESToken_); + } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("EcalDigiProducer") << "Accumulate Signal Hits with Tag " << m_hitsProducerTag; +#endif accumulateCaloHits(ebHandle, eeHandle, esHandle, 0); } @@ -396,33 +407,35 @@ void EcalDigiProducer::accumulate(PileUpEventPrincipal const &e, // Step A: Get Inputs edm::Handle> ebHandle; if (m_doEB) { - edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB"); + edm::InputTag ebTag(m_hitsProducerTagPU, "EcalHitsEB"); e.getByLabel(ebTag, ebHandle); } edm::Handle> eeHandle; if (m_doEE) { - edm::InputTag eeTag(m_hitsProducerTag, "EcalHitsEE"); + edm::InputTag eeTag(m_hitsProducerTagPU, "EcalHitsEE"); e.getByLabel(eeTag, eeHandle); } edm::Handle> esHandle; if (m_doES) { - edm::InputTag esTag(m_hitsProducerTag, "EcalHitsES"); + edm::InputTag esTag(m_hitsProducerTagPU, "EcalHitsES"); e.getByLabel(esTag, esHandle); } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("EcalDigiProducer") << "Accumulate PU Hits with Tag " << m_hitsProducerTagPU; +#endif accumulateCaloHits(ebHandle, eeHandle, esHandle, e.bunchCrossing()); } void EcalDigiProducer::finalizeEvent(edm::Event &event, edm::EventSetup const &eventSetup) { // Step B: Create empty output - std::unique_ptr apdResult(!m_apdSeparateDigi || !m_doEB ? nullptr : new EBDigiCollection()); - std::unique_ptr componentResult(!m_componentSeparateDigi || !m_doEB ? nullptr - : new EBDigiCollection()); - std::unique_ptr barrelResult(new EBDigiCollection()); - std::unique_ptr endcapResult(new EEDigiCollection()); - std::unique_ptr preshowerResult(new ESDigiCollection()); + auto apdResult = (!m_apdSeparateDigi || !m_doEB ? nullptr : std::make_unique()); + auto componentResult(!m_componentSeparateDigi || !m_doEB ? nullptr : std::make_unique()); + auto barrelResult = std::make_unique(); + auto endcapResult = std::make_unique(); + auto preshowerResult = std::make_unique(); // run the algorithm diff --git a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h index e462f466206a1..44665a147d7d3 100644 --- a/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h +++ b/SimCalorimetry/HcalSimProducers/interface/HcalDigitizer.h @@ -69,7 +69,8 @@ class HcalDigitizer { int bunchCrossing, CLHEP::HepRandomEngine *, const HcalTopology *h, - const ZdcTopology *z); + const ZdcTopology *z, + bool signal); /// some hits in each subdetector, just for testing purposes void fillFakeHits(); @@ -103,12 +104,12 @@ class HcalDigitizer { const HcalDDDRecConstants *theRecNumber; /** Reconstruction algorithm*/ - typedef CaloTDigitizer HBHEDigitizer; - typedef CaloTDigitizer HODigitizer; - typedef CaloTDigitizer HFDigitizer; - typedef CaloTDigitizer ZDCDigitizer; - typedef CaloTDigitizer QIE10Digitizer; - typedef CaloTDigitizer QIE11Digitizer; + using HBHEDigitizer = CaloTDigitizer; + using HODigitizer = CaloTDigitizer; + using HFDigitizer = CaloTDigitizer; + using ZDCDigitizer = CaloTDigitizer; + using QIE10Digitizer = CaloTDigitizer; + using QIE11Digitizer = CaloTDigitizer; HcalSimParameterMap theParameterMap; HcalShapes theShapes; @@ -169,6 +170,7 @@ class HcalDigitizer { bool isZDC, isHCAL, zdcgeo, hbhegeo, hogeo, hfgeo; bool testNumbering_; + bool testNumberingPU_; bool doHFWindow_; bool killHE_; bool debugCS_; @@ -176,6 +178,7 @@ class HcalDigitizer { bool injectTestHits_; std::string hitsProducer_; + std::string hitsProducerPU_; int theHOSiPMCode; diff --git a/SimCalorimetry/HcalSimProducers/python/hcalUnsuppressedDigis_cfi.py b/SimCalorimetry/HcalSimProducers/python/hcalUnsuppressedDigis_cfi.py index 63f79f75b5c19..ef9d52fa63308 100644 --- a/SimCalorimetry/HcalSimProducers/python/hcalUnsuppressedDigis_cfi.py +++ b/SimCalorimetry/HcalSimProducers/python/hcalUnsuppressedDigis_cfi.py @@ -21,8 +21,10 @@ doTimeSlew = cms.bool(True), doHFWindow = cms.bool(False), hitsProducer = cms.string('g4SimHits'), + hitsProducerPU = cms.string('g4SimHits'), DelivLuminosity = cms.double(0), TestNumbering = cms.bool(False), + TestNumberingPU = cms.bool(False), doNeutralDensityFilter = cms.bool(True), HBDarkening = cms.bool(False), HEDarkening = cms.bool(False), @@ -46,6 +48,13 @@ ) from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(hcalSimBlock, + hitsProducer = cms.string('fastSimProducer'), + hitsProducerPU = cms.string('fastSimProducer') ) + +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(hcalSimBlock, + hitsProducerPU = cms.string('fastSimProducer') ) from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1 premix_stage1.toModify(hcalSimBlock, @@ -59,7 +68,11 @@ # test numbering not used in fastsim from Configuration.Eras.Modifier_run2_HCAL_2017_cff import run2_HCAL_2017 -(run2_HCAL_2017 & ~fastSim).toModify( hcalSimBlock, TestNumbering = True ) +(run2_HCAL_2017 & ~fastSim).toModify( hcalSimBlock, + TestNumbering = True, + TestNumberingPU = True ) +(run2_HCAL_2017 & fastSimPU).toModify( hcalSimBlock, + TestNumberingPU = False ) # remove HE processing for phase 2, completely put in HGCal land from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal diff --git a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc index 5930e11b54768..b5fedbcd9a9dd 100644 --- a/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc +++ b/SimCalorimetry/HcalSimProducers/src/HcalDigitizer.cc @@ -96,12 +96,11 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector ignoreTime_(ps.getParameter("ignoreGeantTime")), injectTestHits_(ps.getParameter("injectTestHits")), hitsProducer_(ps.getParameter("hitsProducer")), + hitsProducerPU_(ps.getParameter("hitsProducerPU")), theHOSiPMCode(ps.getParameter("ho").getParameter("siPMCode")), deliveredLumi(0.), agingFlagHB(ps.getParameter("HBDarkening")), agingFlagHE(ps.getParameter("HEDarkening")), - zdcToken_(iC.consumes(edm::InputTag(hitsProducer_, "ZDCHITS"))), - hcalToken_(iC.consumes(edm::InputTag(hitsProducer_, "HcalHits"))), m_HBDarkening(nullptr), m_HEDarkening(nullptr), m_HFRecalibration(nullptr), @@ -118,6 +117,9 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector mcParamsToken_ = iC.esConsumes(); } + // Get the tokens for signal + zdcToken_ = iC.consumes>(edm::InputTag(hitsProducer_, "ZDCHITS")); + hcalToken_ = iC.consumes>(edm::InputTag(hitsProducer_, "HcalHits")); bool doNoise = ps.getParameter("doNoise"); bool PreMix1 = ps.getParameter("HcalPreMixStage1"); // special threshold/pedestal treatment @@ -216,10 +218,12 @@ HcalDigitizer::HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector edm::LogVerbatim("HcalDigitizer") << "iszDC: " << isZDC << " theZDCDigitizer: " << theZDCDigitizer; testNumbering_ = ps.getParameter("TestNumbering"); + testNumberingPU_ = ps.getParameter("TestNumberingPU"); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("HcalSim") << "Flag to see if Hit Relabeller to be initiated " << testNumbering_; + edm::LogVerbatim("HcalSim") << "Flag to see if Hit Relabeller to be initiated " << testNumbering_ << ":" + << testNumberingPU_; #endif - if (testNumbering_) + if (testNumbering_ || testNumberingPU_) theRelabeller = std::make_unique(ps.getParameter("doNeutralDensityFilter")); if (ps.getParameter("doIonFeedback") && theHBHEResponse) { @@ -359,7 +363,8 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const int bunchCrossing, CLHEP::HepRandomEngine *engine, const HcalTopology *htopoP, - const ZdcTopology *ztopoP) { + const ZdcTopology *ztopoP, + bool signal) { // Step A: pass in inputs, and accumulate digis if (isHCAL) { std::vector hcalHitsOrig = *hcalHandle.product(); @@ -369,12 +374,12 @@ void HcalDigitizer::accumulateCaloHits(edm::Handle> const hcalHits.reserve(hcalHitsOrig.size()); // evaluate darkening before relabeling - if (testNumbering_) { + if ((signal && testNumbering_) || ((!signal) && testNumberingPU_)) { if (m_HBDarkening || m_HEDarkening || m_HFRecalibration) { darkening(hcalHitsOrig); } // Relabel PCaloHits if necessary - edm::LogVerbatim("HcalDigitizer") << "Calling Relabeller"; + edm::LogVerbatim("HcalDigitizer") << "Calling Relabeller for signal " << signal; theRelabeller->process(hcalHitsOrig); } @@ -468,19 +473,22 @@ void HcalDigitizer::accumulate(edm::Event const &e, edm::EventSetup const &event const HcalTopology *htopoP = &eventSetup.getData(topoToken_); const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_); - accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP, ztopoP); +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("HcalDigitizer") << "Accumulate Signal Hits with Tag " << hitsProducer_; +#endif + accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP, ztopoP, true); } void HcalDigitizer::accumulate(PileUpEventPrincipal const &e, edm::EventSetup const &eventSetup, CLHEP::HepRandomEngine *engine) { // Step A: Get Inputs - edm::InputTag zdcTag(hitsProducer_, "ZDCHITS"); + edm::InputTag zdcTag(hitsProducerPU_, "ZDCHITS"); edm::Handle> zdcHandle; e.getByLabel(zdcTag, zdcHandle); isZDC = zdcHandle.isValid(); - edm::InputTag hcalTag(hitsProducer_, "HcalHits"); + edm::InputTag hcalTag(hitsProducerPU_, "HcalHits"); edm::Handle> hcalHandle; e.getByLabel(hcalTag, hcalHandle); isHCAL = hcalHandle.isValid(); @@ -488,23 +496,24 @@ void HcalDigitizer::accumulate(PileUpEventPrincipal const &e, const HcalTopology *htopoP = &eventSetup.getData(topoToken_); const ZdcTopology *ztopoP = &eventSetup.getData(topoZToken_); - accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP, ztopoP); + accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP, ztopoP, false); } void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSetup, CLHEP::HepRandomEngine *engine) { // Step B: Create empty output - std::unique_ptr hbheResult(new HBHEDigiCollection()); - std::unique_ptr hoResult(new HODigiCollection()); - std::unique_ptr hfResult(new HFDigiCollection()); - std::unique_ptr zdcResult(new ZDCDigiCollection()); - std::unique_ptr hfQIE10Result(new QIE10DigiCollection( + auto hbheResult = std::make_unique(); + auto hoResult = std::make_unique(); + auto hfResult = std::make_unique(); + auto zdcResult = std::make_unique(); + + auto hfQIE10Result = std::make_unique( !theHFQIE10DetIds.empty() ? theHFQIE10Response.get()->getReadoutFrameSize(theHFQIE10DetIds[0]) - : QIE10DigiCollection::MAXSAMPLES)); - std::unique_ptr hbheQIE11Result(new QIE11DigiCollection( + : QIE10DigiCollection::MAXSAMPLES); + auto hbheQIE11Result = std::make_unique( !theHBHEQIE11DetIds.empty() ? theHBHESiPMResponse.get()->getReadoutFrameSize(theHBHEQIE11DetIds[0]) : // theParameterMap->simParameters(theHBHEQIE11DetIds[0]).readoutFrameSize() // : - QIE11DigiCollection::MAXSAMPLES)); + QIE11DigiCollection::MAXSAMPLES); // Step C: Invoke the algorithm, getting back outputs. if (isHCAL && hbhegeo) { @@ -545,7 +554,7 @@ void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSet e.put(std::move(hbheQIE11Result), "HBHEQIE11DigiCollection"); if (debugCS_) { - std::unique_ptr csResult(new CaloSamplesCollection()); + auto csResult = std::make_unique(); // smush together all the results if (theHBHEDigitizer) csResult->insert( @@ -573,7 +582,7 @@ void HcalDigitizer::finalizeEvent(edm::Event &e, const edm::EventSetup &eventSet } if (injectTestHits_) { - std::unique_ptr pcResult(new edm::PCaloHitContainer()); + auto pcResult = std::make_unique(); pcResult->insert(pcResult->end(), injectedHits_.begin(), injectedHits_.end()); e.put(std::move(pcResult), "HcalHits"); } diff --git a/SimGeneral/MixingModule/plugins/MixingModule.cc b/SimGeneral/MixingModule/plugins/MixingModule.cc index 0cf6dfe04f41e..d8223468e4ae9 100644 --- a/SimGeneral/MixingModule/plugins/MixingModule.cc +++ b/SimGeneral/MixingModule/plugins/MixingModule.cc @@ -77,6 +77,10 @@ namespace edm { skipSignal_ = ps_mix.getParameter("skipSignal"); } + skipProductCheck_ = false; + if (ps_mix.exists("skipProductCheck")) { + skipProductCheck_ = ps_mix.getParameter("skipProductCheck"); + } ParameterSet ps = ps_mix.getParameter("mixObjects"); std::vector names = ps.getParameterNames(); for (std::vector::iterator it = names.begin(); it != names.end(); ++it) { @@ -92,25 +96,22 @@ namespace edm { std::string labelCF = " "; if (object == "SimTrack") { - InputTag tag; - if (!tags.empty()) - tag = tags[0]; - std::string label; - - branchesActivate(TypeID(typeid(std::vector)).friendlyClassName(), std::string(""), tag, label); - adjustersObjects_.push_back(new Adjuster >(tag, consumesCollector(), wrapLongTimes_)); - bool makeCrossingFrame = pset.getUntrackedParameter("makeCrossingFrame", false); - if (makeCrossingFrame) { - workersObjects_.push_back(new MixingWorker( - minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF)); - produces >(label); - } - consumes >(tag); + for (auto& tag : tags) { + std::string label; - LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be " - << label; - // std::cout <<"Will mix "<)).friendlyClassName(), std::string(""), tag, label); + adjustersObjects_.push_back(new Adjuster >(tag, consumesCollector(), wrapLongTimes_)); + bool makeCrossingFrame = pset.getUntrackedParameter("makeCrossingFrame", false); + if (makeCrossingFrame) { + workersObjects_.push_back(new MixingWorker( + minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF)); + produces >(label); + } + consumes >(tag); + LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be " + << label; + } } else if (object == "RecoTrack") { InputTag tag; if (!tags.empty()) @@ -131,28 +132,23 @@ namespace edm { LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be " << label; - //std::cout <<"Will mix "<)).friendlyClassName(), std::string(""), tag, label); - adjustersObjects_.push_back(new Adjuster >(tag, consumesCollector(), wrapLongTimes_)); - bool makeCrossingFrame = pset.getUntrackedParameter("makeCrossingFrame", false); - if (makeCrossingFrame) { - workersObjects_.push_back(new MixingWorker( - minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF)); - produces >(label); - } - consumes >(tag); + for (auto& tag : tags) { + std::string label; - LogInfo("MixingModule") << "Will mix " << object << "s with InputTag " << tag.encode() << ", label will be " - << label; - // std::cout <<"Will mix "<)).friendlyClassName(), std::string(""), tag, label); + adjustersObjects_.push_back(new Adjuster >(tag, consumesCollector(), wrapLongTimes_)); + bool makeCrossingFrame = pset.getUntrackedParameter("makeCrossingFrame", false); + if (makeCrossingFrame) { + workersObjects_.push_back(new MixingWorker( + minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF)); + produces >(label); + } + consumes >(tag); + LogInfo("MixingModule") << "Will mix " << object << "s with InputTag " << tag.encode() << ", label will be " + << label; + } } else if (object == "HepMCProduct") { InputTag tag; if (!tags.empty()) @@ -170,7 +166,6 @@ namespace edm { LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be " << label; - // std::cout <<"Will mix "<checkSignal(e)) { + if (skipSignal_ or skipProductCheck_ or adjuster->checkSignal(e)) { adjusters_.push_back(adjuster); } } } if (workers_.empty()) { for (auto const& worker : workersObjects_) { - if (skipSignal_ or worker->checkSignal(e)) { + if (skipSignal_ or skipProductCheck_ or worker->checkSignal(e)) { workers_.push_back(worker); } } @@ -394,8 +387,6 @@ namespace edm { for (auto const& worker : workers_) { LogDebug("MixingModule") << " merging Event: id " << eventPrincipal.id(); - // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl; - worker->addPileups(eventPrincipal, &moduleCallingContext, eventId); } @@ -499,10 +490,6 @@ namespace edm { bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_); } - // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) { - // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl; - //} - for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) { for (size_t setBcrIdx = 0; setBcrIdx < workers_.size(); ++setBcrIdx) { workers_[setBcrIdx]->setBcrOffset(); diff --git a/SimGeneral/MixingModule/plugins/MixingModule.h b/SimGeneral/MixingModule/plugins/MixingModule.h index 69af3006a0b09..8c0de6c3d3d8a 100644 --- a/SimGeneral/MixingModule/plugins/MixingModule.h +++ b/SimGeneral/MixingModule/plugins/MixingModule.h @@ -109,6 +109,7 @@ namespace edm { bool useCurrentProcessOnly_; bool wrapLongTimes_; bool skipSignal_; + bool skipProductCheck_; // Digi-producing algorithms Accumulators digiAccumulators_; diff --git a/SimGeneral/MixingModule/plugins/MixingWorker.cc b/SimGeneral/MixingModule/plugins/MixingWorker.cc index 7131a1f3c36ed..09809a12ea4e6 100644 --- a/SimGeneral/MixingModule/plugins/MixingWorker.cc +++ b/SimGeneral/MixingModule/plugins/MixingWorker.cc @@ -52,6 +52,7 @@ namespace edm { InputTag t = InputTag(tag.label(), tag.instance()); LogInfo("MixingModule") << " Will create a CrossingFrame for HepMCProduct with " << " with InputTag= " << t.encode(); + break; } } diff --git a/SimGeneral/MixingModule/plugins/MixingWorker.h b/SimGeneral/MixingModule/plugins/MixingWorker.h index 15cda3122bda4..6bfb911347980 100644 --- a/SimGeneral/MixingModule/plugins/MixingWorker.h +++ b/SimGeneral/MixingModule/plugins/MixingWorker.h @@ -121,7 +121,6 @@ namespace edm { if (got) LogInfo("MixingModule") << " Will create a CrossingFrame for " << typeid(T).name() << " with InputTag= " << t.encode(); - return got; } @@ -159,6 +158,7 @@ namespace edm { // When using mixed secondary source // Copy the data from the PCrossingFrame to the CrossingFrame virtual void copyPCrossingFrame(const PCrossingFrame *PCF); + InputTag getInputTag() const override { return tag_; } private: int minBunch_; diff --git a/SimGeneral/MixingModule/plugins/MixingWorkerBase.h b/SimGeneral/MixingModule/plugins/MixingWorkerBase.h index c7c7d2a458249..0c3aed663f11c 100644 --- a/SimGeneral/MixingModule/plugins/MixingWorkerBase.h +++ b/SimGeneral/MixingModule/plugins/MixingWorkerBase.h @@ -43,6 +43,7 @@ namespace edm { virtual void setTof() = 0; virtual void put(edm::Event &e) = 0; virtual void reload(int minBunch, int maxBunch, int bunchSpace) {} + virtual InputTag getInputTag() const = 0; }; } // namespace edm diff --git a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py index f77a914693d8a..7428da9cda4fc 100644 --- a/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py @@ -63,6 +63,11 @@ def _modifyPixelDigitizerForRun3( digitizer ): 'TrackerHitsPixelBarrelHighTof', 'TrackerHitsPixelEndcapLowTof', 'TrackerHitsPixelEndcapHighTof'), + RoutListPU = cms.vstring( + 'TrackerHitsPixelBarrelLowTof', + 'TrackerHitsPixelBarrelHighTof', + 'TrackerHitsPixelEndcapLowTof', + 'TrackerHitsPixelEndcapHighTof'), OffsetSmearing = cms.double(0.0), ThresholdInElectrons_FPix = cms.double(3000.0), ThresholdInElectrons_BPix = cms.double(3500.0), @@ -140,6 +145,14 @@ def _modifyPixelDigitizerForRun3( digitizer ): KillBadFEDChannels = False, #done in second step killModules = False #done in second step ) +# when FastSim events as PileUP events during mixing +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(SiPixelSimBlock, + RoutListPU = cms.vstring('TrackerHits')) +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(SiPixelSimBlock, + RoutList = cms.vstring('TrackerHits'), + RoutListPU = cms.vstring('TrackerHits')) ## ## Disable all noise for the tau embedding methods simulation step diff --git a/SimGeneral/MixingModule/python/SiStripSimParameters_cfi.py b/SimGeneral/MixingModule/python/SiStripSimParameters_cfi.py index b4f2f06376a25..25fd55da3897a 100644 --- a/SimGeneral/MixingModule/python/SiStripSimParameters_cfi.py +++ b/SimGeneral/MixingModule/python/SiStripSimParameters_cfi.py @@ -87,6 +87,10 @@ "TrackerHitsTIDLowTof","TrackerHitsTIDHighTof", "TrackerHitsTOBLowTof","TrackerHitsTOBHighTof", "TrackerHitsTECLowTof","TrackerHitsTECHighTof"), + ROUListPU = cms.vstring("TrackerHitsTIBLowTof","TrackerHitsTIBHighTof", + "TrackerHitsTIDLowTof","TrackerHitsTIDHighTof", + "TrackerHitsTOBLowTof","TrackerHitsTOBHighTof", + "TrackerHitsTECLowTof","TrackerHitsTECHighTof"), GeometryType = cms.string('idealForDigi'), TrackerConfigurationFromDB = cms.bool(False), ZeroSuppression = cms.bool(True), @@ -157,8 +161,18 @@ APVShapeDecoFile =cms.FileInPath("SimTracker/SiStripDigitizer/data/APVShapeDeco_320.txt") ) +# when FastSim events as PileUP events during mixing +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(SiStripSimBlock, + ROUListPU = cms.vstring('TrackerHits')) +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(SiStripSimBlock, + ROUList = cms.vstring('TrackerHits'), + ROUListPU = cms.vstring('TrackerHits')) + ## ## Disable all noise for the tau embedding methods simulation step ## from Configuration.ProcessModifiers.tau_embedding_sim_cff import tau_embedding_sim -tau_embedding_sim.toModify(SiStripSimBlock, Noise = False) \ No newline at end of file +tau_embedding_sim.toModify(SiStripSimBlock, Noise = False) + diff --git a/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py b/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py index 46814f64ca198..bddfb1c42cb15 100644 --- a/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py @@ -20,11 +20,19 @@ ecal_notCont_sim, es_electronics_sim, hitsProducer = cms.string('g4SimHits'), + hitsProducerPU = cms.string('g4SimHits'), accumulatorType = cms.string("EcalDigiProducer"), makeDigiSimLinks = cms.untracked.bool(False) ) from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(ecalDigitizer, + hitsProducer = cms.string('fastSimProducer'), + hitsProducerPU = cms.string('fastSimProducer')) + +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(ecalDigitizer, + hitsProducerPU = cms.string('fastSimProducer')) ecalDigitizer.doEB = cms.bool(True) ecalDigitizer.doEE = cms.bool(True) diff --git a/SimGeneral/MixingModule/python/mixObjects_cfi.py b/SimGeneral/MixingModule/python/mixObjects_cfi.py index f8b585c7fb9d3..1a9e270fa24bc 100644 --- a/SimGeneral/MixingModule/python/mixObjects_cfi.py +++ b/SimGeneral/MixingModule/python/mixObjects_cfi.py @@ -72,7 +72,21 @@ 'MuonRPCHits', 'TrackerHits') ) - +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(mixSimHits, + input = mixSimHits.input + + [ cms.InputTag("MuonSimHits","MuonCSCHits"), + cms.InputTag("MuonSimHits","MuonDTHits"), + cms.InputTag("MuonSimHits","MuonRPCHits"), + cms.InputTag("MuonSimHits","MuonGEMHits"), + cms.InputTag("fastSimProducer","TrackerHits")], + subdets = mixSimHits.subdets + + ['MuonCSCHits', + 'MuonDTHits', + 'MuonRPCHits', + 'MuonGEMHits', + 'TrackerHits'] +) mixCaloHits = cms.PSet( input = cms.VInputTag( # note that this list needs to be in the same order as the subdets #cms.InputTag("g4SimHits","CaloHitsTk"), cms.InputTag("g4SimHits","CastorBU"), cms.InputTag("g4SimHits","CastorPL"), cms.InputTag("g4SimHits","CastorTU"), @@ -109,6 +123,19 @@ 'EcalHitsES', 'HcalHits'] ) +# fastsimPU customs +fastSimPU.toModify(mixCaloHits, + input = mixCaloHits.input + + ["fastSimProducer:EcalHitsEB", + "fastSimProducer:EcalHitsEE", + "fastSimProducer:EcalHitsES", + "fastSimProducer:HcalHits"], + subdets = mixCaloHits.subdets + + ['EcalHitsEB', + 'EcalHitsEE', + 'EcalHitsES', + 'HcalHits'] +) mixSimTracks = cms.PSet( @@ -125,7 +152,9 @@ # fastsim customs fastSim.toModify(mixSimTracks, input = ["fastSimProducer"]) fastSim.toModify(mixSimVertices, input = ["fastSimProducer"]) - +fastSimPU.toModify(mixSimTracks, input = mixSimTracks.input + ["fastSimProducer"]) +fastSimPU.toModify(mixSimVertices, input = mixSimVertices.input + ["fastSimProducer"]) + mixHepMCProducts = cms.PSet( makeCrossingFrame = cms.untracked.bool(True), input = cms.VInputTag(cms.InputTag("generatorSmeared"),cms.InputTag("generator")), @@ -157,7 +186,7 @@ ) # fastsim customs -fastSim.toModify(theMixObjects, mixRecoTracks = cms.PSet(mixReconstructedTracks)) +(fastSim | fastSimPU).toModify(theMixObjects, mixRecoTracks = cms.PSet(mixReconstructedTracks)) mixPCFSimHits = cms.PSet( input = cms.VInputTag(cms.InputTag("CFWriter","g4SimHitsBSCHits"), cms.InputTag("CFWriter","g4SimHitsBCM1FHits"), cms.InputTag("CFWriter","g4SimHitsPLTHits"), cms.InputTag("CFWriter","g4SimHitsFP420SI"), cms.InputTag("CFWriter","g4SimHitsMuonCSCHits"), cms.InputTag("CFWriter","g4SimHitsMuonDTHits"), cms.InputTag("CFWriter","g4SimHitsMuonRPCHits"), diff --git a/SimGeneral/MixingModule/python/mix_probFunction_25ns_PoissonOOTPU_cfi.py b/SimGeneral/MixingModule/python/mix_probFunction_25ns_PoissonOOTPU_cfi.py index b0466ad56277a..6e36dd286977a 100644 --- a/SimGeneral/MixingModule/python/mix_probFunction_25ns_PoissonOOTPU_cfi.py +++ b/SimGeneral/MixingModule/python/mix_probFunction_25ns_PoissonOOTPU_cfi.py @@ -52,5 +52,5 @@ mixObjects = cms.PSet(theMixObjects) ) - - +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(mix, skipProductCheck = cms.bool(True)) diff --git a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py index 7dbb0ab4b9e14..cdbdf2e5130fd 100644 --- a/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/pixelDigitizer_cfi.py @@ -6,6 +6,7 @@ SiPixelSimBlock, accumulatorType = cms.string("SiPixelDigitizer"), hitsProducer = cms.string('g4SimHits'), + hitsProducerPU = cms.string('g4SimHits'), makeDigiSimLinks = cms.untracked.bool(True) ) from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1 @@ -56,4 +57,12 @@ AdcFullScale = 1023, MissCalibrate = False ) +# when FastSim events as PileUP events during mixing +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(pixelDigitizer, + hitsProducerPU = cms.string('fastSimProducer')) +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(pixelDigitizer, + hitsProducer = cms.string('fastSimProducer'), + hitsProducerPU = cms.string('fastSimProducer')) diff --git a/SimGeneral/MixingModule/python/stripDigitizer_cfi.py b/SimGeneral/MixingModule/python/stripDigitizer_cfi.py index 0a99a3424543c..ace231c76bde2 100644 --- a/SimGeneral/MixingModule/python/stripDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/stripDigitizer_cfi.py @@ -7,6 +7,7 @@ SiStripSimBlock, accumulatorType = cms.string("SiStripDigitizer"), hitsProducer = cms.string('g4SimHits'), + hitsProducerPU = cms.string('g4SimHits'), makeDigiSimLinks = cms.untracked.bool(True) ) @@ -30,4 +31,12 @@ phase2_tracker.toModify( stripDigitizer, ROUList = ["g4SimHitsTrackerHitsPixelBarrelLowTof", "g4SimHitsTrackerHitsPixelEndcapLowTof"] ) +# when FastSim events as PileUP events during mixing +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(stripDigitizer, + hitsProducerPU = cms.string('fastSimProducer')) +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(stripDigitizer, + hitsProducer = cms.string('fastSimProducer'), + hitsProducerPU = cms.string('fastSimProducer')) diff --git a/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py b/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py index a8967462c2fef..8c93c0047842f 100644 --- a/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py @@ -21,12 +21,14 @@ cms.InputTag('g4SimHits','TrackerHitsTECLowTof'), cms.InputTag('g4SimHits','TrackerHitsTECHighTof') ), pixel = cms.VInputTag(cms.InputTag( 'g4SimHits','TrackerHitsPixelBarrelLowTof'), - cms.InputTag('g4SimHits','TrackerHitsPixelBarrelHighTof'), - cms.InputTag('g4SimHits','TrackerHitsPixelEndcapLowTof'), - cms.InputTag('g4SimHits','TrackerHitsPixelEndcapHighTof') ) + cms.InputTag('g4SimHits','TrackerHitsPixelBarrelHighTof'), + cms.InputTag('g4SimHits','TrackerHitsPixelEndcapLowTof'), + cms.InputTag('g4SimHits','TrackerHitsPixelEndcapHighTof') ) ), simTrackCollection = cms.InputTag('g4SimHits'), simVertexCollection = cms.InputTag('g4SimHits'), + simTrackCollectionPU = cms.InputTag('g4SimHits'), + simVertexCollectionPU = cms.InputTag('g4SimHits'), genParticleCollection = cms.InputTag('genParticles'), removeDeadModules = cms.bool(False), # currently not implemented volumeRadius = cms.double(120.0), @@ -48,10 +50,42 @@ cms.InputTag('MuonSimHits','MuonRPCHits') ), trackerAndPixel = cms.VInputTag( cms.InputTag('fastSimProducer','TrackerHits') ) ), - simTrackCollection = 'fastSimProducer', - simVertexCollection = 'fastSimProducer' + simTrackCollection = cms.InputTag('fastSimProducer'), + simVertexCollection = cms.InputTag('fastSimProducer'), + simTrackCollectionPU = cms.InputTag('fastSimProducer'), + simVertexCollectionPU = cms.InputTag('fastSimProducer') ) +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(trackingParticles, + simHitCollections = cms.PSet( + muon = cms.VInputTag( + cms.InputTag('g4SimHits','MuonDTHits'), + cms.InputTag('g4SimHits','MuonCSCHits'), + cms.InputTag('g4SimHits','MuonRPCHits'), + cms.InputTag('MuonSimHits','MuonDTHits'), + cms.InputTag('MuonSimHits','MuonCSCHits'), + cms.InputTag('MuonSimHits','MuonRPCHits') ), + tracker = cms.VInputTag( + cms.InputTag('g4SimHits','TrackerHitsTIBLowTof'), + cms.InputTag('g4SimHits','TrackerHitsTIBHighTof'), + cms.InputTag('g4SimHits','TrackerHitsTIDLowTof'), + cms.InputTag('g4SimHits','TrackerHitsTIDHighTof'), + cms.InputTag('g4SimHits','TrackerHitsTOBLowTof'), + cms.InputTag('g4SimHits','TrackerHitsTOBHighTof'), + cms.InputTag('g4SimHits','TrackerHitsTECLowTof'), + cms.InputTag('g4SimHits','TrackerHitsTECHighTof')), + pixel = cms.VInputTag( + cms.InputTag('g4SimHits','TrackerHitsPixelBarrelLowTof'), + cms.InputTag('g4SimHits','TrackerHitsPixelBarrelHighTof'), + cms.InputTag('g4SimHits','TrackerHitsPixelEndcapLowTof'), + cms.InputTag('g4SimHits','TrackerHitsPixelEndcapHighTof')), + trackerAndPixel = cms.VInputTag( cms.InputTag('fastSimProducer','TrackerHits') ) + ), + simTrackCollectionPU = cms.InputTag('fastSimProducer'), + simVertexCollectionPU = cms.InputTag('fastSimProducer') +) + from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 run2_GEM_2017.toModify(trackingParticles, simHitCollections = dict( muon = trackingParticles.simHitCollections.muon+[cms.InputTag("g4SimHits","MuonGEMHits")])) diff --git a/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.cc b/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.cc index 9d99992b4be05..e96af53339c29 100644 --- a/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.cc +++ b/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.cc @@ -269,8 +269,10 @@ TrackingTruthAccumulator::TrackingTruthAccumulator(const edm::ParameterSet &conf createInitialVertexCollection_(config.getParameter("createInitialVertexCollection")), addAncestors_(config.getParameter("alwaysAddAncestors")), removeDeadModules_(config.getParameter("removeDeadModules")), - simTrackLabel_(config.getParameter("simTrackCollection")), - simVertexLabel_(config.getParameter("simVertexCollection")), + simTrackLabelSig_(config.getParameter("simTrackCollection")), + simVertexLabelSig_(config.getParameter("simVertexCollection")), + simTrackLabelPU_(config.getParameter("simTrackCollectionPU")), + simVertexLabelPU_(config.getParameter("simVertexCollectionPU")), collectionTags_(), genParticleLabel_(config.getParameter("genParticleCollection")), hepMCproductLabel_(config.getParameter("HepMCProductLabel")), @@ -335,6 +337,8 @@ TrackingTruthAccumulator::TrackingTruthAccumulator(const edm::ParameterSet &conf iC.consumes>(simTrackLabel_); iC.consumes>(simVertexLabel_); + iC.consumes>(simTrackLabelPU_); + iC.consumes>(simVertexLabelPU_); iC.consumes>(genParticleLabel_); iC.consumes>(genParticleLabel_); iC.consumes>(hepMCproductLabel_); @@ -390,6 +394,13 @@ void TrackingTruthAccumulator::accumulate(edm::Event const &event, edm::EventSet edm::Handle hepmc; event.getByLabel(hepMCproductLabel_, hepmc); + simTrackLabel_ = simTrackLabelSig_; + simVertexLabel_ = simVertexLabelSig_; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("TrackingTruthAccumulator") << "accumulate for Signal " + << " SimVertex " << simVertexLabel_ << " SimTrack " << simTrackLabel_; +#endif accumulateEvent(event, setup, hepmc); } @@ -405,6 +416,14 @@ void TrackingTruthAccumulator::accumulate(PileUpEventPrincipal const &event, // simply create empty handle as we do not have a HepMCProduct in PU anyway edm::Handle hepmc; + simTrackLabel_ = simTrackLabelPU_; + simVertexLabel_ = simVertexLabelPU_; + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("TrackingTruthAccumulator") << "accumulate for PU " + << " SimVertex " << simVertexLabel_ << " SimTrack " << simTrackLabel_; +#endif + accumulateEvent(event, setup, hepmc); } else edm::LogInfo(messageCategory_) << "Skipping pileup event for bunch crossing " << event.bunchCrossing(); @@ -575,6 +594,13 @@ void TrackingTruthAccumulator::fillSimHits(std::vector &returnV event.getByLabel(collectionTag, hSimHits); // TODO - implement removing the dead modules + if (!hSimHits.isValid()) + continue; + // TODO - implement removing the dead modules +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("TrackingTruthAccumulator") + << "fillSimHits " << collectionTag << " SimHit Size " << hSimHits->size(); +#endif for (const auto &simHit : *hSimHits) { returnValue.push_back(&simHit); } @@ -1028,8 +1054,6 @@ namespace // Unnamed namespace for things only used in this file "parent."); } } // end of loop over decay vertices - - std::cout << "TrackingTruthAccumulator.cc integrityCheck() completed successfully" << std::endl; } // end of ::DecayChain::integrityCheck() #endif diff --git a/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.h b/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.h index 0863f1172148a..183746209782d 100644 --- a/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.h +++ b/SimGeneral/TrackingAnalysis/plugins/TrackingTruthAccumulator.h @@ -137,8 +137,12 @@ class TrackingTruthAccumulator : public DigiAccumulatorMixMod { /// As of 11/Feb/2013 this option hasn't been implemented yet. const bool removeDeadModules_; - const edm::InputTag simTrackLabel_; - const edm::InputTag simVertexLabel_; + edm::InputTag simTrackLabel_; + edm::InputTag simVertexLabel_; + edm::InputTag simTrackLabelSig_; + edm::InputTag simVertexLabelSig_; + edm::InputTag simTrackLabelPU_; + edm::InputTag simVertexLabelPU_; std::vector collectionTags_; edm::InputTag genParticleLabel_; /// Needed to add HepMC::GenVertex to SimVertex diff --git a/SimMuon/CSCDigitizer/python/muonCSCDigis_cfi.py b/SimMuon/CSCDigitizer/python/muonCSCDigis_cfi.py index 14f17c91b9deb..e6abb24265176 100644 --- a/SimMuon/CSCDigitizer/python/muonCSCDigis_cfi.py +++ b/SimMuon/CSCDigitizer/python/muonCSCDigis_cfi.py @@ -74,6 +74,7 @@ mixLabel = cms.string("mix"), InputCollection = cms.string("g4SimHitsMuonCSCHits"), + InputCollectionPU = cms.string('g4SimHitsMuonCSCHits'), stripConditions = cms.string('Database'), GeometryType = cms.string('idealForDigi'), @@ -90,7 +91,13 @@ run2_common.toModify( simMuonCSCDigis.wires, bunchTimingOffsets=[0.0, 22.88, 22.55, 29.28, 30.0, 30.0, 30.5, 31.0, 29.5, 29.1, 29.88] ) from Configuration.Eras.Modifier_fastSim_cff import fastSim -fastSim.toModify(simMuonCSCDigis, InputCollection = 'MuonSimHitsMuonCSCHits') +fastSim.toModify(simMuonCSCDigis, + InputCollection = cms.string('MuonSimHitsMuonCSCHits'), + InputCollectionPU = cms.string('MuonSimHitsMuonCSCHits')) + +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(simMuonCSCDigis, + InputCollectionPU = cms.string('MuonSimHitsMuonCSCHits')) from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 premix_stage2.toModify(simMuonCSCDigis, mixLabel = "mixData") diff --git a/SimMuon/CSCDigitizer/src/CSCDigiProducer.cc b/SimMuon/CSCDigitizer/src/CSCDigiProducer.cc index 993eb879b8676..4d884c3a27576 100644 --- a/SimMuon/CSCDigitizer/src/CSCDigiProducer.cc +++ b/SimMuon/CSCDigitizer/src/CSCDigiProducer.cc @@ -47,9 +47,15 @@ CSCDigiProducer::CSCDigiProducer(const edm::ParameterSet &ps) : theDigitizer(ps) "in the configuration file or remove the modules that require it."; } - std::string mix_ = ps.getParameter("mixLabel"); - std::string collection_ = ps.getParameter("InputCollection"); - cf_token = consumes>(edm::InputTag(mix_, collection_)); + const std::string &mix = ps.getParameter("mixLabel"); + const std::set collections_for_XF{ps.getParameter("InputCollection"), + ps.getParameter("InputCollectionPU")}; + for (const auto &cname : collections_for_XF) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("CSCDigiProducer") << "Creating CrossingFrame Consumers for InputTag " << mix << ":" << cname; +#endif + cf_tokens.push_back(consumes>(edm::InputTag(mix, cname))); + } } CSCDigiProducer::~CSCDigiProducer() { delete theStripConditions; } @@ -60,18 +66,22 @@ void CSCDigiProducer::produce(edm::Event &ev, const edm::EventSetup &eventSetup) edm::Service rng; CLHEP::HepRandomEngine *engine = &rng->getEngine(ev.streamID()); - edm::Handle> cf; - ev.getByToken(cf_token, cf); - - std::unique_ptr> hits(new MixCollection(cf.product())); + std::vector *> cf_list; + for (const auto &token : cf_tokens) { + const auto &handle = ev.getHandle(token); + if (handle.isValid()) { + cf_list.emplace_back(handle.product()); + } else + edm::LogWarning("CSCDigitizer") << "Input Source not Valid !!"; + } + auto hits = std::make_unique>(cf_list); // Create empty output - - std::unique_ptr pWireDigis(new CSCWireDigiCollection()); - std::unique_ptr pStripDigis(new CSCStripDigiCollection()); - std::unique_ptr pComparatorDigis(new CSCComparatorDigiCollection()); - std::unique_ptr pWireDigiSimLinks(new DigiSimLinks()); - std::unique_ptr pStripDigiSimLinks(new DigiSimLinks()); + auto pWireDigis = std::make_unique(); + auto pStripDigis = std::make_unique(); + auto pComparatorDigis = std::make_unique(); + auto pWireDigiSimLinks = std::make_unique(); + auto pStripDigiSimLinks = std::make_unique(); //@@ DOES NOTHING IF NO HITS. Remove this for when there's real neutrons if (hits->size() > 0) { diff --git a/SimMuon/CSCDigitizer/src/CSCDigiProducer.h b/SimMuon/CSCDigitizer/src/CSCDigiProducer.h index d7d49a347232f..7fded8d1a46c5 100644 --- a/SimMuon/CSCDigitizer/src/CSCDigiProducer.h +++ b/SimMuon/CSCDigitizer/src/CSCDigiProducer.h @@ -28,7 +28,7 @@ class CSCDigiProducer : public edm::stream::EDProducer<> { CSCDigitizer theDigitizer; CSCStripConditions *theStripConditions; - edm::EDGetTokenT> cf_token; + std::vector>> cf_tokens; edm::ESGetToken geom_Token; edm::ESGetToken magfield_Token; edm::ESGetToken pdt_Token; diff --git a/SimMuon/DTDigitizer/python/muonDTDigis_cfi.py b/SimMuon/DTDigitizer/python/muonDTDigis_cfi.py index 5002f3028be74..21b0c070f70b6 100644 --- a/SimMuon/DTDigitizer/python/muonDTDigis_cfi.py +++ b/SimMuon/DTDigitizer/python/muonDTDigis_cfi.py @@ -22,6 +22,7 @@ #Name of Collection used for create the XF mixLabel = cms.string('mix'), InputCollection = cms.string('g4SimHitsMuonDTHits'), + InputCollectionPU = cms.string('g4SimHitsMuonDTHits'), debug = cms.untracked.bool(False), # Its parameters pset = cms.PSet( @@ -41,7 +42,13 @@ from Configuration.Eras.Modifier_fastSim_cff import fastSim -fastSim.toModify(simMuonDTDigis, InputCollection = 'MuonSimHitsMuonDTHits') +fastSim.toModify(simMuonDTDigis, + InputCollection = cms.string('MuonSimHitsMuonDTHits'), + InputCollectionPU = cms.string('MuonSimHitsMuonDTHits')) +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(simMuonDTDigis, + InputCollectionPU = cms.string('MuonSimHitsMuonDTHits')) + from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 premix_stage2.toModify(simMuonDTDigis, mixLabel = "mixData") diff --git a/SimMuon/DTDigitizer/src/DTDigitizer.cc b/SimMuon/DTDigitizer/src/DTDigitizer.cc index 29d762a450abe..3525d9db76d0c 100644 --- a/SimMuon/DTDigitizer/src/DTDigitizer.cc +++ b/SimMuon/DTDigitizer/src/DTDigitizer.cc @@ -115,9 +115,16 @@ DTDigitizer::DTDigitizer(const ParameterSet &conf_) LinksTimeWindow = conf_.getParameter("LinksTimeWindow"); // (10 ns) // Name of Collection used for create the XF - mix_ = conf_.getParameter("mixLabel"); - collection_for_XF = conf_.getParameter("InputCollection"); - cf_token = consumes>(edm::InputTag(mix_, collection_for_XF)); + const std::string &mix = conf_.getParameter("mixLabel"); + const std::set collections_for_XF{conf_.getParameter("InputCollection"), + conf_.getParameter("InputCollectionPU")}; + for (const auto &cname : collections_for_XF) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("DTDigiProducer") << "Creating CrossingFrame Consumers for InputTag " << mix << ":" << cname; +#endif + cf_tokens.push_back(consumes>(edm::InputTag(mix, cname))); + } + magnField_token = esConsumes(); // String to choose between ideal (the default) and (mis)aligned geometry @@ -140,15 +147,21 @@ void DTDigitizer::produce(Event &iEvent, const EventSetup &iSetup) { // iEvent.getByLabel("g4SimHits","MuonDTHits",simHits); // use MixCollection instead of the previous - Handle> xFrame; - iEvent.getByToken(cf_token, xFrame); - - unique_ptr> simHits(new MixCollection(xFrame.product())); + std::vector *> cf_list; + for (const auto &token : cf_tokens) { + const auto &handle = iEvent.getHandle(token); + if (handle.isValid()) { + cf_list.emplace_back(handle.product()); + + } else + edm::LogWarning("DTDigitizer") << "Input Source not Valid !!"; + } + auto simHits = std::make_unique>(cf_list); // create the pointer to the Digi container - unique_ptr output(new DTDigiCollection()); + auto output = std::make_unique(); // pointer to the DigiSimLink container - unique_ptr outputLinks(new DTDigiSimLinkCollection()); + auto outputLinks = std::make_unique(); // Muon Geometry ESHandle muonGeom = iSetup.getHandle(muonGeom_token); diff --git a/SimMuon/DTDigitizer/src/DTDigitizer.h b/SimMuon/DTDigitizer/src/DTDigitizer.h index bda10dce56be2..fe66ff151a23b 100644 --- a/SimMuon/DTDigitizer/src/DTDigitizer.h +++ b/SimMuon/DTDigitizer/src/DTDigitizer.h @@ -128,11 +128,7 @@ class DTDigitizer : public edm::stream::EDProducer<> { bool MultipleLinks; float LinksTimeWindow; - // Name of Collection use for create the XF - std::string mix_; - std::string collection_for_XF; - - edm::EDGetTokenT> cf_token; + std::vector>> cf_tokens; edm::ESGetToken muonGeom_token; edm::ESGetToken magnField_token; }; diff --git a/SimMuon/GEMDigitizer/plugins/GEMDigiProducer.cc b/SimMuon/GEMDigitizer/plugins/GEMDigiProducer.cc index 5ba8003404b7d..d2af233265188 100644 --- a/SimMuon/GEMDigitizer/plugins/GEMDigiProducer.cc +++ b/SimMuon/GEMDigitizer/plugins/GEMDigiProducer.cc @@ -36,7 +36,7 @@ namespace CLHEP { class GEMDigiProducer : public edm::stream::EDProducer { public: - typedef edm::DetSetVector GEMDigiSimLinks; + using GEMDigiSimLinks = edm::DetSetVector; explicit GEMDigiProducer(const edm::ParameterSet& ps); @@ -50,7 +50,7 @@ class GEMDigiProducer : public edm::stream::EDProducer { private: //Name of Collection used for create the XF - edm::EDGetTokenT > cf_token; + std::vector>> cf_tokens_; edm::ESGetToken geom_token_; const GEMGeometry* geometry_; @@ -69,10 +69,15 @@ GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps) : gemDigiModule_(s << "Add the service in the configuration file or remove the modules that require it."; } - std::string mix_(ps.getParameter("mixLabel")); - std::string collection_(ps.getParameter("inputCollection")); - - cf_token = consumes >(edm::InputTag(mix_, collection_)); + const std::string& mix = ps.getParameter("mixLabel"); + const std::set collections_for_XF{ps.getParameter("inputCollection"), + ps.getParameter("inputCollectionPU")}; + for (const auto& cname : collections_for_XF) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("GEMDigiProducer") << "Creating CrossingFrame Consumers for InputTag " << mix << ":" << cname; +#endif + cf_tokens_.push_back(consumes>(edm::InputTag(mix, cname))); + } geom_token_ = esConsumes(); } @@ -81,6 +86,7 @@ GEMDigiProducer::~GEMDigiProducer() = default; void GEMDigiProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("inputCollection", "g4SimHitsMuonGEMHits"); + desc.add("inputCollectionPU", "g4SimHitsMuonGEMHits"); desc.add("mixLabel", "mix"); desc.add("signalPropagationSpeed", 0.66); @@ -116,8 +122,8 @@ void GEMDigiProducer::fillDescriptions(edm::ConfigurationDescriptions& descripti // The follwing parameters are needed to model the background contribution // The parameters have been obtained after the fit of th perdicted by FLUKA - // By default the backgroundmodeling with these parameters should be disabled with - // the 9_2_X release setting simulateBkgNoise = false + // By default the backgroundmodeling with these parameters should be disabled + // with the 9_2_X release setting simulateBkgNoise = false desc.add("GE11ModNeuBkgParam0", 5710.23); desc.add("GE11ModNeuBkgParam1", -43.3928); desc.add("GE11ModNeuBkgParam2", 0.0863681); @@ -144,10 +150,14 @@ void GEMDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) edm::Service rng; CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID()); - edm::Handle > cf; - e.getByToken(cf_token, cf); - - MixCollection hits{cf.product()}; + std::vector*> cf_list; + for (auto const& token : cf_tokens_) { + const auto& handle = e.getHandle(token); + if (handle.isValid()) { + cf_list.emplace_back(handle.product()); + } + } + auto hits = std::make_unique>(cf_list); // Create empty output auto digis = std::make_unique(); @@ -155,7 +165,7 @@ void GEMDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) // arrange the hits by eta partition std::map hitMap; - for (const auto& hit : hits) { + for (const auto& hit : *hits) { hitMap[GEMDetId(hit.detUnitId()).rawId()].emplace_back(hit); } diff --git a/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py b/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py index 146dc34109ff7..17e3596fbf931 100644 --- a/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py +++ b/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py @@ -14,3 +14,7 @@ from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toModify( simMuonGEMDigis, instLumi = 5) + +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(simMuonGEMDigis, + inputCollectionPU = cms.string('MuonSimHitsMuonGEMHits')) diff --git a/SimMuon/RPCDigitizer/python/muonRPCDigis_cfi.py b/SimMuon/RPCDigitizer/python/muonRPCDigis_cfi.py index 6b7f809c1f48e..d1afb3f04e023 100644 --- a/SimMuon/RPCDigitizer/python/muonRPCDigis_cfi.py +++ b/SimMuon/RPCDigitizer/python/muonRPCDigis_cfi.py @@ -29,11 +29,19 @@ Signal = cms.bool(True), mixLabel = cms.string('mix'), InputCollection = cms.string('g4SimHitsMuonRPCHits'), + InputCollectionPU = cms.string('g4SimHitsMuonRPCHits'), digiModel = cms.string('RPCSimAsymmetricCls') ) #the digitizer for PhaseII muon upgrade is RPCSimModelTiming and for the moment is based on RPCSimAverageNoiseEffCls from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(simMuonRPCDigis, + InputCollection = cms.string('MuonSimHitsMuonRPCHits'), + InputCollectionPU = cms.string('MuonSimHitsMuonRPCHits')) + +from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU +fastSimPU.toModify(simMuonRPCDigis, + InputCollectionPU = cms.string('MuonSimHitsMuonRPCHits')) _simMuonRPCDigisPhaseII = cms.EDProducer("RPCandIRPCDigiProducer", Noise = cms.bool(True), diff --git a/SimMuon/RPCDigitizer/src/RPCDigiProducer.cc b/SimMuon/RPCDigitizer/src/RPCDigiProducer.cc index b322b8733d5fb..d480de8f1c4bb 100644 --- a/SimMuon/RPCDigitizer/src/RPCDigiProducer.cc +++ b/SimMuon/RPCDigitizer/src/RPCDigiProducer.cc @@ -37,8 +37,15 @@ RPCDigiProducer::RPCDigiProducer(const edm::ParameterSet& ps) { produces("RPCDigiSimLink"); //Name of Collection used for create the XF - mix_ = ps.getParameter("mixLabel"); - collection_for_XF = ps.getParameter("InputCollection"); + const std::string& mix = ps.getParameter("mixLabel"); + const std::set collections_for_XF{ps.getParameter("InputCollection"), + ps.getParameter("InputCollectionPU")}; + for (const auto& cname : collections_for_XF) { +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("RPCDigiProducer") << "Creating CrossingFrame Consumers for InputTag " << mix << ":" << cname; +#endif + crossingFrameTokens.push_back(consumes>(edm::InputTag(mix, cname))); + } edm::Service rng; if (!rng.isAvailable()) { @@ -49,7 +56,6 @@ RPCDigiProducer::RPCDigiProducer(const edm::ParameterSet& ps) { } theRPCSimSetUp = new RPCSimSetUp(ps); theDigitizer = new RPCDigitizer(ps); - crossingFrameToken = consumes>(edm::InputTag(mix_, collection_for_XF)); geomToken = esConsumes(); noiseToken = esConsumes(); clsToken = esConsumes(); @@ -89,16 +95,19 @@ void RPCDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) << "[RPCDigiProducer::produce] to activate the test go in RPCDigiProducer.cc and uncomment the line below"; // LogDebug ("RPCDigiProducer")<<"[RPCDigiProducer::produce] Fired RandFlat :: "<>& cf = e.getHandle(crossingFrameToken); - - std::unique_ptr> hits(new MixCollection(cf.product())); + std::vector*> cf_list; + for (const auto& token : crossingFrameTokens) { + const auto& handle = e.getHandle(token); + if (handle.isValid()) { + cf_list.emplace_back(handle.product()); + } + } + auto hits = std::make_unique>(cf_list); // Create empty output - std::unique_ptr pDigis(new RPCDigiCollection()); - std::unique_ptr RPCDigitSimLink(new RPCDigitizerSimLinks()); + auto pDigis = std::make_unique(); + auto RPCDigitSimLink = std::make_unique(); // run the digitizer theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); diff --git a/SimMuon/RPCDigitizer/src/RPCDigiProducer.h b/SimMuon/RPCDigitizer/src/RPCDigiProducer.h index 05f1836399312..55352ed7a47f0 100644 --- a/SimMuon/RPCDigitizer/src/RPCDigiProducer.h +++ b/SimMuon/RPCDigitizer/src/RPCDigiProducer.h @@ -38,12 +38,8 @@ class RPCDigiProducer : public edm::stream::EDProducer { RPCDigitizer* theDigitizer; RPCSimSetUp* theRPCSimSetUp; - //Name of Collection used for create the XF - std::string mix_; - std::string collection_for_XF; - //Token for accessing data - edm::EDGetTokenT> crossingFrameToken; + std::vector>> crossingFrameTokens; //EventSetup Tokens edm::ESGetToken geomToken; diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc index 2738d96921150..80213ea19b164 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.cc @@ -97,7 +97,9 @@ namespace cms { : false), _pixeldigialgo(), hitsProducer(iConfig.getParameter("hitsProducer")), - trackerContainers(iConfig.getParameter >("RoutList")), + hitsProducerPU(iConfig.getParameter("hitsProducerPU")), + trackerContainers(iConfig.getParameter>("RoutList")), + trackerContainersPU(iConfig.getParameter>("RoutListPU")), pilotBlades(iConfig.exists("enablePilotBlades") ? iConfig.getParameter("enablePilotBlades") : false), NumberOfEndcapDisks(iConfig.exists("NumPixelEndcap") ? iConfig.getParameter("NumPixelEndcap") : 2), tTopoToken_(iC.esConsumes()), @@ -109,18 +111,21 @@ namespace cms { const std::string alias("simSiPixelDigis"); - producesCollector.produces >().setBranchAlias(alias); - producesCollector.produces >().setBranchAlias(alias + "siPixelDigiSimLink"); + producesCollector.produces>().setBranchAlias(alias); + producesCollector.produces>().setBranchAlias(alias + "siPixelDigiSimLink"); if (store_SimHitEntryExitPoints_) - producesCollector.produces >().setBranchAlias(alias + - "siPixelExtraSimHit"); + producesCollector.produces>().setBranchAlias(alias + + "siPixelExtraSimHit"); if (store_SimHitEntryExitPointsLite_) - producesCollector.produces >().setBranchAlias( + producesCollector.produces>().setBranchAlias( alias + "siPixelExtraSimHitLite"); - for (auto const& trackerContainer : trackerContainers) { - edm::InputTag tag(hitsProducer, trackerContainer); - iC.consumes >(edm::InputTag(hitsProducer, trackerContainer)); + const std::map> pmap = {{hitsProducer, trackerContainers}, + {hitsProducerPU, trackerContainersPU}}; + for (auto const& ip : pmap) { + for (auto const& ic : ip.second) { + iC.consumes>(edm::InputTag(ip.first, ic)); + } } edm::Service rng; if (!rng.isAvailable()) { @@ -141,7 +146,7 @@ namespace cms { // member functions // - void SiPixelDigitizer::accumulatePixelHits(edm::Handle > hSimHits, + void SiPixelDigitizer::accumulatePixelHits(edm::Handle> hSimHits, size_t globalSimHitIndex, const unsigned int tofBin, edm::EventSetup const& iSetup) { @@ -153,18 +158,13 @@ namespace cms { for (std::vector::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex) { unsigned int detId = (*it).detUnitId(); - if (detIds.insert(detId).second) { - // The insert succeeded, so this detector element has not yet been processed. - assert(detectorUnits[detId]); - if (detectorUnits[detId] && - detectorUnits[detId] - ->type() - .isTrackerPixel()) { // this test could be avoided and changed into a check of pixdet!=0 - std::map::iterator itDet = detectorUnits.find(detId); - if (itDet == detectorUnits.end()) - continue; - auto pixdet = itDet->second; - assert(pixdet != nullptr); + auto itDet = detectorUnits.find(detId); + if (itDet == detectorUnits.end()) + continue; + auto pixdet = itDet->second; + assert(pixdet != nullptr); + if (pixdet && pixdet->type().isTrackerPixel()) { + if (detIds.insert(detId).second) { //access to magnetic field in global coordinates GlobalVector bfield = pSetup->inTesla(pixdet->surface().position()); LogDebug("PixelDigitizer ") << "B-field(T) at " << pixdet->surface().position() @@ -222,10 +222,16 @@ namespace cms { void SiPixelDigitizer::accumulate(edm::Event const& iEvent, edm::EventSetup const& iSetup) { // Step A: Get Inputs for (vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) { - edm::Handle > simHits; + edm::Handle> simHits; edm::InputTag tag(hitsProducer, *i); iEvent.getByLabel(tag, simHits); + if (!simHits.isValid()) + continue; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("SiPixelDigitizer") << "accumulate " + << " Accumulating SimHits for Signals with InputTag " << tag; +#endif unsigned int tofBin = PixelDigiSimLink::LowTof; if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof; @@ -234,7 +240,6 @@ namespace cms { // the global counter. Next time accumulateStripHits() is called it will count the sim hits // as though they were on the end of this collection. // Note that this is only used for creating digi-sim links (if configured to do so). - // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl; if (simHits.isValid()) crossingSimHitIndexOffset_[tag.encode()] += simHits->size(); } @@ -244,11 +249,19 @@ namespace cms { edm::EventSetup const& iSetup, edm::StreamID const& streamID) { // Step A: Get Inputs - for (vstring::const_iterator i = trackerContainers.begin(), iEnd = trackerContainers.end(); i != iEnd; ++i) { - edm::Handle > simHits; - edm::InputTag tag(hitsProducer, *i); + for (vstring::const_iterator i = trackerContainersPU.begin(), iEnd = trackerContainersPU.end(); i != iEnd; ++i) { + edm::Handle> simHits; + edm::InputTag tag(hitsProducerPU, *i); iEvent.getByLabel(tag, simHits); + + if (!simHits.isValid()) + continue; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("SiPixelDigitizer") << "accumulate " + << " Accumulating SimHits for PUs with InputTag " << tag; +#endif + unsigned int tofBin = PixelDigiSimLink::LowTof; if ((*i).find(std::string("HighTof")) != std::string::npos) tofBin = PixelDigiSimLink::HighTof; @@ -257,7 +270,6 @@ namespace cms { // the global counter. Next time accumulateStripHits() is called it will count the sim hits // as though they were on the end of this collection. // Note that this is only used for creating digi-sim links (if configured to do so). - // std::cout << "index offset, current hit count = " << crossingSimHitIndexOffset_[tag.encode()] << ", " << simHits->size() << std::endl; if (simHits.isValid()) crossingSimHitIndexOffset_[tag.encode()] += simHits->size(); } @@ -267,10 +279,10 @@ namespace cms { void SiPixelDigitizer::finalizeEvent(edm::Event& iEvent, const edm::EventSetup& iSetup) { const TrackerTopology* tTopo = &iSetup.getData(tTopoToken_); - std::vector > theDigiVector; - std::vector > theDigiLinkVector; - std::vector > theExtraSimHitInfoVector; - std::vector > theExtraSimHitInfoLiteVector; + std::vector> theDigiVector; + std::vector> theDigiLinkVector; + std::vector> theExtraSimHitInfoVector; + std::vector> theExtraSimHitInfoLiteVector; if (firstFinalizeEvent_) { _pixeldigialgo->init_DynIneffDB(iSetup); @@ -286,7 +298,6 @@ namespace cms { } iEvent.put(std::move(PixelFEDChannelCollection_)); } - for (const auto& iu : pDD->detUnits()) { if (iu->type().isTrackerPixel()) { // @@ -400,13 +411,14 @@ namespace cms { _pixeldigialgo->resetSimHitMaps(); // Step C: create collection with the cache vector of DetSet - std::unique_ptr > output(new edm::DetSetVector(theDigiVector)); - std::unique_ptr > outputlink( - new edm::DetSetVector(theDigiLinkVector)); - std::unique_ptr > outputExtraSim( - new edm::DetSetVector(theExtraSimHitInfoVector)); - std::unique_ptr > outputExtraSimLite( - new edm::DetSetVector(theExtraSimHitInfoLiteVector)); + std::unique_ptr> output = + std::make_unique>(theDigiVector); + std::unique_ptr> outputlink = + std::make_unique>(theDigiLinkVector); + std::unique_ptr> outputExtraSim = + std::make_unique>(theExtraSimHitInfoVector); + std::unique_ptr> outputExtraSimLite = + std::make_unique>(theExtraSimHitInfoLiteVector); // Step D: write output to file iEvent.put(std::move(output)); diff --git a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h index 5606cc2fa86f0..9b9aa09ce3470 100644 --- a/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h +++ b/SimTracker/SiPixelDigitizer/plugins/SiPixelDigitizer.h @@ -89,9 +89,11 @@ namespace cms { * The key is the name of the sim hit collection. */ std::map crossingSimHitIndexOffset_; - typedef std::vector vstring; + using vstring = std::vector; const std::string hitsProducer; + const std::string hitsProducerPU; const vstring trackerContainers; + const vstring trackerContainersPU; const TrackerGeometry* pDD = nullptr; const MagneticField* pSetup = nullptr; std::map detectorUnits; diff --git a/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.cc b/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.cc index 1c3959b14002d..6f47b677eb0da 100644 --- a/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.cc +++ b/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.cc @@ -54,7 +54,9 @@ SiStripDigitizer::SiStripDigitizer(const edm::ParameterSet& conf, edm::ProducesCollector producesCollector, edm::ConsumesCollector& iC) : hitsProducer(conf.getParameter("hitsProducer")), + hitsProducerPU(conf.getParameter("hitsProducerPU")), trackerContainers(conf.getParameter>("ROUList")), + trackerContainersPU(conf.getParameter>("ROUListPU")), ZSDigi(conf.getParameter("DigiModeList").getParameter("ZSDigi")), SCDigi(conf.getParameter("DigiModeList").getParameter("SCDigi")), VRDigi(conf.getParameter("DigiModeList").getParameter("VRDigi")), @@ -95,10 +97,15 @@ SiStripDigitizer::SiStripDigitizer(const edm::ParameterSet& conf, producesCollector.produces("SimulatedAPVDynamicGain").setBranchAlias(alias + "SimulatedAPVDynamicGain"); producesCollector.produces>>>("AffectedAPVList") .setBranchAlias(alias + "AffectedAPV"); - for (auto const& trackerContainer : trackerContainers) { - edm::InputTag tag(hitsProducer, trackerContainer); - iC.consumes>(edm::InputTag(hitsProducer, trackerContainer)); + + const std::map> pmap = {{hitsProducer, trackerContainers}, + {hitsProducerPU, trackerContainersPU}}; + for (auto const& ip : pmap) { + for (auto const& ic : ip.second) { + iC.consumes>(edm::InputTag(ip.first, ic)); + } } + edm::Service rng; if (!rng.isAvailable()) { throw cms::Exception("Configuration") @@ -126,11 +133,13 @@ void SiStripDigitizer::accumulateStripHits(edm::Handle> hSi for (std::vector::const_iterator it = simHits.begin(), itEnd = simHits.end(); it != itEnd; ++it, ++globalSimHitIndex) { unsigned int detId = (*it).detUnitId(); - if (detIds.insert(detId).second) { - // The insert succeeded, so this detector element has not yet been processed. - assert(detectorUnits[detId]); - if (detectorUnits[detId]->type().isTrackerStrip()) { // this test can be removed and replaced by stripdet!=0 - auto stripdet = detectorUnits[detId]; + auto itDet = detectorUnits.find(detId); + if (itDet == detectorUnits.end()) + continue; + auto stripdet = detectorUnits[detId]; + assert(stripdet); + if (stripdet->type().isTrackerStrip()) { + if (detIds.insert(detId).second) { //access to magnetic field in global coordinates GlobalVector bfield = pSetup->inTesla(stripdet->surface().position()); LogDebug("Digitizer ") << "B-field(T) at " << stripdet->surface().position() @@ -156,6 +165,13 @@ void SiStripDigitizer::accumulate(edm::Event const& iEvent, edm::EventSetup cons tofBin = StripDigiSimLink::HighTof; iEvent.getByLabel(tag, simHits); + + if (!simHits.isValid()) + continue; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("SiStripDigitizer") << "accumulate " + << " Accumulating SimHits for Signals with InputTag " << tag; +#endif accumulateStripHits(simHits, tTopo, crossingSimHitIndexOffset_[tag.encode()], tofBin); // Now that the hits have been processed, I'll add the amount of hits in this crossing on to // the global counter. Next time accumulateStripHits() is called it will count the sim hits @@ -175,14 +191,21 @@ void SiStripDigitizer::accumulate(PileUpEventPrincipal const& iEvent, theDigiAlgo->calculateInstlumiScale(PileupInfo_.get()); // Step A: Get Inputs - for (auto const& trackerContainer : trackerContainers) { + for (auto const& trackerContainer : trackerContainersPU) { edm::Handle> simHits; - edm::InputTag tag(hitsProducer, trackerContainer); + edm::InputTag tag(hitsProducerPU, trackerContainer); unsigned int tofBin = StripDigiSimLink::LowTof; if (trackerContainer.find(std::string("HighTof")) != std::string::npos) tofBin = StripDigiSimLink::HighTof; iEvent.getByLabel(tag, simHits); + if (!simHits.isValid()) + continue; +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("SiStripDigitizer") << "accumulate " + << " Accumulating SimHits for PUs with InputTag " << tag; +#endif + accumulateStripHits(simHits, tTopo, crossingSimHitIndexOffset_[tag.encode()], tofBin); // Now that the hits have been processed, I'll add the amount of hits in this crossing on to // the global counter. Next time accumulateStripHits() is called it will count the sim hits @@ -252,18 +275,20 @@ void SiStripDigitizer::finalizeEvent(edm::Event& iEvent, edm::EventSetup const& } std::vector> theDigiVector; std::vector> theRawDigiVector; - std::unique_ptr> theStripAmplitudeVector(new edm::DetSetVector()); - std::unique_ptr> theStripAmplitudeVectorPostAPV( - new edm::DetSetVector()); - std::unique_ptr> theStripAPVBaselines(new edm::DetSetVector()); - std::unique_ptr> pOutputDigiSimLink(new edm::DetSetVector); + std::unique_ptr> theStripAmplitudeVector = + std::make_unique>(); + std::unique_ptr> theStripAmplitudeVectorPostAPV = + std::make_unique>(); + std::unique_ptr> theStripAPVBaselines = + std::make_unique>(); + std::unique_ptr> pOutputDigiSimLink = + std::make_unique>(); const TrackerTopology* tTopo = &iSetup.getData(tTopoToken_); // Step B: LOOP on StripGeomDetUnit theDigiVector.reserve(10000); theDigiVector.clear(); - for (const auto& iu : pDD->detUnits()) { if (useConfFromDB) { //apply the cable map _before_ digitization: consider only the detis that are connected @@ -323,12 +348,16 @@ void SiStripDigitizer::finalizeEvent(edm::Event& iEvent, edm::EventSetup const& } if (zeroSuppression) { // Step C: create output collection - std::unique_ptr> output_virginraw(new edm::DetSetVector()); - std::unique_ptr> output_scopemode(new edm::DetSetVector()); - std::unique_ptr> output_processedraw(new edm::DetSetVector()); - std::unique_ptr> output(new edm::DetSetVector(theDigiVector)); - std::unique_ptr>>> AffectedAPVList( - new std::vector>>(theAffectedAPVvector)); + std::unique_ptr> output_virginraw = + std::make_unique>(); + std::unique_ptr> output_scopemode = + std::make_unique>(); + std::unique_ptr> output_processedraw = + std::make_unique>(); + std::unique_ptr> output = + std::make_unique>(theDigiVector); + std::unique_ptr>>> AffectedAPVList = + std::make_unique>>>(theAffectedAPVvector); // Step D: write output to file iEvent.put(std::move(output), ZSDigi); @@ -345,11 +374,13 @@ void SiStripDigitizer::finalizeEvent(edm::Event& iEvent, edm::EventSetup const& std::move(pOutputDigiSimLink)); // The previous EDProducer didn't name this collection so I won't either } else { // Step C: create output collection - std::unique_ptr> output_virginraw( - new edm::DetSetVector(theRawDigiVector)); - std::unique_ptr> output_scopemode(new edm::DetSetVector()); - std::unique_ptr> output_processedraw(new edm::DetSetVector()); - std::unique_ptr> output(new edm::DetSetVector()); + std::unique_ptr> output_virginraw = + std::make_unique>(theRawDigiVector); + std::unique_ptr> output_scopemode = + std::make_unique>(); + std::unique_ptr> output_processedraw = + std::make_unique>(); + std::unique_ptr> output = std::make_unique>(); // Step D: write output to file iEvent.put(std::move(output), ZSDigi); diff --git a/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.h b/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.h index 0959f2b4608ee..a5559ecb56cc2 100644 --- a/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.h +++ b/SimTracker/SiStripDigitizer/plugins/SiStripDigitizer.h @@ -82,12 +82,14 @@ class SiStripDigitizer : public DigiAccumulatorMixMod { size_t globalSimHitIndex, const unsigned int tofBin); - typedef std::vector vstring; - typedef std::map>, std::less> simhit_map; - typedef simhit_map::iterator simhit_map_iterator; + using vstring = std::vector; + using simhit_map = std::map>, std::less>; + using simhit_map_iterator = simhit_map::iterator; const std::string hitsProducer; + const std::string hitsProducerPU; const vstring trackerContainers; + const vstring trackerContainersPU; const std::string ZSDigi; const std::string SCDigi; const std::string VRDigi;