Belle II Software  release-08-01-10
ParticleListHelper Class Reference

Class to help managing creation and adding to ParticleLists. More...

#include <ParticleListHelper.h>

Collaboration diagram for ParticleListHelper:

Public Member Functions

 ParticleListHelper ()=default
 Default constructor, does nothing.
 
 ParticleListHelper (const std::string &listname, bool save=true)
 Construct and initialize right away. More...
 
void registerList (const std::string &listname, bool save=true)
 Register a list by name. More...
 
void registerList (const DecayDescriptor &decay, bool save=true)
 Register a list using a decay descriptor. More...
 
int getPDGCode () const
 Return the pdg code of the main list. More...
 
bool isSelfConjugated () const
 Return whether or not this list is self conjugated.
 
void create ()
 Create the list objects. More...
 
template<class ... Args>
Particleadd (Args &&... args)
 Add a particle to the list by forwarding all arguments to the constructor of the Particle object: Any valid arguments to construct a Belle2::Particle work here. More...
 
ParticleaddParticle (const Particle &particle)
 Non-templated convenience function to add a particle from an existing particle object.
 
ParticleaddParticle (const ROOT::Math::PxPyPzEVector &momentum, bool conjugated=false)
 Non-templated convenience function to add a particle from simple four momentum and an indicator whether it's particle or anti particle. More...
 

Private Attributes

StoreArray< Particlem_particles
 Store array for the particles.
 
StoreObjPtr< ParticleListm_list
 Store object for the list.
 
std::optional< StoreObjPtr< ParticleList > > m_antiList
 Optional store object for the conjugated list if that exists.
 
int m_pdg
 PDG code of the list.
 

Detailed Description

Class to help managing creation and adding to ParticleLists.

There's a bit of management involved when trying to create a new particle list

  • the list needs to be registered in the datastore
  • the conjugated list needs to be registered in the datastore unless the particle is self conjugated
  • the particles array needs to be registered in the datastore
  • in each event the lists need to be initialized
  • when adding a particle it needs to be added to the particles array and then with the index it has in the array it is added to the particle list

This class is managing all this in a clean interface

  1. Add one instance as member to your class
  2. in the initialize() function call registerList() with the full list name (or the DecayDescriptor)
  3. in the beginning of the event() function call create()
  4. Fill particles with add() or addParticle (the second one is for the benefit of python as currently ROOT has problems with variadic template functions forwarding arguments)

Definition at line 48 of file ParticleListHelper.h.

Constructor & Destructor Documentation

◆ ParticleListHelper()

ParticleListHelper ( const std::string &  listname,
bool  save = true 
)
inlineexplicit

Construct and initialize right away.

Useful in cases where you create these objects directly in the initialize() function of a module

Definition at line 55 of file ParticleListHelper.h.

56  {
57  registerList(listname, save);
58  }
ParticleListHelper()=default
Default constructor, does nothing.
void registerList(const std::string &listname, bool save=true)
Register a list by name.

Member Function Documentation

◆ add()

Particle& add ( Args &&...  args)
inline

Add a particle to the list by forwarding all arguments to the constructor of the Particle object: Any valid arguments to construct a Belle2::Particle work here.

It will return a reference to the created particle for further modification.

Definition at line 89 of file ParticleListHelper.h.

◆ addParticle()

Particle& addParticle ( const ROOT::Math::PxPyPzEVector &  momentum,
bool  conjugated = false 
)
inline

Non-templated convenience function to add a particle from simple four momentum and an indicator whether it's particle or anti particle.

Warning
particle/conjugates particle is based on what name was given when creating the list. If you created the list as 'anti-B0' than supplying 'conjugated=true' will create a 'B0'

Definition at line 110 of file ParticleListHelper.h.

◆ getPDGCode()

int getPDGCode ( void  ) const
inline

Return the pdg code of the main list.

If it's not a self conjugated list there is also a list with the negative pdg value

Definition at line 77 of file ParticleListHelper.h.


The documentation for this class was generated from the following files: