2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #ifndef MUONTESTER_MUONSSetBranch_IXX
5 #define MUONTESTER_MUONSSetBranch_IXX
7 #include "MuonTesterTree/throwExcept.h"
9 template <class T> SetBranch<T>::SetBranch(TTree* tree, const std::string& name) : MuonTesterBranch(tree, name) {}
11 template <class T> SetBranch<T>::SetBranch(MuonTesterTree& tree, const std::string& name) : MuonTesterBranch(tree, name) {}
13 template <class T> bool SetBranch<T>::fill(const EventContext&) {
15 ATH_MSG_ERROR("fill() -- The set branch " << name() << " is not initialized yet.");
18 if (!m_updated) m_variable.clear();
22 template <class T> bool SetBranch<T>::init() { return addToTree(m_variable); }
23 template <class T> size_t SetBranch<T>::size() const {
24 if (!m_updated) return 0;
25 return m_variable.size();
27 template <class T> std::set<T>& SetBranch<T>::operator->(){ return get();}
28 template <class T> std::set<T>& SetBranch<T>::get() {
29 if(!m_updated) m_variable.clear();
33 template <class T> void SetBranch<T>::operator=(const std::set<T>& other) {
36 template <class T> const std::set<T>& SetBranch<T>::operator->() const{ return get();}
37 template <class T> const std::set<T>& SetBranch<T>::get() const {
39 static const std::set<T> dummy{};
44 template <class T> void SetBranch<T>::insert(const T& value) {
45 if (!m_updated) m_variable.clear();
46 // Throw an exception in cases where the branch is not initialized
47 if (!initialized()) { THROW_EXCEPTION(name() + " is not initialized yet"); }
48 m_variable.insert(value);
51 template <class T> void SetBranch<T>::operator+=(const T& value) { insert(value); }
52 template <class T> bool SetBranch<T>::isUpdated() const { return m_updated; }