rivet is hosted by Hepforge, IPPP Durham
ProjectionApplier.cc
Go to the documentation of this file.
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), _owned(false),
00012       _projhandler(ProjectionHandler::getInstance())
00013   {  }
00014 
00015 
00016   ProjectionApplier::~ProjectionApplier() {
00017     if ( ! _owned )
00018       getProjHandler().removeProjectionApplier(*this);
00019   }
00020 
00021 
00022   const Projection& ProjectionApplier::_applyProjection(const Event& evt,
00023                                                         const string& name) const {
00024     return evt.applyProjection(getProjection(name));
00025   }
00026 
00027 
00028   const Projection& ProjectionApplier::_applyProjection(const Event& evt,
00029                                                         const Projection& proj) const {
00030     return evt.applyProjection(proj);
00031   }
00032 
00033 
00034   const Projection& ProjectionApplier::_declareProjection(const Projection& proj,
00035                                                       const std::string& name) {
00036     if (!_allowProjReg) {
00037       cerr << "Trying to register projection '"
00038            << proj.name() << "' before init phase in '" << this->name() << "'." << endl;
00039       exit(2);
00040     }
00041     const Projection& reg = getProjHandler().registerProjection(*this, proj, name);
00042     return reg;
00043   }
00044 
00045 
00046 }