Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LinkerBranch.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 #include <format>
6 namespace MuonVal{
8  ParticleBranch_ptr linkColl,
9  Linker_t linker,
10  const std::string& altName):
12  std::format("{:}_{:}Link", parent.name(), altName.empty() ? linkColl->name() : altName)},
13  m_linkColl{linkColl},
14  m_linkerFunc{std::move(linker)} {}
15 
17  push_back(p);
18  }
20  push_back(p);
21  }
23  push_back(&p);
24  }
26  const xAOD::IParticle* related = m_linkerFunc(p);
27  if (related) {
28  ParticleBranch_ptr linkColl = m_linkColl.lock();
29  linkColl->push_back(related);
30  VectorBranch<unsigned short>::push_back(linkColl->find(related));
31  } else {
33  }
34  }
35 
36 
38  ParticleBranch_ptr secondColl,
39  Linker_t fromPrimToSec,
40  const std::string& altPrimName,
41  const std::string& altSecName) {
42  return primColl->addVariable(std::make_unique<LinkerBranch>(*primColl, secondColl, fromPrimToSec, altPrimName)) &&
43  secondColl->addVariable(std::unique_ptr<IParticleDecorationBranch>{new BilateralLinkerBranch(*secondColl, primColl, fromPrimToSec, altSecName)});
44  }
45 
47  ParticleBranch_ptr primColl,
48  Linker_t linker,
49  const std::string& altName):
51  std::format("{:}_{:}Link", parent.name(), altName.empty() ? primColl->name() : altName)},
52  m_parent{parent},
53  m_linkColl{primColl},
54  m_linkerFunc{std::move(linker)} {
55  setDefault(-1);
56  }
57 
59  }
61  push_back(&p);
62  }
64  push_back(p);
65  }
67  push_back(p);
68  }
69  bool BilateralLinkerBranch::fill(const EventContext& ctx) {
70  ATH_MSG_VERBOSE("Fill "<<name()<<", size: "<<m_parent.size()<<", "<<m_parent.name());
71  if (m_parent.size()) {
73  get(m_parent.size() -1);
74  ParticleBranch_ptr linkColl = m_linkColl.lock();
75  const std::vector<const xAOD::IParticle*>& linkeMe = linkColl->getCached();
76  for (std::size_t primToSec = 0 ; primToSec < linkeMe.size(); ++primToSec) {
77  const size_t linkIdx = m_parent.find(m_linkerFunc(linkeMe[primToSec]));
78  if (linkIdx < size()) {
79  get(linkIdx) = primToSec;
80  }
81  }
82  }
84  }
85 }
MuonVal::BilateralLinkerBranch::m_parent
const IParticleFourMomBranch & m_parent
Definition: LinkerBranch.h:76
MuonVal::BilateralLinkerBranch::Linker_t
LinkerBranch::Linker_t Linker_t
Definition: LinkerBranch.h:54
vtune_athena.format
format
Definition: vtune_athena.py:14
LinkerBranch.h
xAOD::short
short
Definition: Vertex_v1.cxx:165
MuonVal::BilateralLinkerBranch::push_back
void push_back(const xAOD::IParticle *p) override
Interface methods to handle the particle.
Definition: LinkerBranch.cxx:58
MuonVal::VectorBranch
Definition: VectorBranch.h:14
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonVal::LinkerBranch::Linker_t
std::function< const xAOD::IParticle *(const xAOD::IParticle *)> Linker_t
Typedef of the linker function.
Definition: LinkerBranch.h:25
MuonVal::LinkerBranch::LinkerBranch
LinkerBranch(IParticleFourMomBranch &parent, ParticleBranch_ptr linkColl, Linker_t linker, const std::string &altName="")
Standard constructor fo the LinkerBranch.
Definition: LinkerBranch.cxx:7
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
MuonVal::BilateralLinkerBranch::ParticleBranch_ptr
LinkerBranch::ParticleBranch_ptr ParticleBranch_ptr
Definition: LinkerBranch.h:55
MuonVal::LinkerBranch::m_linkColl
std::weak_ptr< IParticleFourMomBranch > m_linkColl
Definition: LinkerBranch.h:47
MuonVal::BilateralLinkerBranch::fill
bool fill(const EventContext &ctx) override
The fill method checks if enough information is provided such that the branch is cleared from the inf...
Definition: LinkerBranch.cxx:69
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MuonVal::BilateralLinkerBranch::m_linkerFunc
Linker_t m_linkerFunc
Definition: LinkerBranch.h:78
MuonVal::VectorBranch::fill
bool fill(const EventContext &ctx) override
Clears vector in cases that it has not been updated in this event Retursn falls if the vector has not...
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MuonVal::IParticleFourMomBranch::size
size_t size() const
How many particles have been pushed back already.
Definition: IParticleFourMomBranch.cxx:28
MuonVal::BilateralLinkerBranch::connectCollections
static bool connectCollections(ParticleBranch_ptr primColl, ParticleBranch_ptr secondColl, Linker_t fromPrimToSec, const std::string &altPrimName="", const std::string &altSecName="")
Definition: LinkerBranch.cxx:37
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
MuonVal::LinkerBranch::operator+=
void operator+=(const xAOD::IParticle *p) override
Definition: LinkerBranch.cxx:16
MuonVal::BilateralLinkerBranch::operator+=
void operator+=(const xAOD::IParticle *p) override
Definition: LinkerBranch.cxx:63
MuonVal
Class to store array like branches into the n-tuples.
Definition: HitValAlg.cxx:19
MuonVal::MuonTesterTree::name
std::string name() const
Name of the tree.
Definition: MuonTesterTree.cxx:20
MuonVal::LinkerBranch::m_linkerFunc
Linker_t m_linkerFunc
Definition: LinkerBranch.h:48
MuonVal::BilateralLinkerBranch::m_linkColl
std::weak_ptr< IParticleFourMomBranch > m_linkColl
Definition: LinkerBranch.h:77
MuonVal::MuonTesterBranch::parent
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
Definition: MuonTesterBranch.cxx:38
MuonVal::IMuonTesterBranch::name
virtual std::string name() const =0
Returns the name of the branch.
MuonVal::IParticleFourMomBranch::name
std::string name() const override
Name of the four momentum branch.
Definition: IParticleFourMomBranch.cxx:29
MuonVal::BilateralLinkerBranch::BilateralLinkerBranch
BilateralLinkerBranch(IParticleFourMomBranch &bilatColl, ParticleBranch_ptr primColl, Linker_t linker, const std::string &altName)
Definition: LinkerBranch.cxx:46
MuonVal::VectorBranch< unsigned short >::get
unsigned short & get(size_t idx)
MuonVal::VectorBranch< unsigned short >::size
size_t size() const
Returns the number of actual saved elements.
MuonVal::IParticleFourMomBranch
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTr...
Definition: IParticleFourMomBranch.h:31
MuonVal::MuonTesterTree::tree
TTree * tree()
TTree object.
Definition: MuonTesterTree.cxx:22
MuonVal::LinkerBranch::ParticleBranch_ptr
std::shared_ptr< IParticleFourMomBranch > ParticleBranch_ptr
Abreviation of the pointer to the particle branch.
Definition: LinkerBranch.h:21
MuonVal::IParticleFourMomBranch::find
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 ...
Definition: IParticleFourMomBranch.cxx:65
MuonVal::LinkerBranch::push_back
void push_back(const xAOD::IParticle *p) override
Interface methods to handle the particle.
Definition: LinkerBranch.cxx:25