ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonValidation
MuonPRDTest
Root
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
*/
5
#include <
MuonPRDTest/ParticleVariables.h
>
6
#include <
StoreGate/ReadHandle.h
>
7
8
namespace
MuonPRDTest
{
9
ParticleVariables::ParticleVariables
(
MuonTesterTree
&
tree
,
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)} {
tree
.addBranch(
m_branch
);}
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
}
28
bool
ParticleVariables::declare_keys
() {
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() &&
33
parent
().
addBranch
(
m_branch
);
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
}
46
size_t
ParticleVariables::push_back
(
const
xAOD::IParticle
* p) {
47
m_branch
->push_back(p);
48
return
m_branch
->find(p);
49
}
50
51
}
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ParticleVariables.h
ReadHandle.h
Handle class for reading from StoreGate.
MuonPRDTest::ParticleVariables::m_branch
std::shared_ptr< IParticleFourMomBranch > m_branch
Definition
ParticleVariables.h:88
MuonPRDTest::ParticleVariables::m_key
SG::ReadHandleKey< xAOD::IParticleContainer > m_key
Definition
ParticleVariables.h:85
MuonPRDTest::ParticleVariables::declare_decorator
void declare_decorator(const std::string &decorName)
Declares the dependency on a decorator.
Definition
ParticleVariables.cxx:35
MuonPRDTest::ParticleVariables::m_decorKeys
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_decorKeys
Definition
ParticleVariables.h:87
MuonPRDTest::ParticleVariables::push_back
size_t push_back(const xAOD::IParticle *p)
Definition
ParticleVariables.cxx:46
MuonPRDTest::ParticleVariables::addVariable
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 ...
Definition
ParticleVariables.h:30
MuonPRDTest::ParticleVariables::fill
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...
Definition
ParticleVariables.cxx:17
MuonPRDTest::ParticleVariables::DecorKey_t
SG::ReadDecorHandleKey< xAOD::IParticleContainer > DecorKey_t
Definition
ParticleVariables.h:86
MuonPRDTest::ParticleVariables::ParticleVariables
ParticleVariables(MuonTesterTree &tree, const std::string &containerKey, const std::string &outName, MSG::Level msglvl)
Definition
ParticleVariables.cxx:9
MuonPRDTest::ParticleVariables::declare_keys
bool declare_keys() override final
Definition
ParticleVariables.cxx:28
MuonPRDTest::PrdTesterModule::PrdTesterModule
PrdTesterModule(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl)
Definition
PrdTesterModule.cxx:8
MuonVal::IParticleFourMomBranch
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTr...
Definition
IParticleFourMomBranch.h:32
MuonVal::MuonTesterBranch::parent
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
Definition
MuonTesterBranch.cxx:38
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition
MuonTesterBranch.cxx:53
MuonVal::MuonTesterTree
Definition
MuonTesterTree.h:38
MuonVal::MuonTesterTree::addBranch
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.
Definition
MuonTesterTree.cxx:63
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition
StoreGate/src/VarHandleBase.cxx:400
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
MuonPRDTest
Definition
MuonHitTesterAlg.h:15
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0