FastJet 3.0beta1
D0RunIBaseConePlugin.cc
00001 //STARTHEADER
00002 // $Id: D0RunIBaseConePlugin.cc 1779 2010-10-25 10:32:59Z soyez $
00003 //
00004 // Copyright (c) 2009-2010, Matteo Cacciari, Gavin 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, write to the Free Software
00026 //  Foundation, Inc.:
00027 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //----------------------------------------------------------------------
00029 //ENDHEADER
00030 
00031 #include "fastjet/D0RunIBaseConePlugin.hh"
00032 #include "fastjet/D0RunIpre96ConePlugin.hh"
00033 #include "fastjet/D0RunIConePlugin.hh"
00034 #include "fastjet/ClusterSequence.hh"
00035 #include "fastjet/Error.hh"
00036 #include <sstream>
00037 
00038 // D0 stuff
00039 #include <list>
00040 #include "ConeClusterAlgo.hpp"
00041 #include "HepEntityIpre96.h"
00042 #include "HepEntityI.h"
00043 
00044 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00045 
00046 using namespace std; 
00047 using namespace d0runi;
00048 
00049 /////////////////////////////////////////////
00050 //                                         //
00051 // D0RunIBaseConePlugin implementation     //
00052 //                                         //
00053 /////////////////////////////////////////////
00054 
00055 const double D0RunIBaseConePlugin::_DEFAULT_SPLifr             = 0.5; //shared Et fraction threshold
00056 const double D0RunIBaseConePlugin::_DEFAULT_TWOrad             = 0.; 
00057 const bool   D0RunIBaseConePlugin::_DEFAULT_D0_Angle           = false;
00058 const bool   D0RunIBaseConePlugin::_DEFAULT_Increase_Delta_R   = true;
00059 const bool   D0RunIBaseConePlugin::_DEFAULT_Kill_Far_Clusters  = true;
00060 const bool   D0RunIBaseConePlugin::_DEFAULT_Jet_Et_Min_On_Iter = true;
00061 const double D0RunIBaseConePlugin::_DEFAULT_Far_Ratio          = 0.5;
00062 const double D0RunIBaseConePlugin::_DEFAULT_Eitem_Negdrop      = -1.0;
00063 const double D0RunIBaseConePlugin::_DEFAULT_Et_Min_Ratio       = 0.5;
00064 const double D0RunIBaseConePlugin::_DEFAULT_Thresh_Diff_Et     = 0.01;
00065 
00066 
00067 // for the real work, we write a template class that decides which
00068 // HepEntity type to use
00069 template<typename HepEntityType>
00070 void D0RunIBaseConePlugin::run_clustering_worker(ClusterSequence & clust_seq) const{
00071   // create the entities needed by the D0 code
00072   vector<HepEntityType> entities(clust_seq.jets().size());
00073   list<const HepEntityType * > 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   ConeClusterAlgo<HepEntityType> 
00088     RunIconeAlgo(CONErad(), 
00089                  JETmne(),
00090                  TWOrad(),
00091                  SPLifr(),
00092                  D0_Angle(),
00093                  Increase_Delta_R(),
00094                  Kill_Far_Clusters(),
00095                  Jet_Et_Min_On_Iter(),
00096                  Far_Ratio(),
00097                  Eitem_Negdrop(),
00098                  Et_Min_Ratio(),
00099                  Thresh_Diff_Et());
00100 
00101 
00102   // run the algorithm
00103   float Zvertex = 0.;
00104   list<HepEntityType> jets;
00105   RunIconeAlgo.makeClusters(jets, ensemble, Zvertex);
00106 
00107   // now transfer the information about the jets into the
00108   // FastJet structure
00109   for(int i = RunIconeAlgo.TempColl.size()-1; i >= 0; i--) {
00110     
00111     std::list<const HepEntityType*> tlist = RunIconeAlgo.TempColl[i].LItems();
00112     typename std::list<const HepEntityType*>::iterator tk;
00113         
00114     // get first particle in list
00115     tk = tlist.begin();
00116     int jet_k = (*tk)->index;
00117 
00118     // GS addition: in order to use the proper recombination scheme
00119     // used by D0 we need to keep track of the sum as a
00120     // "HepEntityType"
00121     HepEntityType jet_current_momentum = *(*tk);
00122 
00123     // now merge with remaining particles in list
00124     tk++;
00125     for (; tk != tlist.end(); tk++) {
00126       int jet_i = jet_k;
00127       int jet_j = (*tk)->index;
00128       // do a fake recombination step with dij=0
00129       double dij = 0.0;
00130 
00131       // GS addition: find the new momentum and convert that into a
00132       // pseudo-jet
00133       jet_current_momentum.Add(**tk);
00134       PseudoJet new_mom(jet_current_momentum.px(), jet_current_momentum.py(), 
00135                         jet_current_momentum.pz(), jet_current_momentum.E());
00136 
00137       clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, new_mom, jet_k);
00138     }
00139     
00140     // NB: put a sensible looking d_iB just to be nice...
00141     double d_iB = clust_seq.jets()[jet_k].perp2();
00142     clust_seq.plugin_record_iB_recombination(jet_k, d_iB);    
00143   }
00144 }
00145 
00146 
00147 /////////////////////////////////////////////
00148 //                                         //
00149 // D0RunIpre96ConePlugin implementation    //
00150 //                                         //
00151 /////////////////////////////////////////////
00152 
00153 string D0RunIpre96ConePlugin::description () const {
00154   ostringstream desc;
00155   
00156   desc << "D0 Run I (pre 96) cone jet algorithm, with ";
00157   desc << "cone_radius = "        << CONErad        () << ", "
00158        << "min_jet_Et = "         << JETmne         () << ", " 
00159        << "split_fraction = "     << SPLifr         ();
00160 
00161   return desc.str();
00162 }
00163 
00164 void D0RunIpre96ConePlugin::run_clustering(ClusterSequence & clust_seq) const {
00165   run_clustering_worker<HepEntityIpre96>(clust_seq);
00166 }
00167 
00168 
00169 
00170 /////////////////////////////////////////////
00171 //                                         //
00172 // D0RunIConePlugin implementation         //
00173 //                                         //
00174 /////////////////////////////////////////////
00175 
00176 string D0RunIConePlugin::description () const {
00177   ostringstream desc;
00178   
00179   desc << "D0 Run I cone jet algorithm, with ";
00180   desc << "cone_radius = "        << CONErad        () << ", "
00181        << "min_jet_Et = "         << JETmne         () << ", " 
00182        << "split_fraction = "     << SPLifr         ();
00183 
00184   return desc.str();
00185 }
00186 
00187 void D0RunIConePlugin::run_clustering(ClusterSequence & clust_seq) const {
00188   run_clustering_worker<HepEntityI>(clust_seq);
00189 }
00190 
00191 
00192 
00193 
00194 
00195 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends