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