ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleVariables.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
7
8namespace MuonPRDTest {
10 const std::string& containerKey,
11 const std::string& outName,
12 MSG::Level msglvl) :
13 PrdTesterModule(tree, "Particles"+ containerKey+outName, msglvl),
14 m_key{containerKey},
15 m_branch{std::make_shared<IParticleFourMomBranch>(tree, outName)} {}
16
17 bool ParticleVariables::fill(const EventContext& ctx) {
18 SG::ReadHandle readHandle{m_key, ctx};
19 if(!readHandle.isPresent()) {
20 ATH_MSG_FATAL("Failed to retrieve "<<m_key.fullKey());
21 return false;
22 }
23 for (const xAOD::IParticle* particle : *readHandle){
24 m_branch->push_back(particle);
25 }
26 return true;
27 }
29 return declare_dependency(m_key) &&
30 std::ranges::find_if(m_decorKeys,[this](DecorKey_t& key) {
31 return !declare_dependency(key);
32 }) == m_decorKeys.end() &&
34 }
35 void ParticleVariables::declare_decorator(const std::string& decorName) {
36 if (decorName.empty()){
37 ATH_MSG_WARNING("Empty decorator names are not allowed");
38 } else {
39 m_decorKeys.emplace_back(m_key, decorName);
40 ATH_MSG_DEBUG("Declare new dependency on "<<m_decorKeys.back().fullKey());
41 }
42 }
43 bool ParticleVariables::addVariable(std::shared_ptr<IParticleDecorationBranch> branch) {
44 return m_branch->addVariable(std::move(branch));
45 }
47 m_branch->push_back(p);
48 return m_branch->find(p);
49 }
50
51}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
std::shared_ptr< IParticleFourMomBranch > m_branch
SG::ReadHandleKey< xAOD::IParticleContainer > m_key
void declare_decorator(const std::string &decorName)
Declares the dependency on a decorator.
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_decorKeys
size_t push_back(const xAOD::IParticle *p)
bool addVariable(const std::string &variable, const bool declareDep=false)
Adds a variable of the primitive data type that can be directly read-off from the xAOD::IParticle as ...
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
SG::ReadDecorHandleKey< xAOD::IParticleContainer > DecorKey_t
ParticleVariables(MuonTesterTree &tree, const std::string &containerKey, const std::string &outName, MSG::Level msglvl)
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTr...
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.
bool isPresent() const
Is the referenced object present in SG?
Class providing the definition of the 4-vector interface.
STL namespace.