ATLAS Offline Software
IParticleFourMomBranch.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_H
5 #define MUONTESTERTREE_IPARTICLEFOURMOMBRANCH_H
6 
11 
12 namespace MuonVal {
32  public:
37  IParticleFourMomBranch(MuonTesterTree& tree, const std::string& particle);
39  bool fill(const EventContext& ctx) override;
41  bool init() override;
43  std::string name() const override;
45  const TTree* tree() const override;
46  TTree* tree() override;
47 
51  bool initialized() const;
53  std::vector<DataDependency> data_dependencies() override;
55  size_t size() const;
56 
57  void push_back(const xAOD::IParticle* p) override;
58  void push_back(const xAOD::IParticle& p) override;
59  void operator+=(const xAOD::IParticle* p) override;
60  void operator+=(const xAOD::IParticle& p) override;
61 
62 
67  size_t find(const xAOD::IParticle& p) const;
68  size_t find(const xAOD::IParticle* p) const;
72  size_t find(std::function<bool(const xAOD::IParticle*)> func) const;
74  const std::vector<const xAOD::IParticle*>& getCached() const;
82  template <typename T>
83  bool addVariable(const std::string& variable,
84  const std::string& accName = "");
91  template <typename T>
92  bool addVariable(T defaultValue,
93  const std::string& variable,
94  const std::string& accName = "");
95 
101  template <typename T>
102  bool addVariableGeV(const std::string& variable,
103  const std::string& accName = "");
110  template <typename T>
111  bool addVariableGeV(T defaultValue,
112  const std::string& variable,
113  const std::string& accName = "");
114 
119  template <typename T>
120  std::shared_ptr<ParticleVariableBranch<T>> getBranch(const std::string& var) const;
121 
122  bool addVariable(std::shared_ptr<IParticleDecorationBranch> branch);
123 
124 
125  private:
127  std::string m_name;
128  bool m_init{false};
134 
135  std::vector<std::shared_ptr<IParticleDecorationBranch>> m_variables{};
136  std::vector<const xAOD::IParticle*> m_cached_particles{};
137 };
138 
139 }
141 #endif
MuonVal::IParticleFourMomBranch::tree
const TTree * tree() const override
Return the underyling TTree pointer.
Definition: IParticleFourMomBranch.cxx:30
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
MuonVal::IParticleFourMomBranch::fill
bool fill(const EventContext &ctx) override
Fill the branch.
Definition: IParticleFourMomBranch.cxx:75
MuonVal::IParticleFourMomBranch::addVariable
bool addVariable(T defaultValue, const std::string &variable, const std::string &accName="")
Write a variable of type <T> to the TTree.
MuonVal::IParticleFourMomBranch::addVariableGeV
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.
MuonVal::IParticleDecorationBranch
Definition: IMuonTesterBranch.h:65
MuonVal::IParticleFourMomBranch::getCached
const std::vector< const xAOD::IParticle * > & getCached() const
Returns the list of currently cached particles.
Definition: IParticleFourMomBranch.cxx:24
MuonVal::VectorBranch< float >
MuonTesterTree.h
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
MuonVal::IParticleFourMomBranch::m_e
VectorBranch< float > m_e
Definition: IParticleFourMomBranch.h:132
MuonVal::IParticleFourMomBranch::init
bool init() override
Initialize the branches and all children.
Definition: IParticleFourMomBranch.cxx:91
IParticleFourMomBranch.icc
MuonVal::IParticleFourMomBranch::getTree
MuonTesterTree & getTree()
Access to the MuonTrestTree parent.
Definition: IParticleFourMomBranch.cxx:21
IMuonTesterBranch.h
MuonVal::IParticleFourMomBranch::m_cached_particles
std::vector< const xAOD::IParticle * > m_cached_particles
Definition: IParticleFourMomBranch.h:136
MuonVal::IParticleFourMomBranch::IParticleFourMomBranch
IParticleFourMomBranch(MuonTesterTree &tree, const std::string &particle)
Construct an IParticleFourMomBranch.
Definition: IParticleFourMomBranch.cxx:15
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MuonVal::IParticleFourMomBranch::addVariable
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....
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonVal::IParticleFourMomBranch::m_init
bool m_init
Definition: IParticleFourMomBranch.h:128
MuonVal::IParticleFourMomBranch::initialized
bool initialized() const
Has the init method been called.
Definition: IParticleFourMomBranch.cxx:88
MuonVal::IParticleFourMomBranch::m_phi
VectorBranch< float > m_phi
Definition: IParticleFourMomBranch.h:131
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonVal::IParticleFourMomBranch::size
size_t size() const
How many particles have been pushed back already.
Definition: IParticleFourMomBranch.cxx:28
python.selection.variable
variable
Definition: selection.py:33
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonVal::IParticleFourMomBranch::push_back
void push_back(const xAOD::IParticle *p) override
Similar to the IAuxElementDecoration branch but only accepting IParticles.
Definition: IParticleFourMomBranch.cxx:35
MuonVal::IParticleFourMomBranch::m_eta
VectorBranch< float > m_eta
Definition: IParticleFourMomBranch.h:130
MuonVal::IParticleFourMomBranch::operator+=
void operator+=(const xAOD::IParticle *p) override
Definition: IParticleFourMomBranch.cxx:32
MuonVal::IParticleFourMomBranch::addVariableGeV
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.
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
MuonVal::IParticleFourMomBranch::m_pt
VectorBranch< float > m_pt
Definition: IParticleFourMomBranch.h:129
MuonVal::IParticleFourMomBranch::name
std::string name() const override
Name of the four momentum branch.
Definition: IParticleFourMomBranch.cxx:29
AthMessaging.h
MuonVal::IParticleFourMomBranch::getBranch
std::shared_ptr< ParticleVariableBranch< T > > getBranch(const std::string &var) const
Returns the point to the underlying ParticleVariableBranch translating the IParticle Accessors into T...
MuonVal::IParticleFourMomBranch::data_dependencies
std::vector< DataDependency > data_dependencies() override
Returns a list of all Read(Coond)HandleKeys needed by the branch.
Definition: IParticleFourMomBranch.cxx:139
MuonVal::IParticleFourMomBranch::m_variables
std::vector< std::shared_ptr< IParticleDecorationBranch > > m_variables
Definition: IParticleFourMomBranch.h:135
AuxElementBranch.h
MuonVal::IParticleFourMomBranch::m_q
VectorBranch< int > m_q
Definition: IParticleFourMomBranch.h:133
MuonVal::IParticleFourMomBranch::m_parent
MuonTesterTree & m_parent
Definition: IParticleFourMomBranch.h:126
MuonVal::IParticleFourMomBranch
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTr...
Definition: IParticleFourMomBranch.h:31
MuonVal::IParticleFourMomBranch::m_name
std::string m_name
Definition: IParticleFourMomBranch.h:127
MuonVal::MuonTesterTree::tree
TTree * tree()
TTree object.
Definition: MuonTesterTree.cxx:22
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:56