ATLAS Offline Software
Loading...
Searching...
No Matches
AuxElementBranch.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTESTER_AUXELEMENTBRANCH_IXX
5#define MUONTESTER_AUXELEMENTBRANCH_IXX
6
7
8//########################################################################################
9// AuxElementBranch
10//########################################################################################
11namespace MuonVal {
12template <class T> void AuxElementBranch<T>::setAccessor(const std::string& name) {
13 if (!initialized()) m_acc = SG::ConstAccessor<T>(name);
14}
15template <class T> void AuxElementBranch<T>::push_back(const SG::AuxElement* p) {
16 if (p != nullptr) push_back(*p);
17}
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());
25 } else {
26 THROW_EXCEPTION("Decoration is not available to fill " + name());
27 }
28}
29template <class T>
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) {}
32template <class T>
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) {}
35
36//########################################################################################
37// GenericAuxDecorationBranch
38//########################################################################################
39template <class T>
40 GenericAuxDecorationBranch<T>::GenericAuxDecorationBranch(TTree* t, const std::string& var_name, const FuncType_t& func):
41 VectorBranch<T>(t, var_name),
42 m_func{func}{}
43template <class T>
44 GenericAuxDecorationBranch<T>::GenericAuxDecorationBranch(MuonTesterTree& t, const std::string& var_name, const FuncType_t& func):
45 VectorBranch<T>(t, var_name),
46 m_func{func}{}
47
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//########################################################################################
55template <class T>
56ParticleVariableBranch<T>::ParticleVariableBranch(TTree* t, const std::string& var_name, const std::string& acc) :
57 AuxElementBranch<T>(t, var_name, acc) {}
58template <class T>
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); }
65
66//########################################################################################
67// ParticleVariableBranchGeV
68//########################################################################################
69template <class T>
70ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(TTree* t, const std::string& var_name, const std::string& acc) :
71 ParticleVariableBranch<T>(t, var_name, acc) {}
72
73template <class T>
74ParticleVariableBranchGeV<T>::ParticleVariableBranchGeV(MuonTesterTree& t, const std::string& var_name, const std::string& acc) :
75 ParticleVariableBranch<T>(t, var_name, acc) {}
76
77template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle* p) {
78 if (p) push_back(*p);
79}
80template <class T> void ParticleVariableBranchGeV<T>::push_back(const xAOD::IParticle& p) {
81 size_t s = size();
82 ParticleVariableBranch<T>::push_back(p);
83 constexpr double MeVtoGeV = 1.e-3;
84 get(s) *= MeVtoGeV;
85}
86}
87#endif