LeadingParticlesFinalState.cc

Go to the documentation of this file.
00001 #include "Rivet/Projections/LeadingParticlesFinalState.hh"
00002 #include "Rivet/Particle.hh"
00003 
00004 namespace Rivet {
00005 
00006 
00007   int LeadingParticlesFinalState::compare(const Projection& p) const {
00008     // First compare the final states we are running on
00009     int fscmp = mkNamedPCmp(p, "FS");
00010     if (fscmp != EQUIVALENT) return fscmp;
00011 
00012     // Then compare the two as final states
00013     const LeadingParticlesFinalState& other = dynamic_cast<const LeadingParticlesFinalState&>(p);
00014     fscmp = FinalState::compare(other);
00015     if (fscmp != EQUIVALENT) return fscmp;
00016 
00017     // Finally compare the IDs
00018     if (_ids < other._ids) return ORDERED;
00019     else if (other._ids < _ids) return UNORDERED;
00020     return EQUIVALENT;
00021   }
00022 
00023 
00024   void LeadingParticlesFinalState::project(const Event & e) {
00025     _theParticles.clear();
00026     const FinalState& fs = applyProjection<FinalState>(e, "FS");
00027 
00028     // Temporary container
00029     map<long, ParticleVector::const_iterator> tmp;
00030 
00031     const ParticleVector& particles = fs.particles();
00032     getLog() << Log::DEBUG << "Original final state particles size " << particles.size() << endl;
00033     ParticleVector::const_iterator ifs;
00034     for (ifs = particles.begin(); ifs != particles.end(); ++ifs) {
00035       if (inList(*ifs) && FinalState::accept(ifs->genParticle())) {
00036         // Look for an existing particle in tmp container
00037         map < long, ParticleVector::const_iterator >::const_iterator itmp = tmp.find(ifs->pdgId());
00038         if (itmp != tmp.end()) {  // if a particle with this type has been already selected
00039           // If the new pT is higher than the previous one, then substitute...
00040           if (ifs->momentum().pT() > itmp->second->momentum().pT()) {
00041             tmp[ifs->pdgId()] = ifs;
00042           }
00043           // ...otherwise insert in the container
00044         } else {
00045           tmp[ifs->pdgId()] = ifs;
00046         }
00047       }
00048     }
00049  
00050     // Loop on the tmp container and fill _theParticles
00051     map<long, ParticleVector::const_iterator>::const_iterator i;
00052     for (i = tmp.begin(); i != tmp.end(); ++i) {
00053       getLog() << Log::DEBUG << "LeadingParticlesFinalState is accepting particle ID " << i->second->pdgId()
00054                << " with momentum " << i->second->momentum() << endl;
00055       _theParticles.push_back(*(i->second));
00056     }
00057   }
00058 
00059 
00060   bool LeadingParticlesFinalState::inList(const Particle & particle) const {
00061     std::set < long >::const_iterator ilist = _ids.find(particle.pdgId());
00062     if (ilist != _ids.end()) return true;
00063     return false;
00064   }
00065 
00066 
00067 }