ATLAS Offline Software
Loading...
Searching...
No Matches
ArrayBranch.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTESTER_ARRAYBRANCH_H
5#define MUONTESTER_ARRAYBRANCH_H
6
9#include <TTree.h>
11
12namespace MuonVal {
13class MuonTesterTree;
14template <class T> class ArrayBranch : public MuonTesterBranch, virtual public IMuonTesterBranch {
15public:
17 ArrayBranch(TTree* tree, const std::string& name, size_t size);
18 ArrayBranch(MuonTesterTree& tree, const std::string& name, size_t size);
19
21 ArrayBranch(TTree* tree, const std::string& name, size_t size, const T& def_val);
22 ArrayBranch(MuonTesterTree& tree, const std::string& name, size_t size, const T& def_val);
23
24 virtual ~ArrayBranch() = default;
25
27 bool fill(const EventContext&) override final;
29 bool init() override final;
30
33
35 size_t size() const;
36
38 void set(size_t s, const T& val);
40 const T& get(size_t s) const;
41
43 const T& operator[](size_t s) const;
45 T& operator[](size_t s);
46
49
50 void setDefault(const T& val);
51
56 void reset();
57 size_t m_size{0};
58 std::vector<T> m_data{};
59 std::vector<bool> m_updated{};
60
61 bool m_init{false};
62
66};
67
68template <> std::string ArrayBranch<char*>::tree_data_type() const;
69template <> std::string ArrayBranch<std::string>::tree_data_type() const;
70template <> std::string ArrayBranch<Char_t>::tree_data_type() const;
71template <> std::string ArrayBranch<UChar_t>::tree_data_type() const;
72template <> std::string ArrayBranch<Short_t>::tree_data_type() const;
73template <> std::string ArrayBranch<Int_t>::tree_data_type() const;
74template <> std::string ArrayBranch<Long64_t>::tree_data_type() const;
75template <> std::string ArrayBranch<UShort_t>::tree_data_type() const;
76template <> std::string ArrayBranch<UInt_t>::tree_data_type() const;
77template <> std::string ArrayBranch<ULong64_t>::tree_data_type() const;
78template <> std::string ArrayBranch<Float_t>::tree_data_type() const;
79template <> std::string ArrayBranch<Double_t>::tree_data_type() const;
80template <> std::string ArrayBranch<Bool_t>::tree_data_type() const;
81}
83#endif
ArrayBranch(MuonTesterTree &tree, const std::string &name, size_t size, const T &def_val)
ArrayBranch(TTree *tree, const std::string &name, size_t size, const T &def_val)
Constructor with default value to be set in case an element is not updated.
std::vector< bool > m_updated
Definition ArrayBranch.h:59
ArrayBranch(TTree *tree, const std::string &name, size_t size)
Constructor.
bool initialized() const
Is the branch initialized.
void setDefault(const T &val)
const T & get(size_t s) const
Returns the i-th value.
bool fill(const EventContext &) override final
Returns false if one of the array values is not updated.
size_t size() const
How large is the array.
std::vector< T > m_data
Definition ArrayBranch.h:58
void set(size_t s, const T &val)
Set's the i-th entry of the array to val.
virtual ~ArrayBranch()=default
const T & getDefault() const
default value in cases the branch is not updated
bool init() override final
Connects the branch with the tree.
std::string tree_data_type() const
Data type of the branch in the tree.
void reset()
Resets the check mask.
ArrayBranch(MuonTesterTree &tree, const std::string &name, size_t size)
T m_default
Default value in cases where the part are not updated.
Definition ArrayBranch.h:64
Most basic interface class used by the MuonTester tree.
virtual std::string name() const =0
Returns the name of the branch.
virtual TTree * tree()=0
Returns the pointer to the underlying TTree object.
MuonTesterBranch(MuonTesterTree &tree, const std::string &br_name)
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19
STL namespace.
#define private