ATLAS Offline Software
VectorBranch.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2023 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>
10 class TTree;
11 // Implementation to store vector like variables
12 namespace MuonVal {
13 class MuonTesterTree;
14 template <class T> class VectorBranch : public MuonTesterBranch, virtual public IMuonTesterBranch {
15 public:
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 
42  inline T& operator[](size_t idx);
43  inline T& get(size_t idx);
44 
45  inline const T& getDefault() const;
46  void setDefault(const T& def);
47 
48  inline bool isUpdated() const;
49  inline bool hasDefault() const;
50 
51 private:
52  std::vector<T> m_variable{};
53  T m_default{};
54  bool m_hasDefault{false};
55  bool m_updated{false};
56 };
57 
58 template <> bool& VectorBranch<bool>::get(size_t idx);
59 }
61 #endif
MuonVal::IMuonTesterBranch::tree
virtual TTree * tree()=0
Returns the pointer to the underlying TTree object.
MuonVal::VectorBranch::VectorBranch
VectorBranch(TTree *tree, const std::string &name, const T &def)
Constructor with assigned default value.
MuonVal::VectorBranch::setDefault
void setDefault(const T &def)
MuonVal::VectorBranch::VectorBranch
VectorBranch(MuonTesterTree &tree, const std::string &name)
MuonVal::MuonTesterBranch
Definition: MuonTesterBranch.h:21
MuonVal::VectorBranch::~VectorBranch
virtual ~VectorBranch()=default
MuonVal::VectorBranch::hasDefault
bool hasDefault() const
athena.value
value
Definition: athena.py:124
MuonVal::VectorBranch
Definition: VectorBranch.h:14
MuonVal::VectorBranch::isUpdated
bool isUpdated() const
VectorBranch.icc
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonVal::VectorBranch::getDefault
const T & getDefault() const
MuonVal::VectorBranch::m_variable
std::vector< T > m_variable
Definition: VectorBranch.h:52
MuonVal::VectorBranch::fill
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...
MuonVal::VectorBranch::operator[]
T & operator[](size_t idx)
Accesses the idx-th element.
MuonVal::VectorBranch::m_hasDefault
bool m_hasDefault
Definition: VectorBranch.h:54
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonTesterBranch.h
MuonVal::VectorBranch::m_default
T m_default
Definition: VectorBranch.h:53
MuonVal::IMuonTesterBranch::name
virtual std::string name() const =0
Returns the name of the branch.
MuonVal::VectorBranch::m_updated
bool m_updated
Definition: VectorBranch.h:55
MuonVal::VectorBranch::VectorBranch
VectorBranch(MuonTesterTree &tree, const std::string &name, const T &def)
MuonVal::VectorBranch::init
bool init() override
Initialized the Branch.
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
MuonVal::VectorBranch::get
T & get(size_t idx)
MuonVal::VectorBranch::size
size_t size() const
Returns the number of actual saved elements.
MuonVal::VectorBranch::operator+=
void operator+=(const T &value)
MuonVal::IMuonTesterBranch
Most basic interface class used by the MuonTester tree.
Definition: IMuonTesterBranch.h:20
MuonVal::VectorBranch::VectorBranch
VectorBranch(TTree *tree, const std::string &name)
Standard constructor.