Rivet  1.8.3
Event.hh
1 // -*- C++ -*-
2 #ifndef RIVET_Event_HH
3 #define RIVET_Event_HH
4 
5 #include "Rivet/Rivet.hh"
6 #include "Rivet/Projection.hh"
7 
8 namespace Rivet {
9 
10 
22  class Event {
23  public:
24 
26 
27 
29  Event(const GenEvent& ge);
30 
32  Event(const Event& e);
33 
35  ~Event();
36 
38 
39 
40  public:
41 
43  const GenEvent& genEvent() const;
44 
46  double weight() const {
47  return _weight;
48  }
49 
50 
51  public:
52 
59  template <typename PROJ>
60  const PROJ& applyProjection(PROJ& p) const {
61  const Projection* cpp(&p);
62  std::set<const Projection*>::const_iterator old = _projections.find(cpp);
63  if (old != _projections.end()) {
64  const Projection& pRef = **old;
65  return pcast<PROJ>(pRef);
66  }
67  // Add the projection via the Projection base class (only
68  // possible because Event is a friend of Projection)
69  Projection* pp = const_cast<Projection*>(cpp);
70  pp->project(*this);
71  _projections.insert(pp);
72  return p;
73  }
74 
75 
76  template <typename PROJ>
77  const PROJ& applyProjection(PROJ* pp) const {
78  if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null.");
79  return applyProjection(*pp);
80  }
81 
82 
83  private:
84  void _geNormAlignment();
85 
86 
89  GenEvent const& _genEvent;
90 
91  GenEvent* _modGenEvent;
92 
94  mutable std::set<ConstProjectionPtr> _projections;
95 
98  double _weight;
99 
100  };
101 
102 
103 }
104 
105 #endif