00001 // -*- C++ -*- 00002 #include "Rivet/ProjectionApplier.hh" 00003 #include "Rivet/Tools/Logging.hh" 00004 #include "Rivet/Event.hh" 00005 00006 namespace Rivet { 00007 00008 00009 // NB. Allow proj registration in constructor by default -- explicitly disable for Analysis 00010 ProjectionApplier::ProjectionApplier() 00011 : _allowProjReg(true), 00012 _projhandler(ProjectionHandler::create()) 00013 { } 00014 00015 00016 ProjectionApplier::~ProjectionApplier() { 00017 getProjHandler().removeProjectionApplier(*this); 00018 } 00019 00020 00021 const Projection& ProjectionApplier::_applyProjection(const Event& evt, 00022 const string& name) const { 00023 return evt.applyProjection(getProjection(name)); 00024 } 00025 00026 00027 const Projection& ProjectionApplier::_applyProjection(const Event& evt, 00028 const Projection& proj) const { 00029 return evt.applyProjection(proj); 00030 } 00031 00032 00033 const Projection& ProjectionApplier::_addProjection(const Projection& proj, 00034 const std::string& name) { 00035 if (!_allowProjReg) { 00036 getLog() << Log::ERROR << "Trying to register projection '" 00037 << proj.name() << "' before init phase in '" << this->name() << "'." << endl; 00038 exit(2); 00039 } 00040 const Projection& reg = getProjHandler().registerProjection(*this, proj, name); 00041 return reg; 00042 } 00043 00044 00045 }