ATLAS Offline Software
Loading...
Searching...
No Matches
IParticleFourMomBranch.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_H
5#define MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_H
6
11#include <string_view>
12
13namespace MuonVal {
33 public:
38 IParticleFourMomBranch(MuonTesterTree& tree, const std::string& particle);
40 bool fill(const EventContext& ctx) override;
42 bool init() override;
44 std::string name() const override;
46 const TTree* tree() const override;
47 TTree* tree() override;
48
52 bool initialized() const;
54 std::vector<DataDependency> data_dependencies() override;
56 size_t size() const;
57
58 void push_back(const xAOD::IParticle* p) override;
59 void push_back(const xAOD::IParticle& p) override;
60 void operator+=(const xAOD::IParticle* p) override;
61 void operator+=(const xAOD::IParticle& p) override;
62
63
68 size_t find(const xAOD::IParticle& p) const;
69 size_t find(const xAOD::IParticle* p) const;
73 size_t find(std::function<bool(const xAOD::IParticle*)> func) const;
75 const std::vector<const xAOD::IParticle*>& getCached() const;
83 template <typename T>
84 bool addVariable(const std::string& variable,
85 std::string_view accName = "");
92 template <typename T>
93 bool addVariable(T defaultValue,
94 const std::string& variable,
95 std::string_view accName = "");
96
102 template <typename T>
103 bool addVariableGeV(const std::string& variable,
104 const std::string& accName = "");
111 template <typename T>
112 bool addVariableGeV(T defaultValue,
113 const std::string& variable,
114 const std::string& accName = "");
115
120 template <typename T>
121 std::shared_ptr<ParticleVariableBranch<T>> getBranch(const std::string& var) const;
122
123 bool addVariable(std::shared_ptr<IParticleDecorationBranch> branch);
124
125
126 private:
128 std::string m_name{};
129 bool m_init{false};
130 bool m_updated{false};
136
137 std::vector<std::shared_ptr<IParticleDecorationBranch>> m_variables{};
138 std::vector<const xAOD::IParticle*> m_cached_particles{};
139};
140
141}
143#endif
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const std::vector< const xAOD::IParticle * > & getCached() const
Returns the list of currently cached particles.
void operator+=(const xAOD::IParticle *p) override
std::vector< DataDependency > data_dependencies() override
Returns a list of all Read(Coond)HandleKeys needed by the branch.
bool addVariable(const std::string &variable, std::string_view accName="")
Writes a variable of type <T> which can be directly accessed via an SG::AuxElement e....
bool addVariable(T defaultValue, const std::string &variable, std::string_view accName="")
Write a variable of type <T> to the TTree.
size_t size() const
How many particles have been pushed back already.
std::shared_ptr< ParticleVariableBranch< T > > getBranch(const std::string &var) const
Returns the point to the underlying ParticleVariableBranch translating the IParticle Accessors into T...
IParticleFourMomBranch(MuonTesterTree &tree, const std::string &particle)
Construct an IParticleFourMomBranch.
bool fill(const EventContext &ctx) override
Fill the branch.
MuonTesterTree & getTree()
Access to the MuonTrestTree parent.
bool addVariableGeV(T defaultValue, const std::string &variable, const std::string &accName="")
Write a variable of type <T> to the TTree, but divide it by 1k before dumping.
bool addVariableGeV(const std::string &variable, const std::string &accName="")
Write a variable of type <T> to the TTree, but divide it by 1k before dumping.
std::vector< const xAOD::IParticle * > m_cached_particles
size_t find(const xAOD::IParticle &p) const
Returns the position at which the particle has already be inserted in the chain – If the particle is ...
bool initialized() const
Has the init method been called.
void push_back(const xAOD::IParticle *p) override
Similar to the IAuxElementDecoration branch but only accepting IParticles.
std::vector< std::shared_ptr< IParticleDecorationBranch > > m_variables
std::string name() const override
Name of the four momentum branch.
const TTree * tree() const override
Return the underyling TTree pointer.
bool init() override
Initialize the branches and all children.
Class providing the definition of the 4-vector interface.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19