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

Refactoring of TICL EnergyRegression and PID model #45821

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

hltTiclTracksterLinks = cms.EDProducer("TracksterLinksProducer",
detector = cms.string('HGCAL'),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(2.5),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
layer_clusters = cms.InputTag("hltHgcalMergeLayerClusters"),
layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster"),
inferenceAlgo = cms.string('TracksterInferenceByDNN'),
linkingPSet = cms.PSet(
algo_verbosity = cms.int32(0),
cylinder_radius_sqr = cms.vdouble(9, 9),
Expand All @@ -25,10 +20,25 @@
type = cms.string('Skeletons'),
wind = cms.double(0.036)
),
pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
algo_verbosity = cms.int32(0),
onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/id_v0.onnx'),
onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/energy_v0.onnx'),
inputNames = cms.vstring('input'),
output_en = cms.vstring('enreg_output'),
output_id = cms.vstring('pid_output'),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
doPID = cms.int32(1),
doRegression = cms.int32(1),
type = cms.string('TracksterInferenceByDNN')
),
mightGet = cms.optional.untracked.vstring,
original_masks = cms.VInputTag("hltHgcalMergeLayerClusters:InitialLayerClustersMask"),
propagator = cms.string('PropagatorWithMaterial'),
regressionAndPid = cms.bool(True),
tfDnnLabel = cms.string('tracksterSelectionTf'),
tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHigh", "hltTiclTrackstersPassthrough")
)


Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
mightGet = cms.optional.untracked.vstring,
original_mask = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","InitialLayerClustersMask"),
patternRecognitionBy = cms.string('CLUE3D'),
inferenceAlgo = cms.string('TracksterInferenceByCNNv4'),
pluginPatternRecognitionByCA = cms.PSet(
algo_verbosity = cms.int32(0),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(1),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
energy_em_over_total_threshold = cms.double(-1),
etaLimitIncreaseWindow = cms.double(2.1),
filter_on_categories = cms.vint32(0),
Expand Down Expand Up @@ -100,34 +95,51 @@
2,
2
),
eid_input_name = cms.string('input'),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
computeLocalTime = cms.bool(False),
doPidCut = cms.bool(True),
cutHadProb = cms.double(999.),
type = cms.string('CLUE3D')

),
pluginPatternRecognitionByFastJet = cms.PSet(
algo_verbosity = cms.int32(0),
antikt_radius = cms.double(0.09),
eid_input_name = cms.string('input'),
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
),
pluginInferenceAlgoTracksterInferenceByCNNv4 = cms.PSet(
algo_verbosity = cms.int32(0),
onnxModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv4/onnx_models/energy_id_v0.onnx'),
inputNames = cms.vstring('input:0'),
outputNames = cms.vstring("output/regressed_energy:0", "output/id_probabilities:0"),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
doPID = cms.int32(1),
doRegression = cms.int32(0),
type = cms.string('TracksterInferenceByCNNv4')
Moanwar marked this conversation as resolved.
Show resolved Hide resolved
),
pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. I see that here you use the pluginInferenceAlgoTracksterInferenceByDNN with a TICLv4 model, while in the TracksterProducer and the linking variant, there is also the plugin TracksterInferenceByCNNv4. If we configure the DNN one, should we expect regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Marco, so this additional empty plugin is set up in anticipation of future models that might arrive later, so we prepared the configuration for it in advance. Thanks!

algo_verbosity = cms.int32(0),
onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/id_v0.onnx'),
onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/energy_v0.onnx'),
inputNames = cms.vstring('input'),
output_en = cms.vstring('enreg_output'),
output_id = cms.vstring('pid_output'),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
eid_n_clusters = cms.int32(10),
doPID = cms.int32(1),
doRegression = cms.int32(0),
type = cms.string('TracksterInferenceByDNN')
),
pluginInferenceAlgoTracksterInferenceByANN = cms.PSet(
algo_verbosity = cms.int32(0),
type = cms.string('TracksterInferenceByANN')

),
seeding_regions = cms.InputTag("hltTiclSeedingL1"),
tfDnnLabel = cms.string('tracksterSelectionTf'),
time_layerclusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","timeLayerCluster")
time_layerclusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","timeLayerCluster"),
)

