ParticleName.hh

Go to the documentation of this file.
00001 #ifndef RIVET_PARTICLENAME_HH
00002 #define RIVET_PARTICLENAME_HH
00003 
00004 #include "Rivet/Particle.fhh"
00005 #include "Rivet/Exceptions.hh"
00006 
00007 
00008 namespace Rivet {
00009 
00010 
00011   /// @name Static const convenience particle ID names
00012   //@{
00013   static const PdgId ELECTRON = 11;
00014   static const PdgId POSITRON = -11;
00015   static const PdgId PROTON = 2212;
00016   static const PdgId ANTIPROTON = -2212;
00017   static const PdgId PHOTON = 22;
00018   static const PdgId NEUTRON = 2112;
00019   static const PdgId ANTINEUTRON = -2112;
00020   static const PdgId MUON = 13;
00021   static const PdgId ANTIMUON = -13;
00022   static const PdgId NU_E = 12;
00023   static const PdgId NU_EBAR = -12;
00024   static const PdgId NU_MU = 14;
00025   static const PdgId NU_MUBAR = -14;
00026   static const PdgId NU_TAU = 16;
00027   static const PdgId NU_TAUBAR = -16;
00028   static const PdgId PIPLUS = 211;
00029   static const PdgId PIMINUS = -211;
00030   static const PdgId K0L = 130;
00031   static const PdgId K0S = 310;
00032   static const PdgId KPLUS = 321;
00033   static const PdgId KMINUS = -321;
00034   static const PdgId LAMBDA = 3122;
00035   static const PdgId LAMBDABAR = -3122;
00036   static const PdgId XIMINUS = 3312;
00037   static const PdgId XIPLUS = -3312;
00038   static const PdgId OMEGAMINUS = 3334;
00039   static const PdgId OMEGAPLUS = -3334;
00040   static const PdgId TAU = 15;
00041   static const PdgId ANTITAU = -15;
00042   static const PdgId EMINUS = 11;
00043   static const PdgId EPLUS = -11;
00044   static const PdgId P = 2212;
00045   static const PdgId PBAR = -2212;
00046   static const PdgId GLUON = 21;
00047   static const PdgId GAMMA = 22;
00048   static const PdgId WPLUSBOSON = 24;
00049   static const PdgId WMINUSBOSON = -24;
00050   static const PdgId ZBOSON = 23;
00051   static const PdgId HIGGS = 25;
00052   static const PdgId DQUARK = 1;
00053   static const PdgId UQUARK = 2;
00054   static const PdgId SQUARK = 3;
00055   static const PdgId CQUARK = 4;
00056   static const PdgId BQUARK = 5;
00057   static const PdgId TQUARK = 6;
00058   static const PdgId ANY = 10000;
00059   // static const PdgId PHOTOELECTRON;
00060   // static const PdgId PHOTOPOSITRON;
00061   // static const PdgId PHOTOMUON;
00062   // static const PdgId PHOTOANTIMUON;
00063   // static const PdgId PHOTOTAU;
00064   // static const PdgId PHOTOANTITAU;
00065   //@}
00066 
00067 
00068   class ParticleNames {
00069   public:
00070 
00071     static const std::string& particleName(PdgId pid) {
00072       if (!_instance) _instance = new ParticleNames();
00073       return _instance->_particleName(pid);
00074     }
00075 
00076     static PdgId particleId(const std::string& pname) {
00077       if (!_instance) _instance = new ParticleNames();
00078       return _instance->_particleId(pname);
00079     }
00080 
00081 
00082   public:
00083 
00084     const std::string& _particleName(PdgId pid);
00085 
00086 
00087     PdgId _particleId(const std::string& pname);
00088 
00089 
00090   private:
00091 
00092     ParticleNames() {
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     }
00124 
00125     void _add_pid_name(PdgId pid, const std::string& pname) {
00126       _ids_names[pid] = pname;
00127       _names_ids[pname] = pid;
00128     }
00129 
00130 
00131     static ParticleNames* _instance;
00132 
00133     std::map<PdgId, std::string> _ids_names;
00134 
00135     std::map<std::string, PdgId> _names_ids;
00136 
00137   };
00138 
00139 
00140   /// Print a PdgId as a named string.
00141   inline const std::string& toParticleName(PdgId p) {
00142     return ParticleNames::particleName(p);
00143   }
00144 
00145 
00146   /// Print a PdgId as a named string.
00147   inline PdgId toParticleId(const std::string& pname) {
00148     return ParticleNames::particleId(pname);
00149   }
00150 
00151 
00152   /// Convenience maker of particle ID pairs from PdgIds.
00153   inline std::pair<PdgId,PdgId> make_pdgid_pair(PdgId a, PdgId b) {
00154     return make_pair<PdgId,PdgId>(a, b);
00155   }
00156 
00157 
00158   /// Convenience maker of particle ID pairs from particle names.
00159   inline std::pair<PdgId,PdgId> make_pdgid_pair(const std::string& a, const std::string& b) {
00160     const PdgId pa = toParticleId(a);
00161     const PdgId pb = toParticleId(b);
00162     return make_pair<PdgId,PdgId>(pa, pb);
00163   }
00164 
00165 
00166   /// Print a PdgIdPair as a string.
00167   inline std::string toBeamsString(const PdgIdPair& pair) {
00168     string out = "[" +
00169       toParticleName(pair.first) + ", " +
00170       toParticleName(pair.second) + "]";
00171     return out;
00172   }
00173 
00174 
00175 }
00176 
00177 #endif