Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customize to include Alpaka HCal PF Clustering at HLT #43971

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(''),
)
Comment on lines +37 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these numbers should now be taken from the GT, so is this ESProducer still needed ? (I'm not thinking about the customisation per se, but about what we will actually integrate in the HLT menu)

Copy link
Contributor

@hatakeyamak hatakeyamak Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that, yes, these numbers are now taken from GT, but we still need to provide some "default" numbers to get the code function (somewhat historic). Perhaps something we can try to see if we can design the code differently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When adding DB thresholds, my understanding was to maintain function with hardcoded parameters if needed. An example of the current implementation starts here:

If there is need to change the functionality to DB only, I can look into it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the reminder. It's probably wise to keep the functionality to use numbers via config.


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:"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hltPFClusterParamsESProducer: instead ? (I guess it does not matter, since the tests passed ? From a quick look, it seems that pfClusterParams is not really used inside LegacyPFClusterProducer)

Copy link
Contributor Author

@waredjeb waredjeb Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess we can directly drop this parameter from LegacyPFClusterProducer

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