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
12#include <string_view>
13#include <span>
14
15namespace MuonVal {
35 public:
40 IParticleFourMomBranch(MuonTesterTree& tree, const std::string& particle);
42 bool fill(const EventContext& ctx) override;
44 bool init() override;
46 std::string name() const override;
48 const TTree* tree() const override;
49 TTree* tree() override;
50
54 bool initialized() const;
56 std::vector<DataDependency> data_dependencies() override;
58 size_t size() const;
59
60 void push_back(const xAOD::IParticle* p) override;
61 void push_back(const xAOD::IParticle& p) override;
62 void operator+=(const xAOD::IParticle* p) override;
63 void operator+=(const xAOD::IParticle& p) override;
64
65
70 size_t find(const xAOD::IParticle& p) const;
71 size_t find(const xAOD::IParticle* p) const;
75 size_t find(std::function<bool(const xAOD::IParticle*)> func) const;
77 std::span<const xAOD::IParticle* const> getCached(const EventContext& ctx);
85 template <typename T>
86 bool addVariable(const std::string& variable,
87 std::string_view accName = "");
94 template <typename T>
95 bool addVariable(T defaultValue,
96 const std::string& variable,
97 std::string_view accName = "");
98
104 template <typename T>
105 bool addVariableGeV(const std::string& variable,
106 const std::string& accName = "");
113 template <typename T>
114 bool addVariableGeV(T defaultValue,
115 const std::string& variable,
116 const std::string& accName = "");
117
122 template <typename T>
123 std::shared_ptr<ParticleVariableBranch<T>> getBranch(const std::string& var) const;
124
125 bool addVariable(std::shared_ptr<IParticleDecorationBranch> branch);
126
127
128 private:
130 std::string m_name{};
131 bool m_init{false};
132 bool m_updated{false};
138
139 std::vector<std::shared_ptr<IParticleDecorationBranch>> m_variables{};
140 std::vector<const xAOD::IParticle*> m_cached_particles{};
141
142 using evt_t = EventIDBase::event_number_t;
143 evt_t m_lastFilled{std::numeric_limits<evt_t>::max()};
144};
145
146}
148#endif
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
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...
std::span< const xAOD::IParticle *const > getCached(const EventContext &ctx)
Returns the list of currently cached particles.
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
EventIDBase::event_number_t evt_t
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