rivet is hosted by Hepforge, IPPP Durham
LossyFinalState.hh
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef RIVET_LossyFinalState_HH
00003 #define RIVET_LossyFinalState_HH
00004 
00005 #include "Rivet/Tools/Logging.hh"
00006 #include "Rivet/Rivet.hh"
00007 #include "Rivet/Particle.hh"
00008 #include "Rivet/Event.hh"
00009 #include "Rivet/Projection.hh"
00010 #include "Rivet/Projections/FinalState.hh"
00011 
00012 namespace Rivet {
00013 
00014 
00015   /// @brief Templated FS projection which can lose some of the supplied particles.
00016   template <typename FILTER>
00017   class LossyFinalState : public FinalState {
00018   public:
00019 
00020     /// @name Constructors
00021     //@{
00022 
00023     /// Constructor from FinalState.
00024     LossyFinalState(const FinalState& fsp, FILTER filter)
00025       : _filter(filter)
00026     {
00027       setName("LossyFinalState");
00028       addProjection(fsp, "FS");
00029     }
00030 
00031     /// Stand-alone constructor. Initialises the base FinalState projection.
00032     LossyFinalState(FILTER filter,
00033                     double mineta = -MAXRAPIDITY,
00034                     double maxeta = MAXRAPIDITY,
00035                     double minpt = 0.0)
00036       : _filter(filter)
00037     {
00038       setName("LossyFinalState");
00039       addProjection(FinalState(mineta, maxeta, minpt), "FS");
00040     }
00041 
00042     /// Virtual destructor, to allow subclassing
00043     virtual ~LossyFinalState() { }
00044 
00045     /// Clone on the heap.
00046     virtual const Projection* clone() const {
00047       return new LossyFinalState<FILTER>(*this);
00048     }
00049 
00050     //@}
00051 
00052 
00053   protected:
00054 
00055     /// Apply the projection on the supplied event.
00056     void project(const Event& e) {
00057       const FinalState& fs = applyProjection<FinalState>(e, "FS");
00058       getLog() << Log::DEBUG << "Pre-loss number of FS particles = " << fs.particles().size() << endl;
00059       _theParticles.clear();
00060       std::remove_copy_if(fs.particles().begin(), fs.particles().end(),
00061                           std::back_inserter(_theParticles), _filter);
00062       getLog() << Log::DEBUG << "Filtered number of FS particles = " << _theParticles.size() << endl;
00063     }
00064 
00065 
00066     /// Compare projections.
00067     int compare(const Projection& p) const {
00068       const LossyFinalState<FILTER>& other = pcast< LossyFinalState<FILTER> >(p);
00069       const int fscmp = mkNamedPCmp(other, "FS");
00070       if (fscmp) return fscmp;
00071       return _filter.compare(other._filter);
00072     }
00073 
00074 
00075   protected:
00076 
00077     /// Filtering object: must support operator(const Particle&) and compare(const Filter&)
00078     FILTER _filter;
00079 
00080   };
00081 
00082 
00083 }
00084 
00085 #endif