rivet is hosted by Hepforge, IPPP Durham

#include <ParticleName.hh>

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 unique_ptr< ParticleNames_instance = nullptr

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 162 of file ParticleName.hh.


Constructor & Destructor Documentation

ParticleNames ( ) [inline, private]

Definition at line 184 of file ParticleName.hh.

                      {
        _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 211 of file ParticleName.hh.

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

Definition at line 21 of file ParticleName.cc.

                                                           {
      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 13 of file ParticleName.cc.

                                                           {
      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 171 of file ParticleName.hh.

                                                      {
        /// @todo Isn't there a nicer, pointerless way to do singletons?
        if (!_instance) _instance = unique_ptr<ParticleNames>(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 165 of file ParticleName.hh.

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

Member Data Documentation

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

Definition at line 218 of file ParticleName.hh.

unique_ptr< ParticleNames > _instance = nullptr [static, private]

Definition at line 216 of file ParticleName.hh.

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

Definition at line 220 of file ParticleName.hh.


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