herwig is hosted by Hepforge, IPPP Durham
Herwig++  2.7.0
EventExtractor.h
00001 // -*- C++ -*-
00002 
00003 // (C) 2007-2009 Simon Plaetzer -- sp@particle.uni-karlsruhe.de
00004 
00005 #ifndef Analysis2_EventExtractor_H
00006 #define Analysis2_EventExtractor_H
00007 //
00008 // This is the declaration of the EventExtractor class.
00009 //
00010 
00011 #include "ThePEG/Interface/Interfaced.h"
00012 
00013 #include "ThePEG/EventRecord/Event.h"
00014 #include "ThePEG/Vectors/Lorentz5Vector.h"
00015 
00016 namespace Analysis2 {
00017 
00018 using namespace ThePEG;
00019 
00027 class EventExtractor: public Interfaced {
00028 
00029 public:
00030 
00036   inline EventExtractor()
00037     : _lastEvent(), _ok(false), _doneEvent(false), _lastMomenta(), _lastWeight(0.) {}
00038 
00042   virtual ~EventExtractor();
00044 
00045 public:
00046 
00047   virtual void prepare ();
00048 
00049   inline void use (tcEventPtr ev) { _lastEvent = ev; prepare(); }
00050 
00051   inline tcEventPtr lastEvent() const { return _lastEvent; }
00052 
00053 public:
00054 
00055   virtual inline EventExtractor& operator >> (pair<vector<Lorentz5Momentum>,double> & ev) {
00056     if (_doneEvent) {
00057       _ok = false;
00058       return *this;
00059     }
00060     ev = make_pair(_lastMomenta,_lastWeight);
00061     _doneEvent = true;
00062     return *this;
00063   }
00064 
00065 public:
00066 
00067   inline operator bool () const { return _ok; }
00068 
00069   inline bool operator ! () const { return !_ok; }
00070 
00071 protected:
00072 
00073   inline bool& ok () { return _ok; }
00074 
00075 public:
00076 
00083   void persistentOutput(PersistentOStream & os) const;
00084 
00090   void persistentInput(PersistentIStream & is, int version);
00092 
00099   static void Init();
00100 
00101 
00102 // If needed, insert declarations of virtual function defined in the
00103 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
00104 
00105 protected:
00106 
00113   inline virtual IBPtr clone() const { return new_ptr(*this); }
00114 
00119   inline virtual IBPtr fullclone() const { return new_ptr(*this); }
00121 
00122 private:
00123 
00125   tcEventPtr _lastEvent;
00126 
00128   bool _ok;
00129 
00130   bool _doneEvent;
00131 
00133   vector<Lorentz5Momentum> _lastMomenta;
00134 
00136   double _lastWeight;
00137 
00142   static ClassDescription<EventExtractor> initEventExtractor;
00143 
00148   EventExtractor & operator=(const EventExtractor &);
00149 
00150 };
00151 
00152 }
00153 
00154 #include "ThePEG/Utilities/ClassTraits.h"
00155 #include "ThePEG/Config/Pointers.h"
00156 
00157 namespace ThePEG {
00158 
00159 ThePEG_DECLARE_POINTERS(Analysis2::EventExtractor,EventExtractorPtr);
00160 
00165 template <>
00166 struct BaseClassTrait<Analysis2::EventExtractor,1> {
00168   typedef Interfaced NthBase;
00169 };
00170 
00173 template <>
00174 struct ClassTraits<Analysis2::EventExtractor>
00175   : public ClassTraitsBase<Analysis2::EventExtractor> {
00177   static string className() { return "Analysis2::EventExtractor"; }
00185   static string library() { return "Analysis2.so"; }
00186 };
00187 
00190 }
00191 
00192 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
00193 // #include "EventExtractor.tcc"
00194 #endif
00195 
00196 #endif /* Analysis2_EventExtractor_H */