Belle II Software  release-05-02-19
EvtPDLUtil.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Anze Zupanc *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/utility/EvtPDLUtil.h>
12 #include <TDatabasePDG.h>
13 
15 {
16  TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdgCode);
17  TParticlePDG* antiParticle = particle->AntiParticle();
18 
19  return antiParticle and (particle != antiParticle);
20 }
21 
22 std::string Belle2::EvtPDLUtil::particleName(int pdgCode)
23 {
24  return TDatabasePDG::Instance()->GetParticle(pdgCode)->GetName();
25 }
26 
27 std::string Belle2::EvtPDLUtil::antiParticleName(int pdgCode)
28 {
29  return TDatabasePDG::Instance()->GetParticle(pdgCode)->AntiParticle()->GetName();
30 }
31 
32 std::string Belle2::EvtPDLUtil::antiParticleListName(int pdgCode, const std::string& label)
33 {
34  if (label.empty())
35  return antiParticleName(pdgCode);
36  return antiParticleName(pdgCode) + ":" + label;
37 }
38 
39 std::string Belle2::EvtPDLUtil::particleListName(int pdgCode, const std::string& label)
40 {
41  if (label.empty())
42  return particleName(pdgCode);
43  return particleName(pdgCode) + ":" + label;
44 }
45 
46 double Belle2::EvtPDLUtil::charge(int pdgCode)
47 {
48  return TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge() / 3.0;
49 }
Belle2::EvtPDLUtil::charge
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:46
Belle2::EvtPDLUtil::antiParticleName
std::string antiParticleName(int pdgCode)
Returns the name of the anti-particle of a particle with given pdg code.
Definition: EvtPDLUtil.cc:27
Belle2::EvtPDLUtil::particleListName
std::string particleListName(int pdgCode, const std::string &label)
Returns the name of the particle ParticleList for particles with given pdg code and with given label.
Definition: EvtPDLUtil.cc:39
Belle2::EvtPDLUtil::particleName
std::string particleName(int pdgCode)
Returns the name of a particle with given pdg code.
Definition: EvtPDLUtil.cc:22
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::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