ParticleUtils.hh
Go to the documentation of this file.
00001 #ifndef RIVET_PARTICLEUTILS_HH 00002 #define RIVET_PARTICLEUTILS_HH 00003 00004 #include "Rivet/Particle.hh" 00005 #include "Rivet/Tools/ParticleIdUtils.hh" 00006 00007 // Macros to map Rivet::Particle functions to PID:: functions of the same name 00008 /// @todo Can leave return type out of the macro and put that on each line where it's used? 00009 #define PARTICLE_TO_PID_BOOLFN(fname) inline bool fname (const Particle& p) { return PID:: fname (p.pid()); } 00010 #define PARTICLE_TO_PID_INTFN(fname) inline int fname (const Particle& p) { return PID:: fname (p.pid()); } 00011 #define PARTICLE_TO_PID_DBLFN(fname) inline double fname (const Particle& p) { return PID:: fname (p.pid()); } 00012 00013 namespace Rivet { 00014 00015 00016 /// @name Particle classifier functions 00017 //@{ 00018 00019 /// Is this particle species charged? 00020 PARTICLE_TO_PID_BOOLFN(isCharged) 00021 00022 /// Is this particle species neutral? 00023 PARTICLE_TO_PID_BOOLFN(isNeutral) 00024 00025 00026 /// Is this a neutrino? 00027 PARTICLE_TO_PID_BOOLFN(isNeutrino) 00028 00029 /// Determine if the PID is that of a charged lepton 00030 PARTICLE_TO_PID_BOOLFN(isChLepton) 00031 00032 /// Determine if the PID is that of a photon 00033 PARTICLE_TO_PID_BOOLFN(isPhoton) 00034 00035 /// Determine if the PID is that of an electron or positron 00036 PARTICLE_TO_PID_BOOLFN(isElectron) 00037 00038 /// Determine if the PID is that of an muon or antimuon 00039 PARTICLE_TO_PID_BOOLFN(isMuon) 00040 00041 /// Determine if the PID is that of an tau or antitau 00042 PARTICLE_TO_PID_BOOLFN(isTau) 00043 00044 /// Determine if the PID is that of a hadron 00045 PARTICLE_TO_PID_BOOLFN(isHadron) 00046 00047 /// Determine if the PID is that of a meson 00048 PARTICLE_TO_PID_BOOLFN(isMeson) 00049 00050 /// Determine if the PID is that of a baryon 00051 PARTICLE_TO_PID_BOOLFN(isBaryon) 00052 00053 /// Determine if the PID is that of a quark 00054 PARTICLE_TO_PID_BOOLFN(isQuark) 00055 00056 /// Determine if the PID is that of a parton (quark or gluon) 00057 PARTICLE_TO_PID_BOOLFN(isParton) 00058 00059 00060 00061 /// Determine if the PID is that of a W+ 00062 PARTICLE_TO_PID_BOOLFN(isWplus) 00063 00064 /// Determine if the PID is that of a W- 00065 PARTICLE_TO_PID_BOOLFN(isWminus) 00066 00067 /// Determine if the PID is that of a W+- 00068 PARTICLE_TO_PID_BOOLFN(isW) 00069 00070 /// Determine if the PID is that of a Z0 00071 PARTICLE_TO_PID_BOOLFN(isZ) 00072 00073 /// Determine if the PID is that of an SM/lightest SUSY Higgs 00074 PARTICLE_TO_PID_BOOLFN(isHiggs) 00075 00076 /// Determine if the PID is that of a t/tbar 00077 PARTICLE_TO_PID_BOOLFN(isTop) 00078 00079 00080 /// Determine if the particle is a heavy flavour hadron or parton 00081 PARTICLE_TO_PID_BOOLFN(isHeavyFlavour) 00082 00083 /// Determine if the PID is that of a heavy parton (c,b,t) 00084 PARTICLE_TO_PID_BOOLFN(isHeavyParton) 00085 00086 /// Determine if the PID is that of a light parton (u,d,s) 00087 PARTICLE_TO_PID_BOOLFN(isLightParton) 00088 00089 00090 /// Determine if the PID is that of a heavy flavour (b or c) meson 00091 PARTICLE_TO_PID_BOOLFN(isHeavyMeson) 00092 00093 /// Determine if the PID is that of a heavy flavour (b or c) baryon 00094 PARTICLE_TO_PID_BOOLFN(isHeavyBaryon) 00095 00096 /// Determine if the PID is that of a heavy flavour (b or c) hadron 00097 PARTICLE_TO_PID_BOOLFN(isHeavyHadron) 00098 00099 00100 /// Determine if the PID is that of a light flavour (not b or c) meson 00101 PARTICLE_TO_PID_BOOLFN(isLightMeson) 00102 00103 /// Determine if the PID is that of a light flavour (not b or c) baryon 00104 PARTICLE_TO_PID_BOOLFN(isLightBaryon) 00105 00106 /// Determine if the PID is that of a light flavour (not b or c) hadron 00107 PARTICLE_TO_PID_BOOLFN(isLightHadron) 00108 00109 00110 /// Determine if the PID is that of a b-meson. 00111 PARTICLE_TO_PID_BOOLFN(isBottomMeson) 00112 00113 /// Determine if the PID is that of a b-baryon. 00114 PARTICLE_TO_PID_BOOLFN(isBottomBaryon) 00115 00116 /// Determine if the PID is that of a b-hadron. 00117 PARTICLE_TO_PID_BOOLFN(isBottomHadron) 00118 00119 00120 /// @brief Determine if the PID is that of a c-meson. 00121 /// 00122 /// Specifically, the _heaviest_ quark is a c: a B_c is a b-meson and NOT a c-meson. 00123 /// Charmonia (closed charm) are counted as c-mesons here. 00124 PARTICLE_TO_PID_BOOLFN(isCharmMeson) 00125 00126 /// @brief Determine if the PID is that of a c-baryon. 00127 /// 00128 /// Specifically, the _heaviest_ quark is a c: a baryon containing a b & c 00129 /// is a b-baryon and NOT a c-baryon. To test for the simpler case, just use 00130 /// a combination of hasCharm() and isBaryon(). 00131 PARTICLE_TO_PID_BOOLFN(isCharmBaryon) 00132 00133 /// Determine if the PID is that of a c-hadron. 00134 PARTICLE_TO_PID_BOOLFN(isCharmHadron) 00135 00136 00137 // /// Determine if the PID is that of a strange meson 00138 // PARTICLE_TO_PID_BOOLFN(isStrangeMeson) 00139 00140 // /// Determine if the PID is that of a strange baryon 00141 // PARTICLE_TO_PID_BOOLFN(isStrangeBaryon) 00142 00143 // /// Determine if the PID is that of a strange hadron 00144 // PARTICLE_TO_PID_BOOLFN(isStrangeHadron) 00145 00146 00147 00148 /// Is this a pomeron, odderon, or generic reggeon? 00149 PARTICLE_TO_PID_BOOLFN(isReggeon) 00150 00151 /// Determine if the PID is that of a diquark (used in hadronization models) 00152 PARTICLE_TO_PID_BOOLFN(isDiquark) 00153 00154 /// Determine if the PID is that of a pentaquark (hypothetical hadron) 00155 PARTICLE_TO_PID_BOOLFN(isPentaquark) 00156 00157 /// Is this a fundamental SUSY particle? 00158 PARTICLE_TO_PID_BOOLFN(isSUSY) 00159 00160 /// Is this an R-hadron? 00161 PARTICLE_TO_PID_BOOLFN(isRhadron) 00162 00163 /// Is this a technicolor particle? 00164 PARTICLE_TO_PID_BOOLFN(isTechnicolor) 00165 00166 /// Is this an excited (composite) quark or lepton? 00167 PARTICLE_TO_PID_BOOLFN(isExcited) 00168 00169 /// Is this a Kaluza-Klein excitation? 00170 PARTICLE_TO_PID_BOOLFN(isKK) 00171 00172 /// Is this a graviton? 00173 PARTICLE_TO_PID_BOOLFN(isGraviton) 00174 00175 /// Is this a BSM particle (including graviton)? 00176 PARTICLE_TO_PID_BOOLFN(isBSM) 00177 00178 00179 00180 /// Determine if the PID is in the generator-specific range 00181 PARTICLE_TO_PID_BOOLFN(isGenSpecific) 00182 00183 /// Determine if the PID is that of an EW scale resonance 00184 PARTICLE_TO_PID_BOOLFN(isResonance) 00185 00186 /// Check the PID for usability in transport codes like Geant4 00187 PARTICLE_TO_PID_BOOLFN(isTransportable) 00188 00189 00190 00191 /// Does this particle contain an up quark? 00192 PARTICLE_TO_PID_BOOLFN(hasUp) 00193 00194 /// Does this particle contain a down quark? 00195 PARTICLE_TO_PID_BOOLFN(hasDown) 00196 00197 /// Does this particle contain a strange quark? 00198 PARTICLE_TO_PID_BOOLFN(hasStrange) 00199 00200 /// Does this particle contain a charm quark? 00201 PARTICLE_TO_PID_BOOLFN(hasCharm) 00202 00203 /// Does this particle contain a bottom quark? 00204 PARTICLE_TO_PID_BOOLFN(hasBottom) 00205 00206 /// Does this particle contain a top quark? 00207 PARTICLE_TO_PID_BOOLFN(hasTop) 00208 00209 00210 00211 /// jSpin returns 2J+1, where J is the total spin 00212 PARTICLE_TO_PID_INTFN(jSpin) 00213 00214 /// sSpin returns 2S+1, where S is the spin 00215 PARTICLE_TO_PID_INTFN(sSpin) 00216 00217 /// lSpin returns 2L+1, where L is the orbital angular momentum 00218 PARTICLE_TO_PID_INTFN(lSpin) 00219 00220 00221 /// Return 3 times the charge (3 x quark charge is an int) 00222 PARTICLE_TO_PID_INTFN(threeCharge) 00223 00224 /// Return the charge 00225 PARTICLE_TO_PID_DBLFN(charge) 00226 00227 //@} 00228 00229 00230 /// @name Particle charge/sign comparison functions 00231 //@{ 00232 00233 /// @brief Return true if Particles @a a and @a b have the opposite charge sign 00234 /// @note Two neutrals returns false 00235 inline bool oppSign(const Particle& a, const Particle& b) { 00236 return sign(a.threeCharge()) == -sign(b.threeCharge()) && sign(a.threeCharge()) != ZERO; 00237 } 00238 00239 /// Return true if Particles @a a and @a b have the same charge sign 00240 /// @note Two neutrals returns true 00241 inline bool sameSign(const Particle& a, const Particle& b) { 00242 return sign(a.threeCharge()) == sign(b.threeCharge()); 00243 } 00244 00245 /// Return true if Particles @a a and @a b have the exactly opposite charge 00246 /// @note Two neutrals returns false 00247 inline bool oppCharge(const Particle& a, const Particle& b) { 00248 return a.threeCharge() == -b.threeCharge() && a.threeCharge() != 0; 00249 } 00250 00251 /// Return true if Particles @a a and @a b have the same charge (including neutral) 00252 /// @note Two neutrals returns true 00253 inline bool sameCharge(const Particle& a, const Particle& b) { 00254 return a.threeCharge() == b.threeCharge(); 00255 } 00256 00257 /// Return true if Particles @a a and @a b have a different (not necessarily opposite) charge 00258 inline bool diffCharge(const Particle& a, const Particle& b) { 00259 return a.threeCharge() != b.threeCharge(); 00260 } 00261 00262 //@} 00263 00264 00265 /// @name Particle classifying functors 00266 /// 00267 /// To be passed to any() or all() e.g. any(p.children(), HasPID(PID::MUON)) 00268 //@{ 00269 00270 /// Base type for Particle -> bool functors 00271 struct BoolParticleFunctor { 00272 virtual bool operator()(const Particle& p) const = 0; 00273 }; 00274 00275 /// PID matching functor 00276 struct HasPID : public BoolParticleFunctor { 00277 HasPID(PdgId pid) : targetpid(pid) { } 00278 bool operator()(const Particle& p) const { return p.pid() == targetpid; } 00279 PdgId targetpid; 00280 }; 00281 00282 /// |PID| matching functor 00283 struct HasAbsPID : public BoolParticleFunctor { 00284 HasAbsPID(PdgId pid) : targetpid(abs(pid)) { } 00285 bool operator()(const Particle& p) const { return p.abspid() == abs(targetpid); } 00286 PdgId targetpid; 00287 }; 00288 00289 //@} 00290 00291 00292 } 00293 00294 #endif Generated on Wed Oct 7 2015 12:09:14 for The Rivet MC analysis system by ![]() |