diff --git a/core/Constants.hpp b/core/Constants.hpp index 9d1c5a1c..61d8399a 100644 --- a/core/Constants.hpp +++ b/core/Constants.hpp @@ -30,6 +30,7 @@ typedef UInt_t UInteger_t; typedef Short_t ShortInt_t; typedef Long64_t PdgCode_t; +constexpr double UndefValueDouble = -999.; constexpr Floating_t UndefValueFloat = -999.f; constexpr ShortInt_t UndefValueShort = -999; constexpr Integer_t UndefValueInt = -999; diff --git a/core/Container.cpp b/core/Container.cpp index 3a568bb0..be9933b4 100644 --- a/core/Container.cpp +++ b/core/Container.cpp @@ -5,6 +5,8 @@ #include "BranchConfig.hpp" +#include + namespace AnalysisTree { template<> @@ -32,6 +34,13 @@ void Container::Init(const AnalysisTree::BranchConfig& branch) { bools_.resize(branch.GetSize()); } +void Container::Reset() { + std::fill(doubles_.begin(), doubles_.end(), UndefValueDouble); + std::fill(floats_.begin(), floats_.end(), UndefValueFloat); + std::fill(ints_.begin(), ints_.end(), UndefValueInt); + std::fill(bools_.begin(), bools_.end(), false); +} + void Container::Print() const noexcept { if (!ints_.empty()) { std::cout << "Integer fields: "; diff --git a/core/Container.hpp b/core/Container.hpp index 6613ffa7..1babd078 100644 --- a/core/Container.hpp +++ b/core/Container.hpp @@ -55,6 +55,12 @@ class Container : public IndexedObject { } void Init(const BranchConfig& branch); + + /** + * @brief Sets all user-defined fields to undefined values (UndefValueDouble, UndefValueFloat, UndefValueInt, false) + */ + virtual void Reset(); + virtual void Print() const noexcept; protected: diff --git a/core/EventHeader.cpp b/core/EventHeader.cpp index a9d431a1..4cffefdd 100644 --- a/core/EventHeader.cpp +++ b/core/EventHeader.cpp @@ -17,6 +17,11 @@ void EventHeader::SetVertexPosition3(const TVector3& pos) { vtx_pos_[Exyz::kZ] = pos.Pz(); } +void EventHeader::Reset() { + Container::Reset(); + vtx_pos_.fill(UndefValueFloat); +} + const EventHeader& EventHeader::GetChannel(size_t i) const { if (i == 0) { return *this; diff --git a/core/EventHeader.hpp b/core/EventHeader.hpp index 09898d42..30082e94 100644 --- a/core/EventHeader.hpp +++ b/core/EventHeader.hpp @@ -34,6 +34,11 @@ class EventHeader : public Container { void SetVertexPosition3(const TVector3& pos); + /** + * @brief Sets vertex position and all user-defined fields to undefined values + */ + void Reset() override; + template T GetField(Integer_t iField) const { if (iField >= 0)