00001
00002
00003 #include "fastjet/ClusterSequence.hh"
00004 #include "SISConePlugin.hh"
00005
00006
00007 #include "momentum.h"
00008 #include "siscone.h"
00009
00010 FASTJET_BEGIN_NAMESPACE
00011
00012 using namespace std;
00013 using namespace siscone;
00014
00015
00016 auto_ptr<SISConePlugin > SISConePlugin::stored_plugin ;
00017 auto_ptr<vector<PseudoJet> > SISConePlugin::stored_particles ;
00018 auto_ptr<Csiscone > SISConePlugin::stored_siscone ;
00019
00020 string SISConePlugin::description () const {
00021 ostringstream desc;
00022
00023 const string on = "on";
00024 const string off = "off";
00025 const string pt2m2 = "mt=sqrt(pt^2+m^2)";
00026 const string pt2 = "pt (IR unsafe)";
00027
00028 desc << "SISCone jet finder with " ;
00029 desc << "cone_radius = " << cone_radius () << ", ";
00030 desc << "overlap_threshold = " << overlap_threshold () << ", ";
00031 desc << "n_pass_max = " << n_pass_max () << ", ";
00032 desc << "protojet_ptmin = " << protojet_ptmin() << ", ";
00033 desc << "split-merge uses " << (_split_merge_on_transverse_mass ?
00034 pt2m2 : pt2) << ", ";
00035 desc << "caching turned " << (caching() ? on : off);
00036
00037
00038 Csiscone siscone;
00039 if (siscone.merge_identical_protocones) {
00040 desc << ", and (IR unsafe) merge_indentical_protocones=true" ;
00041 }
00042
00043 return desc.str();
00044 }
00045
00046
00048 template<> PseudoJet::PseudoJet(const Cmomentum & four_vector) {
00049 (*this) = PseudoJet(four_vector.px,four_vector.py,four_vector.pz,
00050 four_vector.E);
00051 }
00052
00053
00054 void SISConePlugin::run_clustering(ClusterSequence & clust_seq) const {
00055
00056
00057 Csiscone * siscone;
00058 Csiscone local_siscone;
00059
00060 unsigned n = clust_seq.jets().size();
00061
00062 bool new_siscone = true;
00063
00064 if (caching()) {
00065
00066
00067
00068
00069
00070 if (stored_siscone.get() != 0) {
00071 new_siscone = !(stored_plugin->cone_radius() == cone_radius()
00072 && stored_plugin->n_pass_max() == n_pass_max()
00073 && stored_particles->size() == n);
00074 if (!new_siscone) {
00075 for(unsigned i = 0; i < n; i++) {
00076
00077
00078 new_siscone |= !have_same_momentum(clust_seq.jets()[i],
00079 (*stored_particles)[i]);
00080 }
00081 }
00082 }
00083
00084
00085 if (new_siscone) {
00086 stored_siscone .reset( new Csiscone );
00087 stored_particles.reset( new vector<PseudoJet>(clust_seq.jets()));
00088 stored_plugin .reset( new SISConePlugin(*this) );
00089 }
00090
00091 siscone = stored_siscone.get();
00092 } else {
00093 siscone = &local_siscone;
00094 }
00095
00096 if (new_siscone) {
00097
00098 vector<Cmomentum> siscone_momenta(n);
00099 for(unsigned i = 0; i < n; i++) {
00100 const PseudoJet & p = clust_seq.jets()[i];
00101 siscone_momenta[i] = Cmomentum(p.px(), p.py(), p.pz(), p.E());
00102 }
00103
00104
00105 siscone->compute_jets(siscone_momenta, cone_radius(), overlap_threshold(),
00106 n_pass_max(), protojet_ptmin(),
00107 split_merge_on_transverse_mass());
00108 } else {
00109
00110 siscone->recompute_jets(overlap_threshold(), protojet_ptmin(),
00111 split_merge_on_transverse_mass());
00112 }
00113
00114
00115 int njet = siscone->jets.size();
00116
00117 for (int ijet = njet-1; ijet >= 0; ijet--) {
00118 const Cjet & jet = siscone->jets[ijet];
00119
00120
00121
00122
00123 int jet_k = jet.contents[0];
00124 for (unsigned ipart = 1; ipart < jet.contents.size(); ipart++) {
00125
00126 int jet_i = jet_k;
00127
00128 int jet_j = jet.contents[ipart];
00129
00130 double dij = 0.0;
00131
00132
00133 PseudoJet newjet = clust_seq.jets()[jet_i] + clust_seq.jets()[jet_j];
00134
00135
00136 newjet.set_user_index(jet.pass);
00137
00138 clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, newjet, jet_k);
00139 }
00140
00141
00142
00143 double d_iB = clust_seq.jets()[jet_k].perp2();
00144 clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
00145 }
00146
00147
00148 SISConeExtras * extras = new SISConeExtras;
00149 for (unsigned ipass = 0; ipass < siscone->protocones_list.size(); ipass++) {
00150 for (unsigned ipc = 0; ipc < siscone->protocones_list[ipass].size(); ipc++) {
00151 double rap = siscone->protocones_list[ipass][ipc].eta;
00152 double phi = siscone->protocones_list[ipass][ipc].phi;
00153 PseudoJet protocone(cos(phi),sin(phi),sinh(rap),cosh(rap));
00154
00155 protocone.set_user_index(ipass);
00156 extras->_protocones.push_back(protocone);
00157 }
00158 }
00159 extras->_most_ambiguous_split = siscone->most_ambiguous_split;
00160
00161
00162 extras->_jet_def_plugin = this;
00163
00164
00165 clust_seq.plugin_associate_extras(auto_ptr<ClusterSequence::Extras>(extras));
00166 }
00167
00168
00170 string SISConeExtras::description() const {
00171 ostringstream ostr;
00172 ostr << "This SISCone clustering found " << protocones().size()
00173 << " stable protocones";
00174 return ostr.str();
00175 }
00176
00177
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 FASTJET_END_NAMESPACE