TrackJetPlugin.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "fastjet/ClusterSequence.hh"
00033 #include "fastjet/TrackJetPlugin.hh"
00034
00035
00036 #include <list>
00037 #include <memory>
00038 #include <cmath>
00039 #include <vector>
00040 #include <sstream>
00041
00042 FASTJET_BEGIN_NAMESPACE
00043
00044 using namespace std;
00045
00046 class TrackJetParticlePtr{
00047 public:
00048 TrackJetParticlePtr(int i_index, double i_perp2)
00049 : index(i_index), perp2(i_perp2){}
00050
00051 int index;
00052 double perp2;
00053
00054 bool operator <(const TrackJetParticlePtr &other) const {
00055 return perp2>other.perp2;
00056 }
00057 };
00058
00059 string TrackJetPlugin::description () const {
00060 ostringstream desc;
00061 desc << "TrackJet algorithm with R = " << R();
00062 return desc.str();
00063 }
00064
00065 void TrackJetPlugin::run_clustering(ClusterSequence & clust_seq) const {
00066
00067 vector<TrackJetParticlePtr> particle_list;
00068
00069 const vector<PseudoJet> & jets = clust_seq.jets();
00070 int index=0;
00071 for (vector<PseudoJet>::const_iterator mom_it = jets.begin(); mom_it != jets.end(); mom_it++){
00072 particle_list.push_back(TrackJetParticlePtr(index, mom_it->perp2()));
00073 index++;
00074 }
00075
00076
00077 sort(particle_list.begin(), particle_list.end());
00078
00079
00080
00081
00082
00083 vector<PseudoJet> tuned_particles = clust_seq.jets();
00084 vector<PseudoJet> tuned_tracks = clust_seq.jets();
00085 for (vector<PseudoJet>::iterator pit = tuned_particles.begin();
00086 pit != tuned_particles.end(); pit++)
00087 _jet_recombiner.preprocess(*pit);
00088 for (vector<PseudoJet>::iterator pit = tuned_tracks.begin();
00089 pit != tuned_tracks.end(); pit++)
00090 _track_recombiner.preprocess(*pit);
00091
00092
00093
00094 list<int> sorted_pt_index;
00095 for (vector<TrackJetParticlePtr>::iterator mom_it = particle_list.begin();
00096 mom_it != particle_list.end(); mom_it++)
00097 sorted_pt_index.push_back(mom_it->index);
00098
00099
00100 while (sorted_pt_index.size()){
00101
00102
00103
00104 int current_jet_index = sorted_pt_index.front();
00105 PseudoJet current_jet = tuned_particles[current_jet_index];
00106 PseudoJet current_track = tuned_tracks[current_jet_index];
00107
00108
00109 list<int>::iterator index_it = sorted_pt_index.begin();
00110 sorted_pt_index.erase(index_it);
00111
00112
00113 index_it = sorted_pt_index.begin();
00114 while (index_it != sorted_pt_index.end()){
00115 const PseudoJet & current_particle = tuned_particles[*index_it];
00116 const PseudoJet & current_particle_track = tuned_tracks[*index_it];
00117
00118
00119 double distance2 = current_track.plain_distance(current_particle_track);
00120 if (distance2 <= _radius2){
00121
00122 PseudoJet new_track;
00123 PseudoJet new_jet;
00124 _jet_recombiner.recombine(current_jet, current_particle, new_jet);
00125 _track_recombiner.recombine(current_track, current_particle_track, new_track);
00126
00127 int new_jet_index;
00128 clust_seq.plugin_record_ij_recombination(current_jet_index, *index_it, distance2, new_jet, new_jet_index);
00129
00130 current_jet = new_jet;
00131 current_track = new_track;
00132 current_jet_index = new_jet_index;
00133
00134
00135 sorted_pt_index.erase(index_it);
00136
00137
00138
00139 index_it = sorted_pt_index.begin();
00140 } else {
00141 index_it++;
00142 }
00143 }
00144
00145
00146 clust_seq.plugin_record_iB_recombination(current_jet_index, _radius2);
00147 }
00148
00149 }
00150
00151 FASTJET_END_NAMESPACE