Belle II Software development
ParticleListHelper.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/DecayDescriptor/ParticleListHelper.h>
10#include <analysis/DecayDescriptor/ParticleListName.h>
11#include <analysis/DecayDescriptor/DecayDescriptor.h>
12
13namespace Belle2 {
18 void ParticleListHelper::registerList(const std::string& listname, bool save)
19 {
20 DecayDescriptor decayDescriptor;
21 bool valid = decayDescriptor.init(listname);
22 if (!valid)
23 throw std::runtime_error("Invalid ParticleList name: '" + listname + "' Should be EVTPDLNAME[:LABEL], e.g. B+ or B+:mylist.");
24 ParticleListHelper::registerList(decayDescriptor, save);
25 }
26
28 {
29 auto listname = decay.getMother()->getFullName();
30 m_pdg = decay.getMother()->getPDGCode();
31 auto storeFlags = save ? DataStore::c_WriteOut : DataStore::c_DontWriteOut;
33 m_list.registerInDataStore(listname, storeFlags);
34 auto antiListName = ParticleListName::antiParticleListName(listname);
35 if (antiListName != listname) {
36 m_antiList.emplace(antiListName);
37 m_antiList->registerInDataStore(storeFlags);
38 }
39 }
41 {
42 m_list.create();
43 m_list->initialize(m_pdg, m_list.getName());
44 if (m_antiList) {
45 m_antiList->create();
46 (*m_antiList)->initialize(-m_pdg, m_antiList->getName());
47 m_list->bindAntiParticleList(**m_antiList);
48 }
49 }
51}
@ c_WriteOut
Object/array should be saved by output modules.
Definition: DataStore.h:70
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
int getPDGCode() const
Return PDG code.
std::string getFullName() const
returns the full name of the particle full_name = name:label
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
const DecayDescriptorParticle * getMother() const
return mother.
StoreObjPtr< ParticleList > m_list
Store object for the list.
StoreArray< Particle > m_particles
Store array for the particles.
int m_pdg
PDG code of the list.
std::optional< StoreObjPtr< ParticleList > > m_antiList
Optional store object for the conjugated list if that exists.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
void registerList(const std::string &listname, bool save=true)
Register a list by name.
void create()
Create the list objects.
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Abstract base class for different kinds of events.