Beam.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Rivet.hh"
00003 #include "Rivet/Tools/Logging.hh"
00004 #include "Rivet/Projections/Beam.hh"
00005 
00006 namespace Rivet {
00007 
00008 
00009   ParticlePair beams(const Event& e) {
00010     Beam beamproj;
00011     beamproj.project(e);
00012     return beamproj.beams();
00013   }
00014 
00015   BeamPair beamIds(const Event& e) {
00016     Beam beamproj;
00017     beamproj.project(e);
00018     return beamproj.beamIds();
00019   }
00020 
00021   BeamPair beamIds(const ParticlePair& beams) {
00022     return make_pair(beams.first.pdgId(), beams.second.pdgId());
00023   }
00024 
00025   double sqrtS(const Event& e) {
00026     Beam beamproj;
00027     beamproj.project(e);
00028     return beamproj.sqrtS();
00029   }
00030 
00031   double sqrtS(const ParticlePair& beams) {
00032     return sqrtS(beams.first.momentum(), beams.second.momentum());
00033   }
00034 
00035   double sqrtS(const FourMomentum& pa, const FourMomentum& pb) {
00036     const double mom1 = pa.pz();
00037     const double e1 = pa.E();
00038     const double mom2 = pb.pz();
00039     const double e2 = pb.E();
00040     double sqrts = sqrt( sqr(e1+e2) - sqr(mom1+mom2) );
00041     return sqrts;
00042   }
00043 
00044 
00045 
00046   /////////////////////////////////////////////
00047 
00048 
00049 
00050   void Beam::project(const Event& e) {
00051     assert(e.genEvent().particles_size() >= 2);
00052     pair<HepMC::GenParticle*, HepMC::GenParticle*> beams = e.genEvent().beam_particles();
00053     assert(beams.first && beams.second);
00054     _theBeams.first = *(beams.first);
00055     _theBeams.second = *(beams.second);
00056     getLog() << Log::DEBUG << "Beam particle IDs = " << beamIds() << endl;
00057   }
00058 
00059 
00060   double Beam::sqrtS() const {
00061     double sqrts = Rivet::sqrtS(beams());
00062     getLog() << Log::DEBUG << "sqrt(s) = " << sqrts/GeV << " GeV" << endl;
00063     return sqrts;
00064   }
00065   
00066 
00067 
00068 }