rivet is hosted by Hepforge, IPPP Durham
Particle.cc
Go to the documentation of this file.
00001 #include "Rivet/Particle.hh"
00002 #include "Rivet/Tools/RivetBoost.hh"
00003 #include "Rivet/Tools/ParticleIdUtils.hh"
00004 
00005 namespace Rivet {
00006 
00007 
00008   /// @todo Neaten this up with C++11, via one walker function and several uses with lamba tests
00009 
00010 
00011   bool Particle::hasAncestor(PdgId pdg_id) const {
00012     const GenVertex* prodVtx = genParticle()->production_vertex();
00013     if (prodVtx == NULL) return false;
00014     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00015       if (ancestor->pdg_id() == pdg_id) return true;
00016     }
00017     return false;
00018   }
00019 
00020 
00021   bool Particle::fromBottom() const {
00022     const GenVertex* prodVtx = genParticle()->production_vertex();
00023     if (prodVtx == NULL) return false;
00024     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00025       const PdgId pid = ancestor->pdg_id();
00026       if (ancestor->status() == 2 && (PID::isHadron(pid) && PID::hasBottom(pid))) return true;
00027     }
00028     return false;
00029   }
00030 
00031 
00032   bool Particle::fromCharm() const {
00033     const GenVertex* prodVtx = genParticle()->production_vertex();
00034     if (prodVtx == NULL) return false;
00035     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00036       const PdgId pid = ancestor->pdg_id();
00037       if (ancestor->status() == 2 && (PID::isHadron(pid) && PID::hasCharm(pid) && !PID::hasBottom(pid))) return true;
00038     }
00039     return false;
00040   }
00041 
00042 
00043 
00044   bool Particle::fromHadron() const {
00045     const GenVertex* prodVtx = genParticle()->production_vertex();
00046     if (prodVtx == NULL) return false;
00047     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00048       const PdgId pid = ancestor->pdg_id();
00049       if (ancestor->status() == 2 && PID::isHadron(pid)) return true;
00050     }
00051     return false;
00052   }
00053 
00054 
00055   bool Particle::fromTau(bool prompt_taus_only) const {
00056     if (prompt_taus_only && fromHadron()) return false;
00057     const GenVertex* prodVtx = genParticle()->production_vertex();
00058     if (prodVtx == NULL) return false;
00059     foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00060       const PdgId pid = ancestor->pdg_id();
00061       if (ancestor->status() == 2 && abs(pid) == PID::TAU) return true;
00062     }
00063     return false;
00064   }
00065 
00066 
00067   // bool Particle::fromDecay() const {
00068   //   const GenVertex* prodVtx = genParticle()->production_vertex();
00069   //   if (prodVtx == NULL) return false;
00070   //   foreach (const GenParticle* ancestor, particles(prodVtx, HepMC::ancestors)) {
00071   //     const PdgId pid = ancestor->pdg_id();
00072   //     if (ancestor->status() == 2 && (PID::isHadron(pid) || abs(pid) == PID::TAU)) return true;
00073   //   }
00074   //   return false;
00075   // }
00076 
00077 
00078 }