rivet is hosted by Hepforge, IPPP Durham

#include <Event.hh>

Collaboration diagram for Event:

List of all members.

Public Member Functions

const GenEvent * genEvent () const
 The generated event obtained from an external event generator.
double weight () const
 The generation weight associated with the event.
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
Standard constructors and destructors.
 Event (const GenEvent &ge)
 Constructor from a HepMC GenEvent reference.
 Event (const GenEvent *ge)
 Constructor from a HepMC GenEvent pointer.
 Event (const Event &e)
 Copy constructor.

Private Member Functions

void _init (const GenEvent &ge)
 Actual (shared) implementation of the constructors from GenEvents.
void _geNormAlignment ()
 Convert the GenEvent to use conventional alignment.

Private Attributes

const GenEvent * _originalGenEvent
 The generated event, as obtained from an external generator.
GenEvent _genEvent
 The GenEvent used by Rivet analysis projections etc.
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 Projections object 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 reference.

Definition at line 29 of file Event.hh.

References Event::_init().

      : _originalGenEvent(&ge), _genEvent(ge)
    { _init(ge); }
Event ( const GenEvent *  ge) [inline]

Constructor from a HepMC GenEvent pointer.

Definition at line 34 of file Event.hh.

References Event::_init().

      : _originalGenEvent(ge), _genEvent(*ge)
    { assert(ge); _init(*ge); }
Event ( const Event e) [inline]

Copy constructor.

Definition at line 39 of file Event.hh.

      : _originalGenEvent(e._originalGenEvent), _genEvent(e._genEvent)
    {  }

Member Function Documentation

void _geNormAlignment ( ) [private]

Convert the GenEvent to use conventional alignment.

For example, FHerwig only produces DIS events in the unconventional hadron-lepton orientation and has to be corrected for DIS analysis portability.

Todo:
Is there an e+ e- convention for longitudinal boosting, e.g. at B-factories? Different from LEP?

Definition at line 48 of file Event.cc.

References Event::_genEvent, Log::getLog(), Rivet::GeV, Log::isActive(), Rivet::PID::PROTON, and Log::TRACE.

Referenced by Event::_init().

                               {
    if (!_genEvent.valid_beam_particles()) return;
    typedef pair<HepMC::GenParticle*, HepMC::GenParticle*> GPPair;
    GPPair bps = _genEvent.beam_particles();

    // Rotate e+- p and ppbar to put p along +z
    /// @todo Is there an e+ e- convention for longitudinal boosting, e.g. at B-factories? Different from LEP?
    // if (compatible(beamids, make_pdgid_pair(ELECTRON, PROTON)) ||
    //     compatible(beamids, make_pdgid_pair(POSITRON, PROTON)) ||
    //     compatible(beamids, make_pdgid_pair(ANTIPROTON, PROTON)) ) {
    //   Log::getLog("Rivet.Event") << Log::TRACE << "May need to rotate event..." << endl;
    bool rot = false;
    const HepMC::GenParticle* plusgp = 0;
    if (bps.first->pdg_id() != PID::PROTON || bps.second->pdg_id() != PID::PROTON) {
      if (bps.first->pdg_id() == PID::PROTON) {
        plusgp = bps.first;
      } else if (bps.second->pdg_id() == PID::PROTON) {
        plusgp = bps.second;
      }
      if (plusgp && plusgp->momentum().pz() < 0) {
        rot = true;
      }
    }

    // Do the rotation
    if (rot) {
      if (Log::getLog("Rivet.Event").isActive(Log::TRACE)) {
        Log::getLog("Rivet.Event") << Log::TRACE << "Rotating event\n"
                                   << "Before rotation: "
                                   << bps.first->pdg_id() << "@pz=" << bps.first->momentum().pz()/GeV << ", "
                                   << bps.second->pdg_id() << "@pz=" << bps.second->momentum().pz()/GeV << endl;
      }
      _geRot180x(_genEvent);
    }
  }
void _init ( const GenEvent &  ge) [private]

Actual (shared) implementation of the constructors from GenEvents.

Todo:
When we can require C++11, constructors can call each other and this can be removed.
Todo:
Enable this when HepMC has been fixed to allow printing to a stream like the Rivet logger.

Definition at line 10 of file Event.cc.

References Event::_genEvent, and Event::_geNormAlignment().

Referenced by Event::Event().

                                      {
    // 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 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 72 of file Event.hh.

References Event::_projections, and Projection::project().

Referenced by ProjectionApplier::_applyProjection(), and Event::applyProjection().

                                               {
      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]

Definition at line 89 of file Event.hh.

References Event::applyProjection().

                                                {
      if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null.");
      return applyProjection(*pp);
    }
const GenEvent* genEvent ( ) const [inline]

Member Data Documentation

GenEvent _genEvent [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 much neater this way.

Definition at line 126 of file Event.hh.

Referenced by Event::_geNormAlignment(), Event::_init(), Event::genEvent(), and Event::weight().

const GenEvent* _originalGenEvent [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 116 of file Event.hh.

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

The set of Projection objects applied so far.

Definition at line 129 of file Event.hh.

Referenced by Event::applyProjection().


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