2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #ifndef MUONTESTER_MUONSCALARBRANCH_IXX
5 #define MUONTESTER_MUONSCALARBRANCH_IXX
9 template <class T> ScalarBranch<T>::ScalarBranch(TTree* tree, const std::string& name) : MuonTesterBranch(tree, name) {}
10 template <class T> ScalarBranch<T>::ScalarBranch(MuonTesterTree& tree, const std::string& name) : MuonTesterBranch(tree, name) {}
11 template <class T> ScalarBranch<T>::ScalarBranch(TTree* tree, const std::string& name, const T& default_value) : ScalarBranch(tree, name) {
12 setDefault(default_value);
15 ScalarBranch<T>::ScalarBranch(MuonTesterTree& tree, const std::string& name, const T& default_value) : ScalarBranch(tree, name) {
16 setDefault(default_value);
18 template <class T> bool ScalarBranch<T>::fill(const EventContext&) {
20 ATH_MSG_ERROR("init() -- The branch " << name() << " is not initialized yet.");
24 if (mustBeUpdated()) {
25 ATH_MSG_ERROR("The scalar variable " << name() << " must always be filled between a fill call ");
28 m_variable = getDefault();
33 template <class T> bool ScalarBranch<T>::init() { return addToTree(m_variable); }
34 template <class T> void ScalarBranch<T>::setValue(const T& value) { this->operator=(value); }
35 template <class T> void ScalarBranch<T>::operator=(const T& value) {
36 if (!initialized()) return;
40 template <class T> void ScalarBranch<T>::setDefault(const T& def) {
46 template <class T> void ScalarBranch<T>::disableFailing() {
47 if (!initialized()) m_failIfNotUpdated = false;
49 template <class T> const T& ScalarBranch<T>::getDefault() const { return m_default; }
50 template <class T> const T& ScalarBranch<T>::getVariable() const { return m_variable; }
51 template <class T> bool ScalarBranch<T>::mustBeUpdated() const { return m_failIfNotUpdated; }
52 template <class T> bool ScalarBranch<T>::isUpdated() const { return m_updated; }
54 template <typename T> std::ostream& operator<<(std::ostream& out, const ScalarBranch<T>& B) {
55 out << B.getVariable();