Event.cc
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #include "Rivet/Event.hh" 00003 #include "Rivet/Tools/BeamConstraint.hh" 00004 #include "Rivet/Projections/Beam.hh" 00005 #include "HepMC/GenEvent.h" 00006 00007 namespace Rivet { 00008 00009 00010 ParticlePair Event::beams() const { return Rivet::beams(*this); } 00011 00012 // PdgIdPair Event::beamIds() const { return pids(beams()); } 00013 00014 double Event::sqrtS() const { return Rivet::sqrtS(beams()); } 00015 00016 double Event::asqrtS() const { return Rivet::asqrtS(beams()); } 00017 00018 // Vector3 Event::beamCMSBoost() const { return Rivet::beamCMSBoost(*this); } 00019 00020 // LorentzTransform Event::beamCMSTransform() const { return Rivet::beamCMSTransform(*this); } 00021 00022 00023 00024 void Event::_init(const GenEvent& ge) { 00025 // Use Rivet's preferred units if possible 00026 #ifdef HEPMC_HAS_UNITS 00027 _genevent.use_units(HepMC::Units::GEV, HepMC::Units::MM); 00028 #endif 00029 00030 // Use the conventional alignment 00031 // _geNormAlignment(); 00032 00033 /// @todo Filter the event to remove generator-specific particles: optional 00034 /// behaviour? Maybe disableable in an inconvenient way, e.g. with an env 00035 /// var, to communicate the appropriate distaste for this sort of truth 00036 /// analysis ;-) 00037 00038 // Debug printout to check that copying/mangling has worked 00039 /// @todo Enable this when HepMC has been fixed to allow printing to a stream like the Rivet logger. 00040 //_genevent.print(); 00041 } 00042 00043 00044 // namespace { // unnamed namespace for hiding 00045 // 00046 // void _geRot180x(GenEvent& ge) { 00047 // /// @todo Use nicer iterators over HepMC particles 00048 // for (HepMC::GenEvent::particle_iterator ip = ge.particles_begin(); ip != ge.particles_end(); ++ip) { 00049 // const HepMC::FourVector& mom = (*ip)->momentum(); 00050 // (*ip)->set_momentum(HepMC::FourVector(mom.px(), -mom.py(), -mom.pz(), mom.e())); 00051 // } 00052 // /// @todo Use nicer iterators over HepMC vertices 00053 // for (HepMC::GenEvent::vertex_iterator iv = ge.vertices_begin(); iv != ge.vertices_end(); ++iv) { 00054 // const HepMC::FourVector& pos = (*iv)->position(); 00055 // (*iv)->set_position(HepMC::FourVector(pos.x(), -pos.y(), -pos.z(), pos.t())); 00056 // } 00057 // } 00058 // 00059 // } 00060 00061 00062 // void Event::_geNormAlignment() { 00063 // if (!_genevent.valid_beam_particles()) return; 00064 // typedef pair<HepMC::GenParticle*, HepMC::GenParticle*> GPPair; 00065 // GPPair bps = _genevent.beam_particles(); 00066 // 00067 // // Rotate e+- p and ppbar to put p along +z 00068 // /// @todo Is there an e+ e- convention for longitudinal boosting, e.g. at B-factories? Different from LEP? 00069 // // if (compatible(beamids, make_pdgid_pair(ELECTRON, PROTON)) || 00070 // // compatible(beamids, make_pdgid_pair(POSITRON, PROTON)) || 00071 // // compatible(beamids, make_pdgid_pair(ANTIPROTON, PROTON)) ) { 00072 // // Log::getLog("Rivet.Event") << Log::TRACE << "May need to rotate event..." << endl; 00073 // bool rot = false; 00074 // const HepMC::GenParticle* plusgp = 0; 00075 // if (bps.first->pdg_id() != PID::PROTON || bps.second->pdg_id() != PID::PROTON) { 00076 // if (bps.first->pdg_id() == PID::PROTON) { 00077 // plusgp = bps.first; 00078 // } else if (bps.second->pdg_id() == PID::PROTON) { 00079 // plusgp = bps.second; 00080 // } 00081 // if (plusgp && plusgp->momentum().pz() < 0) { 00082 // rot = true; 00083 // } 00084 // } 00085 // 00086 // // Do the rotation 00087 // if (rot) { 00088 // if (Log::getLog("Rivet.Event").isActive(Log::TRACE)) { 00089 // Log::getLog("Rivet.Event") << Log::TRACE << "Rotating event\n" 00090 // << "Before rotation: " 00091 // << bps.first->pdg_id() << "@pz=" << bps.first->momentum().pz()/GeV << ", " 00092 // << bps.second->pdg_id() << "@pz=" << bps.second->momentum().pz()/GeV << endl; 00093 // } 00094 // _geRot180x(_genevent); 00095 // } 00096 // } 00097 00098 00099 const Particles& Event::allParticles() const { 00100 if (_particles.empty()) { //< assume that empty means no attempt yet made 00101 for (const GenParticle* gp : particles(genEvent())) { 00102 _particles += Particle(gp); 00103 } 00104 } 00105 return _particles; 00106 } 00107 00108 00109 double Event::weight() const { 00110 return (!_genevent.weights().empty()) ? _genevent.weights()[0] : 1.0; 00111 } 00112 00113 00114 } Generated on Tue Dec 13 2016 16:32:37 for The Rivet MC analysis system by ![]() |