rivet is hosted by Hepforge, IPPP Durham

#include <ParticleName.hh>

Collaboration diagram for ParticleNames:

List of all members.

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

Detailed Description

Todo:
Add axion, black hole remnant, etc. on demand

Handler for particle name code <-> string conversion

Todo:
Hide this utility class or equiv in an unnamed namespace in a .cc file.

Definition at line 157 of file ParticleName.hh.


Constructor & Destructor Documentation

ParticleNames ( ) [inline, private]

Definition at line 179 of file ParticleName.hh.

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

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

                      {
        _add_pid_name(ELECTRON, "ELECTRON");
        _add_pid_name(POSITRON, "POSITRON");
        _add_pid_name(PROTON, "PROTON");
        _add_pid_name(ANTIPROTON, "ANTIPROTON");
        _add_pid_name(PHOTON, "PHOTON");
        _add_pid_name(NEUTRON, "NEUTRON");
        _add_pid_name(ANTINEUTRON, "ANTINEUTRON");
        _add_pid_name(MUON, "MUON");
        _add_pid_name(ANTIMUON, "ANTIMUON");
        _add_pid_name(NU_E, "NU_E");
        _add_pid_name(NU_EBAR, "NU_EBAR");
        _add_pid_name(NU_MU, "NU_MU");
        _add_pid_name(NU_MUBAR, "NU_MUBAR");
        _add_pid_name(NU_TAU, "NU_TAU");
        _add_pid_name(NU_TAUBAR, "NU_TAUBAR");
        _add_pid_name(PIPLUS, "PIPLUS");
        _add_pid_name(PIMINUS, "PIMINUS");
        _add_pid_name(TAU, "TAU");
        _add_pid_name(WPLUSBOSON, "WPLUSBOSON");
        _add_pid_name(WMINUSBOSON, "WMINUSBOSON");
        _add_pid_name(ZBOSON, "ZBOSON");
        _add_pid_name(HIGGS, "HIGGS");
        _add_pid_name(ANTITAU, "ANTITAU");
        _add_pid_name(ANY, "*");
      }

Member Function Documentation

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

Definition at line 206 of file ParticleName.hh.

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

Referenced by ParticleNames::ParticleNames().

                                                            {
        _ids_names[pid] = pname;
        _names_ids[pname] = pid;
      }
PdgId _particleId ( const std::string &  pname)

Definition at line 22 of file ParticleName.cc.

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

Referenced by ParticleNames::particleId().

                                                           {
      if (_names_ids.find(pname) == _names_ids.end()) {
        if (toUpper(pname) == "P+" || toUpper(pname) == "P") return PROTON;
        if (toUpper(pname) == "P-" || toUpper(pname) == "PBAR") return ANTIPROTON;
        if (toUpper(pname) == "E-") return ELECTRON;
        if (toUpper(pname) == "E+") return POSITRON;
        if (toUpper(pname) == "GAMMA") return PHOTON;
        if (toUpper(pname) == "N") return NEUTRON;
        try {
          PdgId rtn = lexical_cast<PdgId>(pname);
          return rtn;
        } catch (const bad_lexical_cast& blc) {
          throw PidError("Particle name '" + pname + "' not known and could not be directly cast to a PDG ID.");
        }
      }
      return _names_ids[pname];
    }
const std::string & _particleName ( PdgId  pid)

Definition at line 14 of file ParticleName.cc.

References ParticleNames::_ids_names.

Referenced by ParticleNames::particleName().

                                                           {
      if (_ids_names.find(pid) == _ids_names.end()) {
        throw PidError("Particle ID '" + lexical_cast<string>(pid) + "' not known.");
      }
      return _ids_names[pid];
    }
static PdgId particleId ( const std::string &  pname) [inline, static]
Todo:
Isn't there a nicer, pointerless way to do singletons?

Definition at line 166 of file ParticleName.hh.

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

Referenced by Rivet::PID::toParticleId().

                                                      {
        /// @todo Isn't there a nicer, pointerless way to do singletons?
        if (!_instance) _instance = new ParticleNames();
        return _instance->_particleId(pname);
      }
static const std::string& particleName ( PdgId  pid) [inline, static]
Todo:
Isn't there a nicer, pointerless way to do singletons?

Definition at line 160 of file ParticleName.hh.

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

Referenced by Rivet::PID::toParticleName().

                                                      {
        /// @todo Isn't there a nicer, pointerless way to do singletons?
        if (!_instance) _instance = new ParticleNames();
        return _instance->_particleName(pid);
      }

Member Data Documentation

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

Definition at line 213 of file ParticleName.hh.

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

ParticleNames * _instance = 0 [static, private]

Definition at line 211 of file ParticleName.hh.

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

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

Definition at line 215 of file ParticleName.hh.

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


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