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

Redesign of the association maps, multivector manager, HGCAL Rechits and Validation with significant speedup of Phase-2 workflows #45865

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1faf505
Update MultiVectorManager to C++20 and improve it by avoiding copies.
felicepantaleo Aug 29, 2024
ed85e4d
Introduce ticl::AssociationMap
felicepantaleo Aug 29, 2024
f229809
Improve RecHit data format and producers to be faster and to support …
felicepantaleo Aug 29, 2024
d64f2ab
TICL Associators: Create Hit To Tracksters associator using ticl::Ass…
felicepantaleo Aug 29, 2024
419ba45
TICL Associators: Create LayerCluster to Trackster associator using t…
felicepantaleo Aug 29, 2024
86e196d
TICL Associators: Create hits to layerclusters and sim objects associ…
felicepantaleo Aug 29, 2024
d46cbfc
TICL Associators: Create SimCluster To Caloparticle associator using …
felicepantaleo Aug 29, 2024
704d51e
TICL Associators: Create Trackster To SimTrackster associator using t…
felicepantaleo Aug 29, 2024
c7592bf
ticlv5: rename Tracksters by Passthrough to Recovery
felicepantaleo Aug 29, 2024
d8dd2e4
Double to float
felicepantaleo Aug 29, 2024
65bd5fe
Fix HLTCaloObjInRegionsProducer.cc to use the new HGCRecHit collection.
AuroraPerego Aug 29, 2024
5361e0c
Run new TICL associators
felicepantaleo Aug 29, 2024
0bcfc35
Adapt TICLDumper to use the new TICL Associators
felicepantaleo Aug 29, 2024
e660109
Validation is Automation: Redesign of the HGCAL Trackster Validation …
felicepantaleo Aug 29, 2024
eed28af
Pass the new AssociationMaps to the TICLCandidateValidator
felicepantaleo Aug 29, 2024
b16adf4
fix hgcal event content for hlt and add new associators
felicepantaleo Sep 2, 2024
acff6a7
Optimize egamma recostruction using MultiVectorManager and RecHitMap
felicepantaleo Sep 3, 2024
7983397
Improve operator< for HGCRecHit
felicepantaleo Sep 3, 2024
a5a2af5
Remove redundant HGCRecHitComparison
felicepantaleo Sep 4, 2024
d11f67a
Make MultivectorManager unique_ptr in ClusterTools
felicepantaleo Sep 5, 2024
28509ad
code format
felicepantaleo Sep 5, 2024
8d8b7d4
Remove duplicate dictionary from classes_def.xml
felicepantaleo Sep 6, 2024
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
12 changes: 6 additions & 6 deletions CommonTools/RecoAlgos/interface/MultiVectorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <vector>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <span>

