00001
00002
00003 #include "Rivet/Tools/Logging.hh"
00004 #include "Rivet/Projections/TotalVisibleMomentum.hh"
00005 #include "Rivet/Cmp.hh"
00006 #include "HepPDT/ParticleID.hh"
00007
00008
00009 namespace Rivet {
00010
00011 int TotalVisibleMomentum::compare(const Projection& p) const {
00012 const TotalVisibleMomentum& other = dynamic_cast<const TotalVisibleMomentum&>(p);
00013 return pcmp(*_fsproj, *other._fsproj);
00014 }
00015
00016
00017 void TotalVisibleMomentum::project(const Event& e) {
00018 Log& log = getLog();
00019
00020 _momentum = LorentzVector();
00021 _momentum.setPx(0.0);
00022 _momentum.setPy(0.0);
00023 _momentum.setPz(0.0);
00024 _momentum.setE(0.0);
00025
00026
00027 const FinalState& fs = e.applyProjection(*_fsproj);
00028
00029
00030 for (ParticleVector::const_iterator p = fs.particles().begin(); p != fs.particles().end(); ++p) {
00031 _momentum += p->getMomentum();
00032 }
00033
00034 log << Log::DEBUG << "Done" << endl;
00035 }
00036
00037
00038 }