Rivet  1.8.0
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 
36  virtual std::string name() const = 0;
38 
40 
41 
42  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 
66  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