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
17
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 doubles_(branch.GetSize<double>()),
26 floats_(branch.GetSize<float>()),
27 ints_(branch.GetSize<int>()),
28 bools_(branch.GetSize<bool>()) {}
29
30 Container(const Container& container) = default;
31 Container(Container&& container) = default;
32 Container& operator=(Container&&) = default;
33 Container& operator=(const Container& part) = default;
34 ~Container() override = default;
35
36 template<class T>
37 std::vector<T>& Vector();
38
39 template<class T>
40 const std::vector<T>& GetVector() const;
41
42 template<typename T>
43 void SetField(T value, Integer_t field_id) {
44 Vector<T>().at(field_id) = value;
45 }
46
47 template<typename T>
48 ANALYSISTREE_ATTR_NODISCARD T GetField(Integer_t field_id) const {
49 return GetVector<T>().at(field_id);
50 }
51
52 template<typename T>
53 ANALYSISTREE_ATTR_NODISCARD size_t GetSize() const {
54 return GetVector<T>().size();
55 }
56
57 void Init(const BranchConfig& branch);
58 virtual void Print() const noexcept;
59
60 protected:
61 std::vector<double> doubles_{};
62 std::vector<float> floats_{};
63 std::vector<int> ints_{};
64 std::vector<bool> bools_{};
65
66 ClassDefOverride(Container, 3);
67};
68
69}// namespace AnalysisTree
70#endif//ANALYSISTREE_BASECONTAINER_H
A class to store configuration of the Container.
Definition BranchConfig.hpp:89
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10