rivet is hosted by Hepforge, IPPP Durham
Jet.cc
Go to the documentation of this file.
00001 #include "Rivet/Jet.hh"
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Tools/ParticleIdUtils.hh"
00004 #include "Rivet/ParticleName.hh"
00005 #include "Rivet/RivetBoost.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   Jet& Jet::setState(const vector<Particle>& particles, const FourMomentum& pjet) {
00011     setParticles(particles);
00012     setMomentum(pjet);
00013     return *this;
00014   }
00015 
00016 
00017   // Jet& Jet::setState(const vector<FourMomentum>& momenta, const FourMomentum& pjet) {
00018   //   setParticles(momenta);
00019   //   setMomentum(pjet);
00020   //   return *this;
00021   // }
00022 
00023 
00024   Jet& Jet::setMomentum(const FourMomentum& momentum) {
00025     _momentum = momentum;
00026     return *this;
00027   }
00028 
00029 
00030  Jet& Jet::setParticles(const vector<Particle>& particles) {
00031    _particles = particles;
00032    // foreach (const Particle& p, particles) {
00033    //   _momenta.push_back(p.momentum());
00034    // }
00035    return *this;
00036  }
00037 
00038 
00039   // Jet& Jet::setParticles(const vector<FourMomentum>& momenta) {
00040   //   _momenta = momenta;
00041   //   return *this;
00042   // }
00043 
00044 
00045   // Jet& Jet::addParticle(const FourMomentum& particle) {
00046   //   _momenta.push_back(particle);
00047   //   return *this;
00048   // }
00049 
00050 
00051   // Jet& Jet::addParticle(const Particle& particle) {
00052   //   _particles.push_back(particle);
00053   //   _momenta.push_back(particle.momentum());
00054   //   return *this;
00055   // }
00056 
00057 
00058   bool Jet::containsParticle(const Particle& particle) const {
00059     const int barcode = particle.genParticle().barcode();
00060     foreach (const Particle& p, particles()) {
00061       if (p.genParticle().barcode() == barcode) return true;
00062     }
00063     return false;
00064   }
00065 
00066 
00067   bool Jet::containsParticleId(PdgId pid) const {
00068     foreach (const Particle& p, particles()) {
00069       if (p.pdgId() == pid) return true;
00070     }
00071     return false;
00072   }
00073 
00074 
00075   bool Jet::containsParticleId(const vector<PdgId>& pids) const {
00076     foreach (const Particle& p, particles()) {
00077       foreach (PdgId pid, pids) {
00078         if (p.pdgId() == pid) return true;
00079       }
00080     }
00081     return false;
00082   }
00083 
00084 
00085   /// @todo Jet::containsMatch(Matcher m) { ... if m(pid) return true; ... }
00086 
00087 
00088   double Jet::neutralEnergy() const {
00089     double e_neutral = 0.0;
00090     foreach (const Particle& p, particles()) {
00091       const PdgId pid = p.pdgId();
00092       if (PID::threeCharge(pid) == 0) {
00093         e_neutral += p.momentum().E();
00094       }
00095     }
00096     return e_neutral;
00097   }
00098 
00099 
00100   double Jet::hadronicEnergy() const {
00101     double e_hadr = 0.0;
00102     foreach (const Particle& p, particles()) {
00103       const PdgId pid = p.pdgId();
00104       if (PID::isHadron(pid)) {
00105         e_hadr += p.momentum().E();
00106       }
00107     }
00108     return e_hadr;
00109   }
00110 
00111 
00112   bool Jet::containsCharm() const {
00113     foreach (const Particle& p, particles()) {
00114       const PdgId pid = p.pdgId();
00115       if (abs(pid) == CQUARK) return true;
00116       if (PID::isHadron(pid) && PID::hasCharm(pid)) return true;
00117       HepMC::GenVertex* gv = p.genParticle().production_vertex();
00118       if (gv) {
00119         foreach (const GenParticle* pi, Rivet::particles(gv, HepMC::ancestors)) {
00120           const PdgId pid2 = pi->pdg_id();
00121           if (PID::isHadron(pid2) && PID::hasCharm(pid2)) return true;
00122         }
00123       }
00124     }
00125     return false;
00126   }
00127 
00128 
00129   bool Jet::containsBottom() const {
00130     foreach (const Particle& p, particles()) {
00131       const PdgId pid = p.pdgId();
00132       if (abs(pid) == BQUARK) return true;
00133       if (PID::isHadron(pid) && PID::hasBottom(pid)) return true;
00134       HepMC::GenVertex* gv = p.genParticle().production_vertex();
00135       if (gv) {
00136         foreach (const GenParticle* pi, Rivet::particles(gv, HepMC::ancestors)) {
00137           const PdgId pid2 = pi->pdg_id();
00138           if (PID::isHadron(pid2) && PID::hasBottom(pid2)) return true;
00139         }
00140       }
00141     }
00142     return false;
00143   }
00144 
00145 
00146   Jet& Jet::clear() {
00147     //_momenta.clear();
00148     _particles.clear();
00149     _momentum = FourMomentum();
00150     return *this;
00151   }
00152 
00153 
00154 }