ATLAS Offline Software
|
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTree. More...
#include <IParticleFourMomBranch.h>
Public Types | |
using | DataDependency = SG::VarHandleKey * |
Public Member Functions | |
IParticleFourMomBranch (MuonTesterTree &tree, const std::string &particle) | |
Construct an IParticleFourMomBranch. More... | |
bool | fill (const EventContext &ctx) override |
Fill the branch. More... | |
bool | init () override |
Initialize the branches and all children. More... | |
std::string | name () const override |
Name of the four momentum branch. More... | |
const TTree * | tree () const override |
Return the underyling TTree pointer. More... | |
TTree * | tree () override |
Returns the pointer to the underlying TTree object. More... | |
MuonTesterTree & | getTree () |
Access to the MuonTrestTree parent. More... | |
bool | initialized () const |
Has the init method been called. More... | |
std::vector< DataDependency > | data_dependencies () override |
Returns a list of all Read(Coond)HandleKeys needed by the branch. More... | |
size_t | size () const |
How many particles have been pushed back already. More... | |
void | push_back (const xAOD::IParticle *p) override |
Similar to the IAuxElementDecoration branch but only accepting IParticles. More... | |
void | push_back (const xAOD::IParticle &p) override |
void | operator+= (const xAOD::IParticle *p) override |
void | operator+= (const xAOD::IParticle &p) override |
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 not present then the size is returned – In cases of nullptr -1 is returned. More... | |
size_t | find (const xAOD::IParticle *p) const |
size_t | find (std::function< bool(const xAOD::IParticle *)> func) const |
Find the first particle satisfying the selection criteria given by the client. More... | |
const std::vector< const xAOD::IParticle * > & | getCached () const |
Returns the list of currently cached particles. More... | |
template<typename T > | |
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.g. More... | |
template<typename T > | |
bool | addVariable (T defaultValue, const std::string &variable, const std::string &accName="") |
Write a variable of type <T> to the TTree. More... | |
template<typename T > | |
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. More... | |
template<typename T > | |
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. More... | |
template<typename T > | |
std::shared_ptr< ParticleVariableBranch< T > > | getBranch (const std::string &var) const |
Returns the point to the underlying ParticleVariableBranch translating the IParticle Accessors into TTree branches. More... | |
bool | addVariable (std::shared_ptr< IParticleDecorationBranch > branch) |
bool | msgLvl (const MSG::Level lvl) const |
Test the output level. More... | |
MsgStream & | msg () const |
The standard message stream. More... | |
MsgStream & | msg (const MSG::Level lvl) const |
The standard message stream. More... | |
void | setLevel (MSG::Level lvl) |
Change the current logging level. More... | |
Private Member Functions | |
void | initMessaging () const |
Initialize our message level and MessageSvc. More... | |
Private Attributes | |
MuonTesterTree & | m_parent |
std::string | m_name |
bool | m_init {false} |
VectorBranch< float > | m_pt {m_parent.tree(), m_name +"_pt"} |
VectorBranch< float > | m_eta {m_parent.tree(), m_name + "_eta"} |
VectorBranch< float > | m_phi {m_parent.tree(), m_name + "_phi"} |
VectorBranch< float > | m_e {m_parent.tree(), m_name + "_e"} |
VectorBranch< int > | m_q {m_parent.tree(), m_name+"_q"} |
std::vector< std::shared_ptr< IParticleDecorationBranch > > | m_variables {} |
std::vector< const xAOD::IParticle * > | m_cached_particles {} |
std::string | m_nm |
Message source name. More... | |
boost::thread_specific_ptr< MsgStream > | m_msg_tls |
MsgStream instance (a std::cout like with print-out levels) More... | |
std::atomic< IMessageSvc * > | m_imsg { nullptr } |
MessageSvc pointer. More... | |
std::atomic< MSG::Level > | m_lvl { MSG::NIL } |
Current logging level. More... | |
std::atomic_flag m_initialized | ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT |
Messaging initialized (initMessaging) More... | |
Helper class to easily to add xAOD::IParticles and associated decorator variables to the MuonTesterTree.
The branch saves, the particle 4-momentum (E,Pt, Eta, Phi). Energy and Pt are saved in units of GeV. Extra information decorated to the particle can also easily appended to the tree output.
Potential setup:
auto part_br = std::make_shared<IParticleFourMomBranch>(m_testerTree, "TheCakeIsALie"); /// Adds a branch ptcone30 and fetches the infromation from ptcone30 part_br->addVariable<float>("ptcone30"); /// Adds a branch caloIso and fetches the information from etcone20 part_br->addVariable<float>("caloIso", "etcone20");
m_testerTree.addBranch(part_br); Then fill the branches: for (const xAOD::IParticle* part : *container) { part_br->push_back(part); }
Definition at line 31 of file IParticleFourMomBranch.h.
|
inherited |
Definition at line 39 of file IMuonTesterBranch.h.
MuonVal::IParticleFourMomBranch::IParticleFourMomBranch | ( | MuonTesterTree & | tree, |
const std::string & | particle | ||
) |
Construct an IParticleFourMomBranch.
tree | Instance of the parental MuonTesterTree to which the IParticleFourMom branch is added |
particle | Name of the IParticleFourMomBranch inside the TTree |
Definition at line 15 of file IParticleFourMomBranch.cxx.
bool MuonVal::IParticleFourMomBranch::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.g.
SG::AuxElement::Accessor<float> acc_ptCone30{"pt_cone30"}; const float ptCone30 = acc_ptCone30(*partPtr); to the TTree. If the variable is not available the filling of the TTree fails
variable | Name of the branch in the output tree |
accName | Name of the accessor to obtain the information. If left empty, it's assumed that the accesor is the same as the variable name |
bool MuonVal::IParticleFourMomBranch::addVariable | ( | std::shared_ptr< IParticleDecorationBranch > | branch | ) |
Definition at line 116 of file IParticleFourMomBranch.cxx.
bool MuonVal::IParticleFourMomBranch::addVariable | ( | T | defaultValue, |
const std::string & | variable, | ||
const std::string & | accName = "" |
||
) |
Write a variable of type <T> to the TTree.
If the information is not decorated to the particle a default value is used
defValue | Default value to use as a backup option |
variable | Name of the branch in the output tree |
accName | Name of the accessor to obtain the information. If left empty, it's assumed that the accesor is the same as the variable name |
bool MuonVal::IParticleFourMomBranch::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.
Useful for the conversion from MeV to GeV
variable | Name of the branch in the output tree | * |
accName | Name of the accessor to obtain the information. If left empty, it's assumed that the accesor is the same as the variable name |
bool MuonVal::IParticleFourMomBranch::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.
Useful for the conversion from MeV to GeV
defValue | Default value to use as a backup option |
variable | Name of the branch in the output tree |
accName | Name of the accessor to obtain the information. If left empty, it's assumed that the accesor is the same as the variable name |
|
overridevirtual |
Returns a list of all Read(Coond)HandleKeys needed by the branch.
Implements MuonVal::IMuonTesterBranch.
Definition at line 139 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Fill the branch.
Implements MuonVal::IMuonTesterBranch.
Definition at line 75 of file IParticleFourMomBranch.cxx.
size_t MuonVal::IParticleFourMomBranch::find | ( | const xAOD::IParticle & | p | ) | const |
Returns the position at which the particle has already be inserted in the chain – If the particle is not present then the size is returned – In cases of nullptr -1 is returned.
Definition at line 56 of file IParticleFourMomBranch.cxx.
size_t MuonVal::IParticleFourMomBranch::find | ( | const xAOD::IParticle * | p | ) | const |
Definition at line 59 of file IParticleFourMomBranch.cxx.
size_t MuonVal::IParticleFourMomBranch::find | ( | std::function< bool(const xAOD::IParticle *)> | func | ) | const |
Find the first particle satisfying the selection criteria given by the client.
If none of the particle is actually matching the current size of the branch is returned
Definition at line 65 of file IParticleFourMomBranch.cxx.
std::shared_ptr<ParticleVariableBranch<T> > MuonVal::IParticleFourMomBranch::getBranch | ( | const std::string & | var | ) | const |
Returns the point to the underlying ParticleVariableBranch translating the IParticle Accessors into TTree branches.
variable | Name of the branch as parsed in addVariable(GeV) |
const std::vector< const xAOD::IParticle * > & MuonVal::IParticleFourMomBranch::getCached | ( | ) | const |
Returns the list of currently cached particles.
Definition at line 24 of file IParticleFourMomBranch.cxx.
MuonTesterTree & MuonVal::IParticleFourMomBranch::getTree | ( | ) |
Access to the MuonTrestTree parent.
Definition at line 21 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Initialize the branches and all children.
Implements MuonVal::IMuonTesterBranch.
Definition at line 91 of file IParticleFourMomBranch.cxx.
bool MuonVal::IParticleFourMomBranch::initialized | ( | ) | const |
Has the init method been called.
Definition at line 88 of file IParticleFourMomBranch.cxx.
|
privateinherited |
Initialize our message level and MessageSvc.
This method should only be called once.
Definition at line 39 of file AthMessaging.cxx.
|
inlineinherited |
The standard message stream.
Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.
Definition at line 164 of file AthMessaging.h.
|
inlineinherited |
The standard message stream.
Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.
Definition at line 179 of file AthMessaging.h.
|
inlineinherited |
Test the output level.
lvl | The message level to test against |
true | Messages at level "lvl" will be printed |
Definition at line 151 of file AthMessaging.h.
|
overridevirtual |
Name of the four momentum branch.
Implements MuonVal::IMuonTesterBranch.
Definition at line 29 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Implements MuonVal::IParticleDecorationBranch.
Definition at line 33 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Implements MuonVal::IParticleDecorationBranch.
Definition at line 32 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Implements MuonVal::IParticleDecorationBranch.
Definition at line 34 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Similar to the IAuxElementDecoration branch but only accepting IParticles.
Avoid that the particle is added twice to the tree
Implements MuonVal::IParticleDecorationBranch.
Definition at line 35 of file IParticleFourMomBranch.cxx.
|
inherited |
Change the current logging level.
Use this rather than msg().setLevel() for proper operation with MT.
Definition at line 28 of file AthMessaging.cxx.
size_t MuonVal::IParticleFourMomBranch::size | ( | ) | const |
How many particles have been pushed back already.
Definition at line 28 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Return the underyling TTree pointer.
Implements MuonVal::IMuonTesterBranch.
Definition at line 30 of file IParticleFourMomBranch.cxx.
|
overridevirtual |
Returns the pointer to the underlying TTree object.
Implements MuonVal::IMuonTesterBranch.
Definition at line 31 of file IParticleFourMomBranch.cxx.
|
mutableprivateinherited |
Messaging initialized (initMessaging)
Definition at line 141 of file AthMessaging.h.
|
private |
Definition at line 136 of file IParticleFourMomBranch.h.
|
private |
Definition at line 132 of file IParticleFourMomBranch.h.
|
private |
Definition at line 130 of file IParticleFourMomBranch.h.
|
mutableprivateinherited |
MessageSvc pointer.
Definition at line 135 of file AthMessaging.h.
|
private |
Definition at line 128 of file IParticleFourMomBranch.h.
|
mutableprivateinherited |
Current logging level.
Definition at line 138 of file AthMessaging.h.
|
mutableprivateinherited |
MsgStream instance (a std::cout like with print-out levels)
Definition at line 132 of file AthMessaging.h.
|
private |
Definition at line 127 of file IParticleFourMomBranch.h.
|
privateinherited |
Message source name.
Definition at line 129 of file AthMessaging.h.
|
private |
Definition at line 126 of file IParticleFourMomBranch.h.
|
private |
Definition at line 131 of file IParticleFourMomBranch.h.
|
private |
Definition at line 129 of file IParticleFourMomBranch.h.
|
private |
Definition at line 133 of file IParticleFourMomBranch.h.
|
private |
Definition at line 135 of file IParticleFourMomBranch.h.