57 #include "fastjet/ClusterSequence.hh" 
   58 #include "fastjet/TrackJetPlugin.hh" 
   67 FASTJET_BEGIN_NAMESPACE      
 
   74 class TrackJetParticlePtr{
 
   76   TrackJetParticlePtr(
int i_index, 
double i_perp2)
 
   77     :  index(i_index), perp2(i_perp2){}
 
   82   bool operator <(
const TrackJetParticlePtr &other)
 const { 
 
   83     return perp2>other.perp2;
 
   91 thread_safety_helpers::FirstTimeTrue TrackJetPlugin::_first_time;
 
   93 string TrackJetPlugin::description ()
 const {
 
   95   desc << 
"TrackJet algorithm with R = " << R();
 
  104   vector<TrackJetParticlePtr> particle_list;
 
  106   const vector<PseudoJet> & jets = clust_seq.
jets();  
 
  108   for (vector<PseudoJet>::const_iterator mom_it = jets.begin(); mom_it != jets.end(); mom_it++){
 
  109     particle_list.push_back(TrackJetParticlePtr(index, mom_it->perp2()));
 
  114   stable_sort(particle_list.begin(), particle_list.end());
 
  120   vector<PseudoJet> tuned_particles = clust_seq.
jets();
 
  121   vector<PseudoJet> tuned_tracks = clust_seq.
jets();
 
  122   for (vector<PseudoJet>::iterator pit = tuned_particles.begin();
 
  123        pit != tuned_particles.end(); pit++)
 
  124     _jet_recombiner.preprocess(*pit);
 
  125   for (vector<PseudoJet>::iterator pit = tuned_tracks.begin();
 
  126        pit != tuned_tracks.end(); pit++)
 
  127     _track_recombiner.preprocess(*pit);
 
  131   list<int> sorted_pt_index;
 
  132   for (vector<TrackJetParticlePtr>::iterator mom_it = particle_list.begin();
 
  133        mom_it != particle_list.end(); mom_it++)
 
  134     sorted_pt_index.push_back(mom_it->index);
 
  137   while (sorted_pt_index.size()){
 
  141     int current_jet_index = sorted_pt_index.front();
 
  142     PseudoJet current_jet   = tuned_particles[current_jet_index];
 
  143     PseudoJet current_track = tuned_tracks[current_jet_index];
 
  146     list<int>::iterator index_it = sorted_pt_index.begin();
 
  147     sorted_pt_index.erase(index_it);
 
  150     index_it = sorted_pt_index.begin();
 
  151     while (index_it != sorted_pt_index.end()){
 
  152       const PseudoJet & current_particle = tuned_particles[*index_it];
 
  153       const PseudoJet & current_particle_track = tuned_tracks[*index_it];
 
  156       double distance2 = current_track.
plain_distance(current_particle_track);
 
  157       if (distance2 <= _radius2){
 
  161         _jet_recombiner.recombine(current_jet, current_particle, new_jet);
 
  162         _track_recombiner.recombine(current_track, current_particle_track, new_track);
 
  167         current_jet = new_jet;
 
  168         current_track = new_track;
 
  169         current_jet_index = new_jet_index;
 
  172         sorted_pt_index.erase(index_it);
 
  176         index_it = sorted_pt_index.begin();
 
  189 void TrackJetPlugin::_print_banner(ostream *ostr)
 const{
 
  190   if (! _first_time()) 
return;
 
  195   (*ostr) << 
"#-------------------------------------------------------------------------" << endl;
 
  196   (*ostr) << 
"# You are running the TrackJet plugin for FastJet. It is based on         " << endl;
 
  197   (*ostr) << 
"# the implementation by Andy Buckley and Manuel Bahr that is to be        " << endl;
 
  198   (*ostr) << 
"# found in Rivet 1.1.2. See http://www.hepforge.org/downloads/rivet.      " << endl;
 
  199   (*ostr) << 
"#-------------------------------------------------------------------------" << endl;
 
  205 FASTJET_END_NAMESPACE