PxConePlugin.cc

Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: PxConePlugin.cc 939 2007-11-08 12:18:08Z salam $
00003 //
00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
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/PxConePlugin.hh"
00032 
00033 #include "fastjet/ClusterSequence.hh"
00034 #include <sstream>
00035 
00036 // pxcone stuff
00037 #include "pxcone.h"
00038 
00039 
00040 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00041 
00042 using namespace std;
00043 
00044 string PxConePlugin::description () const {
00045   ostringstream desc;
00046   
00047   desc << "PxCone jet algorithm with " 
00048        << "cone_radius = "        << cone_radius        () << ", "
00049        << "min_jet_energy = "     << min_jet_energy     () << ", "
00050        << "overlap_threshold  = " << overlap_threshold  () << ", "
00051        << "E_scheme_jets  = "     << E_scheme_jets      () 
00052        << " (NB: non-standard version of PxCone, containing small bug fixes by Gavin Salam)";
00053 
00054   return desc.str();
00055 }
00056 
00057 
00058 void PxConePlugin::run_clustering(ClusterSequence & clust_seq) const {
00059  
00060   // only have hh mode
00061   int mode = 2;
00062 
00063   int    ntrak = clust_seq.jets().size(), itkdm = 4;
00064   double ptrak[ntrak][4];
00065   for (int i = 0; i < ntrak; i++) {
00066     ptrak[i][0] = clust_seq.jets()[i].px();
00067     ptrak[i][1] = clust_seq.jets()[i].py();
00068     ptrak[i][2] = clust_seq.jets()[i].pz();
00069     ptrak[i][3] = clust_seq.jets()[i].E();
00070   }  
00071 
00072   // max number of allowed jets
00073   int mxjet = ntrak;
00074   int njet;
00075   double pjet[mxjet][5];
00076   int    ipass[ntrak], ijmul[mxjet], ierr;
00077 
00078   // run pxcone
00079   pxcone(
00080     mode   ,    // 1=>e+e-, 2=>hadron-hadron
00081     ntrak  ,    // Number of particles
00082     itkdm  ,    // First dimension of PTRAK array: 
00083     &(ptrak[0][0])  ,    // Array of particle 4-momenta (Px,Py,Pz,E)
00084     cone_radius()  ,    // Cone size (half angle) in radians
00085     min_jet_energy() ,    // Minimum Jet energy (GeV)
00086     overlap_threshold()  ,    // Maximum fraction of overlap energy in a jet
00087     mxjet  ,    // Maximum possible number of jets
00088     njet   ,    // Number of jets found
00089     &(pjet[0][0]),       // 5-vectors of jets
00090     ipass,      // Particle k belongs to jet number IPASS(k)-1
00091                 // IPASS = -1 if not assosciated to a jet
00092     ijmul,      // Jet i contains IJMUL[i] particles
00093     ierr        // = 0 if all is OK ;   = -1 otherwise
00094     );
00095 
00096   if (ierr != 0) throw Error("An error occurred while running PXCONE");
00097 
00098   // now transfer information back 
00099   valarray<int> last_index_created(njet);
00100 
00101   vector<vector<int> > jet_particle_content(njet);
00102 
00103   // get a list of particles in each jet
00104   for (int itrak = 0; itrak < ntrak; itrak++) {
00105     int jet_i = ipass[itrak] - 1;
00106     if (jet_i >= 0) jet_particle_content[jet_i].push_back(itrak);
00107   }
00108 
00109   // now transfer the jets back into our own structure -- we will
00110   // mimic the cone code with a sequential recombination sequence in
00111   // which the jets are built up by adding one particle at a time
00112   for(int ipxjet = njet-1; ipxjet >= 0; ipxjet--) {
00113     const vector<int> & jet_trak_list = jet_particle_content[ipxjet];
00114     int jet_k = jet_trak_list[0];
00115   
00116     for (unsigned ilist = 1; ilist < jet_trak_list.size(); ilist++) {
00117       int jet_i = jet_k;
00118       // retrieve our misappropriated index for the jet
00119       int jet_j = jet_trak_list[ilist];
00120       // do a fake recombination step with dij=0
00121       double dij = 0.0;
00122       //clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
00123       if (ilist != jet_trak_list.size()-1 || E_scheme_jets()) {
00124         // our E-scheme recombination in cases where it doesn't matter
00125         clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
00126       } else {
00127         // put in pxcone's momentum for the last recombination so that the
00128         // final inclusive jet corresponds exactly to PXCONE's
00129         clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, 
00130                                 PseudoJet(pjet[ipxjet][0],pjet[ipxjet][1],
00131                                           pjet[ipxjet][2],pjet[ipxjet][3]),
00132                                                  jet_k);
00133       }
00134     }
00135   
00136     // NB: put a sensible looking d_iB just to be nice...
00137     double d_iB = clust_seq.jets()[jet_k].perp2();
00138     clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
00139   }
00140 
00141 
00143   //cout << endl;
00144   //for (int ijet = 0; ijet < njet; ijet++) {
00145   //  PseudoJet jet(pjet[ijet][0],pjet[ijet][1],pjet[ijet][2],pjet[ijet][3]);
00146   //  cout << jet.perp() << " " << jet.rap() << endl;
00147   //}
00148   //cout << "-----------------------------------------------------\n";
00149   //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
00150   //for (vector<PseudoJet>::const_iterator ourjet = ourjets.begin();
00151   //     ourjet != ourjets.end(); ourjet++) {
00152   //  cout << ourjet->perp() << " " << ourjet->rap() << endl;
00153   //}
00155 }
00156 
00157 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh

Generated on Tue Dec 18 17:05:02 2007 for fastjet by  doxygen 1.5.2