ParticleNames Class Reference

#include <ParticleName.hh>

Collaboration diagram for ParticleNames:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 68 of file ParticleName.hh.


Public Member Functions

const std::string & _particleName (PdgId pid)
PdgId _particleId (const std::string &pname)

Static Public Member Functions

static const std::string & particleName (PdgId pid)
static PdgId particleId (const std::string &pname)

Private Member Functions

 ParticleNames ()
void _add_pid_name (PdgId pid, const std::string &pname)

Private Attributes

std::map< PdgId, std::string > _ids_names
std::map< std::string, PdgId_names_ids

Static Private Attributes

static ParticleNames_instance = 0

Constructor & Destructor Documentation

ParticleNames (  )  [inline, private]

Definition at line 92 of file ParticleName.hh.

References ParticleNames::_add_pid_name(), Rivet::ANTIMUON, Rivet::ANTINEUTRON, Rivet::ANTIPROTON, Rivet::ANTITAU, Rivet::ANY, Rivet::ELECTRON, Rivet::HIGGS, Rivet::MUON, Rivet::NEUTRON, Rivet::NU_E, Rivet::NU_EBAR, Rivet::NU_MU, Rivet::NU_MUBAR, Rivet::NU_TAU, Rivet::NU_TAUBAR, Rivet::PHOTON, Rivet::PIMINUS, Rivet::PIPLUS, Rivet::POSITRON, Rivet::PROTON, Rivet::TAU, Rivet::WMINUSBOSON, Rivet::WPLUSBOSON, and Rivet::ZBOSON.

Referenced by ParticleNames::particleId(), and ParticleNames::particleName().

00092                     {
00093       _add_pid_name(ELECTRON, "ELECTRON");
00094       _add_pid_name(POSITRON, "POSITRON");
00095       _add_pid_name(PROTON, "PROTON");
00096       _add_pid_name(ANTIPROTON, "ANTIPROTON");
00097       _add_pid_name(PHOTON, "PHOTON");
00098       _add_pid_name(NEUTRON, "NEUTRON");
00099       _add_pid_name(ANTINEUTRON, "ANTINEUTRON");
00100       _add_pid_name(MUON, "MUON");
00101       _add_pid_name(ANTIMUON, "ANTIMUON");
00102       _add_pid_name(NU_E, "NU_E");
00103       _add_pid_name(NU_EBAR, "NU_EBAR");
00104       _add_pid_name(NU_MU, "NU_MU");
00105       _add_pid_name(NU_MUBAR, "NU_MUBAR");
00106       _add_pid_name(NU_TAU, "NU_TAU");
00107       _add_pid_name(NU_TAUBAR, "NU_TAUBAR");
00108       _add_pid_name(PIPLUS, "PIPLUS");
00109       _add_pid_name(PIMINUS, "PIMINUS");
00110       _add_pid_name(TAU, "TAU");
00111       _add_pid_name(WPLUSBOSON, "WPLUSBOSON");
00112       _add_pid_name(WMINUSBOSON, "WMINUSBOSON");
00113       _add_pid_name(ZBOSON, "ZBOSON");
00114       _add_pid_name(HIGGS, "HIGGS");
00115       _add_pid_name(ANTITAU, "ANTITAU");
00116       // _add_pid_name(PHOTOELECTRON, "PHOTOELECTRON");
00117       // _add_pid_name(PHOTOPOSITRON, "PHOTOPOSITRON");
00118       // _add_pid_name(PHOTOMUON, "PHOTOMUON");
00119       // _add_pid_name(PHOTOANTIMUON, "PHOTOANTIMUON");
00120       // _add_pid_name(PHOTOTAU, "PHOTOTAU");
00121       // _add_pid_name(PHOTOANTITAU, "PHOTOANTITAU");
00122       _add_pid_name(ANY, "*");
00123     }


Member Function Documentation

static const std::string& particleName ( PdgId  pid  )  [inline, static]

Definition at line 71 of file ParticleName.hh.

References ParticleNames::_instance, ParticleNames::_particleName(), and ParticleNames::ParticleNames().

Referenced by Rivet::toParticleName().

00071                                                     {
00072       if (!_instance) _instance = new ParticleNames();
00073       return _instance->_particleName(pid);
00074     }

static PdgId particleId ( const std::string &  pname  )  [inline, static]

Definition at line 76 of file ParticleName.hh.

References ParticleNames::_instance, ParticleNames::_particleId(), and ParticleNames::ParticleNames().

Referenced by Rivet::toParticleId().

00076                                                     {
00077       if (!_instance) _instance = new ParticleNames();
00078       return _instance->_particleId(pname);
00079     }

const std::string & _particleName ( PdgId  pid  ) 

Definition at line 13 of file ParticleName.cc.

References ParticleNames::_ids_names.

Referenced by ParticleNames::particleName().

00013                                                          {
00014     if (_ids_names.find(pid) == _ids_names.end()) {
00015       throw PidError("Particle ID '" + lexical_cast<string>(pid) + "' not known.");
00016     }
00017     return _ids_names[pid];
00018   }

PdgId _particleId ( const std::string &  pname  ) 

Definition at line 21 of file ParticleName.cc.

References ParticleNames::_names_ids, Rivet::ANTIPROTON, Rivet::ELECTRON, Rivet::NEUTRON, Rivet::PHOTON, Rivet::POSITRON, Rivet::PROTON, and Rivet::toUpper().

Referenced by ParticleNames::particleId().

00021                                                          {
00022     if (_names_ids.find(pname) == _names_ids.end()) {
00023       if (toUpper(pname) == "P+" || toUpper(pname) == "P") return PROTON;
00024       if (toUpper(pname) == "P-" || toUpper(pname) == "PBAR") return ANTIPROTON;
00025       if (toUpper(pname) == "E-") return ELECTRON;
00026       if (toUpper(pname) == "E+") return POSITRON;
00027       if (toUpper(pname) == "GAMMA") return PHOTON;
00028       if (toUpper(pname) == "N") return NEUTRON;
00029       try {
00030         PdgId rtn = lexical_cast<PdgId>(pname);
00031         return rtn;
00032       } catch (const bad_lexical_cast& blc) {
00033         throw PidError("Particle name '" + pname + "' not known and could not be directly cast to a PDG ID.");
00034       }
00035     }
00036     return _names_ids[pname];
00037   }

void _add_pid_name ( PdgId  pid,
const std::string &  pname 
) [inline, private]

Definition at line 125 of file ParticleName.hh.

References ParticleNames::_ids_names, and ParticleNames::_names_ids.

Referenced by ParticleNames::ParticleNames().

00125                                                           {
00126       _ids_names[pid] = pname;
00127       _names_ids[pname] = pid;
00128     }


Member Data Documentation

ParticleNames * _instance = 0 [static, private]

Definition at line 131 of file ParticleName.hh.

Referenced by ParticleNames::particleId(), and ParticleNames::particleName().

std::map<PdgId, std::string> _ids_names [private]

Definition at line 133 of file ParticleName.hh.

Referenced by ParticleNames::_add_pid_name(), and ParticleNames::_particleName().

std::map<std::string, PdgId> _names_ids [private]

Definition at line 135 of file ParticleName.hh.

Referenced by ParticleNames::_add_pid_name(), and ParticleNames::_particleId().


The documentation for this class was generated from the following files: