00001
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 getLog() << Log::DEBUG << "Number of charged final-state particles = "
00046 << _theParticles.size() << endl;
00047 if (getLog().isActive(Log::TRACE)) {
00048 for (vector<Particle>::iterator p = _theParticles.begin(); p != _theParticles.end(); ++p) {
00049 getLog() << Log::TRACE << "Selected: " << p->pdgId()
00050 << ", charge = " << PID::threeCharge(p->pdgId())/3.0 << endl;
00051 }
00052 }
00053 }
00054
00055
00056 }