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
 Return the generated event obtained from an external event generator.
double weight () const
 The weight associated with the event.
template<typename PROJ >
const PROJ & applyProjection (PROJ &p) const
template<typename PROJ >
const PROJ & applyProjection (PROJ *pp) const
Standard constructors and destructors.
 Event (const GenEvent &ge)
 The default constructor.
 Event (const Event &e)
 The copy constructor.
 ~Event ()
 The destructor.

Private Member Functions

void _geNormAlignment ()

Private Attributes

GenEvent const & _genEvent
 The generated event, obtained from an external generator. Note that it is only externally accessible via a const reference.
GenEvent * _modGenEvent
std::set< ConstProjectionPtr_projections
 The set of Projection objects applied so far.
double _weight
 The generation weight associated with the event. Usually 1.0. Only copied from the HepMC event once, at construction time.

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)

The default constructor.

Definition at line 66 of file Event.cc.

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

    : _genEvent(ge), _modGenEvent(NULL), _weight(1.0)
  {
    // Set the weight if there is one, otherwise default to 1.0
    if (!_genEvent.weights().empty()) {
      _weight = ge.weights()[0];
    }

    // Use Rivet's preferred units if possible
    #ifdef HEPMC_HAS_UNITS
    if (_genEvent.momentum_unit() != HepMC::Units::GEV ||
        _genEvent.length_unit() != HepMC::Units::MM) {
      if (!_modGenEvent) _modGenEvent = new GenEvent(ge);
      _modGenEvent->use_units(HepMC::Units::GEV, HepMC::Units::MM);
    }
    #endif

    // Use the conventional alignment
    _geNormAlignment();

    // Debug printout to check that copying/mangling has worked
    //_genEvent.print();
  }
Event ( const Event e)

The copy constructor.

Definition at line 91 of file Event.cc.

    : _genEvent(e._genEvent), _modGenEvent(e._modGenEvent),
      _weight(e._weight)
  {
    //
  }
~Event ( )

The destructor.

Definition at line 99 of file Event.cc.

References Event::_modGenEvent.

                {
    if (_modGenEvent) delete _modGenEvent;
  }

Member Function Documentation

void _geNormAlignment ( ) [private]
Todo:
e+ e- convention? B-factories different from LEP?

Definition at line 26 of file Event.cc.

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

Referenced by Event::Event().

                               {
    if (!_genEvent.valid_beam_particles()) return;
    typedef pair<HepMC::GenParticle*, HepMC::GenParticle*> GPPair;
    GPPair bps = _genEvent.beam_particles();
    //const PdgIdPair beamids = make_pdgid_pair(bps.first->pdg_id(), bps.second->pdg_id());
    //Log::getLog("Rivet.Event") << Log::TRACE << "Beam IDs: " << beamids << endl;
    const HepMC::GenParticle* plusgp = 0;
    bool rot = false;

    // Rotate e+- p and ppbar to put p along +z
    /// @todo e+ e- convention? 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;
    if (bps.first->pdg_id() != PROTON || bps.second->pdg_id() != PROTON) {
      if (bps.first->pdg_id() == PROTON) {
        plusgp = bps.first;
      } else if (bps.second->pdg_id() == 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" << endl;
        Log::getLog("Rivet.Event") << Log::TRACE << "Before rotation: "
                                   << bps.first->pdg_id() << "@pz=" << bps.first->momentum().pz()/GeV << ", "
                                   << bps.second->pdg_id() << "@pz=" << bps.second->momentum().pz()/GeV << endl;
      }
      if (!_modGenEvent) _modGenEvent = new GenEvent(_genEvent);
      _geRot180x(*_modGenEvent);
    }
  }
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 60 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 77 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

Return the generated event obtained from an external event generator.

Definition at line 103 of file Event.cc.

References Event::_genEvent, and Event::_modGenEvent.

Referenced by CMS_2011_S8941262::analyze(), MC_PDFS::analyze(), MC_IDENTIFIED::analyze(), InitialQuarks::project(), UnstableFinalState::project(), Beam::project(), and FinalState::project().

                                        {
    if (_modGenEvent) return *_modGenEvent;
    return _genEvent;
  }

Member Data Documentation

GenEvent const& _genEvent [private]

The generated event, obtained from an external generator. Note that it is only externally accessible via a const reference.

Definition at line 89 of file Event.hh.

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

GenEvent* _modGenEvent [private]

Definition at line 91 of file Event.hh.

Referenced by Event::_geNormAlignment(), Event::Event(), Event::genEvent(), and Event::~Event().

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

The set of Projection objects applied so far.

Definition at line 94 of file Event.hh.

Referenced by Event::applyProjection().

double _weight [private]

The generation weight associated with the event. Usually 1.0. Only copied from the HepMC event once, at construction time.

Definition at line 98 of file Event.hh.

Referenced by Event::Event(), and Event::weight().


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