From a02cf08b5100cb923c5afcaf8c42428817a63172 Mon Sep 17 00:00:00 2001 From: ragansu Date: Mon, 19 Aug 2024 14:15:27 +0200 Subject: [PATCH 1/6] changes for messages --- .../ScoreBasedAmbiguityResolution.ipp | 52 ++++++++++++++++--- .../ScoreBasedAmbiguityResolution.cpp | 2 +- .../Json/src/AmbiguityConfigJsonConverter.cpp | 23 +++++--- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp index cb3f5803342..1b51e20cd3b 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp @@ -46,10 +46,38 @@ ScoreBasedAmbiguityResolution::computeInitialState( std::vector trackFeaturesVector(numberOfDetectors); for (const auto& ts : track.trackStatesReversed()) { + auto typeFlags(ts.typeFlags()); + if (!ts.hasReferenceSurface()) { - ACTS_ERROR("Track state has no reference surface"); + ACTS_DEBUG("Track state has no reference surface"); + continue; + } + + if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { + ACTS_VERBOSE("Track state type is MeasurementFlag"); + } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) { + ACTS_VERBOSE("Track state type is OutlierFlag"); + } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { + ACTS_VERBOSE("Track state type is HoleFlag"); + } else if (typeFlags.test(Acts::TrackStateFlag::MaterialFlag)) { + ACTS_VERBOSE("Track state type is MaterialFlag"); + continue; + } else if (typeFlags.test(Acts::TrackStateFlag::ParameterFlag)) { + ACTS_VERBOSE("Track state type is ParameterFlag"); continue; + } else if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) { + ACTS_VERBOSE("Track state type is SharedHitFlag"); + } else if (typeFlags.test(Acts::TrackStateFlag::NumTrackStateFlags)) { + ACTS_VERBOSE("Track state type is NumTrackStateFlags"); + continue; + } else { + ACTS_DEBUG( + "Track state type is neither NumTrackStateFlags, MeasurementFlag, " + << "OutlierFlag, HoleFlag, MaterialFlag, SharedHitFlag nor " + "ParameterFlag"); + ACTS_VERBOSE("Track state type is " << typeFlags); } + auto iVolume = ts.referenceSurface().geometryId().volume(); auto volume_it = m_cfg.volumeMap.find(iVolume); if (volume_it == m_cfg.volumeMap.end()) { @@ -58,11 +86,11 @@ ScoreBasedAmbiguityResolution::computeInitialState( } auto detectorId = volume_it->second; - if (ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) { + if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink(); - ACTS_DEBUG("Track state type is MeasurementFlag"); + ACTS_VERBOSE("Track state type is MeasurementFlag"); - if (ts.typeFlags().test(Acts::TrackStateFlag::SharedHitFlag)) { + if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) { trackFeaturesVector[detectorId].nSharedHits++; } trackFeaturesVector[detectorId].nHits++; @@ -74,9 +102,9 @@ ScoreBasedAmbiguityResolution::computeInitialState( bool isoutliner = false; measurements.push_back({emplace.first->second, detectorId, isoutliner}); - } else if (ts.typeFlags().test(Acts::TrackStateFlag::OutlierFlag)) { + } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) { Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink(); - ACTS_DEBUG("Track state type is OutlierFlag"); + ACTS_VERBOSE("Track state type is OutlierFlag"); trackFeaturesVector[detectorId].nOutliers++; // assign a new measurement index if the source link was not seen yet @@ -86,15 +114,22 @@ ScoreBasedAmbiguityResolution::computeInitialState( bool isOutliner = true; measurements.push_back({emplace.first->second, detectorId, isOutliner}); - } else if (ts.typeFlags().test(Acts::TrackStateFlag::HoleFlag)) { - ACTS_DEBUG("Track state type is HoleFlag"); + } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { + ACTS_VERBOSE("Track state type is HoleFlag"); trackFeaturesVector[detectorId].nHoles++; + } else { + ACTS_DEBUG( + "Track state type is neither MeasurementFlag, OutlierFlag nor " + "HoleFlag"); + ACTS_DEBUG("Track state type is " << ts.typeFlags()); } } measurementsPerTrack.push_back(std::move(measurements)); trackFeaturesVectors.push_back(std::move(trackFeaturesVector)); } + ACTS_DEBUG("Number of measurements: " << measurementsPerTrack.size()); + ACTS_DEBUG("Number of trackFeatures: " << trackFeaturesVectors.size()); return measurementsPerTrack; } @@ -445,6 +480,7 @@ std::vector Acts::ScoreBasedAmbiguityResolution::solveAmbiguity( trackScore = simpleScore(tracks, trackFeaturesVectors, optionalCuts); } + std::vector cleanTracks = getCleanedOutTracks( trackScore, trackFeaturesVectors, measurementsPerTrack); diff --git a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp index 9936df2e9cc..af8f72007df 100644 --- a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp +++ b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp @@ -19,7 +19,7 @@ std::vector Acts::ScoreBasedAmbiguityResolution::getCleanedOutTracks( const { std::vector cleanTracks(measurementsPerTrack.size(), false); - ACTS_VERBOSE("Cleaning tracks"); +ACTS_INFO("Cleaning tracks"); if (trackScore.size() != measurementsPerTrack.size()) { throw std::invalid_argument( diff --git a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp index 2542a237b52..36d9159e84a 100644 --- a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp +++ b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp @@ -35,15 +35,26 @@ void from_json(const nlohmann::json& j, ConfigPair& p) { detectorConfig.sharedHitsFlag = value["sharedHitsFlag"]; - std::vector factorHits = value["factorHits"]; - std::vector factorHoles = value["factorHoles"]; + std::vector goodHits = value["goodHits"]; + std::vector goodHoles = value["goodHoles"]; - for (auto factor : factorHits) { - detectorConfig.factorHits.push_back(factor); + std::vector fakeHits = value["fakeHits"]; + std::vector fakeHoles = value["fakeHoles"]; + + if (goodHits.size() != fakeHits.size()) { + throw std::invalid_argument("goodHits and FakeHits size mismatch"); + } + + for (std::size_t i = 0; i < goodHits.size(); i++) { + detectorConfig.factorHits.push_back(goodHits[i] / fakeHits[i]); + } + + if (goodHoles.size() != fakeHoles.size()) { + throw std::invalid_argument("goodHoles and FakeHoles size mismatch"); } - for (auto factor : factorHoles) { - detectorConfig.factorHoles.push_back(factor); + for (std::size_t i = 0; i < goodHoles.size(); i++) { + detectorConfig.factorHoles.push_back(goodHoles[i] / fakeHoles[i]); } detectorConfigs.push_back(detectorConfig); From 81c390a7ffb741369eae65b2089716eafdbc6b17 Mon Sep 17 00:00:00 2001 From: ragansu Date: Wed, 18 Sep 2024 17:21:55 +0200 Subject: [PATCH 2/6] update ERROR to DEBUG --- .../ScoreBasedAmbiguityResolution.ipp | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp index 19fc19d5115..3dcf1a20a01 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp @@ -45,38 +45,10 @@ ScoreBasedAmbiguityResolution::computeInitialState( std::vector trackFeaturesVector(numberOfDetectors); for (const auto& ts : track.trackStatesReversed()) { - auto typeFlags(ts.typeFlags()); - if (!ts.hasReferenceSurface()) { ACTS_DEBUG("Track state has no reference surface"); continue; } - - if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { - ACTS_VERBOSE("Track state type is MeasurementFlag"); - } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) { - ACTS_VERBOSE("Track state type is OutlierFlag"); - } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { - ACTS_VERBOSE("Track state type is HoleFlag"); - } else if (typeFlags.test(Acts::TrackStateFlag::MaterialFlag)) { - ACTS_VERBOSE("Track state type is MaterialFlag"); - continue; - } else if (typeFlags.test(Acts::TrackStateFlag::ParameterFlag)) { - ACTS_VERBOSE("Track state type is ParameterFlag"); - continue; - } else if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) { - ACTS_VERBOSE("Track state type is SharedHitFlag"); - } else if (typeFlags.test(Acts::TrackStateFlag::NumTrackStateFlags)) { - ACTS_VERBOSE("Track state type is NumTrackStateFlags"); - continue; - } else { - ACTS_DEBUG( - "Track state type is neither NumTrackStateFlags, MeasurementFlag, " - << "OutlierFlag, HoleFlag, MaterialFlag, SharedHitFlag nor " - "ParameterFlag"); - ACTS_VERBOSE("Track state type is " << typeFlags); - } - auto iVolume = ts.referenceSurface().geometryId().volume(); auto volume_it = m_cfg.volumeMap.find(iVolume); if (volume_it == m_cfg.volumeMap.end()) { @@ -102,9 +74,9 @@ ScoreBasedAmbiguityResolution::computeInitialState( measurements.push_back({emplace.first->second, detectorId, isOutliner}); } else if (ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) { Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink(); - ACTS_VERBOSE("Track state type is MeasurementFlag"); + ACTS_DEBUG("Track state type is MeasurementFlag"); - if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) { + if (ts.typeFlags().test(Acts::TrackStateFlag::SharedHitFlag)) { trackFeaturesVector[detectorId].nSharedHits++; } trackFeaturesVector[detectorId].nHits++; @@ -122,8 +94,6 @@ ScoreBasedAmbiguityResolution::computeInitialState( trackFeaturesVectors.push_back(std::move(trackFeaturesVector)); } - ACTS_DEBUG("Number of measurements: " << measurementsPerTrack.size()); - ACTS_DEBUG("Number of trackFeatures: " << trackFeaturesVectors.size()); return measurementsPerTrack; } @@ -472,7 +442,6 @@ std::vector Acts::ScoreBasedAmbiguityResolution::solveAmbiguity( trackScore = simpleScore(tracks, trackFeaturesVectors, optionalCuts); } - std::vector cleanTracks = getCleanedOutTracks( trackScore, trackFeaturesVectors, measurementsPerTrack); From 8946da1673cae40ee6b3438c69685fce23966fb5 Mon Sep 17 00:00:00 2001 From: ragansu Date: Thu, 19 Sep 2024 11:01:32 +0200 Subject: [PATCH 3/6] fixing formating issue --- Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp index af8f72007df..8861d7055e7 100644 --- a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp +++ b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp @@ -19,7 +19,7 @@ std::vector Acts::ScoreBasedAmbiguityResolution::getCleanedOutTracks( const { std::vector cleanTracks(measurementsPerTrack.size(), false); -ACTS_INFO("Cleaning tracks"); + ACTS_INFO("Cleaning tracks"); if (trackScore.size() != measurementsPerTrack.size()) { throw std::invalid_argument( From 95417de8d3c4871276b2de30ffc117a831e2f4ee Mon Sep 17 00:00:00 2001 From: Ragansu Chakkappai <66349236+Ragansu@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:09:16 +0200 Subject: [PATCH 4/6] Update Plugins/Json/src/AmbiguityConfigJsonConverter.cpp Co-authored-by: Carlo Varni <75478407+CarloVarni@users.noreply.github.com> --- Plugins/Json/src/AmbiguityConfigJsonConverter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp index 36d9159e84a..7a88a43963b 100644 --- a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp +++ b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp @@ -38,8 +38,8 @@ void from_json(const nlohmann::json& j, ConfigPair& p) { std::vector goodHits = value["goodHits"]; std::vector goodHoles = value["goodHoles"]; - std::vector fakeHits = value["fakeHits"]; - std::vector fakeHoles = value["fakeHoles"]; + const std::vector& fakeHits = value["fakeHits"]; + const std::vector&fakeHoles = value["fakeHoles"]; if (goodHits.size() != fakeHits.size()) { throw std::invalid_argument("goodHits and FakeHits size mismatch"); From 186aadd23be46004f5184d42b03dea6ab953611d Mon Sep 17 00:00:00 2001 From: ragansu Date: Thu, 19 Sep 2024 16:14:48 +0200 Subject: [PATCH 5/6] change copy to const reference --- Plugins/Json/src/AmbiguityConfigJsonConverter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp index 7a88a43963b..3a4c0f44a6f 100644 --- a/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp +++ b/Plugins/Json/src/AmbiguityConfigJsonConverter.cpp @@ -35,11 +35,11 @@ void from_json(const nlohmann::json& j, ConfigPair& p) { detectorConfig.sharedHitsFlag = value["sharedHitsFlag"]; - std::vector goodHits = value["goodHits"]; - std::vector goodHoles = value["goodHoles"]; + const std::vector& goodHits = value["goodHits"]; + const std::vector& goodHoles = value["goodHoles"]; const std::vector& fakeHits = value["fakeHits"]; - const std::vector&fakeHoles = value["fakeHoles"]; + const std::vector& fakeHoles = value["fakeHoles"]; if (goodHits.size() != fakeHits.size()) { throw std::invalid_argument("goodHits and FakeHits size mismatch"); From f1fe868327f00e7e7deaa694fa90fd5fba017069 Mon Sep 17 00:00:00 2001 From: ragansu Date: Thu, 19 Sep 2024 16:17:58 +0200 Subject: [PATCH 6/6] INFO to VERBOSE --- Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp index 8861d7055e7..9936df2e9cc 100644 --- a/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp +++ b/Core/src/AmbiguityResolution/ScoreBasedAmbiguityResolution.cpp @@ -19,7 +19,7 @@ std::vector Acts::ScoreBasedAmbiguityResolution::getCleanedOutTracks( const { std::vector cleanTracks(measurementsPerTrack.size(), false); - ACTS_INFO("Cleaning tracks"); + ACTS_VERBOSE("Cleaning tracks"); if (trackScore.size() != measurementsPerTrack.size()) { throw std::invalid_argument(