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

SISConePlugin.cc

Go to the documentation of this file.
00001 
00002 // fastjet stuff
00003 #include "fastjet/ClusterSequence.hh"
00004 #include "SISConePlugin.hh"
00005 
00006 // scones stuff
00007 #include "momentum.h"
00008 #include "siscone.h"
00009 
00010 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00011 
00012 using namespace std;
00013 using namespace siscone;
00014 
00015 // the static objects
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   // create a fake scones object so that we can find out more about it
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; // by default we'll be running it
00063 
00064   if (caching()) {
00065 
00066     // Establish if we have a cached run with the same R, npass and
00067     // particles. If not then do any tidying up / reallocation that's
00068     // necessary for the next round of caching, otherwise just set
00069     // relevant pointers so that we can reuse and old run.
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           // only check momentum because indices will be correctly dealt
00077           // with anyway when extracting the clustering order.
00078           new_siscone |= !have_same_momentum(clust_seq.jets()[i], 
00079                                              (*stored_particles)[i]);
00080         }
00081       }
00082     } 
00083       
00084     // allocate the new siscone, etc., if need be
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     // transfer fastjet initial particles into the siscone type
00098     vector<Cmomentum> siscone_momenta(n);
00099     for(unsigned i = 0; i < n; i++) {
00100       const PseudoJet & p = clust_seq.jets()[i]; // shorthand
00101       siscone_momenta[i] = Cmomentum(p.px(), p.py(), p.pz(), p.E());
00102     }
00103     
00104     // run the jet finding
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     // just run the overlap part of the jets.
00110     siscone->recompute_jets(overlap_threshold(), protojet_ptmin(), 
00111                             split_merge_on_transverse_mass());
00112   }
00113 
00114   // extract the jets [in reverse order -- to get nice ordering in pt at end]
00115   int njet = siscone->jets.size();
00116 
00117   for (int ijet = njet-1; ijet >= 0; ijet--) {
00118     const Cjet & jet = siscone->jets[ijet]; // shorthand
00119     
00120     // Successively merge the particles that make up the cone jet
00121     // until we have all particles in it.  Start off with the zeroth
00122     // particle.
00123     int jet_k = jet.contents[0];
00124     for (unsigned ipart = 1; ipart < jet.contents.size(); ipart++) {
00125       // take the last result of the merge
00126       int jet_i = jet_k;
00127       // and the next element of the jet
00128       int jet_j = jet.contents[ipart];
00129       // and merge them (with a fake dij)
00130       double dij = 0.0;
00131 
00132       // create the new jet by hand so that we can adjust its user index
00133       PseudoJet newjet = clust_seq.jets()[jet_i] + clust_seq.jets()[jet_j];
00134 
00135       // set the user index to be the pass in which the jet was discovered
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     // we have merged all the jet's particles into a single object, so now
00141     // "declare" it to be a beam (inclusive) jet.
00142     // [NB: put a sensible looking d_iB just to be nice...]
00143     double d_iB = clust_seq.jets()[jet_k].perp2();
00144     clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
00145   }
00146 
00147   // now copy the list of protocones into an "extras" objects
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       //PseudoJet protocone(siscone->protocones_list[ipass][ipc]);
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   // tell it what the jet definition was
00162   extras->_jet_def_plugin = this;
00163 
00164   // give the extras object to the cluster sequence.
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 // OBSOLETE CODE  
00179 //if (siscone.n_warnings > 0) {
00180 //  // print the event (very dirty...)
00181 //  cout.precision(14);
00182 //  cout << "Culprit event is:" << endl;
00183 //  for (int i = 0; i < n; i++) {
00184 //    const PseudoJet & p = clust_seq.jets()[i]; // shorthand
00185 //    cout << p.px() << " " << p.py() << " " << p.pz() << " " << p.E() << endl;
00186 //  }
00187 //}
00188 
00189 
00190 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh

Generated on Sat Mar 3 12:36:10 2007 for fastjet by  doxygen 1.4.2