FastJet 3.0.0
D0RunIIConePlugin.cc
00001 //STARTHEADER
00002 // $Id: D0RunIIConePlugin.cc 2577 2011-09-13 15:11:38Z 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 #include "fastjet/D0RunIIConePlugin.hh"
00030 #include "fastjet/ClusterSequence.hh"
00031 #include "fastjet/Error.hh"
00032 #include <sstream>
00033 
00034 // D0 stuff
00035 #include <list>
00036 #include "ILConeAlgorithm.hpp"
00037 #include "HepEntity.h"
00038 
00039 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00040 
00041 using namespace std;
00042 using namespace d0;
00043 
00044 const double D0RunIIConePlugin::_DEFAULT_split_ratio              = 0.5  ; // overlap threshold
00045 const double D0RunIIConePlugin::_DEFAULT_far_ratio                = 0.5  ;
00046 const double D0RunIIConePlugin::_DEFAULT_Et_min_ratio             = 0.5  ;
00047 const bool   D0RunIIConePlugin::_DEFAULT_kill_duplicate           = true ;
00048 const double D0RunIIConePlugin::_DEFAULT_duplicate_dR             = 0.005; 
00049 const double D0RunIIConePlugin::_DEFAULT_duplicate_dPT            = 0.01 ; 
00050 const double D0RunIIConePlugin::_DEFAULT_search_factor            = 1.0  ; 
00051 const double D0RunIIConePlugin::_DEFAULT_pT_min_leading_protojet  = 0.   ; 
00052 const double D0RunIIConePlugin::_DEFAULT_pT_min_second_protojet   = 0.   ;
00053 const int    D0RunIIConePlugin::_DEFAULT_merge_max                = 10000; 
00054 const double D0RunIIConePlugin::_DEFAULT_pT_min_nomerge           = 0.   ;
00055 
00056 
00057 string D0RunIIConePlugin::description () const {
00058   ostringstream desc;
00059   
00060   desc << "D0 Run II Improved Legacy (midpoint) cone jet algorithm, with ";
00061   desc << "cone_radius = "        << cone_radius        () << ", "
00062        << "min_jet_Et = "         << min_jet_Et         () << ", " 
00063        << "split_ratio = "        << split_ratio        ();
00064 
00065   return desc.str();
00066 }
00067 
00068 
00069 void D0RunIIConePlugin::run_clustering(ClusterSequence & clust_seq) const {
00070  
00071   // create the entities needed by the D0 code
00072   vector<HepEntity> entities(clust_seq.jets().size());
00073   list<const HepEntity * > ensemble;
00074   for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
00075     entities[i].Fill(clust_seq.jets()[i].E(),
00076                      clust_seq.jets()[i].px(),
00077                      clust_seq.jets()[i].py(),
00078                      clust_seq.jets()[i].pz(),
00079                      i);
00080     // use only the particles that do not have infinite rapidity
00081     if (abs(entities[i].pz) < entities[i].E) {
00082       ensemble.push_back(& (entities[i]));
00083     }
00084   }
00085 
00086   // prepare the D0 algorithm
00087   ILConeAlgorithm<HepEntity> 
00088     ilegac(cone_radius(), 
00089            min_jet_Et(), 
00090            split_ratio(),
00091            far_ratio(), 
00092            Et_min_ratio(), 
00093            kill_duplicate(), 
00094            duplicate_dR(), 
00095            duplicate_dPT(), 
00096            search_factor(), 
00097            pT_min_leading_protojet(), 
00098            pT_min_second_protojet(), 
00099            merge_max(), 
00100            pT_min_nomerge());
00101 
00102   // run the algorithm
00103   float Item_ET_Threshold = 0.;
00104   list<HepEntity> jets;
00105   ilegac.makeClusters(jets, ensemble, Item_ET_Threshold);
00106 
00107   // now transfer the information about the jets into the
00108   // FastJet structure
00109   for(int i = ilegac.ilcv.size()-1; i >= 0; i--) {
00110     
00111     std::list<const HepEntity*> tlist = ilegac.ilcv[i].LItems();
00112     std::list<const HepEntity*>::iterator tk;
00113     
00114     // get first particle in list
00115     tk = tlist.begin();
00116 
00117     // if there is no particle, just discard it
00118     // Note: this unexpected behaviour has been observed when the
00119     //       min_jet_Et parameter was set to 0
00120     if (tk==tlist.end())
00121       continue;
00122 
00123     int jet_k = (*tk)->index;
00124     // now merge with remaining particles in list
00125     tk++;
00126     for (; tk != tlist.end(); tk++) {
00127       int jet_i = jet_k;
00128       int jet_j = (*tk)->index;
00129       // do a fake recombination step with dij=0
00130       double dij = 0.0;
00131       clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
00132     }
00133 
00134     // NB: put a sensible looking d_iB just to be nice...
00135     double d_iB = clust_seq.jets()[jet_k].perp2();
00136     clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
00137 
00138   }
00139 }
00140 
00141 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends