ParticleName.cc
Go to the documentation of this file.
00001 #include "Rivet/ParticleName.hh" 00002 #include "Rivet/Tools/RivetBoost.hh" 00003 #include "Rivet/Tools/Utils.hh" 00004 00005 namespace Rivet { 00006 00007 namespace PID { 00008 00009 00010 // Initialise ParticleNames singleton pointer 00011 ParticleNames* ParticleNames::_instance = 0; 00012 00013 00014 const std::string& ParticleNames::_particleName(PdgId pid) { 00015 if (_ids_names.find(pid) == _ids_names.end()) { 00016 throw PidError("Particle ID '" + lexical_cast<string>(pid) + "' not known."); 00017 } 00018 return _ids_names[pid]; 00019 } 00020 00021 00022 PdgId ParticleNames::_particleId(const std::string& pname) { 00023 if (_names_ids.find(pname) == _names_ids.end()) { 00024 if (toUpper(pname) == "P+" || toUpper(pname) == "P") return PROTON; 00025 if (toUpper(pname) == "P-" || toUpper(pname) == "PBAR") return ANTIPROTON; 00026 if (toUpper(pname) == "E-") return ELECTRON; 00027 if (toUpper(pname) == "E+") return POSITRON; 00028 if (toUpper(pname) == "GAMMA") return PHOTON; 00029 if (toUpper(pname) == "N") return NEUTRON; 00030 try { 00031 PdgId rtn = lexical_cast<PdgId>(pname); 00032 return rtn; 00033 } catch (const bad_lexical_cast& blc) { 00034 throw PidError("Particle name '" + pname + "' not known and could not be directly cast to a PDG ID."); 00035 } 00036 } 00037 return _names_ids[pname]; 00038 } 00039 00040 00041 } 00042 00043 } Generated on Thu Feb 6 2014 17:38:46 for The Rivet MC analysis system by ![]() |