#include <Event.hh>
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.
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. |
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.
00067 : _genEvent(ge), _modGenEvent(NULL), _weight(1.0) 00068 { 00069 // Set the weight if there is one, otherwise default to 1.0 00070 if (!_genEvent.weights().empty()) { 00071 _weight = ge.weights()[0]; 00072 } 00073 00074 // Use Rivet's preferred units if possible 00075 #ifdef HEPMC_HAS_UNITS 00076 if (_genEvent.momentum_unit()!=HepMC::Units::GEV || 00077 _genEvent.length_unit()!=HepMC::Units::MM) { 00078 if (!_modGenEvent) _modGenEvent = new GenEvent(ge); 00079 _modGenEvent->use_units(HepMC::Units::GEV, HepMC::Units::MM); 00080 } 00081 #endif 00082 00083 // Use the conventional alignment 00084 _geNormAlignment(); 00085 00086 // Debug printout to check that copying/magling has worked 00087 //_genEvent.print(); 00088 }
The copy constructor.
Definition at line 91 of file Event.cc.
00092 : _genEvent(e._genEvent), _modGenEvent(e._modGenEvent), 00093 _weight(e._weight) 00094 { 00095 // 00096 }
~Event | ( | ) |
The destructor.
Definition at line 99 of file Event.cc.
References Event::_modGenEvent.
00099 { 00100 if (_modGenEvent) delete _modGenEvent; 00101 }
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 UnstableFinalState::project(), PVertex::project(), InitialQuarks::project(), FinalState::project(), and Beam::project().
00103 { 00104 if (_modGenEvent) return *_modGenEvent; 00105 return _genEvent; 00106 }
double weight | ( | ) | const [inline] |
The weight associated with the event.
Definition at line 46 of file Event.hh.
References Event::_weight.
Referenced by OPAL_1993_S2692198::analyze(), MC_ZZJETS::analyze(), MC_WWJETS::analyze(), MC_JetAnalysis::analyze(), JADE_OPAL_2000_S4300807::analyze(), D0_2010_S8671338::analyze(), D0_2010_S8566488::analyze(), D0_2009_S8320160::analyze(), D0_2009_S8202443::analyze(), D0_2008_S7863608::analyze(), D0_2008_S7554427::analyze(), D0_2007_S7075677::analyze(), CDF_2008_S8093652::analyze(), BELLE_2006_S6265367::analyze(), and ALEPH_2004_S5765862::analyze().
00046 { 00047 return _weight; 00048 }
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().
00060 { 00061 const Projection* cpp(&p); 00062 std::set<const Projection*>::const_iterator old = _projections.find(cpp); 00063 if (old != _projections.end()) { 00064 const Projection& pRef = **old; 00065 return pcast<PROJ>(pRef); 00066 } 00067 // Add the projection via the Projection base class (only 00068 // possible because Event is a friend of Projection) 00069 Projection* pp = const_cast<Projection*>(cpp); 00070 pp->project(*this); 00071 _projections.insert(pp); 00072 return p; 00073 }
const PROJ& applyProjection | ( | PROJ * | pp | ) | const [inline] |
Definition at line 77 of file Event.hh.
References Event::applyProjection().
00077 { 00078 if (!pp) throw Error("Event::applyProjection(PROJ*): Projection pointer is null."); 00079 return applyProjection(*pp); 00080 }
void _geNormAlignment | ( | ) | [private] |
Definition at line 26 of file Event.cc.
References Event::_genEvent, Rivet::_geRot180x(), Event::_modGenEvent, Log::getLog(), Rivet::GeV, Log::isActive(), Rivet::make_pdgid_pair(), Rivet::PROTON, and Log::TRACE.
Referenced by Event::Event().
00026 { 00027 if (!_genEvent.valid_beam_particles()) return; 00028 typedef pair<HepMC::GenParticle*, HepMC::GenParticle*> GPPair; 00029 GPPair bps = _genEvent.beam_particles(); 00030 const PdgIdPair beamids = make_pdgid_pair(bps.first->pdg_id(), bps.second->pdg_id()); 00031 //Log::getLog("Rivet.Event") << Log::TRACE << "Beam IDs: " << beamids << endl; 00032 const HepMC::GenParticle* plusgp = 0; 00033 bool rot = false; 00034 00035 // Rotate e+- p and ppbar to put p along +z 00036 /// @todo e+ e- convention? B-factories different from LEP? 00037 // if (compatible(beamids, make_pdgid_pair(ELECTRON, PROTON)) || 00038 // compatible(beamids, make_pdgid_pair(POSITRON, PROTON)) || 00039 // compatible(beamids, make_pdgid_pair(ANTIPROTON, PROTON)) ) { 00040 // Log::getLog("Rivet.Event") << Log::TRACE << "May need to rotate event..." << endl; 00041 if (bps.first->pdg_id() != PROTON || bps.second->pdg_id() != PROTON) { 00042 if (bps.first->pdg_id() == PROTON) { 00043 plusgp = bps.first; 00044 } else if (bps.second->pdg_id() == PROTON) { 00045 plusgp = bps.second; 00046 } 00047 if (plusgp && plusgp->momentum().pz() < 0) { 00048 rot = true; 00049 } 00050 } 00051 00052 // Do the rotation 00053 if (rot) { 00054 if (Log::getLog("Rivet.Event").isActive(Log::TRACE)) { 00055 Log::getLog("Rivet.Event") << Log::TRACE << "Rotating event" << endl; 00056 Log::getLog("Rivet.Event") << Log::TRACE << "Before rotation: " 00057 << bps.first->pdg_id() << "@pz=" << bps.first->momentum().pz()/GeV << ", " 00058 << bps.second->pdg_id() << "@pz=" << bps.second->momentum().pz()/GeV << endl; 00059 } 00060 if (!_modGenEvent) _modGenEvent = new GenEvent(_genEvent); 00061 _geRot180x(*_modGenEvent); 00062 } 00063 }
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().