AnalysisTree
Loading...
Searching...
No Matches
Container.hpp
1/* Copyright (C) 2019-2021 GSI, Universität Tübingen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Viktor Klochkov, Ilya Selyuzhenkov */
4#ifndef ANALYSISTREE_BASECONTAINER_H
5#define ANALYSISTREE_BASECONTAINER_H
6
7#include "BranchConfig.hpp"
8#include "IndexedObject.hpp"
9
10namespace AnalysisTree {
11
13
18class Container : public IndexedObject {
19 public:
20 Container() = default;
21
22 explicit Container(size_t id) : IndexedObject(id) {}
23 Container(size_t id, const BranchConfig& branch)
24 : IndexedObject(id),
25 floats_(branch.GetSize<float>()),
26 ints_(branch.GetSize<int>()),
27 bools_(branch.GetSize<bool>()) {}
28
29 Container(const Container& container) = default;
30 Container(Container&& container) = default;
31 Container& operator=(Container&&) = default;
32 Container& operator=(const Container& part) = default;
33 ~Container() override = default;
34
35 template<class T>
36 std::vector<T>& Vector();
37
38 template<class T>
39 const std::vector<T>& GetVector() const;
40
41 template<typename T>
42 void SetField(T value, Integer_t field_id) {
43 Vector<T>().at(field_id) = value;
44 }
45
46 template<typename T>
47 ANALYSISTREE_ATTR_NODISCARD T GetField(Integer_t field_id) const {
48 return GetVector<T>().at(field_id);
49 }
50
51 template<typename T>
52 ANALYSISTREE_ATTR_NODISCARD size_t GetSize() const {
53 return GetVector<T>().size();
54 }
55
56 void Init(const BranchConfig& branch);
57 virtual void Print() const noexcept;
58
59 protected:
60 std::vector<float> floats_{};
61 std::vector<int> ints_{};
62 std::vector<bool> bools_{};
63
64 ClassDefOverride(Container, 2);
65};
66
67}// namespace AnalysisTree
68#endif//ANALYSISTREE_BASECONTAINER_H
A class to store configuration of the Container.
Definition BranchConfig.hpp:118
A class to store any number of integers, floats and bools.
Definition Container.hpp:18
Definition IndexedObject.hpp:30
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10