template <typename T>
class MultiVectorManager {
public:
void addVector(const std::vector<T>& vec) {
vectors.emplace_back(vec.begin(), vec.end());
void addVector(std::span<const T> vec) {
vectors.emplace_back(vec);
offsets.push_back(totalSize);
totalSize += vec.size();
}
Expand Down Expand Up @@ -39,8 +39,6 @@ class MultiVectorManager {
return offsets[vectorIndex] + localIndex;
}

size_t size() const { return totalSize; }

std::pair<size_t, size_t> getVectorAndLocalIndex(size_t globalIndex) const {
assert(globalIndex < totalSize && "Global index out of range");

Expand All @@ -51,6 +49,8 @@ class MultiVectorManager {
return {vectorIndex, localIndex};
}

size_t size() const { return totalSize; }

class Iterator {
public:
using iterator_category = std::forward_iterator_tag;
Expand All @@ -77,7 +77,7 @@ class MultiVectorManager {
Iterator end() const { return Iterator(*this, totalSize); }

private:
std::vector<std::vector<T>> vectors;
std::vector<std::span<const T>> vectors;
std::vector<size_t> offsets;
size_t totalSize = 0;
};
Expand Down
11 changes: 11 additions & 0 deletions DataFormats/HGCRecHit/interface/HGCRecHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ class HGCRecHit : public CaloRecHit {
//added for validation
uint32_t flagBits() const { return flagBits_; }

//define operator== for std::find
bool operator==(const HGCRecHit& hit) const { return id().rawId() == hit.id().rawId(); }
bool operator==(const DetId& otherid) const { return id().rawId() == otherid.rawId(); }

//define operator< for std::sort
bool operator<(const HGCRecHit& hit) const {
if (id().rawId() == hit.id().rawId())
return energy() < hit.energy();
return id().rawId() < hit.id().rawId();
}

private:
/// store rechit condition (see Flags enum) in a bit-wise way
uint32_t flagBits_;
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/HGCRecHit/interface/HGCRecHitCollections.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include "DataFormats/HGCRecHit/interface/HGCUncalibratedRecHit.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/RefVector.h"
#include <vector>

typedef edm::SortedCollection<HGCRecHit> HGCRecHitCollection;
typedef std::vector<HGCRecHit> HGCRecHitCollection;
typedef edm::Ref<HGCRecHitCollection> HGCRecHitRef;
typedef edm::RefVector<HGCRecHitCollection> HGCRecHitRefs;
typedef edm::RefProd<HGCRecHitCollection> HGCRecHitsRef;
Expand Down
21 changes: 0 additions & 21 deletions DataFormats/HGCRecHit/interface/HGCRecHitComparison.h

This file was deleted.

1 change: 0 additions & 1 deletion DataFormats/HGCRecHit/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/Common/interface/DetSet.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/HGCRecHit/interface/HGCRecHitComparison.h"
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import FWCore.ParameterSet.Config as cms

hltFilteredLayerClustersPassthrough = cms.EDProducer("FilteredLayerClustersProducer",
hltFilteredLayerClustersRecovery = cms.EDProducer("FilteredLayerClustersProducer",
LayerClusters = cms.InputTag("hltHgcalMergeLayerClusters"),
LayerClustersInputMask = cms.InputTag("hltTiclTrackstersCLUE3DHigh"),
algo_number = cms.vint32(6, 7, 8),
clusterFilter = cms.string('ClusterFilterBySize'),
iteration_label = cms.string('Passthrough'),
iteration_label = cms.string('Recovery'),
max_cluster_size = cms.int32(9999),
max_layerId = cms.int32(9999),
mightGet = cms.optional.untracked.vstring,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
propagator = cms.string('PropagatorWithMaterial'),
regressionAndPid = cms.bool(True),
tfDnnLabel = cms.string('tracksterSelectionTf'),
tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHigh", "hltTiclTrackstersPassthrough")
tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHigh", "hltTiclTrackstersRecovery")
)
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import FWCore.ParameterSet.Config as cms

hltTiclTrackstersPassthrough = cms.EDProducer("TrackstersProducer",
hltTiclTrackstersRecovery = cms.EDProducer("TrackstersProducer",
detector = cms.string('HGCAL'),
filtered_mask = cms.InputTag("hltFilteredLayerClustersPassthrough","Passthrough"),
itername = cms.string('PassThrough'),
filtered_mask = cms.InputTag("hltFilteredLayerClustersRecovery","Recovery"),
itername = cms.string('Recovery'),
layer_clusters = cms.InputTag("hltHgcalMergeLayerClusters"),
layer_clusters_hfnose_tiles = cms.InputTag("ticlLayerTileHFNose"),
layer_clusters_tiles = cms.InputTag("hltTiclLayerTileProducer"),
mightGet = cms.optional.untracked.vstring,
original_mask = cms.InputTag("hltTiclTrackstersCLUE3DHigh"),
patternRecognitionBy = cms.string('Passthrough'),
patternRecognitionBy = cms.string('Recovery'),
pluginPatternRecognitionByCA = cms.PSet(
algo_verbosity = cms.int32(0),
computeLocalTime = cms.bool(True),
Expand Down Expand Up @@ -81,9 +81,9 @@
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
),
pluginPatternRecognitionByPassthrough = cms.PSet(
pluginPatternRecognitionByRecovery = cms.PSet(
algo_verbosity = cms.int32(0),
type = cms.string('Passthrough')
type = cms.string('Recovery')
),
seeding_regions = cms.InputTag("hltTiclSeedingGlobal"),
tfDnnLabel = cms.string('tracksterSelectionTf'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from ..sequences.HLTTiclPFSequence_cfi import *
from ..sequences.HLTTiclTracksterMergeSequence_cfi import *
from ..sequences.HLTTiclTrackstersCLUE3DHighStepSequence_cfi import *
from ..sequences.HLTTiclTrackstersPassthroughSequence_cfi import *
from ..sequences.HLTTiclTrackstersRecoverySequence_cfi import *
from ..sequences.HLTTiclTracksterLinksSequence_cfi import *
from ..sequences.HLTTiclCandidateSequence_cfi import *

HLTIterTICLSequence = cms.Sequence(HLTTiclLayerTileSequence+HLTTiclTrackstersCLUE3DHighStepSequence+HLTTiclTracksterMergeSequence+HLTTiclPFSequence)

from Configuration.ProcessModifiers.ticl_v5_cff import ticl_v5
ticl_v5.toReplaceWith(HLTIterTICLSequence, cms.Sequence(HLTTiclLayerTileSequence+HLTTiclTrackstersCLUE3DHighStepSequence+HLTTiclTrackstersPassthroughSequence+HLTTiclTracksterLinksSequence+HLTTiclCandidateSequence+HLTTiclPFSequence))
ticl_v5.toReplaceWith(HLTIterTICLSequence, cms.Sequence(HLTTiclLayerTileSequence+HLTTiclTrackstersCLUE3DHighStepSequence+HLTTiclTrackstersRecoverySequence+HLTTiclTracksterLinksSequence+HLTTiclCandidateSequence+HLTTiclPFSequence))

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FWCore.ParameterSet.Config as cms

from ..modules.hltFilteredLayerClustersRecovery_cfi import *
from ..modules.hltTiclTrackstersRecovery_cfi import *

HLTTiclTrackstersRecoverySequence = cms.Sequence(hltFilteredLayerClustersRecovery+hltTiclTrackstersRecovery)
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void ElectronSeedProducer::fillDescriptions(edm::ConfigurationDescriptions& desc
psd4.add<edm::InputTag>("HGCEEInput", {"HGCalRecHit", "HGCEERecHits"});
psd4.add<edm::InputTag>("HGCFHInput", {"HGCalRecHit", "HGCHEFRecHits"});
psd4.add<edm::InputTag>("HGCBHInput", {"HGCalRecHit", "HGCHEBRecHits"});
psd4.add<edm::InputTag>("hgcalHitMap", {"recHitMapProducer", "hgcalRecHitMap"});
desc.add<edm::ParameterSetDescription>("HGCalConfig", psd4);

// r/z windows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
endcapSuperClusters = 'particleFlowSuperClusterHGCal',
allowHGCal = True,
)
phase2_hgcal.toModify(
ecalDrivenElectronSeeds.HGCalConfig,
hgcalHitMap = cms.InputTag("recHitMapProducer", "hgcalRecHitMap"),
)

from Configuration.ProcessModifiers.egamma_lowPt_exclusive_cff import egamma_lowPt_exclusive
egamma_lowPt_exclusive.toModify(ecalDrivenElectronSeeds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

/**************************************************************
/ purpose: enable filtering of calo objects in eta/phi or deltaR
/ regions around generic objects
/ regions around generic objects
/
/ operation : accepts all objects with
/ (dEta <dEtaMax && dPhi < dPhiMax) || dR < dRMax
Expand Down Expand Up @@ -243,7 +243,7 @@ std::unique_ptr<CaloObjCollType> HLTCaloObjInRegionsProducer<CaloObjType, CaloOb
}
}
} //end check of empty regions
} //end check of empty rec-hits
} //end check of empty rec-hits
return outputColl;
}

Expand Down Expand Up @@ -342,7 +342,7 @@ DEFINE_FWK_MODULE(HLTHGCalDigisInRegionsProducer);

// HGCAL RecHits
#include "DataFormats/HGCRecHit/interface/HGCRecHit.h"
using HLTHGCalRecHitsInRegionsProducer = HLTCaloObjInRegionsProducer<HGCRecHit>;
using HLTHGCalRecHitsInRegionsProducer = HLTCaloObjInRegionsProducer<HGCRecHit, std::vector<HGCRecHit>>;
DEFINE_FWK_MODULE(HLTHGCalRecHitsInRegionsProducer);
#include "DataFormats/HGCRecHit/interface/HGCUncalibratedRecHit.h"
using HLTHGCalUncalibratedRecHitsInRegionsProducer = HLTCaloObjInRegionsProducer<HGCUncalibratedRecHit>;
Expand Down
39 changes: 20 additions & 19 deletions RecoHGCal/Configuration/python/RecoHGCal_EventContent_cff.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import FWCore.ParameterSet.Config as cms

from RecoHGCal.TICL.iterativeTICL_cff import ticlIterLabelsMerge
from RecoHGCal.TICL.iterativeTICL_cff import ticlIterLabels

trackstersIters = ['keep *_ticlTracksters'+iteration+'_*_*' for iteration in ticlIterLabelsMerge]
trackstersHLTIters = ['keep *_hltTiclTracksters'+iteration+'_*_*' for iteration in ticlIterLabelsMerge]
trackstersIters = ['keep *_'+iteration+'_*_*' for iteration in ticlIterLabels]

#AOD content
TICL_AOD = cms.PSet(
Expand All @@ -22,11 +21,9 @@
'keep *_ticlTrackstersHFNoseHAD_*_*',
'keep *_ticlTrackstersHFNoseMerge_*_*',] +
['keep *_pfTICL_*_*'] +
['keep CaloParticles_mix_*_*', 'keep SimClusters_mix_*_*'] +
['keep *_layerClusterSimClusterAssociationProducer_*_*','keep *_layerClusterCaloParticleAssociationProducer_*_*', 'keep *_layerClusterSimTracksterAssociationProducer_*_*'] +
['keep *_tracksterSimTracksterAssociationLinking_*_*' ,'keep *_tracksterSimTracksterAssociationPR_*_*'] +
['keep *_tracksterSimTracksterAssociationLinkingPU_*_*' ,'keep *_tracksterSimTracksterAssociationPRPU_*_*'] +
['keep *_tracksterSimTracksterAssociationLinkingbyCLUE3D_*_*', 'keep *_tracksterSimTracksterAssociationPRbyCLUE3D_*_*']
['keep CaloParticles_mix_*_*', 'keep SimClusters_mix_*_*', 'keep *_SimClusterToCaloParticleAssociation*_*_*'] +
['keep *_SimClusterToCaloParticleAssociation*_*_*', 'keep *_layerClusterSimClusterAssociationProducer_*_*','keep *_layerClusterCaloParticleAssociationProducer_*_*', 'keep *_layerClusterSimTracksterAssociationProducer_*_*'] +
['keep *_tracksterSimTracksterAssociation*_*_*' , 'keep *_tracksterSimTracksterFromCPsAssociation*_*_*' ]
)
)

Expand All @@ -35,9 +32,10 @@
[
'drop *_ticlTracksters*_*_*',
'keep *_ticlTrackstersCLUE3DHigh_*_*',
'keep *_ticlTracksterLinks_*_*',
'keep *_ticlTracksterLinks*_*_*',
'keep *_ticlTracksterLinksSuperclustering*_*_*',
'keep *_ticlCandidate_*_*',

]
)
)
Expand All @@ -61,17 +59,22 @@
'keep *_ticlSimTracksters_*_*',
'keep *_ticlSimTICLCandidates_*_*',
'keep *_ticlSimTrackstersFromCP_*_*',
'keep *_tracksterSimTracksterAssociationLinkingSuperclustering_*_*',
'keep *_tracksterSimTracksterAssociationPRSuperclustering_*_*',
'keep CaloParticles_mix_*_*', 'keep SimClusters_mix_*_*', 'keep *_SimClusterToCaloParticleAssociation*_*_*',
'keep *_SimClusterToCaloParticleAssociation*_*_*', 'keep *_layerClusterSimClusterAssociationProducer_*_*','keep *_layerClusterCaloParticleAssociationProducer_*_*', 'keep *_layerClusterSimTracksterAssociationProducer_*_*',
'keep *_allTrackstersToSimTrackstersAssociations*_*_*'

)
)

TICLv5_FEVT.outputCommands.extend(TICLv5_RECO.outputCommands)

TICL_FEVTHLT = cms.PSet(
outputCommands = cms.untracked.vstring(
trackstersHLTIters +
['keep *_hltPfTICL_*_*']
['keep *_hltPfTICL_*_*',
'keep *_hltTiclTrackstersCLUE3D*_*_*',
'keep *_hltTiclTracksterLinks_*_*',
'keep *_hltTiclCandidate_*_*',
'keep *_hltPfTICL_*_*',]
)
)

Expand Down Expand Up @@ -107,12 +110,10 @@ def cleanOutputAndSet(outputModule, ticl_outputCommads):
'keep *_layerClusterCaloParticleAssociationProducer_*_*',
'keep *_randomEngineStateProducer_*_*',
'keep *_layerClusterSimTracksterAssociationProducer_*_*',
'keep *_tracksterSimTracksterAssociationLinking_*_*',
'keep *_tracksterSimTracksterAssociationPR_*_*',
'keep *_tracksterSimTracksterAssociationLinkingPU_*_*',
'keep *_tracksterSimTracksterAssociationPRPU_*_*',
'keep *_tracksterSimTracksterAssociationLinkingbyCLUE3D_*_*',
'keep *_tracksterSimTracksterAssociationPRbyCLUE3D_*_*',
'keep *_tracksterSimTracksterAssociation*_*_*',
'keep *_tracksterSimTracksterFromCPsAssociation*_*_*',
'keep *_SimClusterToCaloParticleAssociation*_*_*',
'keep *_simClusterToCaloParticleAssociator*_*_*'
])

if hasattr(process, 'FEVTDEBUGEventContent'):
Expand Down
6 changes: 2 additions & 4 deletions RecoHGCal/TICL/plugins/PatternRecognitionPluginFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "PatternRecognitionbyCA.h"
#include "PatternRecognitionbyCLUE3D.h"
#include "PatternRecognitionbyFastJet.h"
#include "PatternRecognitionbyPassthrough.h"
#include "PatternRecognitionbyRecovery.h"
#include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h"
#include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h"

Expand All @@ -11,7 +11,5 @@ EDM_REGISTER_VALIDATED_PLUGINFACTORY(PatternRecognitionHFNoseFactory, "PatternRe
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionFactory, ticl::PatternRecognitionbyCA<TICLLayerTiles>, "CA");
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionFactory, ticl::PatternRecognitionbyCLUE3D<TICLLayerTiles>, "CLUE3D");
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionFactory, ticl::PatternRecognitionbyFastJet<TICLLayerTiles>, "FastJet");
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionFactory,
ticl::PatternRecognitionbyPassthrough<TICLLayerTiles>,
"Passthrough");
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionFactory, ticl::PatternRecognitionbyRecovery<TICLLayerTiles>, "Recovery");
DEFINE_EDM_VALIDATED_PLUGIN(PatternRecognitionHFNoseFactory, ticl::PatternRecognitionbyCA<TICLLayerTilesHFNose>, "CA");
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "PatternRecognitionbyPassthrough.h"
#include "PatternRecognitionbyRecovery.h"
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
Expand All @@ -16,12 +16,12 @@
using namespace ticl;

template <typename TILES>
PatternRecognitionbyPassthrough<TILES>::PatternRecognitionbyPassthrough(const edm::ParameterSet &conf,
edm::ConsumesCollector iC)
PatternRecognitionbyRecovery<TILES>::PatternRecognitionbyRecovery(const edm::ParameterSet &conf,
edm::ConsumesCollector iC)
: PatternRecognitionAlgoBaseT<TILES>(conf, iC), caloGeomToken_(iC.esConsumes<CaloGeometry, CaloGeometryRecord>()) {}

template <typename TILES>
void PatternRecognitionbyPassthrough<TILES>::makeTracksters(
void PatternRecognitionbyRecovery<TILES>::makeTracksters(
const typename PatternRecognitionAlgoBaseT<TILES>::Inputs &input,
std::vector<Trackster> &result,
std::unordered_map<int, std::vector<int>> &seedToTracksterAssociation) {
Expand Down Expand Up @@ -58,15 +58,15 @@ void PatternRecognitionbyPassthrough<TILES>::makeTracksters(

// Log the number of tracksters created
if (PatternRecognitionAlgoBaseT<TILES>::algo_verbosity_ > VerbosityLevel::Advanced) {
edm::LogVerbatim("PatternRecognitionbyPassthrough") << "Created " << result.size() << " tracksters";
edm::LogVerbatim("PatternRecognitionbyRecovery") << "Created " << result.size() << " tracksters";
}
}

template <typename TILES>
void PatternRecognitionbyPassthrough<TILES>::fillPSetDescription(edm::ParameterSetDescription &iDesc) {
void PatternRecognitionbyRecovery<TILES>::fillPSetDescription(edm::ParameterSetDescription &iDesc) {
iDesc.add<int>("algo_verbosity", 0);
}

// Explicitly instantiate the templates
template class ticl::PatternRecognitionbyPassthrough<TICLLayerTiles>;
template class ticl::PatternRecognitionbyPassthrough<TICLLayerTilesHFNose>;
template class ticl::PatternRecognitionbyRecovery<TICLLayerTiles>;
template class ticl::PatternRecognitionbyRecovery<TICLLayerTilesHFNose>;
Loading