Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-05-12 09:05:03

0001 // -*- C++ -*-
0002 #ifndef RIVET_LossyFinalState_HH
0003 #define RIVET_LossyFinalState_HH
0004 
0005 #include "Rivet/Tools/Logging.hh"
0006 #include "Rivet/Config/RivetCommon.hh"
0007 #include "Rivet/Particle.hh"
0008 #include "Rivet/Event.hh"
0009 #include "Rivet/Projection.hh"
0010 #include "Rivet/Projections/FinalState.hh"
0011 
0012 namespace Rivet {
0013 
0014 
0015   /// @brief Templated FS projection which can lose some of the supplied particles.
0016   template <typename FILTER>
0017   class LossyFinalState : public FinalState {
0018   public:
0019 
0020     /// @name Constructors
0021     /// @{
0022 
0023     /// Constructor from FinalState.
0024     LossyFinalState(const FinalState& fsp, FILTER filter)
0025       : _filter(filter)
0026     {
0027       setName("LossyFinalState");
0028       declare(fsp, "FS");
0029     }
0030 
0031     /// Stand-alone constructor. Initialises the base FinalState projection.
0032     LossyFinalState(FILTER filter, const Cut& c=Cuts::open())
0033       : _filter(filter)
0034     {
0035       setName("LossyFinalState");
0036       declare(FinalState(c), "FS");
0037     }
0038 
0039     /// Virtual destructor, to allow subclassing
0040     virtual ~LossyFinalState() { }
0041 
0042     /// Clone on the heap.
0043     RIVET_DEFAULT_PROJ_CLONE(LossyFinalState);
0044 
0045     /// @}
0046 
0047     /// Import to avoid warnings about overload-hiding
0048     using Projection::operator =;
0049 
0050 
0051     /// Apply the projection on the supplied event.
0052     void project(const Event& e) {
0053       const FinalState& fs = apply<FinalState>(e, "FS");
0054       getLog() << Log::DEBUG << "Pre-loss number of FS particles = " << fs.particles().size() << '\n';
0055       _theParticles.clear();
0056       std::remove_copy_if(fs.particles().begin(), fs.particles().end(),
0057                           std::back_inserter(_theParticles), _filter);
0058       getLog() << Log::DEBUG << "Filtered number of FS particles = " << _theParticles.size() << '\n';
0059     }
0060 
0061 
0062     /// Compare projections.
0063     CmpState compare(const Projection& p) const {
0064       const LossyFinalState<FILTER>& other = pcast< LossyFinalState<FILTER> >(p);
0065       const CmpState fscmp = mkNamedPCmp(other, "FS");
0066       if (fscmp != CmpState::EQ) return fscmp;
0067       return _filter.compare(other._filter);
0068     }
0069 
0070 
0071   protected:
0072 
0073     /// Filtering object: must support operator(const Particle&) and compare(const Filter&)
0074     FILTER _filter;
0075 
0076   };
0077 
0078 
0079 }
0080 
0081 #endif