rivet is hosted by Hepforge, IPPP Durham
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   PdgIdPair beamIds(const Event& e) {
00016     Beam beamproj;
00017     beamproj.project(e);
00018     return beamproj.beamIds();
00019   }
00020 
00021   PdgIdPair 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     if (e.genEvent()->valid_beam_particles()) {
00053       pair<HepMC::GenParticle*, HepMC::GenParticle*> beams = e.genEvent()->beam_particles();
00054       assert(beams.first && beams.second);
00055       _theBeams.first = *(beams.first);
00056       _theBeams.second = *(beams.second);
00057     } else if(e.genEvent()->barcode_to_particle(1) && e.genEvent()->barcode_to_particle(2)) {
00058       _theBeams.first = *(e.genEvent()->barcode_to_particle(1));
00059       _theBeams.second = *(e.genEvent()->barcode_to_particle(2));
00060     }
00061     else {
00062       _theBeams.first = Particle(PID::ANY, FourMomentum());
00063       _theBeams.second = Particle(PID::ANY, FourMomentum());
00064     }
00065     //MSG_DEBUG("Beam particle IDs = " << beamIds());
00066   }
00067 
00068 
00069   double Beam::sqrtS() const {
00070     double sqrts = Rivet::sqrtS(beams());
00071     //MSG_DEBUG("sqrt(s) = " << sqrts/GeV << " GeV");
00072     return sqrts;
00073   }
00074 
00075 
00076 
00077 }