ParticleName.hh

Go to the documentation of this file.
00001 #ifndef RIVET_PARTICLENAME_HH
00002 #define RIVET_PARTICLENAME_HH
00003 
00004 #include "Rivet/Rivet.hh"
00005 #include "Rivet/Particle.fhh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// Enumeration of available beam particles (using PDG IDs where available)
00011   enum ParticleName {
00012     ELECTRON = 11,
00013     POSITRON = -11,
00014     PROTON = 2212,
00015     ANTIPROTON = -2212,
00016     PHOTON = 22,
00017     NEUTRON = 2112,
00018     ANTINEUTRON = -2112,
00019     MUON = 13,
00020     ANTIMUON = -13,
00021     NU_E = 12,
00022     NU_EBAR = -12,
00023     NU_MU = 14,
00024     NU_MUBAR = -14,
00025     NU_TAU = 16,
00026     NU_TAUBAR = -16,
00027     PIPLUS = 211,
00028     PIMINUS = -211,
00029     K0L = 130,
00030     K0S = 310,
00031     KPLUS = 321,
00032     KMINUS = -321,
00033     LAMBDA = 3122,
00034     LAMBDABAR = -3122,
00035     XIMINUS = 3312,
00036     XIPLUS = -3312,
00037     OMEGAMINUS = 3334,
00038     OMEGAPLUS = -3334,
00039     TAU = 15,
00040     ANTITAU = -15,
00041     EMINUS = 11,
00042     EPLUS = -11,
00043     P = 2212,
00044     PBAR = -2212,
00045     GLUON = 21,
00046     GAMMA = 22,
00047     WPLUSBOSON = 24,
00048     WMINUSBOSON = -24,
00049     ZBOSON = 23,
00050     HIGGS = 25,
00051     DQUARK = 1,
00052     UQUARK = 2,
00053     SQUARK = 3,
00054     CQUARK = 4,
00055     BQUARK = 5,
00056     TQUARK = 6,
00057     ANY = 10000,
00058     PHOTOELECTRON,
00059     PHOTOPOSITRON,
00060     PHOTOMUON,
00061     PHOTOANTIMUON,
00062     PHOTOTAU,
00063     PHOTOANTITAU
00064   };
00065 
00066 
00067   /// Convenience maker of particle ID pairs.
00068   inline std::pair<PdgId,PdgId> make_pdgid_pair(PdgId a, PdgId b) {
00069     return make_pair<PdgId,PdgId>(a, b);
00070   }
00071 
00072   /// Convenience maker of particle ID pairs.
00073   // inline std::pair<PdgId,PdgId> make_pdgid_pair(ParticleName aname, ParticleName bname) {
00074   //   return make_pdgid_pair(aname, bname);
00075   // }
00076 
00077   /// Convenience maker of particle ID pairs.
00078   inline std::pair<PdgId,PdgId> make_pdgid_pair(std::pair<ParticleName,ParticleName> pnamepair) {
00079     return make_pdgid_pair(pnamepair.first, pnamepair.second);
00080   }
00081 
00082   /// Typedef for a map of beam particle name enums to strings.
00083   typedef std::map<PdgId, std::string> ParticleNameMap;
00084 
00085 
00086   /// Typedef for a map of beam particle name strings to enums.
00087   typedef std::map<std::string, PdgId> ParticleNameMapR;
00088 
00089 
00090   /// Function which returns a map from beam particle enums to the corresponding name strings.
00091   inline ParticleNameMap getParticleNamesMap() {
00092     ParticleNameMap bpmap;
00093     bpmap[ELECTRON] = "ELECTRON";
00094     bpmap[POSITRON] = "POSITRON";
00095     bpmap[PROTON] = "PROTON";
00096     bpmap[ANTIPROTON] = "ANTIPROTON";
00097     bpmap[PHOTON] = "PHOTON";
00098     bpmap[NEUTRON] = "NEUTRON";
00099     bpmap[ANTINEUTRON] = "ANTINEUTRON";
00100     bpmap[MUON] = "MUON";
00101     bpmap[ANTIMUON] = "ANTIMUON";
00102     bpmap[NU_E] = "NU_E";
00103     bpmap[NU_EBAR] = "NU_EBAR";
00104     bpmap[NU_MU] = "NU_MU";
00105     bpmap[NU_MUBAR] = "NU_MUBAR";
00106     bpmap[NU_TAU] = "NU_TAU";
00107     bpmap[NU_TAUBAR] = "NU_TAUBAR";
00108     bpmap[PIPLUS] = "PIPLUS";
00109     bpmap[PIMINUS] = "PIMINUS";
00110     bpmap[TAU] = "TAU";
00111     bpmap[WPLUSBOSON] = "WPLUSBOSON";
00112     bpmap[WMINUSBOSON] = "WMINUSBOSON";
00113     bpmap[ZBOSON] = "ZBOSON";
00114     bpmap[HIGGS] = "HIGGS";
00115     bpmap[ANTITAU] = "ANTITAU";
00116     bpmap[PHOTOELECTRON] = "PHOTOELECTRON";
00117     bpmap[PHOTOPOSITRON] = "PHOTOPOSITRON";
00118     bpmap[PHOTOMUON] = "PHOTOMUON";
00119     bpmap[PHOTOANTIMUON] = "PHOTOANTIMUON";
00120     bpmap[PHOTOTAU] = "PHOTOTAU";
00121     bpmap[PHOTOANTITAU] = "PHOTOANTITAU";
00122     bpmap[ANY] = "*";
00123     return bpmap;
00124   }
00125 
00126 
00127   /// Function which returns a map from beam particle name strings to the corresponding enums.
00128   inline ParticleNameMapR getParticleNamesRMap() {
00129     ParticleNameMap bpmap = getParticleNamesMap();
00130     ParticleNameMapR bpmapr;
00131     for (ParticleNameMap::const_iterator bp = bpmap.begin(); bp != bpmap.end(); ++bp) {
00132       bpmapr[bp->second] = bp->first;
00133     }
00134     return bpmapr;
00135   }
00136 
00137 
00138   /// Typedef for a collection of beam particle name enums.
00139   typedef std::vector<PdgId> ParticleNameList;
00140 
00141 
00142   /// Function which returns a vector of all the beam particle values in
00143   /// the ParticleName enum.
00144   inline ParticleNameList getParticleNameEnums() {
00145     ParticleNameList names;
00146     ParticleNameMap bpmap = getParticleNamesMap();
00147     for (ParticleNameMap::const_iterator bp = bpmap.begin(); bp != bpmap.end(); ++bp) {
00148       names.push_back(bp->first);
00149     }
00150     return names;
00151   }
00152 
00153 
00154   /// Function which converts a particle name string to a ParticleName enum
00155   inline ParticleName getParticleNameEnum(const std::string& pname) {
00156     return (ParticleName) Rivet::getParticleNamesRMap()[pname];
00157   }
00158 
00159 
00160 
00161   /// Function which returns a vector of all the beam particle name strings.
00162   inline std::vector<std::string> getParticleNames() {
00163     vector<string> names;
00164     ParticleNameMap bpmap = getParticleNamesMap();
00165     for (ParticleNameMap::const_iterator bp = bpmap.begin(); bp != bpmap.end(); ++bp) {
00166       names.push_back(bp->second);
00167     }
00168     return names;
00169   }
00170 
00171 
00172   /// Print a ParticleName as a string.
00173   inline std::string toString(const ParticleName& p) {
00174     return getParticleNamesMap()[p];
00175   }
00176 
00177 
00178   /// Print a PdgId as a named string.
00179   inline std::string toParticleName(PdgId p) {
00180     if (getParticleNamesMap().find(p) != getParticleNamesMap().end()) {
00181       return getParticleNamesMap()[p];
00182     }
00183     ostringstream ss;
00184     ss << p;
00185     return ss.str();
00186   }
00187 
00188 
00189   /// Allow ParticleName to be passed to an iostream.
00190   inline std::ostream& operator<<(std::ostream& os, const ParticleName& p) {
00191     os << toString(p);
00192     return os;
00193   }
00194 
00195 
00196   /////////////////////////////////////////////////
00197   // Beams
00198 
00199   /// Print a BeamPair as a string.
00200   inline std::string toString(const BeamPair& pair) {
00201     string out = "[" +
00202       toParticleName(pair.first) + ", " +
00203       toParticleName(pair.second) + "]";
00204     return out;
00205   }
00206 
00207   /// Allow BeamPair to be passed to an ostream.
00208   inline std::ostream& operator<<(std::ostream& os, const BeamPair& bp) {
00209     os << toString(bp);
00210     return os;
00211   }
00212 
00213 
00214 }
00215 
00216 
00217 #endif