rivet is hosted by Hepforge, IPPP Durham

#include <Event.hh>

List of all members.

Public Member Functions

Constructors and destructors.
 Event (const GenEvent *ge)
 Constructor from a HepMC GenEvent pointer.
 Event (const GenEvent &ge)
 Event (const Event &e)
 Copy constructor.
Major event properties
ParticlePair beams () const
 Get the beam particles.
double sqrtS () const
 Get the beam centre-of-mass energy.
double asqrtS () const
 Get the beam centre-of-mass energy per nucleon.
const GenEvent * genEvent () const
 The generated event obtained from an external event generator.
const ParticlesallParticles () const
 All the raw GenEvent particles, wrapped in Rivet::Particle objects.
Particles allParticles (const Cut &c) const
 All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a Cut applied.
template<typename FN >
Particles allParticles (const FN &f) const
 All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a selection function applied.
double weight () const
 The generation weight associated with the event.
Projection running
template<typename PROJ >
const PROJ & applyProjection (PROJ &p) const
 Add a projection p to this Event.
template<typename PROJ >
const PROJ & applyProjection (PROJ *pp) const
 Add a projection p to this Event by pointer.

Private Member Functions

void _init (const GenEvent &ge)
 Actual (shared) implementation of the constructors from GenEvents.

Private Attributes

const GenEvent * _genevent_original
 The generated event, as obtained from an external generator.
GenEvent _genevent
 The GenEvent used by Rivet analysis projections etc.
Particles _particles
std::set< ConstProjectionPtr_projections
 The set of Projection objects applied so far.

Detailed Description

Rivet wrapper for HepMC event and Projection references.

Event is a concrete class representing an generated event in Rivet. It is constructed given a HepMC::GenEvent, a pointer to which is kept by the Event object throughout its lifetime. The user must therefore make sure that the corresponding HepMC::GenEvent will persist at least as long as the Event object.

In addition to the HepMC::GenEvent object the Event also keeps track of all Projection objects which have been applied to the Event so far.

Definition at line 22 of file Event.hh.


Constructor & Destructor Documentation

Event ( const GenEvent *  ge) [inline]

Constructor from a HepMC GenEvent pointer.

Definition at line 29 of file Event.hh.

      : _genevent_original(ge), _genevent(*ge)
    { assert(ge); _init(*ge); }
Event ( const GenEvent &  ge) [inline]

Constructor from a HepMC GenEvent reference

Deprecated:
HepMC uses pointers, so we should talk to HepMC via pointers

Definition at line 35 of file Event.hh.

      : _genevent_original(&ge), _genevent(ge)
    { _init(ge); }
Event ( const Event e) [inline]

Copy constructor.

Definition at line 40 of file Event.hh.

      : _genevent_original(e._genevent_original), _genevent(e._genevent)
    {  }

Member Function Documentation

void _init ( const GenEvent &  ge) [private]

Actual (shared) implementation of the constructors from GenEvents.

Todo:
Filter the event to remove generator-specific particles: optional behaviour? Maybe disableable in an inconvenient way, e.g. with an env var, to communicate the appropriate distaste for this sort of truth analysis ;-)
Todo:
Enable this when HepMC has been fixed to allow printing to a stream like the Rivet logger.

Definition at line 24 of file Event.cc.

                                      {
    // Use Rivet's preferred units if possible
    #ifdef HEPMC_HAS_UNITS
    _genevent.use_units(HepMC::Units::GEV, HepMC::Units::MM);
    #endif

    // Use the conventional alignment
    // _geNormAlignment();

    /// @todo Filter the event to remove generator-specific particles: optional
    /// behaviour? Maybe disableable in an inconvenient way, e.g. with an env
    /// var, to communicate the appropriate distaste for this sort of truth
    /// analysis ;-)

    // Debug printout to check that copying/mangling has worked
    /// @todo Enable this when HepMC has been fixed to allow printing to a stream like the Rivet logger.
    //_genevent.print();
  }
const Particles & allParticles ( ) const

All the raw GenEvent particles, wrapped in Rivet::Particle objects.

Definition at line 99 of file Event.cc.

                                             {
    if (_particles.empty()) { //< assume that empty means no attempt yet made
      for (const GenParticle* gp : particles(genEvent())) {
        _particles += Particle(gp);
      }
    }
    return _particles;
  }
Particles allParticles ( const Cut c) const [inline]

All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a Cut applied.

Note:
Due to the cut, this returns by value, i.e. involves an expensive copy

Definition at line 74 of file Event.hh.

                                                      {
      return filter_select(allParticles(), c);
    }
Particles allParticles ( const FN &  f) const [inline]

All the raw GenEvent particles, wrapped in Rivet::Particle objects, but with a selection function applied.

Note:
Due to the cut, this returns by value, i.e. involves an expensive copy

Definition at line 82 of file Event.hh.

                                                     {
      return filter_select(allParticles(), f);
    }
const PROJ& applyProjection ( PROJ &  p) const [inline]

Add a projection p to this Event.

If an equivalent Projection has been applied before, the Projection::project(const Event&) of p is not called and a reference to the previous equivalent projection is returned. If no previous Projection was found, the Projection::project(const Event&) of p is called and a reference to p is returned.

Definition at line 106 of file Event.hh.

                                               {
      const Projection* cpp(&p);
      std::set<const Projection*>::const_iterator old = _projections.find(cpp);
      if (old != _projections.end()) {
        const Projection& pRef = **old;
        return pcast<PROJ>(pRef);
      }
      // Add the projection via the Projection base class (only
      // possible because Event is a friend of Projection)
      Projection* pp = const_cast<Projection*>(cpp);
      pp->project(*this);
      _projections.insert(pp);
      return p;
    }
const PROJ& applyProjection ( PROJ *  pp) const [inline]

Add a projection p to this Event by pointer.

Definition at line 123 of file Event.hh.

                                                {
      if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null.");
      return applyProjection(*pp);
    }
double asqrtS ( ) const

Get the beam centre-of-mass energy per nucleon.

Definition at line 16 of file Event.cc.

{ return Rivet::asqrtS(beams()); }
ParticlePair beams ( ) const

Get the beam particles.

Definition at line 10 of file Event.cc.

{ return Rivet::beams(*this); }
const GenEvent* genEvent ( ) const [inline]

The generated event obtained from an external event generator.

Definition at line 66 of file Event.hh.

{ return &_genevent; }
double sqrtS ( ) const

Get the beam centre-of-mass energy.

Definition at line 14 of file Event.cc.

{ return Rivet::sqrtS(beams()); }
double weight ( ) const

The generation weight associated with the event.

Todo:
This needs to be revisited when we finally add the mechanism to support NLO counter-events and weight vectors.

Definition at line 109 of file Event.cc.

                             {
    return (!_genevent.weights().empty()) ? _genevent.weights()[0] : 1.0;
  }

Member Data Documentation

GenEvent _genevent [mutable, private]

The GenEvent used by Rivet analysis projections etc.

This version may be rotated to a "normal" alignment, have generator-specific particles stripped out, etc. If an analysis is affected by these modifications, it is probably an unphysical analysis!

Stored as a non-pointer since it may get overwritten, and memory for copying and cleanup is neater this way.

Todo:
Change needed for HepMC3?

Definition at line 160 of file Event.hh.

const GenEvent* _genevent_original [private]

The generated event, as obtained from an external generator.

This is the original GenEvent. In practise the version seen by users will often/always be a modified one.

Todo:
Provide access to this via an Event::originalGenEvent() method? If requested...

Definition at line 149 of file Event.hh.

Particles _particles [mutable, private]

All the GenEvent particles, wrapped as Rivet::Particles

Note:
To be populated lazily, hence mutability

Definition at line 164 of file Event.hh.

std::set<ConstProjectionPtr> _projections [mutable, private]

The set of Projection objects applied so far.

Definition at line 167 of file Event.hh.


The documentation for this class was generated from the following files: