Skip to content

Commit

Permalink
Merge pull request #43979 from waredjeb/integratePFAlpakaClusteringAt…
Browse files Browse the repository at this point in the history
…HLT_14_0_0_pre3

[14.0.X] Add customize to include Alpaka HCal PF Clustering at HLT
  • Loading branch information
cmsbuild authored Feb 16, 2024
2 parents 52b448a + 28e9220 commit 1816fe8
Showing 1 changed file with 251 additions and 0 deletions.
251 changes: 251 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforAlpaka.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,255 @@
import FWCore.ParameterSet.Config as cms
from HeterogeneousCore.AlpakaCore.functions import *

## PF HLT in Alpaka
def customizeHLTforAlpakaParticleFlowClustering(process):
'''Customization to introduce Particle Flow Reconstruction in Alpaka
'''
process.hltPFRecHitHCALParamsRecordSource = cms.ESSource('EmptyESSource',
recordName = cms.string('PFRecHitHCALParamsRecord'),
iovIsRunNotTime = cms.bool(True),
firstValid = cms.vuint32(1)
)

process.hltPFRecHitHCALTopologyRecordSource = cms.ESSource('EmptyESSource',
recordName = cms.string('PFRecHitHCALTopologyRecord'),
iovIsRunNotTime = cms.bool(True),
firstValid = cms.vuint32(1)
)

process.hltPFClusterParamsRecordSource = cms.ESSource('EmptyESSource',
recordName = cms.string('JobConfigurationGPURecord'),
iovIsRunNotTime = cms.bool(True),
firstValid = cms.vuint32(1)
)

process.hltHBHERecHitToSoA = cms.EDProducer("HCALRecHitSoAProducer@alpaka",
src = cms.InputTag("hltHbhereco"),
synchronise = cms.untracked.bool(False)
)

process.hltPFRecHitHCALTopologyESProducer = cms.ESProducer('PFRecHitHCALTopologyESProducer@alpaka',
usePFThresholdsFromDB = cms.bool(True),
appendToDataLabel = cms.string(''),
)


process.hltPFRecHitHCALParamsESProducer = cms.ESProducer('PFRecHitHCALParamsESProducer@alpaka',
energyThresholdsHB = cms.vdouble(
0.1,
0.2,
0.3,
0.3
),
energyThresholdsHE = cms.vdouble(
0.1,
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
),
appendToDataLabel = cms.string(''),
)

process.hltPFRecHitSoAProducerHCAL = cms.EDProducer("PFRecHitSoAProducerHCAL@alpaka",
producers = cms.VPSet(
cms.PSet(
src = cms.InputTag("hltHBHERecHitToSoA"),
params = cms.ESInputTag("hltPFRecHitHCALParamsESProducer:"),
)
),
topology = cms.ESInputTag("hltPFRecHitHCALTopologyESProducer:"),
synchronise = cms.untracked.bool(False)
)

process.hltPFRecHitSoAProducerHCALCPUSerial = makeSerialClone(process.hltPFRecHitSoAProducerHCAL)


process.hltLegacyPFRecHitProducer = cms.EDProducer("LegacyPFRecHitProducer",
src = cms.InputTag("hltPFRecHitSoAProducerHCAL")
)

process.hltLegacyPFRecHitProducerCPUSerial = process.hltLegacyPFRecHitProducer.clone(
src = cms.InputTag("hltPFRecHitSoAProducerHCALCPUSerial")
)

process.hltPFClusterParamsESProducer = cms.ESProducer("PFClusterParamsESProducer@alpaka",
seedFinder = cms.PSet(
nNeighbours = cms.int32(4),
thresholdsByDetector = cms.VPSet(
cms.PSet(
detector = cms.string('HCAL_BARREL1'),
seedingThreshold = cms.vdouble(
0.125,
0.25,
0.35,
0.35
),
seedingThresholdPt = cms.double(0)
),
cms.PSet(
detector = cms.string('HCAL_ENDCAP'),
seedingThreshold = cms.vdouble(
0.1375,
0.275,
0.275,
0.275,
0.275,
0.275,
0.275
),
seedingThresholdPt = cms.double(0)
)
)
),
initialClusteringStep = cms.PSet(
thresholdsByDetector = cms.VPSet(
cms.PSet(
detector = cms.string('HCAL_BARREL1'),
gatheringThreshold = cms.vdouble(
0.1,
0.2,
0.3,
0.3
)
),
cms.PSet(
detector = cms.string('HCAL_ENDCAP'),
gatheringThreshold = cms.vdouble(
0.1,
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
)
)
)
),
pfClusterBuilder = cms.PSet(
maxIterations = cms.uint32(5),
minFracTot = cms.double(1e-20),
minFractionToKeep = cms.double(1e-07),
excludeOtherSeeds = cms.bool(True),
showerSigma = cms.double(10),
stoppingTolerance = cms.double(1e-08),
recHitEnergyNorms = cms.VPSet(
cms.PSet(
detector = cms.string('HCAL_BARREL1'),
recHitEnergyNorm = cms.vdouble(
0.1,
0.2,
0.3,
0.3
)
),
cms.PSet(
detector = cms.string('HCAL_ENDCAP'),
recHitEnergyNorm = cms.vdouble(
0.1,
0.2,
0.2,
0.2,
0.2,
0.2,
0.2
)
)
),
positionCalc = cms.PSet(
minFractionInCalc = cms.double(1e-09),
minAllowedNormalization = cms.double(1e-09)
),
timeResolutionCalcBarrel = cms.PSet(
corrTermLowE = cms.double(0),
threshLowE = cms.double(6),
noiseTerm = cms.double(21.86),
constantTermLowE = cms.double(4.24),
noiseTermLowE = cms.double(8),
threshHighE = cms.double(15),
constantTerm = cms.double(2.82)
),
timeResolutionCalcEndcap = cms.PSet(
corrTermLowE = cms.double(0),
threshLowE = cms.double(6),
noiseTerm = cms.double(21.86),
constantTermLowE = cms.double(4.24),
noiseTermLowE = cms.double(8),
threshHighE = cms.double(15),
constantTerm = cms.double(2.82)
)
),
)

process.hltPFClusterSoAProducer = cms.EDProducer("PFClusterSoAProducer@alpaka",
pfRecHits = cms.InputTag("hltPFRecHitSoAProducerHCAL"),
topology = cms.ESInputTag("hltPFRecHitHCALTopologyESProducer:"),
pfClusterParams = cms.ESInputTag("hltPFClusterParamsESProducer:"),
synchronise = cms.bool(False)
)

process.hltPFClusterSoAProducerCPUSerial = makeSerialClone(process.hltPFClusterSoAProducer,
pfRecHits = cms.InputTag("hltPFRecHitSoAProducerHCALCPUSerial"),
)

process.hltLegacyPFClusterProducer = cms.EDProducer("LegacyPFClusterProducer",
src = cms.InputTag("hltPFClusterSoAProducer"),
pfClusterParams = cms.ESInputTag("pfClusterParamsESProducer:"),
pfClusterBuilder = process.hltParticleFlowClusterHBHE.pfClusterBuilder,
usePFThresholdsFromDB = cms.bool(True),
recHitsSource = cms.InputTag("hltLegacyPFRecHitProducer"),
PFRecHitsLabelIn = cms.InputTag("hltPFRecHitSoAProducerHCAL")
)

#Same as default except change the clusterSource
process.hltParticleFlowClusterHCAL = cms.EDProducer("PFMultiDepthClusterProducer",
clustersSource = cms.InputTag("hltLegacyPFClusterProducer"),
usePFThresholdsFromDB = cms.bool(True),
energyCorrector = process.hltParticleFlowClusterHCAL.energyCorrector,
pfClusterBuilder = process.hltParticleFlowClusterHCAL.pfClusterBuilder,
positionReCalc = process.hltParticleFlowClusterHCAL.positionReCalc
)

#Define the task (I assume the name has to be the same as the default task)
process.HLTPFHcalRecHits = cms.Sequence(
process.hltHBHERecHitToSoA+
process.hltPFRecHitSoAProducerHCAL+
process.hltPFRecHitSoAProducerHCALCPUSerial+
process.hltLegacyPFRecHitProducer+
process.hltLegacyPFRecHitProducerCPUSerial
)

process.HLTPFHcalClustering = cms.Sequence(
process.HLTPFHcalRecHits+
process.hltPFClusterSoAProducer+
process.hltPFClusterSoAProducerCPUSerial+
process.hltLegacyPFClusterProducer+
process.hltParticleFlowClusterHCAL
)

#Some Sequences contain all the modules of process.HLTPFHcalClustering Sequence instead of the Sequence itself
#find these Sequences and replace all the modules with the Sequence
def replaceItemsInSequence(process, itemsToReplace, replacingSequence):
for sequence, items in process.sequences.items():
#Find Sequences containing all the items in itemsToReplace
containsAll = all(items.contains(item) for item in itemsToReplace)
if(containsAll):
for item in itemsToReplace:
#remove items that will be replaced by replacingSequence
if(item != itemsToReplace[-1]):
items.remove(item)
else:
#if last item, replace it with the Sequence
items.replace(item, replacingSequence)
return process

itemsList = [process.hltParticleFlowRecHitHBHE, process.hltParticleFlowClusterHBHE,process.hltParticleFlowClusterHCAL]
process = replaceItemsInSequence(process, itemsList, process.HLTPFHcalClustering)

return process

## Pixel HLT in Alpaka
def customizeHLTforDQMGPUvsCPUPixel(process):
Expand Down Expand Up @@ -649,6 +899,7 @@ def customizeHLTforAlpaka(process):

process = customizeHLTforAlpakaEcalLocalReco(process)
process = customizeHLTforAlpakaPixelReco(process)
process = customizeHLTforAlpakaParticleFlowClustering(process)

return process

0 comments on commit 1816fe8

Please sign in to comment.