Skip to content

Commit

Permalink
ticlv5: Introduce a Passthrough pattern recognition for converting la…
Browse files Browse the repository at this point in the history
…yerclusters directly to tracksters
  • Loading branch information
waredjeb authored and felicepantaleo committed May 31, 2024
1 parent 1527313 commit 92e6a7f
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 2 deletions.
4 changes: 4 additions & 0 deletions RecoHGCal/TICL/plugins/PatternRecognitionPluginFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "PatternRecognitionbyCA.h"
#include "PatternRecognitionbyCLUE3D.h"
#include "PatternRecognitionbyFastJet.h"
#include "PatternRecognitionbyPassthrough.h"
#include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h"
#include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h"

Expand All @@ -10,4 +11,7 @@ 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(PatternRecognitionHFNoseFactory, ticl::PatternRecognitionbyCA<TICLLayerTilesHFNose>, "CA");
71 changes: 71 additions & 0 deletions RecoHGCal/TICL/plugins/PatternRecognitionbyPassthrough.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Author: Felice Pantaleo - [email protected]
// Date: 05/2024

#include <vector>
#include "DataFormats/Math/interface/deltaR.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "PatternRecognitionbyPassthrough.h"
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "TrackstersPCA.h"

using namespace ticl;

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

template <typename TILES>
void PatternRecognitionbyPassthrough<TILES>::makeTracksters(
const typename PatternRecognitionAlgoBaseT<TILES>::Inputs &input,
std::vector<Trackster> &result,
std::unordered_map<int, std::vector<int>> &seedToTracksterAssociation) {
// Get the geometry setup
edm::EventSetup const &es = input.es;
const CaloGeometry &geom = es.getData(caloGeomToken_);
rhtools_.setGeometry(geom);

// Clear the result vector
result.clear();

// Iterate over all layer clusters
for (size_t i = 0; i < input.layerClusters.size(); ++i) {
if (input.mask[i] == 0.) {
continue; // Skip masked clusters
}

// Create a new trackster for each layer cluster
Trackster trackster;
trackster.vertices().push_back(i);
trackster.vertex_multiplicity().push_back(1);

// Add the trackster to the result vector
result.push_back(trackster);
}

// Assign PCA to tracksters
ticl::assignPCAtoTracksters(result,
input.layerClusters,
input.layerClustersTime,
rhtools_.getPositionLayer(rhtools_.lastLayerEE(false), false).z(),
false);

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

template <typename TILES>
void PatternRecognitionbyPassthrough<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>;
30 changes: 30 additions & 0 deletions RecoHGCal/TICL/plugins/PatternRecognitionbyPassthrough.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Author: Felice Pantaleo - [email protected]
// Date: 05/2024

#ifndef __RecoHGCal_TICL_PatternRecognitionbyPassthrough_H__
#define __RecoHGCal_TICL_PatternRecognitionbyPassthrough_H__
#include <memory> // unique_ptr
#include "RecoHGCal/TICL/interface/PatternRecognitionAlgoBase.h"
#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"

namespace ticl {
template <typename TILES>
class PatternRecognitionbyPassthrough final : public PatternRecognitionAlgoBaseT<TILES> {
public:
PatternRecognitionbyPassthrough(const edm::ParameterSet& conf, edm::ConsumesCollector);
~PatternRecognitionbyPassthrough() override = default;

void makeTracksters(const typename PatternRecognitionAlgoBaseT<TILES>::Inputs& input,
std::vector<Trackster>& result,
std::unordered_map<int, std::vector<int>>& seedToTracksterAssociation) override;

static void fillPSetDescription(edm::ParameterSetDescription& iDesc);

private:
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
hgcal::RecHitTools rhtools_;
};

} // namespace ticl

#endif // __RecoHGCal_TICL_PatternRecognitionbyPassthrough_H__
5 changes: 5 additions & 0 deletions RecoHGCal/TICL/plugins/TrackstersProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void TrackstersProducer::fillDescriptions(edm::ConfigurationDescriptions& descri
pluginDescFastJet.addNode(edm::PluginDescription<PatternRecognitionFactory>("type", "FastJet", true));
desc.add<edm::ParameterSetDescription>("pluginPatternRecognitionByFastJet", pluginDescFastJet);

// PassThrough Plugin
edm::ParameterSetDescription pluginDescPassThrough;
pluginDescPassThrough.addNode(edm::PluginDescription<PatternRecognitionFactory>("type", "Passthrough", true));
desc.add<edm::ParameterSetDescription>("pluginPatternRecognitionByPassthrough", pluginDescPassThrough);

descriptions.add("trackstersProducer", desc);
}

Expand Down
33 changes: 33 additions & 0 deletions RecoHGCal/TICL/python/PRbyPassthrough_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import FWCore.ParameterSet.Config as cms

from RecoHGCal.TICL.TICLSeedingRegions_cff import ticlSeedingGlobal, ticlSeedingGlobalHFNose
from RecoHGCal.TICL.trackstersProducer_cfi import trackstersProducer as _trackstersProducer
from RecoHGCal.TICL.filteredLayerClustersProducer_cfi import filteredLayerClustersProducer as _filteredLayerClustersProducer

# CLUSTER FILTERING/MASKING

filteredLayerClustersPassthrough = _filteredLayerClustersProducer.clone(
clusterFilter = "ClusterFilterBySize",
min_cluster_size = 2, # inclusive
iteration_label = "Passthrough",
LayerClustersInputMask = 'ticlTrackstersCLUE3DHigh',
)

# PATTERN RECOGNITION

ticlTrackstersPassthrough = _trackstersProducer.clone(
filtered_mask = "filteredLayerClustersPassthrough:Passthrough",
original_mask = 'ticlTrackstersCLUE3DHigh',
seeding_regions = "ticlSeedingGlobal",
itername = "PassThrough",
patternRecognitionBy = "Passthrough",
pluginPatternRecognitionByPassthrough = dict (
algo_verbosity = 0
)
)

from Configuration.ProcessModifiers.ticl_v5_cff import ticl_v5

ticlPassthroughStepTask = cms.Task(ticlSeedingGlobal
,filteredLayerClustersPassthrough
,ticlTrackstersPassthrough)
8 changes: 6 additions & 2 deletions RecoHGCal/TICL/python/iterativeTICL_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from RecoHGCal.TICL.HADStep_cff import *
from RecoHGCal.TICL.CLUE3DEM_cff import *
from RecoHGCal.TICL.CLUE3DHAD_cff import *
from RecoHGCal.TICL.PRbyPassthrough_cff import *

from RecoHGCal.TICL.ticlLayerTileProducer_cfi import ticlLayerTileProducer
from RecoHGCal.TICL.pfTICLProducer_cfi import pfTICLProducer as _pfTICLProducer
Expand All @@ -27,7 +28,8 @@
ticlTrackstersMerge = _trackstersMergeProducer.clone()
ticlTracksterLinks = _tracksterLinksProducer.clone(
tracksters_collections = cms.VInputTag(
'ticlTrackstersCLUE3DHigh'
'ticlTrackstersCLUE3DHigh',
'ticlTrackstersPassthrough'
),
regressionAndPid = cms.bool(True)
)
Expand All @@ -40,7 +42,9 @@
ticlPFTask = cms.Task(pfTICL)

ticlIterationsTask = cms.Task(
ticlCLUE3DHighStepTask
ticlCLUE3DHighStepTask,
ticlPassthroughStepTask

)
''' For future separate iterations
,ticlCLUE3DEMStepTask,
Expand Down

0 comments on commit 92e6a7f

Please sign in to comment.