00001 // -*- C++ -*- 00002 #include "Rivet/Projections/FinalState.hh" 00003 #include "Rivet/Tools/Logging.hh" 00004 #include "Rivet/Cmp.hh" 00005 00006 00007 namespace Rivet { 00008 00009 int FinalState::compare(const Projection& p) const { 00010 const FinalState & other = dynamic_cast<const FinalState &>(p); 00011 return cmp(_etamin, other._etamin) || cmp(_etamax, other._etamax) || cmp(_ptmin, other._ptmin); 00012 } 00013 00014 00015 void FinalState::project(const Event& e) { 00016 _theParticles.clear(); 00017 00018 00019 for ( GenEvent::particle_const_iterator pi = e.genEvent().particles_begin(); 00020 pi != e.genEvent().particles_end(); ++pi ) { 00021 // Only include particles which are final state (status = 1) and which 00022 // pass the eta and phi cuts. The eta cut is pre-tested by checking if the 00023 // x and y components of the momentum are non-zero since CLHEP might throw 00024 // an exception otherwise. 00025 if ( (*pi)->status() == 1 && 00026 fabs((*pi)->momentum().x()) > 0.0 && 00027 fabs((*pi)->momentum().y()) > 0.0 && 00028 (*pi)->momentum().eta() > _etamin && 00029 (*pi)->momentum().eta() < _etamax && 00030 (*pi)->momentum().perp() >= _ptmin ) 00031 _theParticles.push_back(Particle(**pi)); 00032 } 00033 getLog() << Log::DEBUG << "Number of final-state particles = " 00034 << _theParticles.size() << endl; 00035 } 00036 00037 }