Skip to content

Commit

Permalink
add title_ to BranchConfig for detailed description if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
lubynets committed Aug 5, 2024
1 parent e52e4cb commit 3dee913
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
15 changes: 10 additions & 5 deletions core/BranchConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void BranchConfig::GenerateId() {
id_ = id_hasher(name_);
}

BranchConfig::BranchConfig(std::string name, DetType type) : name_(std::move(name)), type_(type) {
BranchConfig::BranchConfig(std::string name, DetType type, std::string title) : name_(std::move(name)), type_(type), title_(std::move(title)) {
GenerateId();

if (type_ == DetType::kTrack) {
Expand Down Expand Up @@ -184,13 +184,18 @@ void BranchConfig::GuaranteeFieldNameVacancy(const std::string& name) const {
}

void BranchConfig::Print() const {
std::cout << "Branch " << name_ << " (id=" << id_ << ") consists of:" << std::endl;
std::cout << "Floating fields:" << std::endl;
std::cout << "Branch " << name_ << " (" << title_ << ") consists of:" << std::endl;
std::cout << "\nFloating fields:" << std::endl;
VectorConfig<float>::Print();
std::cout << "Integer fields:" << std::endl;
std::cout << "\nInteger fields:" << std::endl;
VectorConfig<int>::Print();
std::cout << "Boolean fields:" << std::endl;
std::cout << "\nBoolean fields:" << std::endl;
VectorConfig<bool>::Print();
// std::cout << std::endl;
}

void BranchConfig::PrintBranchId() const {
std::cout << "Branch " << name_ << " (id=" << id_ << ")" << std::endl;
}

}// namespace AnalysisTree
11 changes: 9 additions & 2 deletions core/BranchConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ class BranchConfig : public VectorConfig<int>, public VectorConfig<float>, publi
BranchConfig& operator=(const BranchConfig&) = default;
~BranchConfig() override = default;

BranchConfig(std::string name, DetType type);
BranchConfig(std::string name, DetType type, std::string title="");

void Print() const override;

void PrintBranchId() const;

ANALYSISTREE_ATTR_NODISCARD Types GetFieldType(const std::string& sField) const;
ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetFieldId(const std::string& sField) const;

Expand Down Expand Up @@ -159,13 +161,17 @@ class BranchConfig : public VectorConfig<int>, public VectorConfig<float>, publi
}
}

void SetTitle(std::string title) { title_ = std::move(title); }

// Getters
template<typename T>
ANALYSISTREE_ATTR_NODISCARD const MapType& GetMap() const { return VectorConfig<T>::GetMap(); }
template<typename T>
ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetSize() const { return VectorConfig<T>::GetSize(); }

ANALYSISTREE_ATTR_NODISCARD std::string GetName() const { return name_; }
ANALYSISTREE_ATTR_NODISCARD std::string GetTitle() const { return title_; }

template<typename T>
ANALYSISTREE_ATTR_NODISCARD std::vector<std::string> GetFieldsNamesT() const {
std::vector<std::string> result;
Expand Down Expand Up @@ -193,10 +199,11 @@ class BranchConfig : public VectorConfig<int>, public VectorConfig<float>, publi
void GuaranteeFieldNameVacancy(const std::string& name) const;

std::string name_;
std::string title_;
size_t id_{0};
DetType type_{DetType(UndefValueShort)};

ClassDefOverride(BranchConfig, 3);
ClassDefOverride(BranchConfig, 4);
};

// BranchConfig Merge(const BranchConfig& primary, const BranchConfig& secondary);
Expand Down
7 changes: 7 additions & 0 deletions core/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ void Configuration::Print(Option_t*) const {
}
}

void Configuration::PrintBranchIds() const {
for (const auto& branch : branches_) {
std::cout << std::endl;
branch.second.PrintBranchId();
}
}

const std::string& Configuration::GetMatchName(const std::string& br1, const std::string& br2) const {
auto search = matches_index_.find({br1, br2});
if (search != matches_index_.end()) {
Expand Down
2 changes: 2 additions & 0 deletions core/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class Configuration : public TObject {

void Print(Option_t* = "") const;

void PrintBranchIds() const;

static MatchingIndex MakeMatchingIndex(const std::vector<MatchingConfig>& matches) {
MatchingIndex result;
for (auto& match : matches) {
Expand Down

0 comments on commit 3dee913

Please sign in to comment.