42 Branch(
BranchConfig config, BranchPointer ptr) : config_(std::move(config)), data_(std::move(ptr)) {
49 std::vector<std::pair<
Field ,
Field >> field_pairs;
53 [[nodiscard]] std::string GetBranchName()
const {
return config_.GetName(); }
54 [[nodiscard]] DetType GetBranchType()
const {
return config_.GetType(); }
55 [[nodiscard]]
const BranchConfig& GetConfig()
const {
return config_; }
59 BranchChannel NewChannel();
60 BranchChannel NullChannel();
62 Field NewVariable(
const std::string& field_name,
const std::string& title, AnalysisTree::Types type);
66 [[nodiscard]]
size_t size()
const;
68 BranchChannel operator[](
size_t i_channel)
const {
69 return BranchChannel(
this, i_channel);
72 std::vector<std::string> GetFieldNames()
const;
74 [[nodiscard]]
size_t GetId()
const {
75 return ANALYSISTREE_UTILS_VISIT(get_id_struct(), data_);
78 [[nodiscard]] BranchPointer GetData()
const {
return data_; }
80 [[nodiscard]] T& GetDataRaw() {
return ANALYSISTREE_UTILS_GET<T>(data_); }
82 [[nodiscard]] Field GetField(std::string field_name)
const {
83 Field field(config_.GetName(), std::move(field_name));
91 bool is_mutable_{
false};
92 bool is_frozen_{
false};
93 std::size_t config_hash_{0};
97 mutable std::map<
const Branch* , FieldsMapping> copy_fields_mapping;
100 void Freeze(
bool freeze =
true) { is_frozen_ = freeze; };
101 void SetMutable(
bool is_mutable =
true) { Branch::is_mutable_ = is_mutable; }
104 inline void CheckFrozen(
bool expected =
true)
const {
105 if (is_frozen_ != expected)
106 throw std::runtime_error(
"Branch is frozen");
108 inline void CheckMutable(
bool expected =
true)
const {
109 if (is_mutable_ != expected)
110 throw std::runtime_error(
"Branch is not mutable");
120 template<
typename... Args>
121 auto GetVars(Args... field_name) {
122 return GetVarsImpl(std::array<std::string,
sizeof...(Args)>{{std::string(field_name)...}},
123 std::make_index_sequence<
sizeof...(Args)>());
129 void UseFields(std::vector<std::pair<std::string, std::reference_wrapper<Field>>>&& vars,
bool ignore_missing =
false);
136 template<
typename EntityPtr>
137 constexpr static const bool is_event_header_v =
138 std::is_same_v<AnalysisTree::EventHeader, std::remove_const_t<std::remove_pointer_t<EntityPtr>>>;
143 void CreateMapping(
const Branch* other, std::string branch_name_prefix =
"")
const;
145 void UpdateConfigHash();
147 [[nodiscard]] AnalysisTree::ShortInt_t Hash()
const {
148 const auto hasher = std::hash<std::string>();
149 return AnalysisTree::ShortInt_t(hasher(config_.GetName()));
void CopyContentsRaw(Branch *other)
Gets variables according to variable names specified in the arguments. Returns tuple of variables whi...
Definition Branch.cpp:132