2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 #ifndef MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_ICC
6 #define MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_ICC
10 bool IParticleFourMomBranch::addVariable(const std::string& var,
11 const std::string& acc) {
12 if (getBranch<T>(var)) {
13 ATH_MSG_WARNING("The variable "<<var<<" has already been added.");
16 return addVariable(std::make_shared<ParticleVariableBranch<T>>(this->tree(),
18 acc.empty() ? var : acc));
21 bool IParticleFourMomBranch::addVariable(T def_value,
22 const std::string& var,
23 const std::string& acc) {
24 if (!addVariable<T>(var, acc)) {
27 std::shared_ptr<ParticleVariableBranch<T>> br = getBranch<T>(var);
29 ATH_MSG_ERROR( "Failed to retrieve "<<var<<".");
32 br->setDefault(def_value);
36 bool IParticleFourMomBranch::addVariableGeV(const std::string& var,
37 const std::string& acc) {
38 if (getBranch<T>(var)) {
39 ATH_MSG_WARNING("The variable "<<var<<" has already been added.");
42 return addVariable(std::make_shared<ParticleVariableBranchGeV<T>>(this->tree(),
44 acc.empty() ? var : acc));
47 bool IParticleFourMomBranch::addVariableGeV(T def_value,
48 const std::string& var,
49 const std::string& acc) {
50 if (!addVariableGeV<T>(var, acc)) {
53 std::shared_ptr<ParticleVariableBranch<T>> br = getBranch<T>(var);
55 ATH_MSG_ERROR( "Failed to retrieve "<<var<<".");
58 br->setDefault(def_value);
63 std::shared_ptr<ParticleVariableBranch<T>> IParticleFourMomBranch::getBranch(const std::string& var) const {
64 const std::string searchMe{name() + "_" + var};
65 for (const auto& b : m_variables) {
66 if (b->name() == searchMe) {
67 return std::dynamic_pointer_cast<ParticleVariableBranch<T>>(b);
70 return std::shared_ptr<ParticleVariableBranch<T>>();