rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
Event.hh
1 // -*- C++ -*-
2 #ifndef RIVET_Event_HH
3 #define RIVET_Event_HH
4 
5 #include "Rivet/Config/RivetCommon.hh"
6 #include "Rivet/Particle.hh"
7 #include "Rivet/Projection.hh"
8 
9 namespace Rivet {
10 
11 
22  class Event {
23  public:
24 
26 
27 
29  Event(const GenEvent* ge)
30  : _genevent_original(ge), _genevent(*ge)
31  { assert(ge); _init(*ge); }
32 
35  Event(const GenEvent& ge)
36  : _genevent_original(&ge), _genevent(ge)
37  { _init(ge); }
38 
40  Event(const Event& e)
41  : _genevent_original(e._genevent_original), _genevent(e._genevent)
42  { }
43 
45 
46 
48 
49 
51  const GenEvent* genEvent() const { return &_genevent; }
52 
57  double weight() const;
58 
60  ParticlePair beams() const;
61 
63  double sqrtS() const;
64 
66  double asqrtS() const;
67 
69  double centrality() const;
70 
71  // /// Get the boost to the beam centre-of-mass
72  // Vector3 beamCMSBoost() const;
73 
74  // /// Get the boost to the beam centre-of-mass
75  // LorentzTransform beamCMSTransform();
76 
78 
79 
81 
82 
84  const Particles& allParticles() const;
85 
89  inline Particles allParticles(const Cut& c) const {
90  return filter_select(allParticles(), c);
91  }
92 
96  template <typename FN>
97  inline Particles allParticles(const FN& f) const {
98  return filter_select(allParticles(), f);
99  }
100 
102 
103 
105 
106 
114  template <typename PROJ>
115  const PROJ& applyProjection(PROJ& p) const {
116  Log& log = Log::getLog("Rivet.Event");
117  log << Log::TRACE << "Applying projection " << &p << " (" << p.name() << ") -> comparing to projections " << _projections << endl;
118  // First search for this projection *or an equivalent* in the already-executed list
119  const Projection* cpp(&p);
120  std::set<const Projection*>::const_iterator old = _projections.find(cpp);
121  if (old != _projections.end()) {
122  log << Log::TRACE << "Equivalent projection found -> returning already-run projection " << *old << endl;
123  const Projection& pRef = **old;
124  return pcast<PROJ>(pRef);
125  }
126  // If this one hasn't been run yet on this event, run it and add to the list
127  log << Log::TRACE << "No equivalent projection in the already-run list -> projecting now" << endl;
128  Projection* pp = const_cast<Projection*>(cpp);
129  pp->project(*this);
130  _projections.insert(pp);
131  return p;
132  }
133 
134 
136  template <typename PROJ>
137  const PROJ& applyProjection(PROJ* pp) const {
138  if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null.");
139  return applyProjection(*pp);
140  }
141 
143 
144 
145  private:
146 
148  void _init(const GenEvent& ge);
149 
150  // /// @brief Convert the GenEvent to use conventional alignment
151  // ///
152  // /// For example, FHerwig only produces DIS events in the unconventional
153  // /// hadron-lepton orientation and has to be corrected for DIS analysis
154  // /// portability.
155  // void _geNormAlignment();
156 
163  const GenEvent* _genevent_original;
164 
174  mutable GenEvent _genevent;
175 
178  mutable Particles _particles;
179 
181  mutable std::set<ConstProjectionPtr> _projections;
182 
183  };
184 
185 
186 }
187 
188 #endif
Particles allParticles(const FN &f) const
All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a selection function app...
Definition: Event.hh:97
Definition: ALICE_2010_I880049.cc:13
double asqrtS() const
Get the beam centre-of-mass energy per nucleon.
Definition: Event.cc:35
Event(const GenEvent &ge)
Definition: Event.hh:35
Particles allParticles(const Cut &c) const
All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a Cut applied...
Definition: Event.hh:89
const PROJ & applyProjection(PROJ *pp) const
Add a projection p to this Event by pointer.
Definition: Event.hh:137
static Log & getLog(const std::string &name)
Definition: Logging.cc:55
ParticlePair beams() const
Get the beam particles.
Definition: Event.cc:31
const GenEvent * genEvent() const
The generated event obtained from an external event generator.
Definition: Event.hh:51
Definition: Logging.hh:9
Generic runtime Rivet error.
Definition: Exceptions.hh:12
virtual void project(const Event &e)=0
double sqrtS() const
Get the beam centre-of-mass energy.
Definition: Event.cc:33
Definition: Event.hh:22
Jets filter_select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition: JetUtils.hh:143
const PROJ & applyProjection(PROJ &p) const
Add a projection p to this Event.
Definition: Event.hh:115
Event(const Event &e)
Copy constructor.
Definition: Event.hh:40
double weight() const
The generation weight associated with the event.
Definition: Event.cc:11
Event(const GenEvent *ge)
Constructor from a HepMC GenEvent pointer.
Definition: Event.hh:29
double centrality() const
Get the generator centrality (impact-parameter quantile in [0,1]; or -1 if undefined (usual for non-H...
Definition: Event.cc:26
const Particles & allParticles() const
All the raw GenEvent particles, wrapped in Rivet::Particle objects.
Definition: Event.cc:47
Base class for all Rivet projections.
Definition: Projection.hh:29