Rivet  1.8.0
Event.hh
00001 // -*- C++ -*-
00002 #ifndef RIVET_Event_HH
00003 #define RIVET_Event_HH
00004 
00005 #include "Rivet/Rivet.hh"
00006 #include "Rivet/Projection.hh"
00007 
00008 namespace Rivet {
00009 
00010 
00022   class Event {
00023   public:
00024 
00026 
00027 
00029     Event(const GenEvent& ge);
00030 
00032     Event(const Event& e);
00033 
00035     ~Event();
00036 
00038 
00039 
00040   public:
00041 
00043     const GenEvent& genEvent() const;
00044 
00046     double weight() const {
00047       return _weight;
00048     }
00049 
00050 
00051   public:
00052 
00059     template <typename PROJ>
00060     const PROJ& applyProjection(PROJ& p) const {
00061       const Projection* cpp(&p);
00062       std::set<const Projection*>::const_iterator old = _projections.find(cpp);
00063       if (old != _projections.end()) {
00064         const Projection& pRef = **old;
00065         return pcast<PROJ>(pRef);
00066       }
00067       // Add the projection via the Projection base class (only
00068       // possible because Event is a friend of Projection)
00069       Projection* pp = const_cast<Projection*>(cpp);
00070       pp->project(*this);
00071       _projections.insert(pp);
00072       return p;
00073     }
00074 
00075 
00076     template <typename PROJ>
00077     const PROJ& applyProjection(PROJ* pp) const {
00078       if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null.");
00079       return applyProjection(*pp);
00080     }
00081 
00082 
00083   private:
00084     void _geNormAlignment();
00085 
00086 
00089     GenEvent const& _genEvent;
00090 
00091     GenEvent* _modGenEvent;
00092 
00094     mutable std::set<ConstProjectionPtr> _projections;
00095 
00098     double _weight;
00099 
00100   };
00101 
00102 
00103 }
00104 
00105 #endif