Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TrackJet.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //     Jet algorithm from the Field & Stuart minimum bias study.
00003 
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Projections/TrackJet.hh"
00006 #include "Rivet/Cmp.hh"
00007 #include "Rivet/RivetCLHEP.hh"
00008 #include <algorithm>
00009 
00010 using namespace Rivet;
00011 using namespace CLHEP;
00012 using namespace std;
00013 
00014 
00015 int TrackJet::compare(const Projection& p) const {
00016   const TrackJet& other = dynamic_cast<const TrackJet&>(p);
00017   return pcmp(*_fsproj, *other._fsproj);
00018 }
00019 
00020 
00021 void TrackJet::project(const Event & e) {
00022   Log& log = getLog();
00023   _jets.clear();
00024 
00025   // Project into final state
00026   // NB to be true to the original, the final state projection should have 
00027   // specific cuts on eta, pT and require stable charged particles.
00028   log << Log::DEBUG << "About to apply the final state projection with eta and pt cuts" << endl;
00029   const FinalState& fs = e.applyProjection(*_fsproj);
00030   
00031   // Put each particle into the collection of tracks and sort (decreasing in pT)
00032   vector<LorentzVector> tracksvector; // Need to use a vector because you can't use std::sort with lists
00033   for (ParticleVector::const_iterator p = fs.particles().begin(); p != fs.particles().end(); ++p) {
00034     HepMC::FourVector fv = p->getMomentum();
00035     LorentzVector lv(fv.px(), fv.py(), fv.pz(), fv.e());
00036     tracksvector.push_back(lv);
00037   }
00038   // Now sort particles in pT
00039   sort(tracksvector.begin(), tracksvector.end(), compareVecsByPt);
00040   // Make it into a list
00041   Tracks tracks(tracksvector.begin(), tracksvector.end());
00042 
00043   // Now find jets using Field & Stuart criteria
00044   log << Log::DEBUG << "About to assign tracks into jets" << endl;
00045   while (!tracks.empty()) {
00046 
00047     Tracks::iterator t = tracks.begin();
00048     // Get eta and phi for this track
00049     const double eta = t->eta();
00050     const double phi = t->phi();
00051     
00052     // Make a new jet and put this seed track into it
00053     Jet thisjet;
00054     thisjet.addParticle(*t);
00055     tracks.erase(t);
00056     
00057     // Compare with all unassociated tracks with a smaller pT measure
00058     Tracks::iterator t2 = tracks.begin();
00059     while (t2 != tracks.end()) {
00060       log << Log::DEBUG << "Building jet from tracks" << endl;
00061 
00062       // Compute Deta and Dphi, mapping Dphi into [0,pi]
00063       double Deta = eta - t2->eta();
00064       double Dphi = phi - t2->phi();
00065       if (Dphi > PI) Dphi = 2*PI - Dphi;
00066 
00067       // Add to this jet if eta-phi distance < 0.7 
00068       if (sqrt(Deta*Deta + Dphi*Dphi) <= 0.7) {
00069         // Move this particle into the current jet (no extra sorting needed)
00070         thisjet.addParticle(*t2);
00071         t2 = tracks.erase(t2);
00072       } else {
00073         ++t2;
00074       }
00075     }
00076 
00077     _jets.push_back(thisjet);
00078   }
00079 
00080   // Sort the jets by pT.
00081   sort(_jets.begin(), _jets.end(), compareJetsByPt);
00082 
00083 
00084   if (log.isActive(Log::DEBUG)) {
00085     log << Log::DEBUG << "Number of jets = " << _jets.size() << endl;
00086     size_t njet = 1;
00087     for (Jets::const_iterator j = _jets.begin(); j != _jets.end(); ++j)
00088       log << Log::DEBUG << "Number of tracks in jet #" << njet++ << " = " << j->getNumParticles() << endl;
00089   }
00090 }