Rivet
1.8.0
|
00001 // -*- C++ -*- 00002 #ifndef RIVET_ProjectionApplier_HH 00003 #define RIVET_ProjectionApplier_HH 00004 00005 #include "Rivet/Rivet.hh" 00006 #include "Rivet/Event.fhh" 00007 #include "Rivet/Projection.fhh" 00008 #include "Rivet/ProjectionHandler.hh" 00009 #include "Rivet/Tools/Logging.hh" 00010 00011 namespace Rivet { 00012 00013 00018 class ProjectionApplier { 00019 public: 00020 00021 // The proj handler needs access to reset the _allowProjReg flag before calling a.init() 00022 // friend class ProjectionHandler; 00023 00025 ProjectionApplier(); 00026 00027 // Virtual destructor: ensure that inheritance is possible. 00028 virtual ~ProjectionApplier(); 00029 00030 00031 public: 00032 00034 00035 00036 virtual std::string name() const = 0; 00038 00040 00041 00042 std::set<ConstProjectionPtr> getProjections() const { 00043 return getProjHandler().getChildProjections(*this, ProjectionHandler::DEEP); 00044 } 00045 00046 00048 template <typename PROJ> 00049 const PROJ& getProjection(const std::string& name) const { 00050 const Projection& p = getProjHandler().getProjection(*this, name); 00051 return pcast<PROJ>(p); 00052 } 00053 00054 00057 const Projection& getProjection(const std::string& name) const { 00058 return getProjHandler().getProjection(*this, name); 00059 } 00061 00062 00064 00065 00066 template <typename PROJ> 00067 const PROJ& applyProjection(const Event& evt, const PROJ& proj) const { 00068 return pcast<PROJ>(_applyProjection(evt, proj)); 00069 } 00070 00071 00073 template <typename PROJ> 00074 const PROJ& applyProjection(const Event& evt, const Projection& proj) const { 00075 return pcast<PROJ>(_applyProjection(evt, proj)); 00076 } 00077 00078 00080 template <typename PROJ> 00081 const PROJ& applyProjection(const Event& evt, const std::string& name) const { 00082 return pcast<PROJ>(_applyProjection(evt, name)); 00083 } 00085 00086 00087 protected: 00088 00089 Log& getLog() const { 00090 return Log::getLog("Rivet.ProjectionHandler"); 00091 } 00092 00094 ProjectionHandler& getProjHandler() const { 00095 return _projhandler; 00096 } 00097 00098 00099 protected: 00100 00101 00103 00104 00112 template <typename PROJ> 00113 const PROJ& addProjection(const PROJ& proj, const std::string& name) { 00114 const Projection& reg = _addProjection(proj, name); 00115 const PROJ& rtn = dynamic_cast<const PROJ&>(reg); 00116 return rtn; 00117 } 00118 00119 00121 const Projection& _addProjection(const Projection& proj, const std::string& name); 00122 00124 00125 00126 private: 00127 00130 const Projection& _applyProjection(const Event& evt, const std::string& name) const; 00131 00134 const Projection& _applyProjection(const Event& evt, const Projection& proj) const; 00135 00136 00137 protected: 00138 00140 bool _allowProjReg; 00141 00142 00143 private: 00144 00146 ProjectionHandler& _projhandler; 00147 00148 }; 00149 00150 } 00151 00152 #endif