From 3b25620b477479819fca8f44453b1b84c3eb68fd Mon Sep 17 00:00:00 2001 From: Xiaocong Ai Date: Sun, 25 Aug 2024 12:28:44 +0800 Subject: [PATCH] set noise hit mcParticleIndex to -1 --- .../TrackFittingAlgorithmFunctionsKalman.cpp | 2 +- .../TruthTracking/TruthSeedSelector.cpp | 1 - .../Io/Root/RootSTCFMeasurementReader_BKG.hpp | 2 +- .../Io/Root/src/RootSTCFMeasurementReader.cpp | 8 +-- .../src/RootSTCFMeasurementReader_BKG.cpp | 67 +++++++++---------- .../Reconstruction/STCFRecCKFTracks_BKG.cpp | 3 +- Fatras/include/ActsFatras/EventData/Hit.hpp | 8 ++- .../include/ActsFatras/EventData/Particle.hpp | 10 +-- .../Selectors/detail/combine_selectors.hpp | 4 +- 9 files changed, 54 insertions(+), 51 deletions(-) diff --git a/Examples/Algorithms/TrackFitting/src/TrackFittingAlgorithmFunctionsKalman.cpp b/Examples/Algorithms/TrackFitting/src/TrackFittingAlgorithmFunctionsKalman.cpp index 76911e692db..7e42b8781dd 100644 --- a/Examples/Algorithms/TrackFitting/src/TrackFittingAlgorithmFunctionsKalman.cpp +++ b/Examples/Algorithms/TrackFitting/src/TrackFittingAlgorithmFunctionsKalman.cpp @@ -55,7 +55,7 @@ struct SimpleOutlierFinder { if (not state.hasCalibrated() or not state.hasPredicted()) { return false; } - //const size_t measdim = state.calibratedSize(); + // const size_t measdim = state.calibratedSize(); // auto geoId = state.referenceSurface().geometryId(); diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp index 88703586576..95e1b5a0db7 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp @@ -111,7 +111,6 @@ ProcessCode TruthSeedSelector::execute(const AlgorithmContext& ctx) const { const auto& hits = makeRange(particleHitsMap.equal_range(p.particleId())); // number of recorded hits size_t nHits = hits.size(); - std::cout << "nHits = " << nHits << std::endl; return within(rho, 0., m_cfg.rhoMax) and within(p.position().z(), m_cfg.zMin, m_cfg.zMax) and within(std::abs(eta), m_cfg.absEtaMin, m_cfg.absEtaMax) and diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootSTCFMeasurementReader_BKG.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootSTCFMeasurementReader_BKG.hpp index 324e06f8cea..33d90f70168 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootSTCFMeasurementReader_BKG.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootSTCFMeasurementReader_BKG.hpp @@ -64,7 +64,7 @@ class RootSTCFMeasurementReader_BKG : public IReader { /// Whether the events are ordered or not bool orderedEvents = true; /// Whether ignore noise hits when reading - bool ignoreNoiseHits = false; + bool ignoreNoiseHits = false; }; /// Constructor diff --git a/Examples/Io/Root/src/RootSTCFMeasurementReader.cpp b/Examples/Io/Root/src/RootSTCFMeasurementReader.cpp index 9bf1ffc6292..0ad3da6f1fb 100644 --- a/Examples/Io/Root/src/RootSTCFMeasurementReader.cpp +++ b/Examples/Io/Root/src/RootSTCFMeasurementReader.cpp @@ -258,9 +258,9 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader::read( // Reading ITK hits for (size_t i = 0; i < ITKpositionX->GetSize(); ++i) { int parentID = (*ITKparentID)[i]; - if (parentID != 0){ + if (parentID != 0) { continue; - } + } nITKHits++; Acts::Vector3 pos((*ITKpositionX)[i], (*ITKpositionY)[i], @@ -331,9 +331,9 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader::read( // Reading MDC hits for (size_t i = 0; i < MDCcellID->GetSize(); ++i) { int parentID = (*MDCparentID)[i]; - if (parentID != 0){ + if (parentID != 0) { continue; - } + } nMDCHits++; Acts::Vector3 pos((*MDCpositionX)[i], (*MDCpositionY)[i], diff --git a/Examples/Io/Root/src/RootSTCFMeasurementReader_BKG.cpp b/Examples/Io/Root/src/RootSTCFMeasurementReader_BKG.cpp index 8b2064592a3..787a9dbdf67 100644 --- a/Examples/Io/Root/src/RootSTCFMeasurementReader_BKG.cpp +++ b/Examples/Io/Root/src/RootSTCFMeasurementReader_BKG.cpp @@ -251,7 +251,7 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( std::map particleITKAllHitIdx; std::map particleITKSigHitIdx; std::map particleHitIdx; - + ///////////////////////////////////////////////////////////////////////////////////////////////// // I. read sim hits ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -269,20 +269,23 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( ///////////////////////////////////////////////////////////////////////////////////////////////// // 1) Reading ITK hits ///////////////////////////////////////////////////////////////////////////////////////////////// - //for (size_t i = 0; i < ITKpositionX->GetSize(); ++i) { + // for (size_t i = 0; i < ITKpositionX->GetSize(); ++i) { for (size_t i = 0; i < ITKtype->GetSize(); ++i) { int parentID = (*ITKparentID)[i]; - if (parentID != 0){ + if (parentID != 0) { continue; - } + } int type = (*ITKtype)[i]; - // std::cout<<"ITK type is :"<GetSize(); ++i) { int parentID = (*MDCparentID)[i]; - if (parentID != 0){ + if (parentID != 0) { continue; - } + } int type = (*MDCtype)[i]; // std::cout<<"MDC type is :"< par{m_ITKRadius[moduleGeoId.layer() / 2 - 1] * Acts::VectorHelpers::phi(pos) + 0.1 * stdNormal(rng), @@ -517,7 +515,7 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( std::array indices = {Acts::eBoundLoc0}; // Gives the drift distance a sign if it's not noise - if (not isNoise) { + if (not isNoiseHit) { auto lpResult = surfacePtr->globalToLocal(context.geoContext, pos, dir); if (not lpResult.ok()) { @@ -541,7 +539,7 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( Acts::ActsSymMatrix<1> cov = Acts::ActsSymMatrix<1>::Identity(); cov(0, 0) = sigma * sigma; - if (not isNoise) { + if (not isNoiseHit) { Acts::ActsVector<1> par{driftDistance + sigma * stdNormal(rng)}; measurements.emplace_back( Acts::Measurement(sourceLink, indices, @@ -569,9 +567,8 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( } std::cout << "nITKHits = " << nITKHits << ", nMDCHits = " << nMDCHits << std::endl; - } // Finish reading sim hits and transform them into measurements - - + } // Finish reading sim hits and transform them into measurements + ///////////////////////////////////////////////////////////////////////////////////////////////// // II. now read particles ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -648,7 +645,7 @@ ActsExamples::ProcessCode ActsExamples::RootSTCFMeasurementReader_BKG::read( } std::cout << "nParticles = " << nParticles << std::endl; } - + // Write the collections to the EventStore context.eventStore.add(m_cfg.outputSourceLinks, std::move(sourceLinks)); context.eventStore.add(m_cfg.outputSourceLinks + "__storage", diff --git a/Examples/Run/Reconstruction/STCFRecCKFTracks_BKG.cpp b/Examples/Run/Reconstruction/STCFRecCKFTracks_BKG.cpp index 7f9704a2d36..e78c1a15ce9 100644 --- a/Examples/Run/Reconstruction/STCFRecCKFTracks_BKG.cpp +++ b/Examples/Run/Reconstruction/STCFRecCKFTracks_BKG.cpp @@ -54,8 +54,7 @@ void addRecCKFOptions(ActsExamples::Options::Description& desc) { using boost::program_options::value; auto opt = desc.add_options(); - opt("reco-ignore-noise", bool_switch(), - "Don't read noise hits"); + opt("reco-ignore-noise", bool_switch(), "Don't read noise hits"); opt("ckf-truth-smeared-seeds", bool_switch(), "Use track parameters smeared from truth particles for steering CKF"); opt("ckf-truth-estimated-seeds", bool_switch(), diff --git a/Fatras/include/ActsFatras/EventData/Hit.hpp b/Fatras/include/ActsFatras/EventData/Hit.hpp index b3410f05c8e..54bb34f486a 100644 --- a/Fatras/include/ActsFatras/EventData/Hit.hpp +++ b/Fatras/include/ActsFatras/EventData/Hit.hpp @@ -46,10 +46,11 @@ class Hit { /// position on the given surface. Hit(Acts::GeometryIdentifier geometryId, Barcode particleId, const Vector4& pos4, const Vector4& before4, const Vector4& after4, - int32_t index_ = -1) + int32_t index_ = -1, bool isNoise_ = false) : m_geometryId(geometryId), m_particleId(particleId), m_index(index_), + m_isNoise(isNoise_), m_pos4(pos4), m_before4(before4), m_after4(after4) {} @@ -67,6 +68,9 @@ class Hit { /// @retval negative if the hit index is undefined. constexpr int32_t index() const { return m_index; } + /// Added by xiaocong. Whether this is a noise + bool isNoise() const { return m_isNoise; } + /// Space-time position four-vector. const Vector4& fourPosition() const { return m_pos4; } /// Three-position, i.e. spatial coordinates without the time. @@ -113,6 +117,8 @@ class Hit { Vector4 m_before4 = Vector4::Zero(); /// Global particle energy-momentum four-vector after the hit. Vector4 m_after4 = Vector4::Zero(); + /// Whether the hit is a noise + bool m_isNoise = false; }; } // namespace ActsFatras diff --git a/Fatras/include/ActsFatras/EventData/Particle.hpp b/Fatras/include/ActsFatras/EventData/Particle.hpp index d9eead8ba32..edf4cb94cae 100644 --- a/Fatras/include/ActsFatras/EventData/Particle.hpp +++ b/Fatras/include/ActsFatras/EventData/Particle.hpp @@ -115,7 +115,9 @@ class Particle { Particle &setCharge(Scalar charge) { return m_charge = charge, *this; } ///**************set the particle ITKHits - Particle &setITKHits(int ITKHits) { return m_ITKHits = ITKHits, *this; }///*** + Particle &setITKHits(int ITKHits) { + return m_ITKHits = ITKHits, *this; + } ///*** /// Change the energy by the given amount. /// @@ -131,8 +133,8 @@ class Particle { } return *this; } - ///***********get particle ITKHits - constexpr int particleITKHits() const { return m_ITKHits; }/////*** + ///***********get particle ITKHits + constexpr int particleITKHits() const { return m_ITKHits; } /////*** /////************** /// Particle identifier within an event. constexpr Barcode particleId() const { return m_particleId; } @@ -224,7 +226,7 @@ class Particle { Scalar m_pathInX0 = Scalar(0); Scalar m_pathInL0 = Scalar(0); ///*******particle ITKHits - int m_ITKHits;///************ + int m_ITKHits; ///************ }; std::ostream &operator<<(std::ostream &os, const Particle &particle); diff --git a/Fatras/include/ActsFatras/Selectors/detail/combine_selectors.hpp b/Fatras/include/ActsFatras/Selectors/detail/combine_selectors.hpp index 96aeb803d03..0fc9e02ac0f 100644 --- a/Fatras/include/ActsFatras/Selectors/detail/combine_selectors.hpp +++ b/Fatras/include/ActsFatras/Selectors/detail/combine_selectors.hpp @@ -29,7 +29,7 @@ class CombineSelectors { /// /// @tparam Ts the types of the selected inputs template - bool operator()(const Ts &... things) const { + bool operator()(const Ts &...things) const { static_assert( (true && ... && std::is_same_v), "Not all selectors conform to the expected interface (bool)(const " @@ -52,7 +52,7 @@ class CombineSelectors { std::tuple m_selectors; template - bool impl(std::index_sequence, const Ts &... things) const { + bool impl(std::index_sequence, const Ts &...things) const { Combine combine; // compute status for all selectors bool status[] = {std::get(m_selectors)(things...)...};