AnalysisTree
Loading...
Searching...
No Matches
BranchChannel.hpp
1/* Copyright (C) 2019-2021 GSI, MEPhI, Universität Tübingen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Eugeny Kashirin, Viktor Klochkov, Ilya Selyuzhenkov */
4#ifndef ANALYSISTREE_INFRA_BRANCHCHANNEL_HPP_
5#define ANALYSISTREE_INFRA_BRANCHCHANNEL_HPP_
6
7#include <cassert>
8#include <iostream>
9#include <utility>
10
11#include "Utils.hpp"
12
13namespace AnalysisTree {
14
15class AnalysisEntry;
16class Branch;
17class Field;
18
20 public:
21 BranchChannel() = default;
22 BranchChannel(ChannelPointer data_ptr, const Branch* branch = nullptr, size_t i_channel = 0)
23 : data_ptr_(std::move(data_ptr)),
24 branch_(branch),
25 i_channel_(i_channel) {}
26
27 /* Getting value */
28 [[nodiscard]] double Value(const Field& v) const;
29 [[nodiscard]] double operator[](const Field& v) const;
30 [[nodiscard]] inline std::size_t GetChannelNumber() const { return i_channel_; }
31 [[nodiscard]] std::size_t GetId() const;
32
33 void SetValue(const Field& v, double value);
34
35 template<typename T>
36 T*& Data() { return ANALYSISTREE_UTILS_GET<T*>(data_ptr_); }
37 template<typename T>
38 const T* Data() const { return ANALYSISTREE_UTILS_GET<T*>(data_ptr_); }
39
45 void CopyContent(const BranchChannel& other, std::string branch_name_prefix = "");
46
47 void MergeContentFromTwoChannels(const BranchChannel& first, const BranchChannel& second);
48
49 void CopyContentRaw(const BranchChannel& other);
50
51 void Print(std::ostream& os = std::cout) const;
52
53 [[nodiscard]] bool IsNullChannel() const { return branch_ == nullptr; }
54
55 private:
56 friend Branch;
57 friend AnalysisEntry;
58
59 BranchChannel(const Branch* branch, std::size_t i_channel);
60 void UpdatePointer();
61 void UpdateChannel(std::size_t new_channel);
62
63 ChannelPointer data_ptr_;
64 const Branch* branch_{nullptr};
65 std::size_t i_channel_{0};
66};
67
68}// namespace AnalysisTree
69
70#endif//ANALYSISTREE_INFRA_BRANCHCHANNEL_HPP_
AnalysisEntry keeps list of Variables from one or more branches. Before each event AnalysisEntry eval...
Definition AnalysisEntry.hpp:20
Definition BranchChannel.hpp:19
void CopyContent(const BranchChannel &other, std::string branch_name_prefix="")
Copy contents of other branch channel.
Definition BranchChannel.cpp:27
Definition Branch.hpp:23
Field is a pointer in a branch/field structure.
Definition Field.hpp:22
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10