00001
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/Projections/IdentifiedFinalState.hh"
00004 #include "Rivet/Cmp.hh"
00005 #include "Rivet/Tools/Utils.hh"
00006 #include <algorithm>
00007
00008 namespace Rivet {
00009
00010
00011 IdentifiedFinalState::IdentifiedFinalState(const FinalState& fsp) {
00012 setName("IdentifiedFinalState");
00013 addProjection(fsp, "FS");
00014 }
00015
00016
00017 IdentifiedFinalState::IdentifiedFinalState(double etamin, double etamax, double ptMin)
00018 : FinalState(etamin, etamax, ptMin)
00019 {
00020 setName("IdentifiedFinalState");
00021 addProjection(FinalState(etamin, etamax, ptMin), "FS");
00022 }
00023
00024
00025 IdentifiedFinalState::IdentifiedFinalState(const vector<pair<double, double> >& etaRanges,
00026 double ptMin)
00027 : FinalState(etaRanges, ptMin)
00028 {
00029 setName("IdentifiedFinalState");
00030 addProjection(FinalState(etaRanges, ptMin), "FS");
00031 }
00032
00033
00034 int IdentifiedFinalState::compare(const Projection& p) const {
00035 const PCmp fscmp = mkNamedPCmp(p, "FS");
00036 if (fscmp != EQUIVALENT) return fscmp;
00037
00038 const IdentifiedFinalState& other = dynamic_cast<const IdentifiedFinalState&>(p);
00039 int pidssize = cmp(_pids.size(), other._pids.size());
00040 if (pidssize != EQUIVALENT) return pidssize;
00041 return cmp(_pids, other._pids);
00042 }
00043
00044
00045 void IdentifiedFinalState::project(const Event& e) {
00046 const FinalState& fs = applyProjection<FinalState>(e, "FS");
00047 _theParticles.clear();
00048 _theParticles.reserve(fs.particles().size());
00049 foreach (const Particle& p, fs.particles()) {
00050 if (acceptedIds().find(p.pdgId()) != acceptedIds().end()) {
00051 _theParticles.push_back(p);
00052 }
00053 }
00054 }
00055
00056
00057 }