Belle II Software  release-05-01-25
ParticleListName.cc
1 #include <analysis/DecayDescriptor/DecayDescriptor.h>
2 #include <analysis/DecayDescriptor/ParticleListName.h>
3 
4 #include <analysis/utility/EvtPDLUtil.h>
5 
6 #include <stdexcept>
7 
8 using namespace Belle2;
9 
10 std::string ParticleListName::antiParticleListName(const std::string& listName)
11 {
12  DecayDescriptor decayDescriptor;
13  bool valid = decayDescriptor.init(listName);
14  if (!valid)
15  throw std::runtime_error("Invalid ParticleList name: '" + listName + "' Should be EVTPDLNAME[:LABEL], e.g. B+ or B+:mylist.");
16 
17  int nProducts = decayDescriptor.getNDaughters();
18  if (nProducts > 0)
19  throw std::runtime_error("Invalid ParticleList name " + listName
20  + ". DecayString should not contain any daughters, only the mother particle.");
21 
22  const DecayDescriptorParticle* mother = decayDescriptor.getMother();
23  const int pdgCode = mother->getPDGCode();
24 
25  bool isSelfConjugatedParticle = !(EvtPDLUtil::hasAntiParticle(pdgCode));
26  if (isSelfConjugatedParticle)
27  return listName;
28  else
29  return EvtPDLUtil::antiParticleListName(pdgCode, mother->getLabel());
30 }
31 
Belle2::DecayDescriptorParticle
Represents a particle in the DecayDescriptor.
Definition: DecayDescriptorParticle.h:37
Belle2::ParticleListName::antiParticleListName
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Definition: ParticleListName.cc:10
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::EvtPDLUtil::hasAntiParticle
bool hasAntiParticle(int pdgCode)
Checks if the particle with given pdg code has an anti-particle or not.
Definition: EvtPDLUtil.cc:14
Belle2::DecayDescriptor
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
Definition: DecayDescriptor.h:43
Belle2::EvtPDLUtil::antiParticleListName
std::string antiParticleListName(int pdgCode, const std::string &label)
Returns the name of the anti-particle ParticleList for particles with given pdg code and with given l...
Definition: EvtPDLUtil.cc:32