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//########################################################################################
12template <class T> void AuxElementBranch<T>::setAccessor(const std::string& name) {
13 if (!initialized()) m_acc = SG::ConstAccessor<T>(name);
15template <class T> void AuxElementBranch<T>::push_back(const SG::AuxElement* p) {
16 if (p != nullptr) push_back(*p);
18template <class T> void AuxElementBranch<T>::operator+=(const SG::AuxElement& p) { push_back(p); }
19template <class T> void AuxElementBranch<T>::operator+=(const SG::AuxElement* p) { push_back(p); }
20template <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());
30AuxElementBranch<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) {}
33AuxElementBranch<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),
48template <class T> void GenericAuxDecorationBranch<T>::push_back(const SG::AuxElement* p) { push_back(m_func(p)); }
49template <class T> void GenericAuxDecorationBranch<T>::push_back(const SG::AuxElement& p) { push_back(&p); }
50template <class T> void GenericAuxDecorationBranch<T>::operator+=(const SG::AuxElement* p) { push_back(p); }
51template <class T> void GenericAuxDecorationBranch<T>::operator+=(const SG::AuxElement& p) { push_back(p); }
52//########################################################################################
53// ParticleVariableBranch
54//########################################################################################
56ParticleVariableBranch<T>::ParticleVariableBranch(TTree* t, const std::string& var_name, const std::string& acc) :
57 AuxElementBranch<T>(t, var_name, acc) {}
59ParticleVariableBranch<T>::ParticleVariableBranch(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
60 AuxElementBranch<T>(t, var_name, acc) {}
61template <class T> void ParticleVariableBranch<T>::push_back(const xAOD::IParticle* p) { AuxElementBranch<T>::push_back(p); }
62template <class T> void ParticleVariableBranch<T>::push_back(const xAOD::IParticle& p) { AuxElementBranch<T>::push_back(p); }
63template <class T> void ParticleVariableBranch<T>::operator+=(const xAOD::IParticle* p) { AuxElementBranch<T>::push_back(p); }
64template <class T> void ParticleVariableBranch<T>::operator+=(const xAOD::IParticle& p) { AuxElementBranch<T>::push_back(p); }
66//########################################################################################
67// ParticleVariableBranchGeV
68//########################################################################################
70ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(TTree* t, const std::string& var_name, const std::string& acc) :
71 ParticleVariableBranch<T>(t, var_name, acc) {}
74ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
75 ParticleVariableBranch<T>(t, var_name, acc) {}
77template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle* p) {
80template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle& p) {
82 ParticleVariableBranch<T>::push_back(p);
83 constexpr double MeVtoGeV = 1.e-3;