Belle II Software  release-05-01-25
ParticleListHelper.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/DecayDescriptor/ParticleListHelper.h>
12 #include <analysis/DecayDescriptor/ParticleListName.h>
13 #include <analysis/DecayDescriptor/DecayDescriptor.h>
14 
15 namespace Belle2 {
20  void ParticleListHelper::registerList(const std::string& listname, bool save)
21  {
22  DecayDescriptor decayDescriptor;
23  bool valid = decayDescriptor.init(listname);
24  if (!valid)
25  throw std::runtime_error("Invalid ParticleList name: '" + listname + "' Should be EVTPDLNAME[:LABEL], e.g. B+ or B+:mylist.");
26  ParticleListHelper::registerList(decayDescriptor, save);
27  }
28 
29  void ParticleListHelper::registerList(const DecayDescriptor& decay, bool save)
30  {
31  auto listname = decay.getMother()->getFullName();
32  m_pdg = decay.getMother()->getPDGCode();
33  auto storeFlags = save ? DataStore::c_WriteOut : DataStore::c_DontWriteOut;
34  m_particles.registerInDataStore(storeFlags);
35  m_list.registerInDataStore(listname, storeFlags);
36  auto antiListName = ParticleListName::antiParticleListName(listname);
37  if (antiListName != listname) {
38  m_antiList.emplace(antiListName);
39  m_antiList->registerInDataStore(storeFlags);
40  }
41  }
43  {
44  m_list.create();
45  m_list->initialize(m_pdg, m_list.getName());
46  if (m_antiList) {
47  m_antiList->create();
48  (*m_antiList)->initialize(-m_pdg, m_antiList->getName());
49  m_list->bindAntiParticleList(**m_antiList);
50  }
51  }
53 }
Belle2::DataStore::c_DontWriteOut
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:73
Belle2::ParticleListName::antiParticleListName
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Definition: ParticleListName.cc:10
Belle2::ParticleListHelper::m_list
StoreObjPtr< ParticleList > m_list
Store object for the list.
Definition: ParticleListHelper.h:123
Belle2::ParticleListHelper::m_pdg
int m_pdg
PDG code of the list.
Definition: ParticleListHelper.h:127
Belle2::DataStore::c_WriteOut
@ c_WriteOut
Object/array should be saved by output modules.
Definition: DataStore.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ParticleListHelper::m_particles
StoreArray< Particle > m_particles
Store array for the particles.
Definition: ParticleListHelper.h:121
Belle2::ParticleListHelper::m_antiList
std::optional< StoreObjPtr< ParticleList > > m_antiList
Optional store object for the conjugated list if that exists.
Definition: ParticleListHelper.h:125
Belle2::ParticleListHelper::registerList
void registerList(const std::string &listname, bool save=true)
Register a list by name.
Definition: ParticleListHelper.cc:28
Belle2::ParticleListHelper::create
void create()
Create the list objects.
Definition: ParticleListHelper.cc:50
Belle2::DecayDescriptor
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Definition: DecayDescriptor.h:43