ATLAS Offline Software
Loading...
Searching...
No Matches
VectorBranch.h
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTESTER_MUONVECTORBRANCH_H
5#define MUONTESTER_MUONVECTORBRANCH_H
6
8#include <vector>
9#include <string>
10class TTree;
11// Implementation to store vector like variables
12namespace MuonVal {
13class MuonTesterTree;
14template <class T> class VectorBranch : public MuonTesterBranch, virtual public IMuonTesterBranch {
15public:
17 VectorBranch(TTree* tree, const std::string& name);
18 VectorBranch(MuonTesterTree& tree, const std::string& name);
19
21 VectorBranch(TTree* tree, const std::string& name, const T& def);
22 VectorBranch(MuonTesterTree& tree, const std::string& name, const T& def);
23
24 virtual ~VectorBranch() = default;
25
28 bool fill(const EventContext& ctx) override;
30 bool init() override;
31
33 inline size_t size() const;
34
36 inline void push_back(const T& value);
37 inline void operator+=(const T& value);
38
39 inline const std::vector<T>& operator=(const std::vector<T>& values);
40
44 inline T& operator[](size_t idx);
45 inline T& get(size_t idx);
46
47 inline const T& getDefault() const;
48 void setDefault(const T& def);
49
50 inline bool isUpdated() const;
51 inline bool hasDefault() const;
52
53private:
54 std::vector<T> m_variable{};
56 bool m_hasDefault{false};
57 bool m_updated{false};
58};
59
60template <> bool& VectorBranch<bool>::get(size_t idx);
61}
63#endif
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)
bool isUpdated() const
size_t size() const
Returns the number of actual saved elements.
void push_back(const T &value)
Adds a new element at the end of the vector.
bool fill(const EventContext &ctx) override
Clears vector in cases that it has not been updated in this event Retursn falls if the vector has not...
const T & getDefault() const
VectorBranch(MuonTesterTree &tree, const std::string &name, const T &def)
void setDefault(const T &def)
T & get(size_t idx)
bool hasDefault() const
VectorBranch(TTree *tree, const std::string &name)
Standard constructor.
virtual ~VectorBranch()=default
T & operator[](size_t idx)
Accesses the idx-th element.
VectorBranch(TTree *tree, const std::string &name, const T &def)
Constructor with assigned default value.
const std::vector< T > & operator=(const std::vector< T > &values)
std::vector< T > m_variable
VectorBranch(MuonTesterTree &tree, const std::string &name)
void operator+=(const T &value)
bool init() override
Initialized the Branch.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19