2   Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 
    4 #ifndef MUONTESTER_AUXELEMENTBRANCH_IXX
 
    5 #define MUONTESTER_AUXELEMENTBRANCH_IXX
 
    8 //########################################################################################
 
   10 //########################################################################################
 
   12 template <class T> void AuxElementBranch<T>::setAccessor(const std::string& name) {
 
   13     if (!initialized()) m_acc = SG::ConstAccessor<T>(name);
 
   15 template <class T> void AuxElementBranch<T>::push_back(const SG::AuxElement* p) {
 
   16     if (p != nullptr) push_back(*p);
 
   18 template <class T> void AuxElementBranch<T>::operator+=(const SG::AuxElement& p) { push_back(p); }
 
   19 template <class T> void AuxElementBranch<T>::operator+=(const SG::AuxElement* p) { push_back(p); }
 
   20 template <class T> void AuxElementBranch<T>::push_back(const SG::AuxElement& p) {
 
   21     if (m_acc.isAvailable(p))
 
   22         VectorBranch<T>::push_back(m_acc(p));
 
   23     else if (hasDefault()) {
 
   24         VectorBranch<T>::push_back(getDefault());
 
   26         THROW_EXCEPTION("Decoration is not available to fill " + name());
 
   30 AuxElementBranch<T>::AuxElementBranch(TTree* t, const std::string& var_name, const std::string& acc) :
 
   31     VectorBranch<T>(t, var_name), m_acc(acc.empty() ? var_name : acc) {}
 
   33 AuxElementBranch<T>::AuxElementBranch(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
 
   34     VectorBranch<T>(t, var_name), m_acc(acc.empty() ? var_name : acc) {}
 
   36 //########################################################################################
 
   37 //                      GenericAuxDecorationBranch
 
   38 //########################################################################################
 
   40     GenericAuxDecorationBranch<T>::GenericAuxDecorationBranch(TTree* t, const std::string& var_name, const FuncType_t& func):
 
   41         VectorBranch<T>(t, var_name),
 
   44     GenericAuxDecorationBranch<T>::GenericAuxDecorationBranch(MuonTesterTree& t, const std::string& var_name, const FuncType_t& func):
 
   45         VectorBranch<T>(t, var_name),
 
   48 template <class T> void GenericAuxDecorationBranch<T>::push_back(const SG::AuxElement* p) { push_back(m_func(p)); }
 
   49 template <class T> void GenericAuxDecorationBranch<T>::push_back(const SG::AuxElement& p) { push_back(&p); }
 
   50 template <class T> void GenericAuxDecorationBranch<T>::operator+=(const SG::AuxElement* p) { push_back(p); }
 
   51 template <class T> void GenericAuxDecorationBranch<T>::operator+=(const SG::AuxElement& p) { push_back(p); }
 
   52 //########################################################################################
 
   53 //                      ParticleVariableBranch
 
   54 //########################################################################################
 
   56 ParticleVariableBranch<T>::ParticleVariableBranch(TTree* t, const std::string& var_name, const std::string& acc) :
 
   57     AuxElementBranch<T>(t, var_name, acc) {}
 
   59 ParticleVariableBranch<T>::ParticleVariableBranch(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
 
   60     AuxElementBranch<T>(t, var_name, acc) {}
 
   61 template <class T> void ParticleVariableBranch<T>::push_back(const xAOD::IParticle* p) { AuxElementBranch<T>::push_back(p); }
 
   62 template <class T> void ParticleVariableBranch<T>::push_back(const xAOD::IParticle& p) { AuxElementBranch<T>::push_back(p); }
 
   63 template <class T> void ParticleVariableBranch<T>::operator+=(const xAOD::IParticle* p) { AuxElementBranch<T>::push_back(p); }
 
   64 template <class T> void ParticleVariableBranch<T>::operator+=(const xAOD::IParticle& p) { AuxElementBranch<T>::push_back(p); }
 
   66 //########################################################################################
 
   67 //                      ParticleVariableBranchGeV
 
   68 //########################################################################################
 
   70 ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(TTree* t, const std::string& var_name, const std::string& acc) :
 
   71     ParticleVariableBranch<T>(t, var_name, acc) {}
 
   74 ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
 
   75     ParticleVariableBranch<T>(t, var_name, acc) {}
 
   77 template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle* p) {
 
   80 template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle& p) {
 
   82     ParticleVariableBranch<T>::push_back(p);
 
   83     constexpr double MeVtoGeV = 1.e-3;