FastJet 3.0.2
JadePlugin.cc
00001 //STARTHEADER
00002 // $Id: JadePlugin.cc 2577 2011-09-13 15:11:38Z salam $
00003 //
00004 // Copyright (c) 2007-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
00005 //
00006 //----------------------------------------------------------------------
00007 // This file is part of FastJet.
00008 //
00009 //  FastJet is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU General Public License as published by
00011 //  the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  The algorithms that underlie FastJet have required considerable
00015 //  development and are described in hep-ph/0512210. If you use
00016 //  FastJet as part of work towards a scientific publication, please
00017 //  include a citation to the FastJet paper.
00018 //
00019 //  FastJet is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
00026 //----------------------------------------------------------------------
00027 //ENDHEADER
00028 
00029 // fastjet stuff
00030 #include "fastjet/ClusterSequence.hh"
00031 #include "fastjet/JadePlugin.hh"
00032 #include <iostream>
00033 //#include "fastjet/internal/ClusterSequence_N2.icc"
00034 #include "fastjet/NNH.hh"
00035 
00036 // other stuff
00037 #include <vector>
00038 #include <sstream>
00039 #include <limits>
00040 
00041 
00042 
00043 
00044 using namespace std;
00045 
00046 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00047 
00048 
00049 //----------------------------------------------------------------------
00050 /// class to help run a JADE algorithm
00051 class JadeBriefJet {
00052 public:
00053   void init(const PseudoJet & jet) {
00054     double norm = 1.0/sqrt(jet.modp2());
00055     nx = jet.px() * norm;
00056     ny = jet.py() * norm;
00057     nz = jet.pz() * norm;
00058     rt2E = sqrt(2.0)*jet.E();
00059   }
00060 
00061   double distance(const JadeBriefJet * jet) const {
00062     double dij = 1 - nx*jet->nx
00063                    - ny*jet->ny
00064                    - nz*jet->nz;
00065     dij *= rt2E*jet->rt2E;
00066     return dij;
00067   }
00068 
00069   double beam_distance() const {
00070     return numeric_limits<double>::max();
00071   }
00072 
00073 private:
00074   double rt2E, nx, ny, nz;
00075 };
00076 
00077 
00078 //----------------------------------------------------------------------
00079 string JadePlugin::description () const {
00080   ostringstream desc;
00081   desc << "e+e- JADE algorithm plugin";
00082   return desc.str();
00083 }
00084 
00085 //----------------------------------------------------------------------
00086 void JadePlugin::run_clustering(ClusterSequence & cs) const {
00087   int njets = cs.jets().size();
00088   NNH<JadeBriefJet> nnh(cs.jets());
00089 
00090   // if testing against Hoeth's implementation, need to rescale the
00091   // dij by Q^2.
00092   //double Q2 = cs.Q2(); 
00093 
00094   while (njets > 0) {
00095     int i, j, k;
00096     double dij = nnh.dij_min(i, j);
00097 
00098     if (j >= 0) {
00099       cs.plugin_record_ij_recombination(i, j, dij, k);
00100       nnh.merge_jets(i, j, cs.jets()[k], k);
00101     } else {
00102       double diB = cs.jets()[i].E()*cs.jets()[i].E(); // get new diB
00103       cs.plugin_record_iB_recombination(i, diB);
00104       nnh.remove_jet(i);
00105     }
00106     njets--;
00107   }
00108 }
00109 
00110 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends