From db178922c64a3fb5b1517e455027370d88f2dcea Mon Sep 17 00:00:00 2001 From: Felice Pantaleo Date: Sat, 28 Sep 2024 14:21:01 +0200 Subject: [PATCH] Speedup PatternRecognitionbyRecovery --- .../plugins/PatternRecognitionbyRecovery.cc | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyRecovery.cc b/RecoHGCal/TICL/plugins/PatternRecognitionbyRecovery.cc index 328a9677dfddc..7d65bdd9a8199 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyRecovery.cc +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyRecovery.cc @@ -29,13 +29,13 @@ void PatternRecognitionbyRecovery::makeTracksters( edm::EventSetup const &es = input.es; const CaloGeometry &geom = es.getData(caloGeomToken_); rhtools_.setGeometry(geom); - + const auto z_limit_em = rhtools_.getPositionLayer(rhtools_.lastLayerEE(false), false).z(); // 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.) { + if (input.mask[i] == 0.f) { continue; // Skip masked clusters } @@ -43,19 +43,22 @@ void PatternRecognitionbyRecovery::makeTracksters( Trackster trackster; trackster.vertices().push_back(i); trackster.vertex_multiplicity().push_back(1); + const auto &lc = input.layerClusters[i]; + trackster.setTimeAndError(input.layerClustersTime.get(i).first, input.layerClustersTime.get(i).second); + trackster.setRawEnergy(lc.energy()); + trackster.setBarycenter({float(lc.x()), float(lc.y()), float(lc.z())}); + float invcosh = 1.f / std::cosh(lc.position().eta()); + trackster.setRawPt(lc.energy() * invcosh); + + if (std::abs(lc.z()) <= z_limit_em) { + trackster.setRawEmEnergy(lc.energy()); + trackster.setRawEmPt(lc.energy() * invcosh); + } // 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(), - rhtools_, - false); - // Log the number of tracksters created if (PatternRecognitionAlgoBaseT::algo_verbosity_ > VerbosityLevel::Advanced) { edm::LogVerbatim("PatternRecognitionbyRecovery") << "Created " << result.size() << " tracksters"; @@ -63,11 +66,10 @@ void PatternRecognitionbyRecovery::makeTracksters( } template -void PatternRecognitionbyRecovery::filter( - std::vector &output, - const std::vector &inTracksters, - const typename PatternRecognitionAlgoBaseT::Inputs &input, - std::unordered_map> &seedToTracksterAssociation) { +void PatternRecognitionbyRecovery::filter(std::vector &output, + const std::vector &inTracksters, + const typename PatternRecognitionAlgoBaseT::Inputs &input, + std::unordered_map> &seedToTracksterAssociation) { output = inTracksters; }