ProjectionApplier.hh
// -*- C++ -*-
#ifndef RIVET_ProjectionApplier_HH
#define RIVET_ProjectionApplier_HH
#include "Rivet/Rivet.hh"
#include "Rivet/Event.fhh"
#include "Rivet/Projection.fhh"
#include "Rivet/ProjectionHandler.hh"
#include "Rivet/Tools/Logging.hh"
namespace Rivet {
class ProjectionApplier {
public:
// The proj handler needs access to reset the _allowProjReg flag before calling a.init()
// friend class ProjectionHandler;
ProjectionApplier();
// Virtual destructor: ensure that inheritance is possible.
virtual ~ProjectionApplier();
public:
virtual std::string name() const = 0;
std::set<ConstProjectionPtr> getProjections() const {
return getProjHandler().getChildProjections(*this, ProjectionHandler::DEEP);
}
template <typename PROJ>
const PROJ& getProjection(const std::string& name) const {
const Projection& p = getProjHandler().getProjection(*this, name);
return pcast<PROJ>(p);
}
const Projection& getProjection(const std::string& name) const {
return getProjHandler().getProjection(*this, name);
}
template <typename PROJ>
const PROJ& applyProjection(const Event& evt, const PROJ& proj) const {
return pcast<PROJ>(_applyProjection(evt, proj));
}
template <typename PROJ>
const PROJ& applyProjection(const Event& evt, const Projection& proj) const {
return pcast<PROJ>(_applyProjection(evt, proj));
}
template <typename PROJ>
const PROJ& applyProjection(const Event& evt, const std::string& name) const {
return pcast<PROJ>(_applyProjection(evt, name));
}
protected:
Log& getLog() const {
return Log::getLog("Rivet.ProjectionHandler");
}
ProjectionHandler& getProjHandler() const {
return _projhandler;
}
protected:
template <typename PROJ>
const PROJ& addProjection(const PROJ& proj, const std::string& name) {
const Projection& reg = _addProjection(proj, name);
const PROJ& rtn = dynamic_cast<const PROJ&>(reg);
return rtn;
}
const Projection& _addProjection(const Projection& proj, const std::string& name);
private:
const Projection& _applyProjection(const Event& evt, const std::string& name) const;
const Projection& _applyProjection(const Event& evt, const Projection& proj) const;
protected:
bool _allowProjReg;
private:
ProjectionHandler& _projhandler;
};
}
#endif
Rivet
Definition: MC_JetAnalysis.hh:9
Rivet::ProjectionApplier::applyProjection
const PROJ & applyProjection(const Event &evt, const Projection &proj) const
Apply the supplied projection on event.
Definition: ProjectionApplier.hh:74
Rivet::ProjectionHandler::getChildProjections
set< const Projection * > getChildProjections(const ProjectionApplier &parent, ProjDepth depth=SHALLOW) const
Definition: ProjectionHandler.cc:233
Rivet::ProjectionApplier::getProjections
std::set< ConstProjectionPtr > getProjections() const
Get the contained projections, including recursion.
Definition: ProjectionApplier.hh:42
Rivet::ProjectionApplier::applyProjection
const PROJ & applyProjection(const Event &evt, const std::string &name) const
Apply the named projection on event.
Definition: ProjectionApplier.hh:81
Rivet::Log::getLog
static Log & getLog(const std::string &name)
Definition: Logging.cc:55
Rivet::Log
Definition: Logging.hh:9
Rivet::ProjectionApplier::name
virtual std::string name() const =0
Get the name of this Projection or Analysis class.
Rivet::ProjectionHandler
The projection handler is a central repository for projections to be used in a Rivet analysis run...
Definition: ProjectionHandler.hh:41
Rivet::Event
Definition: Event.hh:22
Rivet::ProjectionApplier::getProjHandler
ProjectionHandler & getProjHandler() const
Get a reference to the ProjectionHandler for this thread.
Definition: ProjectionApplier.hh:94
Rivet::ProjectionHandler::getProjection
const Projection & getProjection(const ProjectionApplier &parent, const string &name) const
Definition: ProjectionHandler.cc:258
Rivet::ProjectionApplier
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:18
Rivet::ProjectionApplier::getProjection
const PROJ & getProjection(const std::string &name) const
Get the named projection, specifying return type via a template argument.
Definition: ProjectionApplier.hh:49
Rivet::ProjectionApplier::getProjection
const Projection & getProjection(const std::string &name) const
Definition: ProjectionApplier.hh:57
Rivet::ProjectionApplier::addProjection
const PROJ & addProjection(const PROJ &proj, const std::string &name)
Definition: ProjectionApplier.hh:113
Rivet::ProjectionApplier::applyProjection
const PROJ & applyProjection(const Event &evt, const PROJ &proj) const
Apply the supplied projection on event.
Definition: ProjectionApplier.hh:67
Rivet::ProjectionApplier::ProjectionApplier
ProjectionApplier()
Constructor.
Definition: ProjectionApplier.cc:10
Rivet::Projection
Base class for all Rivet projections.
Definition: Projection.hh:28