FastJet 3.0.2
ClusterSequence_N2.cc
00001 //STARTHEADER
00002 // $Id: ClusterSequence_N2.cc 2657 2011-11-07 16:14:30Z salam $
00003 //
00004 // Copyright (c) 2005-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 
00030 // The plain N^2 part of the ClusterSequence class -- separated out
00031 // from the rest of the class implementation so as to speed up
00032 // compilation of this particular part while it is under test.
00033 
00034 #include "fastjet/internal/ClusterSequence_N2.icc"
00035 
00036 #include<iostream>
00037 
00038 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00039 
00040 
00041 using namespace std;
00042 
00043 
00044 //*************************************************************************
00045 //
00046 //                             THINGS FOR E+E-
00047 //
00048 //*************************************************************************
00049 
00050 
00051 //----------------------------------------------------------------------
00052 template<> inline void ClusterSequence::_bj_set_jetinfo(
00053                            EEBriefJet * const jetA, const int _jets_index) const {
00054 
00055   double E = _jets[_jets_index].E();
00056   double scale = E*E; // the default energy scale for the kt alg
00057   double p  = jet_def().extra_param(); // in case we're ee_genkt
00058   switch (_jet_algorithm) {
00059   case ee_kt_algorithm:
00060     assert(_Rparam > 2.0); // force this to be true! [not best place, but works]
00061     // recall that _invR2 is artificially set to 1 for this alg
00062     // so that we automatically have dij = scale * 2(1-cos theta_ij)
00063     // Normally, _Rparam should be automatically set to 4 from JetDefinition
00064     break; 
00065   case ee_genkt_algorithm:
00066     if (p <= 0 && scale < 1e-300) scale = 1e-300; // same dodgy safety as genkt
00067     scale = pow(scale,p);
00068     break;
00069   default:
00070     throw Error("Unrecognised jet algorithm");
00071   }
00072   jetA->kt2  = scale; // "kt2" might one day be renamed as "scale" or some such
00073 
00074   double norm = _jets[_jets_index].modp2();
00075   if (norm > 0) {
00076     norm = 1.0/sqrt(norm);
00077     jetA->nx = norm * _jets[_jets_index].px();
00078     jetA->ny = norm * _jets[_jets_index].py();
00079     jetA->nz = norm * _jets[_jets_index].pz();
00080   } else {
00081     jetA->nx = 0.0;
00082     jetA->ny = 0.0;
00083     jetA->nz = 1.0;
00084   }
00085   jetA->_jets_index = _jets_index;
00086   // initialise NN info as well
00087   jetA->NN_dist = _R2;
00088   jetA->NN      = NULL;
00089 }
00090 
00091 //----------------------------------------------------------------------
00092 // returns the angular distance between the two jets
00093 template<> double ClusterSequence::_bj_dist(
00094                 const EEBriefJet * const jeta, 
00095                 const EEBriefJet * const jetb) const {
00096   double dist = 1.0 
00097     - jeta->nx*jetb->nx
00098     - jeta->ny*jetb->ny
00099     - jeta->nz*jetb->nz;
00100   dist *= 2; // distance is _2_*min(Ei^2,Ej^2)*(1-cos theta)
00101   return dist;
00102 }
00103 
00104 
00105 
00106 // get explicit copies of the two N2 cluster cases we need
00107 // plain BriefJet
00108 void ClusterSequence::_simple_N2_cluster_BriefJet() {  
00109   _simple_N2_cluster<BriefJet>();
00110 }
00111 
00112 
00113 // e+e- BriefJet
00114 void ClusterSequence::_simple_N2_cluster_EEBriefJet() {  
00115   _simple_N2_cluster<EEBriefJet>();
00116 }
00117 
00118 // //----------------------------------------------------------------------
00119 // /// Force instantiation of desired versions of _simple_N2_cluster
00120 // ///
00121 // /// This is not very elegant...
00122 // void ClusterSequence::_dummy_N2_cluster_instantiation() {
00123 //   _simple_N2_cluster<BriefJet>();
00124 //   _simple_N2_cluster<EEBriefJet>();
00125 // }
00126 
00127 FASTJET_END_NAMESPACE
00128 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends