9 constexpr size_t dummyIdx = -1;
17 const std::string& particle):
43 if (p)
ATH_MSG_VERBOSE(
"Rejected particle ("<<p<<
") "<<p->pt()<<
", "<<p->eta()<<
", "<<p->phi()<<
". Size: "<<
size());
48 m_pt.push_back(p->pt() * MeVtoGeV);
49 m_eta.push_back(p->eta());
50 m_phi.push_back(p->phi());
51 m_e.push_back(p->e() * MeVtoGeV);
53 if (acc_charge.isAvailable(*p)) {
60 ATH_MSG_VERBOSE(
"New particle ("<<p<<
") "<<p->pt()<<
", "<<p->eta()<<
", "<<p->phi()<<
", q: "<<q<<
". Size: "<<
size());
96 if (!
m_pt.fill(ctx) || !
m_eta.fill(ctx) || !
m_phi.fill(ctx) || !
m_e.fill(ctx) || !
m_q.fill(ctx)){
100 if (!var->fill(ctx)) {
119 std::vector<IMuonTesterBranch*> branchesToInit{};
121 branchesToInit.push_back(v.get());
123 std::sort(branchesToInit.begin(), branchesToInit.end(),
125 return a->name() < b->name();
127 for (
auto& br : branchesToInit) {
138 ATH_MSG_ERROR(
"The branch is already initialized. Cannot add more branches");
140 }
else if (!branch) {
146 [&branch](
const std::shared_ptr<IParticleDecorationBranch>&
known) {
147 return known == branch || known->name() == branch->name();
150 if (
typeid((*itr).get()) !=
typeid(branch.get())) {
151 ATH_MSG_ERROR(
"Different branches have been added here under "<<branch->name()<<
".");
157 return m_parent.registerBranch(branch);
160 std::vector<DataDependency> to_ret{};
161 for (
const std::shared_ptr<IParticleDecorationBranch>& br :
m_variables) {
162 std::vector<DataDependency> childDep{br->data_dependencies()};
163 to_ret.insert(to_ret.end(),childDep.begin(), childDep.end());
#define ATH_MSG_VERBOSE(x)
double charge(const T &p)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Most basic interface class used by the MuonTester tree.
const std::vector< const xAOD::IParticle * > & getCached() const
Returns the list of currently cached particles.
void operator+=(const xAOD::IParticle *p) override
bool addVariable(const std::string &variable, const std::string &accName="")
Writes a variable of type <T> which can be directly accessed via an SG::AuxElement e....
VectorBranch< float > m_eta
std::vector< DataDependency > data_dependencies() override
Returns a list of all Read(Coond)HandleKeys needed by the branch.
VectorBranch< float > m_pt
size_t size() const
How many particles have been pushed back already.
VectorBranch< float > m_phi
IParticleFourMomBranch(MuonTesterTree &tree, const std::string &particle)
Construct an IParticleFourMomBranch.
bool fill(const EventContext &ctx) override
Fill the branch.
MuonTesterTree & m_parent
MuonTesterTree & getTree()
Access to the MuonTrestTree parent.
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.
VectorBranch< float > m_e
const TTree * tree() const override
Return the underyling TTree pointer.
bool init() override
Initialize the branches and all children.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Class providing the definition of the 4-vector interface.
Class to store array like branches into the n-tuples.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
@ TrackParticle
The object is a charged track particle.
@ TruthParticle
The object is a truth particle.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.