Rivet  1.8.3
ProjectionApplier.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ProjectionApplier_HH
3 #define RIVET_ProjectionApplier_HH
4 
5 #include "Rivet/Rivet.hh"
6 #include "Rivet/Event.fhh"
7 #include "Rivet/Projection.fhh"
8 #include "Rivet/ProjectionHandler.hh"
9 #include "Rivet/Tools/Logging.hh"
10 
11 namespace Rivet {
12 
13 
19  public:
20 
21  // The proj handler needs access to reset the _allowProjReg flag before calling a.init()
22  // friend class ProjectionHandler;
23 
26 
27  // Virtual destructor: ensure that inheritance is possible.
28  virtual ~ProjectionApplier();
29 
30 
31  public:
32 
34 
35  virtual std::string name() const = 0;
38 
40 
41  std::set<ConstProjectionPtr> getProjections() const {
43  return getProjHandler().getChildProjections(*this, ProjectionHandler::DEEP);
44  }
45 
46 
48  template <typename PROJ>
49  const PROJ& getProjection(const std::string& name) const {
50  const Projection& p = getProjHandler().getProjection(*this, name);
51  return pcast<PROJ>(p);
52  }
53 
54 
57  const Projection& getProjection(const std::string& name) const {
58  return getProjHandler().getProjection(*this, name);
59  }
61 
62 
64 
65  template <typename PROJ>
67  const PROJ& applyProjection(const Event& evt, const PROJ& proj) const {
68  return pcast<PROJ>(_applyProjection(evt, proj));
69  }
70 
71 
73  template <typename PROJ>
74  const PROJ& applyProjection(const Event& evt, const Projection& proj) const {
75  return pcast<PROJ>(_applyProjection(evt, proj));
76  }
77 
78 
80  template <typename PROJ>
81  const PROJ& applyProjection(const Event& evt, const std::string& name) const {
82  return pcast<PROJ>(_applyProjection(evt, name));
83  }
85 
86 
87  protected:
88 
89  Log& getLog() const {
90  return Log::getLog("Rivet.ProjectionHandler");
91  }
92 
95  return _projhandler;
96  }
97 
98 
99  protected:
100 
101 
103 
104 
112  template <typename PROJ>
113  const PROJ& addProjection(const PROJ& proj, const std::string& name) {
114  const Projection& reg = _addProjection(proj, name);
115  const PROJ& rtn = dynamic_cast<const PROJ&>(reg);
116  return rtn;
117  }
118 
119 
121  const Projection& _addProjection(const Projection& proj, const std::string& name);
122 
124 
125 
126  private:
127 
130  const Projection& _applyProjection(const Event& evt, const std::string& name) const;
131 
134  const Projection& _applyProjection(const Event& evt, const Projection& proj) const;
135 
136 
137  protected:
138 
140  bool _allowProjReg;
141 
142 
143  private:
144 
146  ProjectionHandler& _projhandler;
147 
148  };
149 
150 }
151 
152 #endif
const Projection & getProjection(const std::string &name) const
Definition: ProjectionApplier.hh:57
const PROJ & applyProjection(const Event &evt, const Projection &proj) const
Apply the supplied projection on event.
Definition: ProjectionApplier.hh:74
const PROJ & getProjection(const std::string &name) const
Get the named projection, specifying return type via a template argument.
Definition: ProjectionApplier.hh:49
static Log & getLog(const std::string &name)
Definition: Logging.cc:55
Definition: Logging.hh:9
virtual std::string name() const =0
Get the name of this Projection or Analysis class.
The projection handler is a central repository for projections to be used in a Rivet analysis run...
Definition: ProjectionHandler.hh:41
const PROJ & applyProjection(const Event &evt, const PROJ &proj) const
Apply the supplied projection on event.
Definition: ProjectionApplier.hh:67
Definition: Event.hh:22
const Projection & getProjection(const ProjectionApplier &parent, const string &name) const
Definition: ProjectionHandler.cc:258
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:18
std::set< ConstProjectionPtr > getProjections() const
Get the contained projections, including recursion.
Definition: ProjectionApplier.hh:42
ProjectionHandler & getProjHandler() const
Get a reference to the ProjectionHandler for this thread.
Definition: ProjectionApplier.hh:94
set< const Projection * > getChildProjections(const ProjectionApplier &parent, ProjDepth depth=SHALLOW) const
Definition: ProjectionHandler.cc:233
const PROJ & applyProjection(const Event &evt, const std::string &name) const
Apply the named projection on event.
Definition: ProjectionApplier.hh:81
const PROJ & addProjection(const PROJ &proj, const std::string &name)
Definition: ProjectionApplier.hh:113
ProjectionApplier()
Constructor.
Definition: ProjectionApplier.cc:10
Base class for all Rivet projections.
Definition: Projection.hh:28