DISLepton.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/RivetCLHEP.hh"
00004 #include "Rivet/Projections/DISLepton.hh"
00005 #include "Rivet/Cmp.hh"
00006 
00007 
00008 namespace Rivet {
00009 
00010   int DISLepton::compare(const Projection& p) const {
00011     const DISLepton& other = dynamic_cast<const DISLepton&>(p);
00012     return
00013       pcmp(_beamproj, other._beamproj) || 
00014       pcmp(_fsproj, other._fsproj) || 
00015       cmp(_idin, other._idin) || 
00016       cmp(_idout, other._idout);
00017   }
00018 
00019 
00020   void DISLepton::project(const Event& e) {
00021     const ParticlePair& inc = e.applyProjection(_beamproj).getBeams();
00022     const FinalState& fs = e.applyProjection(_fsproj);
00023 
00024     bool allowAnti = (_idin * _idout < 0);
00025     if ( _idin == inc.first.getPdgId() || (allowAnti && _idin == -inc.first.getPdgId()) ) {
00026       _incoming = inc.first;
00027     } else if ( _idin == inc.second.getPdgId() || (allowAnti && _idin == -inc.second.getPdgId()) ) {
00028       _incoming = inc.second;
00029     } else {
00030       throw runtime_error("DISLepton projector could not find the correct beam. ");
00031     }
00032 
00033     double emax = 0.0;
00034     for (ParticleVector::const_iterator p = fs.particles().begin(); p != fs.particles().end(); ++p) {
00035       if ( ( _idout == p->getPdgId() || allowAnti && _idout == -p->getPdgId() ) && 
00036            p->getMomentum().e() > emax ) {
00037         // @todo change this to a correct way of finding the scattered lepton.
00038         emax = p->getMomentum().e();
00039         _outgoing = *p;
00040       }
00041     }
00042     
00043     if (!_outgoing.hasHepMCParticle()) {
00044       throw runtime_error("DISLepton projector could not find the scattered lepton.");
00045     }
00046   }
00047   
00048 }
00049