Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions core/Container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "BranchConfig.hpp"

#include <algorithm>

namespace AnalysisTree {

template<>
Expand Down Expand Up @@ -32,6 +34,13 @@ void Container::Init(const AnalysisTree::BranchConfig& branch) {
bools_.resize(branch.GetSize<bool>());
}

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: ";
Expand Down
6 changes: 6 additions & 0 deletions core/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions core/EventHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions core/EventHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
T GetField(Integer_t iField) const {
if (iField >= 0)
Expand Down
Loading