Belle II Software  release-08-01-10
EvtPDLUtil.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/utility/EvtPDLUtil.h>
10 #include <TDatabasePDG.h>
11 
13 {
14  TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(pdgCode);
15  TParticlePDG* antiParticle = particle->AntiParticle();
16 
17  return antiParticle and (particle != antiParticle);
18 }
19 
20 std::string Belle2::EvtPDLUtil::particleName(int pdgCode)
21 {
22  return TDatabasePDG::Instance()->GetParticle(pdgCode)->GetName();
23 }
24 
25 std::string Belle2::EvtPDLUtil::antiParticleName(int pdgCode)
26 {
27  return TDatabasePDG::Instance()->GetParticle(pdgCode)->AntiParticle()->GetName();
28 }
29 
30 std::string Belle2::EvtPDLUtil::antiParticleListName(int pdgCode, const std::string& label)
31 {
32  if (label.empty())
33  return antiParticleName(pdgCode);
34  return antiParticleName(pdgCode) + ":" + label;
35 }
36 
37 std::string Belle2::EvtPDLUtil::particleListName(int pdgCode, const std::string& label)
38 {
39  if (label.empty())
40  return particleName(pdgCode);
41  return particleName(pdgCode) + ":" + label;
42 }
43 
44 double Belle2::EvtPDLUtil::charge(int pdgCode)
45 {
46  return TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge() / 3.0;
47 }
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:30
std::string particleName(int pdgCode)
Returns the name of a particle with given pdg code.
Definition: EvtPDLUtil.cc:20
std::string antiParticleName(int pdgCode)
Returns the name of the anti-particle of a particle with given pdg code.
Definition: EvtPDLUtil.cc:25
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44
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:37
bool hasAntiParticle(int pdgCode)
Checks if the particle with given pdg code has an anti-particle or not.
Definition: EvtPDLUtil.cc:12