Utils.cc

Go to the documentation of this file.
00001 #include "Rivet/Rivet.hh"
00002 #include "Rivet/Tools/Utils.hh"
00003 
00004 
00005 namespace Rivet {
00006 
00007 
00008   /// A function to get the Rivet version string
00009   string version() {
00010     return RIVET_VERSION;
00011   }
00012 
00013 
00014   ////////////////////////////////////////////////////////////////
00015 
00016 
00017   // Return distance of closest approach from track to given (primary) vertex position.
00018   double get2dClosestApproach(const HepMC::GenParticle& track, const Vector3& vtx3pos) {
00019     /// @todo Whoa! - implicit constructors from hell!
00020     HepMC::FourVector trkvec = track;
00021     HepMC::ThreeVector trk3vec = trkvec;
00022     HepMC::ThreeVector trk3pos = track.production_vertex()->position();
00023  
00024     Vector3 diff(vtx3pos.x()-trk3pos.x(), vtx3pos.y()-trk3pos.y(), vtx3pos.z()-trk3pos.z());
00025  
00026     // Impact parameter in the transverse plane
00027     const double d = fabs( trk3vec.x()*diff.y() - trk3vec.y()*diff.x() )
00028       / sqrt( sqr(trk3vec.x()) + sqr(trk3vec.y()) );
00029     return d;
00030   }
00031 
00032 
00033   // Return distance of closest approach from track to given (primary) vertex position.
00034   double get3dClosestApproach(const HepMC::GenParticle& track, const Vector3& vtx3pos) {
00035     HepMC::FourVector trkvec = track;
00036     HepMC::ThreeVector trk3vec = trkvec;
00037     HepMC::FourVector trkpos = track.production_vertex()->position();
00038     HepMC::ThreeVector trk3pos = trkpos;
00039     Vector3 diff(vtx3pos.x()-trk3pos.x(), vtx3pos.y()-trk3pos.y(), vtx3pos.z()-trk3pos.z());
00040  
00041     // Impact parameter in 3 dimensions
00042     const double mag = sqrt( sqr(trk3vec.x()) + sqr(trk3vec.y()) + sqr(trk3vec.z()) );
00043     const double d = sqrt( sqr(trk3vec.y()*diff.z()-trk3vec.z()*diff.y()) -
00044                            sqr(trk3vec.x()*diff.z()-trk3vec.z()*diff.x()) +
00045                            sqr(trk3vec.x()*diff.y()-trk3vec.y()*diff.x()) ) / mag;
00046     return d;
00047   }
00048 
00049 
00050   /// Return Decay Length Significance between two vertices in transverse plane
00051   double get2dDecayLength(const Vector3& vtx1, const Vector3& vtx2, const FourMomentum& jetaxis) {
00052     Vector3 diff = vtx1 - vtx2;
00053     const double l = (jetaxis.px()*diff.x() + jetaxis.py()*diff.y() )
00054       / sqrt(sqr(jetaxis.px())+sqr(jetaxis.py()));
00055     return l;
00056   }
00057 
00058 
00059 
00060   /// Return 3 dimensional Decay Length Significance between vertices
00061   double get3dDecayLength(const Vector3& vtx1, const Vector3& vtx2, const FourMomentum& jetaxis) {
00062     Vector3 diff = vtx1 - vtx2;
00063     const double l = (jetaxis.px()*diff.x() +jetaxis.py()*diff.y() +jetaxis.pz()*diff.z())
00064       / sqrt(sqr(jetaxis.px())+sqr(jetaxis.py())+sqr(jetaxis.pz()));
00065     return l;
00066   }
00067 
00068 }