From 9050f4c395582ed1151bb72ac1f7d00807343822 Mon Sep 17 00:00:00 2001 From: Wahid Redjeb Date: Mon, 16 Sep 2024 17:17:17 +0200 Subject: [PATCH 1/4] TICLv5.1 : Improve skeleton linking and parameters tuning --- .../hltTiclTracksterLinksUnseeded_cfi.py | 60 ++- .../modules/hltTiclTracksterLinks_cfi.py | 60 ++- RecoHGCal/TICL/plugins/TICLDumper.cc | 18 +- RecoHGCal/TICL/plugins/TICLGraph.cc | 57 ++- RecoHGCal/TICL/plugins/TICLGraph.h | 17 +- .../plugins/TracksterLinkingbySkeletons.cc | 433 ++++++++++++------ .../plugins/TracksterLinkingbySkeletons.h | 54 ++- .../TICL/python/customiseTICLFromReco.py | 4 +- RecoHGCal/TICL/python/iterativeTICL_cff.py | 67 ++- RecoHGCal/TICL/python/ticlDumper_cff.py | 4 +- 10 files changed, 547 insertions(+), 227 deletions(-) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py index 4d90a837a4a48..b2130542a506f 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py @@ -6,19 +6,53 @@ 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), - dot_prod_th = cms.double(0.97), - max_distance_projective_sqr = cms.vdouble(60, 60), - max_distance_projective_sqr_closest_points = cms.vdouble(60, 60), - max_z_distance_closest_points = cms.vdouble(35, 35), - min_distance_z = cms.vdouble(30, 30), - min_num_lcs = cms.uint32(7), - min_trackster_energy = cms.double(10), - pca_quality_th = cms.double(0.85), - track_time_quality_threshold = cms.double(0.5), - type = cms.string('Skeletons'), - wind = cms.double(0.036) + cylinder_radius_sqr_split = cms.double(9), + proj_distance_split = cms.double(5), + track_time_quality_threshold = cms.double(0.5), + wind = cms.double(0.072), + min_num_lcs = cms.uint32(15), + min_trackster_energy = cms.double(20), + pca_quality_th = cms.double(0.85), + dot_prod_th = cms.double(0.97), + deltaRxy = cms.double(4), + lower_boundary = cms.vdouble( + 20, + 10 + ), + upper_boundary = cms.vdouble( + 150, + 100 + ), + upper_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + lower_distance_projective_sqr = cms.vdouble( + 30, + 30 + ), + min_distance_z = cms.vdouble( + 35, + 35 + ), + upper_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 30 + ), + lower_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 50 + ), + max_z_distance_closest_points = cms.vdouble( + 35, + 35 + ), + cylinder_radius_sqr = cms.vdouble( + 9, + 15 + ), + algo_verbosity = cms.int32(0), + type = cms.string('Skeletons') ), pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( algo_verbosity = cms.int32(0), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py index 3bf8faa4f4190..2b66f991961ca 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py @@ -6,19 +6,53 @@ 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), - dot_prod_th = cms.double(0.97), - max_distance_projective_sqr = cms.vdouble(60, 60), - max_distance_projective_sqr_closest_points = cms.vdouble(60, 60), - max_z_distance_closest_points = cms.vdouble(35, 35), - min_distance_z = cms.vdouble(30, 30), - min_num_lcs = cms.uint32(7), - min_trackster_energy = cms.double(10), - pca_quality_th = cms.double(0.85), - track_time_quality_threshold = cms.double(0.5), - type = cms.string('Skeletons'), - wind = cms.double(0.036) + cylinder_radius_sqr_split = cms.double(9), + proj_distance_split = cms.double(5), + track_time_quality_threshold = cms.double(0.5), + wind = cms.double(0.072), + min_num_lcs = cms.uint32(15), + min_trackster_energy = cms.double(20), + pca_quality_th = cms.double(0.85), + dot_prod_th = cms.double(0.97), + deltaRxy = cms.double(4), + lower_boundary = cms.vdouble( + 20, + 10 + ), + upper_boundary = cms.vdouble( + 150, + 100 + ), + upper_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + lower_distance_projective_sqr = cms.vdouble( + 30, + 30 + ), + min_distance_z = cms.vdouble( + 35, + 35 + ), + upper_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 30 + ), + lower_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 50 + ), + max_z_distance_closest_points = cms.vdouble( + 35, + 35 + ), + cylinder_radius_sqr = cms.vdouble( + 9, + 15 + ), + algo_verbosity = cms.int32(0), + type = cms.string('Skeletons') ), pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( algo_verbosity = cms.int32(0), diff --git a/RecoHGCal/TICL/plugins/TICLDumper.cc b/RecoHGCal/TICL/plugins/TICLDumper.cc index c40142bf655cd..5a76532f36afe 100644 --- a/RecoHGCal/TICL/plugins/TICLDumper.cc +++ b/RecoHGCal/TICL/plugins/TICLDumper.cc @@ -595,10 +595,10 @@ class TICLDumper : public edm::one::EDAnalyzer> muons_token_; const edm::EDGetTokenT>> clustersTime_token_; const edm::EDGetTokenT> tracksterSeeds_token_; - const edm::EDGetTokenT>> superclustering_linkedResultTracksters_token; - const edm::EDGetTokenT recoSuperClusters_token; - const edm::EDGetTokenT recoSuperClusters_caloClusters_token; - const edm::EDGetTokenT> recoSuperClusters_sourceTracksters_token; + edm::EDGetTokenT>> superclustering_linkedResultTracksters_token; + edm::EDGetTokenT recoSuperClusters_token; + edm::EDGetTokenT recoSuperClusters_caloClusters_token; + edm::EDGetTokenT> recoSuperClusters_sourceTracksters_token; edm::ESGetToken caloGeometry_token_; const edm::EDGetTokenT> simTracksters_SC_token_; // needed for simticlcandidate const edm::EDGetTokenT> simTICLCandidate_token_; @@ -884,6 +884,16 @@ TICLDumper::TICLDumper(const edm::ParameterSet& ps) saveTICLCandidate_(ps.getParameter("saveSimTICLCandidate")), saveSimTICLCandidate_(ps.getParameter("saveSimTICLCandidate")), saveTracks_(ps.getParameter("saveTracks")) { + if (saveSuperclustering_) { + superclustering_linkedResultTracksters_token = + consumes>>(ps.getParameter("superclustering")); + recoSuperClusters_token = + consumes(ps.getParameter("recoSuperClusters")); + recoSuperClusters_caloClusters_token = + consumes(ps.getParameter("recoSuperClusters")); + recoSuperClusters_sourceTracksters_token = consumes>( + ps.getParameter("recoSuperClusters_sourceTracksterCollection")); + } std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive"; hdc_token_ = esConsumes(edm::ESInputTag("", detectorName_)); diff --git a/RecoHGCal/TICL/plugins/TICLGraph.cc b/RecoHGCal/TICL/plugins/TICLGraph.cc index f51e7ab086d05..32b5aae61a2aa 100644 --- a/RecoHGCal/TICL/plugins/TICLGraph.cc +++ b/RecoHGCal/TICL/plugins/TICLGraph.cc @@ -17,6 +17,13 @@ namespace ticl { } } // namespace ticl +TICLGraph::TICLGraph(std::vector& nodes) { + nodes_ = nodes; + rootNodes_.reserve(nodes_.size()); + findRootNodes(); + rootNodes_.shrink_to_fit(); +} + std::vector> TICLGraph::findSubComponents() { std::vector> components; for (auto const& node : nodes_) { @@ -29,32 +36,46 @@ std::vector> TICLGraph::findSubComponents() { components.push_back(tmpSubComponents); } } + // Second loop: DFS for non-root nodes that haven't been visited + for (auto const& node : nodes_) { + auto const id = node.getId(); + if (!node.alreadyVisited()) { // Use the alreadyVisited() method + // Node not visited yet, so perform DFS + std::string tabs = "\t"; + std::vector tmpSubComponents; + nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs); + components.push_back(tmpSubComponents); + } + } return components; } -void TICLGraph::dfsForCC(unsigned int nodeIndex, - std::unordered_set& visited, - std::vector& component) const { - visited.insert(nodeIndex); - component.push_back(nodeIndex); +std::vector> TICLGraph::findSubComponents(std::vector& rootNodes) { + std::vector> components; + for (auto const& node : rootNodes) { + auto const id = node.getId(); + //LogDebug("TICLGraph") << "DFS Starting From " << id << std::endl; + std::string tabs = "\t"; + std::vector tmpSubComponents; + nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs); + components.push_back(tmpSubComponents); + } + return components; +} - for (auto const& neighbourIndex : nodes_[nodeIndex].getOuterNeighbours()) { - if (visited.find(neighbourIndex) == visited.end()) { - dfsForCC(neighbourIndex, visited, component); +inline void TICLGraph::findRootNodes() { + for (auto const& n : nodes_) { + if (n.getInnerNeighbours().size() == 0) { + rootNodes_.push_back(n); } } } -std::vector> TICLGraph::getConnectedComponents() const { - std::unordered_set visited; - std::vector> components; - - for (unsigned int i = 0; i < nodes_.size(); ++i) { - if (visited.find(i) == visited.end()) { - std::vector component; - dfsForCC(i, visited, component); - components.push_back(component); +bool TICLGraph::isGraphOk() { + for (auto n : nodes_) { + if (n.getInnerNeighbours().size() > 1) { + return false; } } - return components; + return true; } diff --git a/RecoHGCal/TICL/plugins/TICLGraph.h b/RecoHGCal/TICL/plugins/TICLGraph.h index 36e09bb87a384..8787ad11c2496 100644 --- a/RecoHGCal/TICL/plugins/TICLGraph.h +++ b/RecoHGCal/TICL/plugins/TICLGraph.h @@ -24,11 +24,12 @@ namespace ticl { auto findInner = std::find(innerNeighboursId_.begin(), innerNeighboursId_.end(), tid); return findInner != innerNeighboursId_.end(); } + inline bool alreadyVisited() const { return alreadyVisited_; } ~Node() = default; private: - unsigned index_; + unsigned int index_; bool isTrackster_; std::vector outerNeighboursId_; @@ -44,25 +45,23 @@ class TICLGraph { // can i remove default constructor ?? edm::Wrapper problem // without default constructor i could initialize connectedComponents when building the Graph TICLGraph() = default; - TICLGraph(std::vector& n, std::vector isRootNode) { - nodes_ = n; - isRootNode_ = isRootNode; - }; + TICLGraph(std::vector& nodes); inline const std::vector& getNodes() const { return nodes_; } inline const ticl::Node& getNode(int i) const { return nodes_[i]; } + inline std::vector getRootNodes() const { return rootNodes_; } + inline void findRootNodes(); std::vector> findSubComponents(); + std::vector> findSubComponents(std::vector& rootNodes); ~TICLGraph() = default; - void dfsForCC(unsigned int nodeIndex, - std::unordered_set& visited, - std::vector& component) const; - std::vector> getConnectedComponents() const; + bool isGraphOk(); private: std::vector nodes_; + std::vector rootNodes_; std::vector isRootNode_; }; diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc index 885d66d2f2bf6..90721eca424dd 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc @@ -11,7 +11,7 @@ #include "TICLGraph.h" namespace { - bool isRoundTrackster(std::array const &skeleton) { return (skeleton[0].Z() == skeleton[2].Z()); } + bool isRoundTrackster(std::array skeleton) { return (skeleton[0].Z() == skeleton[2].Z()); } bool isGoodTrackster(const ticl::Trackster &trackster, const std::array &skeleton, @@ -20,9 +20,15 @@ namespace { const float pca_quality_th) { bool isGood = false; - if (isRoundTrackster(skeleton) or trackster.vertices().size() < min_num_lcs or - trackster.raw_energy() < min_trackster_energy) { - isGood = false; + if (isRoundTrackster(skeleton) or trackster.vertices().size() < min_num_lcs) { + if (trackster.raw_energy() > min_trackster_energy) { + auto const &eigenvalues = trackster.eigenvalues(); + auto const sum = std::accumulate(std::begin(eigenvalues), std::end(eigenvalues), 0.f); + float pcaQuality = eigenvalues[0] / sum; + if (pcaQuality > pca_quality_th) { + isGood = true; + } + } } else { auto const &eigenvalues = trackster.eigenvalues(); auto const sum = std::accumulate(std::begin(eigenvalues), std::end(eigenvalues), 0.f); @@ -35,7 +41,7 @@ namespace { } //distance between skeletons - float projective_distance(const ticl::Vector &point1, const ticl::Vector &point2) { + inline float projective_distance(const ticl::Vector &point1, const ticl::Vector &point2) { // squared projective distance float r1 = std::sqrt(point1.x() * point1.x() + point1.y() * point1.y()); float r2_at_z1 = @@ -54,18 +60,26 @@ TracksterLinkingbySkeletons::TracksterLinkingbySkeletons(const edm::ParameterSet edm::ConsumesCollector iC, cms::Ort::ONNXRuntime const *onnxRuntime) : TracksterLinkingAlgoBase(conf, iC), + lower_boundary_(conf.getParameter>("lower_boundary")), + upper_boundary_(conf.getParameter>("upper_boundary")), + upper_distance_projective_sqr_(conf.getParameter>("upper_distance_projective_sqr")), + lower_distance_projective_sqr_(conf.getParameter>("lower_distance_projective_sqr")), + min_distance_z_(conf.getParameter>("min_distance_z")), + upper_distance_projective_sqr_closest_points_( + conf.getParameter>("upper_distance_projective_sqr_closest_points")), + lower_distance_projective_sqr_closest_points_( + conf.getParameter>("lower_distance_projective_sqr_closest_points")), + max_z_distance_closest_points_(conf.getParameter>("max_z_distance_closest_points")), + cylinder_radius_sqr_(conf.getParameter>("cylinder_radius_sqr")), + cylinder_radius_sqr_split_(conf.getParameter("cylinder_radius_sqr_split")), + proj_distance_split_(conf.getParameter("proj_distance_split")), timing_quality_threshold_(conf.getParameter("track_time_quality_threshold")), del_(conf.getParameter("wind")), - min_num_lcs_(conf.getParameter("min_num_lcs")), min_trackster_energy_(conf.getParameter("min_trackster_energy")), pca_quality_th_(conf.getParameter("pca_quality_th")), dot_prod_th_(conf.getParameter("dot_prod_th")), - max_distance_projective_sqr_(conf.getParameter>("max_distance_projective_sqr")), - min_distance_z_(conf.getParameter>("min_distance_z")), - max_distance_projective_sqr_closest_points_( - conf.getParameter>("max_distance_projective_sqr_closest_points")), - max_z_distance_closest_points_(conf.getParameter>("max_z_distance_closest_points")), - cylinder_radius_sqr_(conf.getParameter>("cylinder_radius_sqr")) + deltaRxy_(conf.getParameter("deltaRxy")), + min_num_lcs_(conf.getParameter("min_num_lcs")) {} @@ -105,6 +119,14 @@ void TracksterLinkingbySkeletons::initialize(const HGCalDDDConstants *hgcons, bfield_ = bfieldH; propagator_ = propH; + + //define LUT for eta windows + // eta windows obtained with a deltaR of 4cm at z = 400 cm + for (int i = 0; i < TileConstants::nEtaBins; ++i) { + float eta = TileConstants::minEta + i * (TileConstants::maxEta - TileConstants::minEta) / TileConstants::nEtaBins; + float R = z_surface * 2.f * std::exp(-eta) / (1.f - std::exp(-2.f * eta)); + eta_windows_[i] = abs(atan(deltaRxy_ / R)); + } } std::array TracksterLinkingbySkeletons::findSkeletonNodes( @@ -116,6 +138,14 @@ std::array TracksterLinkingbySkeletons::findSkeletonNodes( auto const &vertices = trackster.vertices(); auto const trackster_raw_energy = trackster.raw_energy(); // sort vertices by layerId + std::array skeleton; + if (trackster.vertices().size() < 3) { + auto v = layerClusters[trackster.vertices()[0]]; + const Vector intersection(v.x(), v.y(), v.z()); + skeleton = {{intersection, intersection, intersection}}; + return skeleton; + } + std::vector sortedVertices(vertices); std::sort(sortedVertices.begin(), sortedVertices.end(), [&layerClusters](unsigned int i, unsigned int j) { return std::abs(layerClusters[i].z()) < std::abs(layerClusters[j].z()); @@ -145,7 +175,6 @@ std::array TracksterLinkingbySkeletons::findSkeletonNodes( foundOuterLayer = true; } } - std::array skeleton; int minimumDistanceInLayers = 4; if (outerLayerId - innerLayerId < minimumDistanceInLayers) { skeleton = {{trackster.barycenter(), trackster.barycenter(), trackster.barycenter()}}; @@ -169,9 +198,9 @@ std::array TracksterLinkingbySkeletons::findSkeletonNodes( return skeleton; } -bool isInCylinder(const std::array &mySkeleton, - const std::array &otherSkeleton, - const float radius_sqr) { +inline bool isInCylinder(const std::array &mySkeleton, + const std::array &otherSkeleton, + const float radius_sqr) { const auto &first = mySkeleton[0]; const auto &last = mySkeleton[2]; const auto &pointToCheck = otherSkeleton[0]; @@ -192,84 +221,97 @@ bool isInCylinder(const std::array &mySkeleton, const auto &distance = pointToCheck - pointOnAxis; auto distance2 = distance.Dot(distance); - + LogDebug("TracksterLinkingbySkeletons") << "is within lenght " << distance2 << " radius " << radius_sqr << std::endl; bool isWithinRadius = distance2 <= radius_sqr; return isWithinRadius; } +inline float computeParameter(float energy, float en_th_low, float cut1, float en_th_high, float cut2) { + if (energy < en_th_low) { + return cut1; + } else if (energy >= en_th_low && energy <= en_th_high) { + return ((cut2 - cut1) / (en_th_high - en_th_low)) * (energy - en_th_low) + cut1; + } else { + return cut2; + } +} + +// function to check if otherTrackster is a splitted component of myTrackster, meaning that otherTrackster is very close to myTrackster and seems to be generated by splitting of 2D layer clusters +inline bool TracksterLinkingbySkeletons::isSplitComponent(const ticl::Trackster &myTrackster, + const ticl::Trackster &otherTrackster, + const std::array &mySkeleton, + const std::array &otherSkeleton, + float proj_distance) { + //check if otherSKeleton z is within the z range of mySkeleton + if (otherSkeleton[1].z() < mySkeleton[2].z() && otherSkeleton[1].z() > mySkeleton[0].z()) { + if (proj_distance < proj_distance_split_) { + return true; + } else { + // check if barycenter of otherTrackster is within the cirlce of 3cm of myTrackster barycenter + //compute XY distance between barycenters + float distance2 = (myTrackster.barycenter().x() - otherTrackster.barycenter().x()) * + (myTrackster.barycenter().x() - otherTrackster.barycenter().x()) + + (myTrackster.barycenter().y() - otherTrackster.barycenter().y()) * + (myTrackster.barycenter().y() - otherTrackster.barycenter().y()); + if (distance2 < cylinder_radius_sqr_split_) { + return true; + } + } + } + return false; +} + bool TracksterLinkingbySkeletons::areCompatible(const ticl::Trackster &myTrackster, const ticl::Trackster &otherTrackster, const std::array &mySkeleton, const std::array &otherSkeleton) { - //do not start links from small/bad tracksters float zVal_interface = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(); + if (!isGoodTrackster(myTrackster, mySkeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) { LogDebug("TracksterLinkingbySkeletons") << "Inner Trackster with energy " << myTrackster.raw_energy() << " Num LCs " << myTrackster.vertices().size() << " NOT GOOD " << std::endl; return false; - } else { - LogDebug("TracksterLinkingbySkeletons") << "Inner Trackster wi energy " << myTrackster.raw_energy() << " Num LCs " - << myTrackster.vertices().size() << " IS GOOD " << std::endl; - float proj_distance = projective_distance(mySkeleton[1], otherSkeleton[1]); - auto isEE = mySkeleton[1].z() <= zVal_interface ? 0 : 1; - bool areAlignedInProjectiveSpace = proj_distance < max_distance_projective_sqr_[isEE]; - LogDebug("TracksterLinkingbySkeletons") - << "\t Trying to compare with outer Trackster with energy " << otherTrackster.raw_energy() << " Num LCS " - << otherTrackster.vertices().size() << " Projective distance " << proj_distance << " areAlignedProjective " - << areAlignedInProjectiveSpace << " TH " << max_distance_projective_sqr_[isEE] << std::endl; - //check if otherTrackster is good - if (isGoodTrackster(otherTrackster, otherSkeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) { - // if both tracksters are good, then we can check the projective distance between the barycenters. - // if the barycenters are aligned, then we check that the two skeletons are aligned - if (areAlignedInProjectiveSpace) { - auto dotProdSkeletons = - ((mySkeleton[2] - mySkeleton[0]).Unit()).Dot((otherSkeleton[2] - otherSkeleton[0]).Unit()); - bool alignedSkeletons = dotProdSkeletons > dot_prod_th_; - LogDebug("TracksterLinkingbySkeletons") - << "\t Outer Trackster is Good, checking for skeleton alignment " << alignedSkeletons << " dotProd " - << dotProdSkeletons << " Threshold " << dot_prod_th_ << std::endl; - if (alignedSkeletons) - LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl; - return alignedSkeletons; - } else { - // we measure the distance between the two closest nodes in the two skeletons - LogDebug("TracksterLinkingbySkeletons") - << "\t Outer Trackster is not aligned, check skeletons distances " << std::endl; - int myClosestPoint = -1; - int otherClosestPoint = -1; - float minDistance_z = std::numeric_limits::max(); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - float dist_z = std::abs(mySkeleton[i].Z() - otherSkeleton[j].Z()); - if (dist_z < minDistance_z) { - myClosestPoint = i; - otherClosestPoint = j; - minDistance_z = dist_z; - } - } - } - if (minDistance_z < min_distance_z_[isEE]) { - LogDebug("TracksterLinkingbySkeletons") - << "\t Trackster have distance in Z " << minDistance_z - << "Checking if they are aligned in projective space " - << projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) << " TH " - << max_distance_projective_sqr_[isEE] << std::endl; - if (projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) < - max_distance_projective_sqr_[isEE]) { - LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl; - } - return projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]) < - max_distance_projective_sqr_[isEE]; - } else { - LogDebug("TracksterLinkingbySkeletons") << "\t\t Not Linked Distance Z " << minDistance_z << std::endl; - return false; - } - } + } + + LogDebug("TracksterLinkingbySkeletons") << "Inner Trackster with energy " << myTrackster.raw_energy() << " Num LCs " + << myTrackster.vertices().size() << " IS GOOD " << std::endl; + + float proj_distance = projective_distance(mySkeleton[1], otherSkeleton[1]); + auto isEE = mySkeleton[1].z() <= zVal_interface ? 0 : 1; + auto const max_distance_proj_sqr = computeParameter(myTrackster.raw_energy(), + lower_boundary_[isEE], + lower_distance_projective_sqr_[isEE], + upper_boundary_[isEE], + upper_distance_projective_sqr_[isEE]); + bool areAlignedInProjectiveSpace = proj_distance < max_distance_proj_sqr; + + LogDebug("TracksterLinkingbySkeletons") + << "\t Trying to compare with outer Trackster with energy " << otherTrackster.raw_energy() << " Num LCS " + << otherTrackster.vertices().size() << " Projective distance " << proj_distance << " areAlignedProjective " + << areAlignedInProjectiveSpace << " TH " << max_distance_proj_sqr << std::endl; + + if (isGoodTrackster(otherTrackster, otherSkeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) { + if (areAlignedInProjectiveSpace) { + LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl; + return true; } else { - LogDebug("TracksterLinkingbySkeletons") - << "\t Outer Trackster is NOT GOOD, check projective space alignment " << areAlignedInProjectiveSpace - << " proj_distance " << max_distance_projective_sqr_[isEE] << std::endl; + //if the tracksters are not aligned in Projective distance, check if otherTrackster is within the cylinder of 3cm radius + //this is used to recover LC splittings + if (isSplitComponent(myTrackster, otherTrackster, mySkeleton, otherSkeleton, proj_distance)) { + LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! Splitted components!" << std::endl; + return true; + } + //if is EE do not try to link more, PU occupancy is too high in this region + if (isEE) { + return false; + } + //if instead we are in the CE-H part of the detector, we can try to link more + // we measure the distance between the two closest nodes in the two skeletons + return checkClosestPoints(myTrackster, otherTrackster, mySkeleton, otherSkeleton, isEE); + } + } else { + if (otherTrackster.vertices().size() >= 3) { if (areAlignedInProjectiveSpace) { LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl; return true; @@ -277,44 +319,86 @@ bool TracksterLinkingbySkeletons::areCompatible(const ticl::Trackster &myTrackst LogDebug("TracksterLinkingbySkeletons") << "\t Not aligned in projective space, check distance between closest points in the two skeletons " << std::endl; - // we measure the distance between the two closest nodes in the two skeletons - int myClosestPoint = -1; - int otherClosestPoint = -1; - float minDistance_z = std::numeric_limits::max(); - // we skip the innermost node of mySkeleton - for (int i = 1; i < 3; i++) { - for (int j = 0; j < 3; j++) { - float dist_z = std::abs(mySkeleton[i].Z() - otherSkeleton[j].Z()); - if (dist_z < minDistance_z) { - myClosestPoint = i; - otherClosestPoint = j; - minDistance_z = dist_z; - } - } - } - float d = projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]); - LogDebug("TracksterLinkingbySkeletons") - << "\t\t Distance between closest points " << d << " TH " << 10.f << " Z Distance " << minDistance_z - << " TH " << max_distance_projective_sqr_closest_points_[isEE] << std::endl; - if (d < max_distance_projective_sqr_closest_points_[isEE] and - minDistance_z < max_z_distance_closest_points_[isEE]) { - LogDebug("TracksterLinkingbySkeletons") << "\t\t\t Linked! " << d << std::endl; + if (checkClosestPoints(myTrackster, otherTrackster, mySkeleton, otherSkeleton, isEE)) { return true; } else { - LogDebug("TracksterLinkingbySkeletons") << "Distance between closest point " << d << " Distance in z " - << max_z_distance_closest_points_[isEE] << std::endl; - bool isInCyl = isInCylinder(mySkeleton, otherSkeleton, cylinder_radius_sqr_[isEE]); - LogDebug("TracksterLinkingbySkeletons") << "Two Points are in Cylinder " << isInCyl << std::endl; - if (isInCyl) { - LogDebug("TracksterLinkingbySkeletons") << "\t\t\t Linked! " << d << std::endl; - } - return isInCyl; + return checkCylinderAlignment(mySkeleton, otherSkeleton, isEE); } } + } else { + return checkCylinderAlignment(mySkeleton, otherSkeleton, isEE); } } } +bool TracksterLinkingbySkeletons::checkCylinderAlignment(const std::array &mySkeleton, + const std::array &otherSkeleton, + int isEE) { + bool isInCyl = isInCylinder(mySkeleton, otherSkeleton, cylinder_radius_sqr_[isEE]); + if (isInCyl) { + LogDebug("TracksterLinkingbySkeletons") << "Two Points are in Cylinder " << isInCyl << " Linked! " << std::endl; + } + return isInCyl; +} + +bool TracksterLinkingbySkeletons::checkSkeletonAlignment(const ticl::Trackster &myTrackster, + const ticl::Trackster &otherTrackster) { + auto dotProdSkeletons = myTrackster.eigenvectors(0).Dot(otherTrackster.eigenvectors(0)); + bool alignedSkeletons = dotProdSkeletons > dot_prod_th_; + + LogDebug("TracksterLinkingbySkeletons") + << "\t Outer Trackster is Good, checking for skeleton alignment " << alignedSkeletons << " dotProd " + << dotProdSkeletons << " Threshold " << dot_prod_th_ << std::endl; + + if (alignedSkeletons) { + LogDebug("TracksterLinkingbySkeletons") << "\t\t Linked! " << std::endl; + } + + return alignedSkeletons; +} + +bool TracksterLinkingbySkeletons::checkClosestPoints(const ticl::Trackster &myTrackster, + const ticl::Trackster &otherTrackster, + const std::array &mySkeleton, + const std::array &otherSkeleton, + int isEE) { + int myClosestPoint = -1; + int otherClosestPoint = -1; + float minDistance_z = std::numeric_limits::max(); + + for (int i = 1; i < 3; i++) { + for (int j = 0; j < 3; j++) { + float dist_z = std::abs(mySkeleton[i].Z() - otherSkeleton[j].Z()); + if (dist_z < minDistance_z) { + myClosestPoint = i; + otherClosestPoint = j; + minDistance_z = dist_z; + } + } + } + + float d = projective_distance(mySkeleton[myClosestPoint], otherSkeleton[otherClosestPoint]); + auto const max_distance_proj_sqr_closest = computeParameter(myTrackster.raw_energy(), + lower_boundary_[isEE], + lower_distance_projective_sqr_closest_points_[isEE], + upper_boundary_[isEE], + upper_distance_projective_sqr_closest_points_[isEE]); + + LogDebug("TracksterLinkingbySkeletons") + << "\t\t Distance between closest points " << d << " TH " << 10.f << " Z Distance " << minDistance_z << " TH " + << max_distance_proj_sqr_closest << std::endl; + + if (d < max_distance_proj_sqr_closest && minDistance_z < max_z_distance_closest_points_[isEE]) { + LogDebug("TracksterLinkingbySkeletons") << "\t\t\t Linked! " << d << std::endl; + return true; + } + + LogDebug("TracksterLinkingbySkeletons") << "Distance between closest point " << d << " Distance in z " + << max_z_distance_closest_points_[isEE] << std::endl; + + return checkCylinderAlignment(mySkeleton, otherSkeleton, isEE); +} + void TracksterLinkingbySkeletons::linkTracksters( const Inputs &input, std::vector &resultTracksters, @@ -345,7 +429,7 @@ void TracksterLinkingbySkeletons::linkTracksters( std::vector maskReceivedLink(tracksters.size(), 1); std::vector isRootTracksters(tracksters.size(), 1); - std::vector allNodes; + std::vector allNodes; for (size_t it = 0; it < tracksters.size(); ++it) { allNodes.emplace_back(it); } @@ -355,12 +439,14 @@ void TracksterLinkingbySkeletons::linkTracksters( auto const &trackster = tracksters[t_idx]; auto const &skeleton = skeletons[t_idx]; - auto const bary = trackster.barycenter(); - float eta_min = std::max(abs(bary.eta()) - del_, TileConstants::minEta); - float eta_max = std::min(abs(bary.eta()) + del_, TileConstants::maxEta); + auto const &bary = trackster.barycenter(); int tileIndex = bary.eta() > 0.f; const auto &tiles = tracksterTile[tileIndex]; - std::array search_box = tiles.searchBoxEtaPhi(eta_min, eta_max, bary.phi() - del_, bary.phi() + del_); + auto const window = eta_windows_[tiles.etaBin(bary.eta())]; + float eta_min = std::max(abs(bary.eta()) - window, TileConstants::minEta); + float eta_max = std::min(abs(bary.eta()) + window, TileConstants::maxEta); + std::array search_box = tiles.searchBoxEtaPhi(eta_min, eta_max, bary.phi() - window, bary.phi() + window); + if (search_box[2] > search_box[3]) { search_box[3] += TileConstants::nPhiBins; } @@ -371,18 +457,70 @@ void TracksterLinkingbySkeletons::linkTracksters( for (auto n : neighbours) { if (t_idx == n) continue; - if (maskReceivedLink[n] == 0 or allNodes[t_idx].isInnerNeighbour(n)) - continue; - if (isGoodTrackster(trackster, skeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_)) { - LogDebug("TracksterLinkingbySkeletons") - << "Trying to Link Trackster " << t_idx << " With Trackster " << n << std::endl; - if (areCompatible(trackster, tracksters[n], skeleton, skeletons[n])) { + + auto const &tracksterOut = tracksters[n]; + auto const &skeletonOut = skeletons[n]; + auto const deltaphi = reco::deltaPhi(trackster.barycenter().phi(), tracksterOut.barycenter().phi()); + if (abs(trackster.barycenter().eta() - tracksterOut.barycenter().eta()) <= window && deltaphi <= window) { + bool isInGood = isGoodTrackster(trackster, skeleton, min_num_lcs_, min_trackster_energy_, pca_quality_th_); + bool isOutGood = + isGoodTrackster(tracksterOut, skeletonOut, min_num_lcs_, min_trackster_energy_, pca_quality_th_); + if (isInGood) { LogDebug("TracksterLinkingbySkeletons") - << "\t==== LINK: Trackster " << t_idx << " Linked with Trackster " << n << std::endl; - maskReceivedLink[n] = 0; - allNodes[t_idx].addOuterNeighbour(n); - allNodes[n].addInnerNeighbour(t_idx); - isRootTracksters[n] = 0; + << "Trying to Link Trackster " << t_idx << " With Trackster " << n << std::endl; + if (areCompatible(trackster, tracksters[n], skeleton, skeletonOut)) { + LogDebug("TracksterLinkingbySkeletons") + << "\t==== LINK: Trackster " << t_idx << " Linked with Trackster " << n << std::endl; + // maskReceivedLink[n] = 0; + if (isOutGood) { + if (abs(skeleton[0].z()) < abs(skeletonOut[0].z())) { + LogDebug("TracksterLinkingbySkeletons") << "Trackster in energy " << trackster.raw_energy() + << " Out is good " << tracksterOut.raw_energy() << " Sk In " + << skeleton[0] << " Sk out " << skeletonOut[0] << std::endl; + LogDebug("TracksterLinkingbySkeletons") << "\t " << t_idx << " --> " << n << std::endl; + allNodes[t_idx].addOuterNeighbour(n); + allNodes[n].addInnerNeighbour(t_idx); + isRootTracksters[n] = 0; + } else if (abs(skeleton[0].z()) > abs(skeletonOut[0].z())) { + LogDebug("TracksterLinkingbySkeletons") << "Trackster in energy " << trackster.raw_energy() + << " Out is good " << tracksterOut.raw_energy() << " Sk In " + << skeleton[0] << " Sk out " << skeletonOut[0] << std::endl; + LogDebug("TracksterLinkingbySkeletons") << "\t " << n << " --> " << t_idx << std::endl; + allNodes[n].addOuterNeighbour(t_idx); + allNodes[t_idx].addInnerNeighbour(n); + isRootTracksters[t_idx] = 0; + } else { + if (trackster.raw_energy() >= tracksterOut.raw_energy()) { + LogDebug("TracksterLinkingbySkeletons") + << "Trackster in energy " << trackster.raw_energy() << " Out is good " + << tracksterOut.raw_energy() << " Sk In " << skeleton[0] << " Sk out " << skeletonOut[0] + << std::endl; + LogDebug("TracksterLinkingbySkeletons") << "\t " << t_idx << " --> " << n << std::endl; + allNodes[t_idx].addOuterNeighbour(n); + allNodes[n].addInnerNeighbour(t_idx); + isRootTracksters[n] = 0; + } else { + LogDebug("TracksterLinkingbySkeletons") + << "Trackster in energy " << trackster.raw_energy() << " Out is good " + << tracksterOut.raw_energy() << " Sk In " << skeleton[0] << " Sk out " << skeletonOut[0] + << std::endl; + LogDebug("TracksterLinkingbySkeletons") << "\t " << n << " --> " << t_idx << std::endl; + allNodes[n].addOuterNeighbour(t_idx); + allNodes[t_idx].addInnerNeighbour(n); + isRootTracksters[t_idx] = 0; + } + } + } else { + LogDebug("TracksterLinkingbySkeletons") + << "Trackster in energy " << trackster.raw_energy() << " Out is NOT good " + << tracksterOut.raw_energy() << " Sk In " << skeleton[0] << " Sk out " << skeletonOut[0] + << std::endl; + LogDebug("TracksterLinkingbySkeletons") << "\t " << t_idx << " --> " << n << std::endl; + allNodes[t_idx].addOuterNeighbour(n); + allNodes[n].addInnerNeighbour(t_idx); + isRootTracksters[n] = 0; + } + } } } } @@ -391,31 +529,43 @@ void TracksterLinkingbySkeletons::linkTracksters( } LogDebug("TracksterLinkingbySkeletons") << "**************** FINAL GRAPH **********************" << std::endl; - for (auto const &node : allNodes) { - if (isRootTracksters[node.getId()]) { - LogDebug("TracksterLinkingbySkeletons") - << "ISROOT " - << " Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " - << tracksters[node.getId()].raw_energy() << std::endl; - } else { - LogDebug("TracksterLinkingbySkeletons") - << "Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " - << tracksters[node.getId()].raw_energy() << std::endl; - } - } + // for (auto const &node : allNodes) { + // if (isRootTracksters[node.getId()]) { + // LogDebug("TracksterLinkingbySkeletons") + // << "ISROOT " + // << " Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " + // << tracksters[node.getId()].raw_energy() << std::endl; + // } else { + // LogDebug("TracksterLinkingbySkeletons") + // << "Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " + // << tracksters[node.getId()].raw_energy() << std::endl; + // } + // } LogDebug("TracksterLinkingbySkeletons") << "********************************************************" << std::endl; + TICLGraph graph(allNodes); + auto sortedRootNodes = graph.getRootNodes(); + std::sort(sortedRootNodes.begin(), sortedRootNodes.end(), [&tracksters](const ticl::Node &n1, const ticl::Node &n2) { + unsigned int n1Id = n1.getId(); + unsigned int n2Id = n2.getId(); + return tracksters[n1Id].raw_energy() > tracksters[n2Id].raw_energy(); + }); + // for(auto const& n : sortedRootNodes) { + // if(n.getOuterNeighbours().size() > 0){ + // LogDebug("TracksterLinkingbySkeletons") << "Sorted " << n.getId() << " " << tracksters[n.getId()].raw_energy() << std::endl; + // } + // } - TICLGraph graph(allNodes, isRootTracksters); + //assert(graph.isGraphOk() == true && "Graph is not ok"); int ic = 0; - auto const &components = graph.findSubComponents(); + auto const &components = graph.findSubComponents(sortedRootNodes); linkedTracksterIdToInputTracksterId.resize(components.size()); for (auto const &comp : components) { LogDebug("TracksterLinkingbySkeletons") << "Component " << ic << " Node: "; std::vector linkedTracksters; Trackster outTrackster; if (comp.size() == 1) { - if (input.tracksters[comp[0]].vertices().size() <= 3) { + if (input.tracksters[comp[0]].vertices().size() <= 3 && input.tracksters[comp[0]].raw_energy() < 5.f) { continue; } } @@ -425,9 +575,12 @@ void TracksterLinkingbySkeletons::linkTracksters( outTrackster.mergeTracksters(input.tracksters[node]); } linkedTracksters.push_back(resultTracksters.size()); + LogDebug("TracksterLinkingbySkeletons") << "\nOut Trackster " << outTrackster.raw_energy() << std::endl; resultTracksters.push_back(outTrackster); linkedResultTracksters.push_back(linkedTracksters); LogDebug("TracksterLinkingbySkeletons") << "\n"; ++ic; } + LogDebug("TracksterLinkingbySkeletons") << "\n"; + } // linkTracksters diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h index 600d86f9ada21..515325818e7f6 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h @@ -45,23 +45,47 @@ namespace ticl { const std::array& mySkeleton, const std::array& otherSkeleton); + bool checkCylinderAlignment(const std::array& mySkeleton, + const std::array& otherSkeleton, + int isEE); + bool checkSkeletonAlignment(const ticl::Trackster& myTrackster, const ticl::Trackster& otherTrackster); + + bool checkClosestPoints(const ticl::Trackster& myTrackster, + const ticl::Trackster& otherTrackster, + const std::array& mySkeleton, + const std::array& otherSkeleton, + int isEE); + bool isSplitComponent(const ticl::Trackster& myTrackster, + const ticl::Trackster& otherTrackster, + const std::array& mySkeleton, + const std::array& otherSkeleton, + float proj_distance); + void initialize(const HGCalDDDConstants* hgcons, const hgcal::RecHitTools rhtools, const edm::ESHandle bfieldH, const edm::ESHandle propH) override; static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { + iDesc.add("cylinder_radius_sqr_split", 9.); + iDesc.add("proj_distance_split", 5.); iDesc.add("track_time_quality_threshold", 0.5); iDesc.add("wind", 0.036); iDesc.add("min_num_lcs", 7); iDesc.add("min_trackster_energy", 10.); iDesc.add("pca_quality_th", 0.85); iDesc.add("dot_prod_th", 0.97); - iDesc.add>("max_distance_projective_sqr", {60., 60.}); - iDesc.add>("min_distance_z", {30., 30.}); - iDesc.add>("max_distance_projective_sqr_closest_points", {60., 60.}); + iDesc.add("deltaRxy", 4.f); + iDesc.add>("lower_boundary", {10., 150.}); + iDesc.add>("upper_boundary", {3, 70.}); + iDesc.add>("upper_distance_projective_sqr", {40., 60.}); + iDesc.add>("lower_distance_projective_sqr", {10., 30.}); + iDesc.add>("min_distance_z", {35., 35.}); + iDesc.add>("upper_distance_projective_sqr_closest_points", {10., 30.}); + iDesc.add>("lower_distance_projective_sqr_closest_points", {10., 30.}); iDesc.add>("max_z_distance_closest_points", {35., 35.}); - iDesc.add>("cylinder_radius_sqr", {9., 9.}); + iDesc.add>("cylinder_radius_sqr", {10, 20}); + TracksterLinkingAlgoBase::fillPSetDescription(iDesc); } @@ -72,17 +96,26 @@ namespace ticl { void dumpLinksFound(std::vector>& resultCollection, const char* label) const; + static constexpr float z_surface = 400.f; + std::vector lower_boundary_; + std::vector upper_boundary_; + std::vector upper_distance_projective_sqr_; + std::vector lower_distance_projective_sqr_; + std::vector min_distance_z_; + std::vector upper_distance_projective_sqr_closest_points_; + std::vector lower_distance_projective_sqr_closest_points_; + std::vector max_z_distance_closest_points_; + std::vector cylinder_radius_sqr_; + + float cylinder_radius_sqr_split_; + float proj_distance_split_; float timing_quality_threshold_; float del_; - unsigned int min_num_lcs_; float min_trackster_energy_; float pca_quality_th_; float dot_prod_th_; - std::vector max_distance_projective_sqr_; - std::vector min_distance_z_; - std::vector max_distance_projective_sqr_closest_points_; - std::vector max_z_distance_closest_points_; - std::vector cylinder_radius_sqr_; + float deltaRxy_; + unsigned int min_num_lcs_; const HGCalDDDConstants* hgcons_; @@ -93,6 +126,7 @@ namespace ticl { edm::ESHandle bfield_; edm::ESHandle propagator_; + std::array eta_windows_; }; } // namespace ticl diff --git a/RecoHGCal/TICL/python/customiseTICLFromReco.py b/RecoHGCal/TICL/python/customiseTICLFromReco.py index c22dea5fc9738..90679d67a8675 100644 --- a/RecoHGCal/TICL/python/customiseTICLFromReco.py +++ b/RecoHGCal/TICL/python/customiseTICLFromReco.py @@ -65,12 +65,12 @@ def customiseTICLFromReco(process): return process -def customiseTICLForDumper(process): +def customiseTICLForDumper(process, histoName="histo.root"): process.ticlDumper = ticlDumper.clone() process.TFileService = cms.Service("TFileService", - fileName=cms.string("histo.root") + fileName=cms.string(histoName) ) process.FEVTDEBUGHLToutput_step = cms.EndPath( process.FEVTDEBUGHLToutput + process.ticlDumper) diff --git a/RecoHGCal/TICL/python/iterativeTICL_cff.py b/RecoHGCal/TICL/python/iterativeTICL_cff.py index aa43df36379a2..2e4353fc96cf9 100644 --- a/RecoHGCal/TICL/python/iterativeTICL_cff.py +++ b/RecoHGCal/TICL/python/iterativeTICL_cff.py @@ -35,24 +35,57 @@ 'ticlTrackstersCLUE3DHigh', 'ticlTrackstersRecovery' ), - regressionAndPid = cms.bool(True), - inferenceAlgo = cms.string('TracksterInferenceByDNN'), - pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( - algo_verbosity = cms.int32(0), - doPID = cms.int32(1), - doRegression = cms.int32(1), - 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_clusters = cms.int32(10), - eid_n_layers = cms.int32(50), - onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/energy_v0.onnx'), - onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/id_v0.onnx'), - type = cms.string('TracksterInferenceByDNN') - ) + linkingPSet = cms.PSet( + track_time_quality_threshold = cms.double(0.5), + wind = cms.double(0.072), + min_num_lcs = cms.uint32(15), + min_trackster_energy = cms.double(20), + pca_quality_th = cms.double(0.85), + dot_prod_th = cms.double(0.97), + lower_boundary = cms.vdouble( + 20, + 10 + ), + upper_boundary = cms.vdouble( + 150, + 100 + ), + upper_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + lower_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + min_distance_z = cms.vdouble( + 35, + 35 + ), + upper_distance_projective_sqr_closest_points = cms.vdouble( + 5, + 30 + ), + lower_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 50 + ), + max_z_distance_closest_points = cms.vdouble( + 35, + 35 + ), + cylinder_radius_sqr = cms.vdouble( + 9, + 15 + ), + deltaRxy = cms.double(4.), + algo_verbosity = cms.int32(0), + type = cms.string('Skeletons') + + ), + + regressionAndPid = cms.bool(True) ) - ticlCandidate = _ticlCandidateProducer.clone() mtdSoA = _mtdSoAProducer.clone() diff --git a/RecoHGCal/TICL/python/ticlDumper_cff.py b/RecoHGCal/TICL/python/ticlDumper_cff.py index e50ac07a1f799..32b876f7099e1 100644 --- a/RecoHGCal/TICL/python/ticlDumper_cff.py +++ b/RecoHGCal/TICL/python/ticlDumper_cff.py @@ -40,10 +40,12 @@ ), ], - associators=dumperAssociators.copy() + associators=dumperAssociators.copy(), + saveSuperclustering = cms.bool(False) ) ticl_v5.toModify(ticlDumper, ticlcandidates = cms.InputTag("ticlCandidate"), recoSuperClusters_sourceTracksterCollection=cms.InputTag("ticlCandidate")) +ticl_v5.toModify(ticlDumper, saveSuperclustering = cms.bool(True)) From 727d7bf61e5efe76445a14b79962f9d1c037047f Mon Sep 17 00:00:00 2001 From: Wahid Redjeb Date: Wed, 6 Nov 2024 11:51:12 +0100 Subject: [PATCH 2/4] fix HLT configuration for Skeleton Linking, remove Unseeded label --- .../hltTiclTracksterLinksL1Seeded_cfi.py | 61 +++++++++++---- .../hltTiclTracksterLinksUnseeded_cfi.py | 78 ------------------- .../modules/hltTiclTracksterLinks_cfi.py | 5 +- ...ClusteringForEgammaUnseededSequence_cfi.py | 6 +- .../plugins/TracksterLinkingbySkeletons.cc | 1 - .../plugins/TracksterLinkingbySkeletons.h | 2 - RecoHGCal/TICL/python/iterativeTICL_cff.py | 21 ++++- 7 files changed, 70 insertions(+), 104 deletions(-) delete mode 100644 HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py index d4b4940ea7f05..a5c9f73b188d9 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py @@ -6,19 +6,52 @@ layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","timeLayerCluster"), inferenceAlgo = cms.string('TracksterInferenceByDNN'), linkingPSet = cms.PSet( - algo_verbosity = cms.int32(0), - cylinder_radius_sqr = cms.vdouble(9, 9), - dot_prod_th = cms.double(0.97), - max_distance_projective_sqr = cms.vdouble(60, 60), - max_distance_projective_sqr_closest_points = cms.vdouble(60, 60), - max_z_distance_closest_points = cms.vdouble(35, 35), - min_distance_z = cms.vdouble(30, 30), - min_num_lcs = cms.uint32(7), - min_trackster_energy = cms.double(10), - pca_quality_th = cms.double(0.85), - track_time_quality_threshold = cms.double(0.5), - type = cms.string('Skeletons'), - wind = cms.double(0.036) + cylinder_radius_sqr_split = cms.double(9), + proj_distance_split = cms.double(5), + track_time_quality_threshold = cms.double(0.5), + min_num_lcs = cms.uint32(15), + min_trackster_energy = cms.double(20), + pca_quality_th = cms.double(0.85), + dot_prod_th = cms.double(0.97), + deltaRxy = cms.double(4), + lower_boundary = cms.vdouble( + 20, + 10 + ), + upper_boundary = cms.vdouble( + 150, + 100 + ), + upper_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + lower_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + min_distance_z = cms.vdouble( + 35, + 35 + ), + upper_distance_projective_sqr_closest_points = cms.vdouble( + 5, + 30 + ), + lower_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 50 + ), + max_z_distance_closest_points = cms.vdouble( + 35, + 35 + ), + cylinder_radius_sqr = cms.vdouble( + 9, + 15 + ), + algo_verbosity = cms.int32(0), + type = cms.string('Skeletons') ), pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( algo_verbosity = cms.int32(0), @@ -38,7 +71,7 @@ original_masks = cms.VInputTag("hltHgcalMergeLayerClustersL1Seeded:InitialLayerClustersMask"), propagator = cms.string('PropagatorWithMaterial'), regressionAndPid = cms.bool(True), - tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHighL1Seeded", "hltTiclTrackstersPassthrough") + tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHighL1Seeded", "hltTiclTrackstersRecoveryL1Seeded") ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py deleted file mode 100644 index b2130542a506f..0000000000000 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksUnseeded_cfi.py +++ /dev/null @@ -1,78 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -hltTiclTracksterLinksUnseeded = cms.EDProducer("TracksterLinksProducer", - detector = cms.string('HGCAL'), - layer_clusters = cms.InputTag("hltHgcalMergeLayerClusters"), - layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster"), - inferenceAlgo = cms.string('TracksterInferenceByDNN'), - linkingPSet = cms.PSet( - cylinder_radius_sqr_split = cms.double(9), - proj_distance_split = cms.double(5), - track_time_quality_threshold = cms.double(0.5), - wind = cms.double(0.072), - min_num_lcs = cms.uint32(15), - min_trackster_energy = cms.double(20), - pca_quality_th = cms.double(0.85), - dot_prod_th = cms.double(0.97), - deltaRxy = cms.double(4), - lower_boundary = cms.vdouble( - 20, - 10 - ), - upper_boundary = cms.vdouble( - 150, - 100 - ), - upper_distance_projective_sqr = cms.vdouble( - 30, - 60 - ), - lower_distance_projective_sqr = cms.vdouble( - 30, - 30 - ), - min_distance_z = cms.vdouble( - 35, - 35 - ), - upper_distance_projective_sqr_closest_points = cms.vdouble( - 10, - 30 - ), - lower_distance_projective_sqr_closest_points = cms.vdouble( - 10, - 50 - ), - max_z_distance_closest_points = cms.vdouble( - 35, - 35 - ), - cylinder_radius_sqr = cms.vdouble( - 9, - 15 - ), - algo_verbosity = cms.int32(0), - type = cms.string('Skeletons') - ), - 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), - tracksters_collections = cms.VInputTag("hltTiclTrackstersCLUE3DHigh", "hltTiclTrackstersPassthrough") -) - - diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py index 2b66f991961ca..641244a3d24ef 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py @@ -9,7 +9,6 @@ cylinder_radius_sqr_split = cms.double(9), proj_distance_split = cms.double(5), track_time_quality_threshold = cms.double(0.5), - wind = cms.double(0.072), min_num_lcs = cms.uint32(15), min_trackster_energy = cms.double(20), pca_quality_th = cms.double(0.85), @@ -29,14 +28,14 @@ ), lower_distance_projective_sqr = cms.vdouble( 30, - 30 + 60 ), min_distance_z = cms.vdouble( 35, 35 ), upper_distance_projective_sqr_closest_points = cms.vdouble( - 10, + 5, 30 ), lower_distance_projective_sqr_closest_points = cms.vdouble( diff --git a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTHgcalTiclPFClusteringForEgammaUnseededSequence_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTHgcalTiclPFClusteringForEgammaUnseededSequence_cfi.py index f79c08e8721e9..d07102952c60c 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTHgcalTiclPFClusteringForEgammaUnseededSequence_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTHgcalTiclPFClusteringForEgammaUnseededSequence_cfi.py @@ -18,7 +18,7 @@ from ..modules.hltHgcalSoARecHitsLayerClustersProducer_cfi import * from ..modules.hltHgcalSoALayerClustersProducer_cfi import * from ..modules.hltHgcalLayerClustersFromSoAProducer_cfi import * -from ..modules.hltTiclTracksterLinksUnseeded_cfi import * +from ..modules.hltTiclTracksterLinks_cfi import * _HgcalLocalRecoUnseededSequence = cms.Sequence(hltHgcalDigis+hltHGCalUncalibRecHit+hltHGCalRecHit+hltParticleFlowRecHitHGC+hltHgcalLayerClustersEE+hltHgcalLayerClustersHSci+hltHgcalLayerClustersHSi+hltHgcalMergeLayerClusters) _HgcalTICLPatternRecognitionUnseededSequence = cms.Sequence(hltFilteredLayerClustersCLUE3DHigh+hltTiclSeedingGlobal+hltTiclLayerTileProducer+hltTiclTrackstersCLUE3DHigh) @@ -49,7 +49,7 @@ ) # Use EGammaSuperClusterProducer at HLT in ticl v5 -hltTiclTracksterLinksSuperclusteringDNNUnseeded = hltTiclTracksterLinksUnseeded.clone( +hltTiclTracksterLinksSuperclusteringDNNUnseeded = hltTiclTracksterLinks.clone( linkingPSet = cms.PSet( type=cms.string("SuperClusteringDNN"), algo_verbosity=cms.int32(0), @@ -59,7 +59,7 @@ tracksters_collections = [cms.InputTag("hltTiclTrackstersCLUE3DHigh")], # to be changed to ticlTrackstersCLUE3DEM once separate CLUE3D iterations are introduced ) -hltTiclTracksterLinksSuperclusteringMustacheUnseeded = hltTiclTracksterLinksUnseeded.clone( +hltTiclTracksterLinksSuperclusteringMustacheUnseeded = hltTiclTracksterLinks.clone( linkingPSet = cms.PSet( type=cms.string("SuperClusteringMustache"), algo_verbosity=cms.int32(0) diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc index 90721eca424dd..1130e1a83a4c7 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc @@ -74,7 +74,6 @@ TracksterLinkingbySkeletons::TracksterLinkingbySkeletons(const edm::ParameterSet cylinder_radius_sqr_split_(conf.getParameter("cylinder_radius_sqr_split")), proj_distance_split_(conf.getParameter("proj_distance_split")), timing_quality_threshold_(conf.getParameter("track_time_quality_threshold")), - del_(conf.getParameter("wind")), min_trackster_energy_(conf.getParameter("min_trackster_energy")), pca_quality_th_(conf.getParameter("pca_quality_th")), dot_prod_th_(conf.getParameter("dot_prod_th")), diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h index 515325818e7f6..6a09f7297d611 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h @@ -70,7 +70,6 @@ namespace ticl { iDesc.add("cylinder_radius_sqr_split", 9.); iDesc.add("proj_distance_split", 5.); iDesc.add("track_time_quality_threshold", 0.5); - iDesc.add("wind", 0.036); iDesc.add("min_num_lcs", 7); iDesc.add("min_trackster_energy", 10.); iDesc.add("pca_quality_th", 0.85); @@ -110,7 +109,6 @@ namespace ticl { float cylinder_radius_sqr_split_; float proj_distance_split_; float timing_quality_threshold_; - float del_; float min_trackster_energy_; float pca_quality_th_; float dot_prod_th_; diff --git a/RecoHGCal/TICL/python/iterativeTICL_cff.py b/RecoHGCal/TICL/python/iterativeTICL_cff.py index 2e4353fc96cf9..baec9c294c6c1 100644 --- a/RecoHGCal/TICL/python/iterativeTICL_cff.py +++ b/RecoHGCal/TICL/python/iterativeTICL_cff.py @@ -36,8 +36,9 @@ 'ticlTrackstersRecovery' ), linkingPSet = cms.PSet( + cylinder_radius_sqr_split = cms.double(9), + proj_distance_split = cms.double(5), track_time_quality_threshold = cms.double(0.5), - wind = cms.double(0.072), min_num_lcs = cms.uint32(15), min_trackster_energy = cms.double(20), pca_quality_th = cms.double(0.85), @@ -83,8 +84,22 @@ type = cms.string('Skeletons') ), - - regressionAndPid = cms.bool(True) + regressionAndPid = cms.bool(True), + inferenceAlgo = cms.string('TracksterInferenceByDNN'), + pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( + algo_verbosity = cms.int32(0), + doPID = cms.int32(1), + doRegression = cms.int32(1), + 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_clusters = cms.int32(10), + eid_n_layers = cms.int32(50), + onnxEnergyModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/energy_v0.onnx'), + onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/id_v0.onnx'), + type = cms.string('TracksterInferenceByDNN') + ) ) ticlCandidate = _ticlCandidateProducer.clone() mtdSoA = _mtdSoAProducer.clone() From 75b3afc51ab153cbf1b143dfcee1bf476cf28cc7 Mon Sep 17 00:00:00 2001 From: Wahid Redjeb Date: Wed, 6 Nov 2024 11:51:40 +0100 Subject: [PATCH 3/4] add L1Seeded modules and sequecence for recovery tracksters --- ...lteredLayerClustersRecoveryL1Seeded_cfi.py | 14 +++ .../hltTiclTrackstersRecoveryL1Seeded_cfi.py | 93 +++++++++++++++++++ ...lTrackstersRecoverySequenceL1Seeded_cfi.py | 6 ++ RecoHGCal/TICL/plugins/TICLGraph.cc | 17 +--- RecoHGCal/TICL/plugins/TICLGraph.h | 2 +- .../plugins/TracksterLinkingbySkeletons.cc | 40 +++----- 6 files changed, 133 insertions(+), 39 deletions(-) create mode 100644 HLTrigger/Configuration/python/HLT_75e33/modules/hltFilteredLayerClustersRecoveryL1Seeded_cfi.py create mode 100644 HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTrackstersRecoveryL1Seeded_cfi.py create mode 100644 HLTrigger/Configuration/python/HLT_75e33/sequences/HLTTiclTrackstersRecoverySequenceL1Seeded_cfi.py diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltFilteredLayerClustersRecoveryL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltFilteredLayerClustersRecoveryL1Seeded_cfi.py new file mode 100644 index 0000000000000..399eb6076eabc --- /dev/null +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltFilteredLayerClustersRecoveryL1Seeded_cfi.py @@ -0,0 +1,14 @@ +import FWCore.ParameterSet.Config as cms + +hltFilteredLayerClustersRecoveryL1Seeded = cms.EDProducer("FilteredLayerClustersProducer", + LayerClusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded"), + LayerClustersInputMask = cms.InputTag("hltTiclTrackstersCLUE3DHighL1Seeded"), + algo_number = cms.vint32(6, 7, 8), + clusterFilter = cms.string('ClusterFilterBySize'), + iteration_label = cms.string('Recovery'), + max_cluster_size = cms.int32(9999), + max_layerId = cms.int32(9999), + mightGet = cms.optional.untracked.vstring, + min_cluster_size = cms.int32(2), + min_layerId = cms.int32(0) +) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTrackstersRecoveryL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTrackstersRecoveryL1Seeded_cfi.py new file mode 100644 index 0000000000000..43146ea1580bc --- /dev/null +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTrackstersRecoveryL1Seeded_cfi.py @@ -0,0 +1,93 @@ +import FWCore.ParameterSet.Config as cms + +hltTiclTrackstersRecoveryL1Seeded = cms.EDProducer("TrackstersProducer", + detector = cms.string('HGCAL'), + filtered_mask = cms.InputTag("hltFilteredLayerClustersRecoveryL1Seeded","Recovery"), + itername = cms.string('Recovery'), + layer_clusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded"), + layer_clusters_hfnose_tiles = cms.InputTag("ticlLayerTileHFNose"), + layer_clusters_tiles = cms.InputTag("hltTiclLayerTileProducerL1Seeded"), + mightGet = cms.optional.untracked.vstring, + original_mask = cms.InputTag("hltTiclTrackstersCLUE3DHighL1Seeded"), + patternRecognitionBy = cms.string('Recovery'), + inferenceAlgo = cms.string('TracksterInferenceByDNN'), + pluginPatternRecognitionByCA = cms.PSet( + algo_verbosity = cms.int32(0), + computeLocalTime = cms.bool(True), + energy_em_over_total_threshold = cms.double(-1), + etaLimitIncreaseWindow = cms.double(2.1), + filter_on_categories = cms.vint32(0), + max_delta_time = cms.double(3), + max_longitudinal_sigmaPCA = cms.double(9999), + max_missing_layers_in_trackster = cms.int32(9999), + max_out_in_hops = cms.int32(10), + min_cos_pointing = cms.double(-1), + min_cos_theta = cms.double(0.915), + min_layers_per_trackster = cms.int32(10), + oneTracksterPerTrackSeed = cms.bool(False), + out_in_dfs = cms.bool(True), + pid_threshold = cms.double(0), + promoteEmptyRegionToTrackster = cms.bool(False), + root_doublet_max_distance_from_seed_squared = cms.double(9999), + shower_start_max_layer = cms.int32(9999), + siblings_maxRSquared = cms.vdouble(0.0006, 0.0006, 0.0006), + skip_layers = cms.int32(0), + type = cms.string('CA') + ), + pluginPatternRecognitionByCLUE3D = cms.PSet( + algo_verbosity = cms.int32(0), + computeLocalTime = cms.bool(True), + criticalDensity = cms.vdouble(4, 4, 4), + criticalEtaPhiDistance = cms.vdouble(0.025, 0.025, 0.025), + criticalSelfDensity = cms.vdouble(0.15, 0.15, 0.15), + criticalXYDistance = cms.vdouble(1.8, 1.8, 1.8), + criticalZDistanceLyr = cms.vint32(5, 5, 5), + cutHadProb = cms.double(0.5), + densityEtaPhiDistanceSqr = cms.vdouble(0.0008, 0.0008, 0.0008), + densityOnSameLayer = cms.bool(False), + densitySiblingLayers = cms.vint32(3, 3, 3), + densityXYDistanceSqr = cms.vdouble(3.24, 3.24, 3.24), + doPidCut = cms.bool(False), + kernelDensityFactor = cms.vdouble(0.2, 0.2, 0.2), + minNumLayerCluster = cms.vint32(2, 2, 2), + nearestHigherOnSameLayer = cms.bool(False), + outlierMultiplier = cms.vdouble(2, 2, 2), + rescaleDensityByZ = cms.bool(False), + type = cms.string('CLUE3D'), + useAbsoluteProjectiveScale = cms.bool(True), + useClusterDimensionXY = cms.bool(False) + ), + pluginPatternRecognitionByFastJet = cms.PSet( + algo_verbosity = cms.int32(0), + antikt_radius = cms.double(0.09), + computeLocalTime = cms.bool(True), + minNumLayerCluster = cms.int32(5), + type = cms.string('FastJet') + ), + pluginPatternRecognitionByRecovery = cms.PSet( + algo_verbosity = cms.int32(0), + type = cms.string('Recovery') + ), + + 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( + algo_verbosity = cms.int32(0), + type = cms.string('TracksterInferenceByANN') + + ), + seeding_regions = cms.InputTag("hltTiclSeedingL1"), + time_layerclusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","timeLayerCluster") +) diff --git a/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTTiclTrackstersRecoverySequenceL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTTiclTrackstersRecoverySequenceL1Seeded_cfi.py new file mode 100644 index 0000000000000..81cd3d157f059 --- /dev/null +++ b/HLTrigger/Configuration/python/HLT_75e33/sequences/HLTTiclTrackstersRecoverySequenceL1Seeded_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +from ..modules.hltFilteredLayerClustersRecoveryL1Seeded_cfi import * +from ..modules.hltTiclTrackstersRecoveryL1Seeded_cfi import * + +HLTTiclTrackstersRecoverySequence = cms.Sequence(hltFilteredLayerClustersRecovery+hltTiclTrackstersRecovery) diff --git a/RecoHGCal/TICL/plugins/TICLGraph.cc b/RecoHGCal/TICL/plugins/TICLGraph.cc index 32b5aae61a2aa..50fecf98cd16c 100644 --- a/RecoHGCal/TICL/plugins/TICLGraph.cc +++ b/RecoHGCal/TICL/plugins/TICLGraph.cc @@ -3,15 +3,12 @@ namespace ticl { - void Node::findSubComponents(std::vector& graph, std::vector& subComponent, std::string tabs) { - tabs += "\t"; + void Node::findSubComponents(std::vector& graph, std::vector& subComponent) { if (!alreadyVisited_) { - LogDebug("TICLGraph") << tabs << " Visiting node " << index_ << std::endl; alreadyVisited_ = true; subComponent.push_back(index_); for (auto const& neighbour : outerNeighboursId_) { - LogDebug("TICLGraph") << tabs << " Trying to visit " << neighbour << std::endl; - graph[neighbour].findSubComponents(graph, subComponent, tabs); + graph[neighbour].findSubComponents(graph, subComponent); } } } @@ -29,10 +26,8 @@ std::vector> TICLGraph::findSubComponents() { for (auto const& node : nodes_) { auto const id = node.getId(); if (isRootNode_[id]) { - //LogDebug("TICLGraph") << "DFS Starting From " << id << std::endl; - std::string tabs = "\t"; std::vector tmpSubComponents; - nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs); + nodes_[id].findSubComponents(nodes_, tmpSubComponents); components.push_back(tmpSubComponents); } } @@ -41,9 +36,8 @@ std::vector> TICLGraph::findSubComponents() { auto const id = node.getId(); if (!node.alreadyVisited()) { // Use the alreadyVisited() method // Node not visited yet, so perform DFS - std::string tabs = "\t"; std::vector tmpSubComponents; - nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs); + nodes_[id].findSubComponents(nodes_, tmpSubComponents); components.push_back(tmpSubComponents); } } @@ -55,9 +49,8 @@ std::vector> TICLGraph::findSubComponents(std::vector< for (auto const& node : rootNodes) { auto const id = node.getId(); //LogDebug("TICLGraph") << "DFS Starting From " << id << std::endl; - std::string tabs = "\t"; std::vector tmpSubComponents; - nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs); + nodes_[id].findSubComponents(nodes_, tmpSubComponents); components.push_back(tmpSubComponents); } return components; diff --git a/RecoHGCal/TICL/plugins/TICLGraph.h b/RecoHGCal/TICL/plugins/TICLGraph.h index 8787ad11c2496..c78123bdf6577 100644 --- a/RecoHGCal/TICL/plugins/TICLGraph.h +++ b/RecoHGCal/TICL/plugins/TICLGraph.h @@ -18,7 +18,7 @@ namespace ticl { inline const unsigned int getId() const { return index_; } const std::vector& getOuterNeighbours() const { return outerNeighboursId_; } const std::vector& getInnerNeighbours() const { return innerNeighboursId_; } - void findSubComponents(std::vector& graph, std::vector& subComponent, std::string tabs); + void findSubComponents(std::vector& graph, std::vector& subComponent); inline bool isInnerNeighbour(const unsigned int tid) { auto findInner = std::find(innerNeighboursId_.begin(), innerNeighboursId_.end(), tid); diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc index 1130e1a83a4c7..c9712c52e8868 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc @@ -24,7 +24,7 @@ namespace { if (trackster.raw_energy() > min_trackster_energy) { auto const &eigenvalues = trackster.eigenvalues(); auto const sum = std::accumulate(std::begin(eigenvalues), std::end(eigenvalues), 0.f); - float pcaQuality = eigenvalues[0] / sum; + float pcaQuality = sum > 0.f ? eigenvalues[0] / sum : 0.f; if (pcaQuality > pca_quality_th) { isGood = true; } @@ -32,7 +32,7 @@ namespace { } else { auto const &eigenvalues = trackster.eigenvalues(); auto const sum = std::accumulate(std::begin(eigenvalues), std::end(eigenvalues), 0.f); - float pcaQuality = eigenvalues[0] / sum; + float pcaQuality = sum > 0.f ? eigenvalues[0] / sum : 0.f; if (pcaQuality > pca_quality_th) { isGood = true; } @@ -121,10 +121,16 @@ void TracksterLinkingbySkeletons::initialize(const HGCalDDDConstants *hgcons, //define LUT for eta windows // eta windows obtained with a deltaR of 4cm at z = 400 cm + float etaStep = (TileConstants::maxEta - TileConstants::minEta) / TileConstants::nEtaBins; + float expNeg2DeltaRxy = deltaRxy_ * std::exp(-2.f); + for (int i = 0; i < TileConstants::nEtaBins; ++i) { - float eta = TileConstants::minEta + i * (TileConstants::maxEta - TileConstants::minEta) / TileConstants::nEtaBins; - float R = z_surface * 2.f * std::exp(-eta) / (1.f - std::exp(-2.f * eta)); - eta_windows_[i] = abs(atan(deltaRxy_ / R)); + float eta = TileConstants::minEta + i * etaStep; + + float expNegEta = std::exp(-eta); + float R = z_surface * 2.f * expNegEta / (1.f - expNeg2DeltaRxy * expNegEta); + + eta_windows_[i] = std::abs(atan(deltaRxy_ / R)); } } @@ -227,6 +233,9 @@ inline bool isInCylinder(const std::array &mySkeleton, } inline float computeParameter(float energy, float en_th_low, float cut1, float en_th_high, float cut2) { + if (en_th_low == en_th_high) { //protect if the thresholds are equal + return (energy <= en_th_low) ? cut1 : cut2; + } if (energy < en_th_low) { return cut1; } else if (energy >= en_th_low && energy <= en_th_high) { @@ -527,20 +536,6 @@ void TracksterLinkingbySkeletons::linkTracksters( } } - LogDebug("TracksterLinkingbySkeletons") << "**************** FINAL GRAPH **********************" << std::endl; - // for (auto const &node : allNodes) { - // if (isRootTracksters[node.getId()]) { - // LogDebug("TracksterLinkingbySkeletons") - // << "ISROOT " - // << " Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " - // << tracksters[node.getId()].raw_energy() << std::endl; - // } else { - // LogDebug("TracksterLinkingbySkeletons") - // << "Node " << node.getId() << " position " << tracksters[node.getId()].barycenter() << " energy " - // << tracksters[node.getId()].raw_energy() << std::endl; - // } - // } - LogDebug("TracksterLinkingbySkeletons") << "********************************************************" << std::endl; TICLGraph graph(allNodes); auto sortedRootNodes = graph.getRootNodes(); std::sort(sortedRootNodes.begin(), sortedRootNodes.end(), [&tracksters](const ticl::Node &n1, const ticl::Node &n2) { @@ -548,13 +543,6 @@ void TracksterLinkingbySkeletons::linkTracksters( unsigned int n2Id = n2.getId(); return tracksters[n1Id].raw_energy() > tracksters[n2Id].raw_energy(); }); - // for(auto const& n : sortedRootNodes) { - // if(n.getOuterNeighbours().size() > 0){ - // LogDebug("TracksterLinkingbySkeletons") << "Sorted " << n.getId() << " " << tracksters[n.getId()].raw_energy() << std::endl; - // } - // } - - //assert(graph.isGraphOk() == true && "Graph is not ok"); int ic = 0; auto const &components = graph.findSubComponents(sortedRootNodes); From d112936fcfae380c526fd207013d5cdf5b4606f1 Mon Sep 17 00:00:00 2001 From: Wahid Redjeb Date: Wed, 13 Nov 2024 11:23:21 +0100 Subject: [PATCH 4/4] add GlobalPSet for Linking plugin --- .../hltTiclTracksterLinksL1Seeded_cfi.py | 50 +------------------ .../modules/hltTiclTracksterLinks_cfi.py | 50 +------------------ .../psets/hltTiclTracksterLinksPSet_cfi.py | 50 +++++++++++++++++++ 3 files changed, 54 insertions(+), 96 deletions(-) create mode 100644 HLTrigger/Configuration/python/HLT_75e33/psets/hltTiclTracksterLinksPSet_cfi.py diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py index a5c9f73b188d9..d89b5ea6233a4 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinksL1Seeded_cfi.py @@ -1,58 +1,12 @@ import FWCore.ParameterSet.Config as cms +from ..psets.hltTiclTracksterLinksPSet_cfi import hltTiclTracksterLinksPSet hltTiclTracksterLinksL1Seeded = cms.EDProducer("TracksterLinksProducer", detector = cms.string('HGCAL'), layer_clusters = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded"), layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClustersL1Seeded","timeLayerCluster"), inferenceAlgo = cms.string('TracksterInferenceByDNN'), - linkingPSet = cms.PSet( - cylinder_radius_sqr_split = cms.double(9), - proj_distance_split = cms.double(5), - track_time_quality_threshold = cms.double(0.5), - min_num_lcs = cms.uint32(15), - min_trackster_energy = cms.double(20), - pca_quality_th = cms.double(0.85), - dot_prod_th = cms.double(0.97), - deltaRxy = cms.double(4), - lower_boundary = cms.vdouble( - 20, - 10 - ), - upper_boundary = cms.vdouble( - 150, - 100 - ), - upper_distance_projective_sqr = cms.vdouble( - 30, - 60 - ), - lower_distance_projective_sqr = cms.vdouble( - 30, - 60 - ), - min_distance_z = cms.vdouble( - 35, - 35 - ), - upper_distance_projective_sqr_closest_points = cms.vdouble( - 5, - 30 - ), - lower_distance_projective_sqr_closest_points = cms.vdouble( - 10, - 50 - ), - max_z_distance_closest_points = cms.vdouble( - 35, - 35 - ), - cylinder_radius_sqr = cms.vdouble( - 9, - 15 - ), - algo_verbosity = cms.int32(0), - type = cms.string('Skeletons') - ), + linkingPSet = hltTiclTracksterLinksPSet, pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( algo_verbosity = cms.int32(0), onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/id_v0.onnx'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py index 641244a3d24ef..ec40871157f21 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclTracksterLinks_cfi.py @@ -1,58 +1,12 @@ import FWCore.ParameterSet.Config as cms +from ..psets.hltTiclTracksterLinksPSet_cfi import hltTiclTracksterLinksPSet hltTiclTracksterLinks = cms.EDProducer("TracksterLinksProducer", detector = cms.string('HGCAL'), layer_clusters = cms.InputTag("hltHgcalMergeLayerClusters"), layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster"), inferenceAlgo = cms.string('TracksterInferenceByDNN'), - linkingPSet = cms.PSet( - cylinder_radius_sqr_split = cms.double(9), - proj_distance_split = cms.double(5), - track_time_quality_threshold = cms.double(0.5), - min_num_lcs = cms.uint32(15), - min_trackster_energy = cms.double(20), - pca_quality_th = cms.double(0.85), - dot_prod_th = cms.double(0.97), - deltaRxy = cms.double(4), - lower_boundary = cms.vdouble( - 20, - 10 - ), - upper_boundary = cms.vdouble( - 150, - 100 - ), - upper_distance_projective_sqr = cms.vdouble( - 30, - 60 - ), - lower_distance_projective_sqr = cms.vdouble( - 30, - 60 - ), - min_distance_z = cms.vdouble( - 35, - 35 - ), - upper_distance_projective_sqr_closest_points = cms.vdouble( - 5, - 30 - ), - lower_distance_projective_sqr_closest_points = cms.vdouble( - 10, - 50 - ), - max_z_distance_closest_points = cms.vdouble( - 35, - 35 - ), - cylinder_radius_sqr = cms.vdouble( - 9, - 15 - ), - algo_verbosity = cms.int32(0), - type = cms.string('Skeletons') - ), + linkingPSet = hltTiclTracksterLinksPSet, pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet( algo_verbosity = cms.int32(0), onnxPIDModelPath = cms.FileInPath('RecoHGCal/TICL/data/ticlv5/onnx_models/linking/id_v0.onnx'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/psets/hltTiclTracksterLinksPSet_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/psets/hltTiclTracksterLinksPSet_cfi.py new file mode 100644 index 0000000000000..78f553e3d5871 --- /dev/null +++ b/HLTrigger/Configuration/python/HLT_75e33/psets/hltTiclTracksterLinksPSet_cfi.py @@ -0,0 +1,50 @@ +import FWCore.ParameterSet.Config as cms + +hltTiclTracksterLinksPSet = cms.PSet( + cylinder_radius_sqr_split = cms.double(9), + proj_distance_split = cms.double(5), + track_time_quality_threshold = cms.double(0.5), + min_num_lcs = cms.uint32(15), + min_trackster_energy = cms.double(20), + pca_quality_th = cms.double(0.85), + dot_prod_th = cms.double(0.97), + deltaRxy = cms.double(4), + lower_boundary = cms.vdouble( + 20, + 10 + ), + upper_boundary = cms.vdouble( + 150, + 100 + ), + upper_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + lower_distance_projective_sqr = cms.vdouble( + 30, + 60 + ), + min_distance_z = cms.vdouble( + 35, + 35 + ), + upper_distance_projective_sqr_closest_points = cms.vdouble( + 5, + 30 + ), + lower_distance_projective_sqr_closest_points = cms.vdouble( + 10, + 50 + ), + max_z_distance_closest_points = cms.vdouble( + 35, + 35 + ), + cylinder_radius_sqr = cms.vdouble( + 9, + 15 + ), + algo_verbosity = cms.int32(0), + type = cms.string('Skeletons') + )