rivet is hosted by Hepforge, IPPP Durham
ChargedFinalState.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/Projections/ChargedFinalState.hh"
00004 #include "Rivet/Tools/ParticleIdUtils.hh"
00005 #include "Rivet/Cmp.hh"
00006 #include <algorithm>
00007 
00008 namespace Rivet {
00009 
00010 
00011   ChargedFinalState::ChargedFinalState(const FinalState& fsp) {
00012     setName("ChargedFinalState");
00013     addProjection(fsp, "FS");
00014   }
00015 
00016 
00017   ChargedFinalState::ChargedFinalState(double mineta, double maxeta, double minpt) {
00018     setName("ChargedFinalState");
00019     addProjection(FinalState(mineta, maxeta, minpt), "FS");
00020   }
00021 
00022 
00023   ChargedFinalState::ChargedFinalState(const vector<pair<double, double> >& etaRanges,
00024                                        double minpt) {
00025     setName("ChargedFinalState");
00026     addProjection(FinalState(etaRanges, minpt), "FS");
00027   }
00028 
00029 
00030   int ChargedFinalState::compare(const Projection& p) const {
00031     return mkNamedPCmp(p, "FS");
00032   }
00033 
00034 
00035   bool chargedParticleFilter(const Particle& p) {
00036     return PID::threeCharge(p.pdgId()) == 0;
00037   }
00038 
00039 
00040   void ChargedFinalState::project(const Event& e) {
00041     const FinalState& fs = applyProjection<FinalState>(e, "FS");
00042     _theParticles.clear();
00043     std::remove_copy_if(fs.particles().begin(), fs.particles().end(),
00044                         std::back_inserter(_theParticles), chargedParticleFilter);
00045     MSG_DEBUG("Number of charged final-state particles = " << _theParticles.size());
00046     if (getLog().isActive(Log::TRACE)) {
00047       for (vector<Particle>::iterator p = _theParticles.begin(); p != _theParticles.end(); ++p) {
00048         MSG_TRACE("Selected: " << p->pdgId() << ", charge = " << PID::threeCharge(p->pdgId())/3.0);
00049       }
00050     }
00051   }
00052 
00053 
00054 }