rivet is hosted by Hepforge, IPPP Durham
PrimaryHadrons.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Projections/PrimaryHadrons.hh"
00003 
00004 namespace Rivet {
00005 
00006 
00007   void PrimaryHadrons::project(const Event& e) {
00008     _theParticles.clear();
00009 
00010     const Particles& unstables = applyProjection<FinalState>(e, "UFS").particles();
00011     foreach (const Particle& p, unstables) {
00012       // Exclude taus etc.
00013       if (!PID::isHadron(p)) continue;
00014       // A spontaneously appearing hadron: this is weird, but I guess is allowed... and is primary
00015       if (!p.genParticle() || !p.genParticle()->production_vertex()) {
00016         MSG_DEBUG("Hadron " << p.pdgId() << " with no GenParticle or parent found: treating as primary");
00017         _theParticles.push_back(p);
00018         continue;
00019       }
00020       // There are ancestors -- check them for status=2 hadronic content
00021       const vector<GenParticle*> ancestors = particles_in(p.genParticle(), HepMC::ancestors);
00022       bool has_hadron_parent = false;
00023       foreach (const GenParticle* pa, ancestors) {
00024         if (pa->status() != 2) continue;
00025         /// @todo Are hadrons from tau decays "primary hadrons"? I guess not
00026         if (PID::isHadron(pa->pdg_id()) || abs(pa->pdg_id()) == PID::TAU) {
00027           has_hadron_parent = true;
00028           break;
00029         }
00030       }
00031       // If the particle seems to be a primary hadron, add it to the list
00032       if (!has_hadron_parent) _theParticles.push_back(p);
00033     }
00034 
00035     MSG_DEBUG("Number of primary hadrons = " << _theParticles.size());
00036   }
00037 
00038 
00039 }