from Configuration.ProcessModifiers.ticl_v5_cff import ticl_v5
ticl_v5.toModify(hltTiclTrackstersCLUE3DHighL1Seeded.pluginPatternRecognitionByCLUE3D, computeLocalTime = cms.bool(True), doPidCut = cms.bool(False))
ticl_v5.toModify(hltTiclTrackstersCLUE3DHighL1Seeded.inferenceAlgo, type = cms.string('TracksterInferenceByDNN'))
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
mightGet = cms.optional.untracked.vstring,
original_mask = cms.InputTag("hltHgcalMergeLayerClusters","InitialLayerClustersMask"),
patternRecognitionBy = cms.string('CLUE3D'),
inferenceAlgo = cms.string('TracksterInferenceByCNNv4'),
pluginPatternRecognitionByCA = cms.PSet(
algo_verbosity = cms.int32(0),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(1),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
energy_em_over_total_threshold = cms.double(-1),
etaLimitIncreaseWindow = cms.double(2.1),
filter_on_categories = cms.vint32(0),
Expand Down Expand Up @@ -100,12 +95,6 @@
2,
2
),
eid_input_name = cms.string('input'),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
computeLocalTime = cms.bool(False),
doPidCut = cms.bool(True),
cutHadProb = cms.double(999.),
Expand All @@ -115,19 +104,43 @@
pluginPatternRecognitionByFastJet = cms.PSet(
algo_verbosity = cms.int32(0),
antikt_radius = cms.double(0.09),
eid_input_name = cms.string('input'),
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
),
pluginInferenceAlgoTracksterInferenceByCNNv4 = cms.PSet(
algo_verbosity = cms.int32(0),
onnxModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv4/onnx_models/energy_id_v0.onnx'),
inputNames = cms.vstring('input:0'),
outputNames = cms.vstring("output/regressed_energy:0", "output/id_probabilities:0"),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
doPID = cms.int32(1),
doRegression = cms.int32(0),
type = cms.string('TracksterInferenceByCNNv4')
),
pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
algo_verbosity = cms.int32(0),
onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/id_v0.onnx'),
onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/energy_v0.onnx'),
inputNames = cms.vstring('input'),
output_en = cms.vstring('enreg_output'),
output_id = cms.vstring('pid_output'),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
eid_n_clusters = cms.int32(10),
doPID = cms.int32(1),
doRegression = cms.int32(0),
type = cms.string('TracksterInferenceByDNN')
Moanwar marked this conversation as resolved.
Show resolved Hide resolved
),
pluginInferenceAlgoTracksterInferenceByANN = cms.PSet(
Moanwar marked this conversation as resolved.
Show resolved Hide resolved
algo_verbosity = cms.int32(0),
type = cms.string('TracksterInferenceByANN')

Moanwar marked this conversation as resolved.
Show resolved Hide resolved
),
seeding_regions = cms.InputTag("hltTiclSeedingGlobal"),
tfDnnLabel = cms.string('tracksterSelectionTf'),
time_layerclusters = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster")
)

)
from Configuration.ProcessModifiers.ticl_v5_cff import ticl_v5
ticl_v5.toModify(hltTiclTrackstersCLUE3DHigh.pluginPatternRecognitionByCLUE3D, computeLocalTime = cms.bool(True), doPidCut = cms.bool(False))
ticl_v5.toModify(hltTiclTrackstersCLUE3DHigh.inferenceAlgo, type = cms.string('TracksterInferenceByDNN'))
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@
mightGet = cms.optional.untracked.vstring,
original_mask = cms.InputTag("hltTiclTrackstersCLUE3DHigh"),
patternRecognitionBy = cms.string('Passthrough'),
inferenceAlgo = cms.string('TracksterInferenceByDNN'),
pluginPatternRecognitionByCA = cms.PSet(
algo_verbosity = cms.int32(0),
computeLocalTime = cms.bool(True),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(1),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
energy_em_over_total_threshold = cms.double(-1),
etaLimitIncreaseWindow = cms.double(2.1),
filter_on_categories = cms.vint32(0),
Expand Down Expand Up @@ -53,12 +48,6 @@
densitySiblingLayers = cms.vint32(3, 3, 3),
densityXYDistanceSqr = cms.vdouble(3.24, 3.24, 3.24),
doPidCut = cms.bool(False),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(1),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
kernelDensityFactor = cms.vdouble(0.2, 0.2, 0.2),
minNumLayerCluster = cms.vint32(2, 2, 2),
nearestHigherOnSameLayer = cms.bool(False),
Expand All @@ -72,20 +61,33 @@
algo_verbosity = cms.int32(0),
antikt_radius = cms.double(0.09),
computeLocalTime = cms.bool(True),
eid_input_name = cms.string('input'),
eid_min_cluster_energy = cms.double(1),
eid_n_clusters = cms.int32(10),
eid_n_layers = cms.int32(50),
eid_output_name_energy = cms.string('output/regressed_energy'),
eid_output_name_id = cms.string('output/id_probabilities'),
minNumLayerCluster = cms.int32(5),
type = cms.string('FastJet')
),
pluginPatternRecognitionByPassthrough = cms.PSet(
algo_verbosity = cms.int32(0),
type = cms.string('Passthrough')
),

pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
algo_verbosity = cms.int32(0),
onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/id_v0.onnx'),
onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/patternrecognition/energy_v0.onnx'),
inputNames = cms.vstring('input'),
output_en = cms.vstring('enreg_output'),
output_id = cms.vstring('pid_output'),
eid_min_cluster_energy = cms.double(1),
eid_n_layers = cms.int32(50),
eid_n_clusters = cms.int32(10),
doPID = cms.int32(0),
doRegression = cms.int32(0),
type = cms.string('TracksterInferenceByDNN')
),
pluginInferenceAlgoTracksterInferenceByANN = cms.PSet(
Moanwar marked this conversation as resolved.
Show resolved Hide resolved
algo_verbosity = cms.int32(0),
type = cms.string('TracksterInferenceByANN')

),
seeding_regions = cms.InputTag("hltTiclSeedingGlobal"),
tfDnnLabel = cms.string('tracksterSelectionTf'),
time_layerclusters = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster")
)
1 change: 1 addition & 0 deletions RecoHGCal/TICL/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<use name="FWCore/PluginManager"/>
<use name="Geometry/HGCalCommonData"/>
<use name="PhysicsTools/TensorFlow"/>
<use name="PhysicsTools/ONNXRuntime"/>
<export>
<lib name="1"/>
</export>
16 changes: 10 additions & 6 deletions RecoHGCal/TICL/interface/PatternRecognitionAlgoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <memory>
#include <vector>
#include <functional>
#include <algorithm>
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "DataFormats/HGCalReco/interface/TICLLayerTile.h"
Expand All @@ -28,7 +30,7 @@ namespace ticl {
public:
PatternRecognitionAlgoBaseT(const edm::ParameterSet& conf, edm::ConsumesCollector)
: algo_verbosity_(conf.getParameter<int>("algo_verbosity")) {}
virtual ~PatternRecognitionAlgoBaseT(){};
virtual ~PatternRecognitionAlgoBaseT() {};

struct Inputs {
const edm::Event& ev;
Expand All @@ -38,23 +40,25 @@ namespace ticl {
const edm::ValueMap<std::pair<float, float>>& layerClustersTime;
const TILES& tiles;
const std::vector<TICLSeedingRegion>& regions;
const tensorflow::Session* tfSession;

Inputs(const edm::Event& eV,
const edm::EventSetup& eS,
const std::vector<reco::CaloCluster>& lC,
const std::vector<float>& mS,
const edm::ValueMap<std::pair<float, float>>& lT,
const TILES& tL,
const std::vector<TICLSeedingRegion>& rG,
const tensorflow::Session* tS)
: ev(eV), es(eS), layerClusters(lC), mask(mS), layerClustersTime(lT), tiles(tL), regions(rG), tfSession(tS) {}
const std::vector<TICLSeedingRegion>& rG)
: ev(eV), es(eS), layerClusters(lC), mask(mS), layerClustersTime(lT), tiles(tL), regions(rG) {}
};

virtual void makeTracksters(const Inputs& input,
std::vector<Trackster>& result,
std::unordered_map<int, std::vector<int>>& seedToTracksterAssociation) = 0;

virtual void filter(std::vector<Trackster>& output,
const std::vector<Trackster>& inTracksters,
const Inputs& input,
std::unordered_map<int, std::vector<int>>& seedToTracksterAssociation) = 0;

protected:
int algo_verbosity_;
};
Expand Down
38 changes: 38 additions & 0 deletions RecoHGCal/TICL/interface/TracksterInferenceAlgoBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Author: Felice Pantaleo - [email protected]
// Date: 07/2024

#ifndef RecoHGCal_TICL_TracksterInferenceAlgo_H__
#define RecoHGCal_TICL_TracksterInferenceAlgo_H__

#include <vector>
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "DataFormats/Candidate/interface/Candidate.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "DataFormats/HGCalReco/interface/TICLCandidate.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h"
#include "FWCore/PluginManager/interface/PluginFactory.h"

namespace ticl {
class TracksterInferenceAlgoBase {
public:
explicit TracksterInferenceAlgoBase(const edm::ParameterSet& conf)
: algo_verbosity_(conf.getParameter<int>("algo_verbosity")) {}
virtual ~TracksterInferenceAlgoBase() {}

virtual void inputData(const std::vector<reco::CaloCluster>& layerClusters, std::vector<Trackster>& tracksters) = 0;
virtual void runInference(std::vector<Trackster>& tracksters) = 0;
static void fillPSetDescription(edm::ParameterSetDescription& desc) { desc.add<int>("algo_verbosity", 0); };

protected:
int algo_verbosity_;
};
} // namespace ticl

#endif
15 changes: 15 additions & 0 deletions RecoHGCal/TICL/interface/TracksterInferenceAlgoFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Author: Felice Pantaleo - [email protected]
// Date: 07/2024

#ifndef RecoHGCal_TICL_TracksterInferenceAlgoFactory_H__
#define RecoHGCal_TICL_TracksterInferenceAlgoFactory_H__

#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h"
#include "RecoHGCal/TICL/interface/TracksterInferenceAlgoBase.h"

typedef edmplugin::PluginFactory<ticl::TracksterInferenceAlgoBase*(const edm::ParameterSet&)>
TracksterInferenceAlgoFactory;

#endif
Loading