CDFJetCluPlugin.cc

Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: CDFJetCluPlugin.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/CDFJetCluPlugin.hh"
00032 #include "fastjet/ClusterSequence.hh"
00033 #include <sstream>
00034 
00035 // CDF stuff
00036 #include "JetCluAlgorithm.hh"
00037 #include "PhysicsTower.hh"
00038 #include "Cluster.hh"
00039 
00040 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00041 
00042 using namespace std;
00043 
00044 string CDFJetCluPlugin::description () const {
00045   ostringstream desc;
00046   
00047   desc << "CDF JetClu jet algorithm with " 
00048        << "seed_threshold = "     << seed_threshold    () << ", "
00049        << "cone_radius = "        << cone_radius       () << ", "
00050        << "adjacency_cut = "      << adjacency_cut     () << ", " 
00051        << "max_iterations = "     << max_iterations    () << ", "
00052        << "iratch = "             << iratch            () << ", "
00053        << "overlap_threshold = "  << overlap_threshold () ;
00054 
00055   return desc.str();
00056 }
00057 
00058 
00059 void CDFJetCluPlugin::run_clustering(ClusterSequence & clust_seq) const {
00060  
00061   // create the physics towers needed by the CDF code
00062   vector<PhysicsTower> towers;
00063   towers.reserve(clust_seq.jets().size());
00064 
00065   // create a map to identify jets (actually just the input particles)...
00066   map<double,int> jetmap;
00067 
00068   for (unsigned i = 0; i < clust_seq.jets().size(); i++) {
00069     PseudoJet particle(clust_seq.jets()[i]);
00070     _insert_unique(particle, jetmap);
00071     LorentzVector fourvect(particle.px(), particle.py(),
00072                            particle.pz(), particle.E());
00073     PhysicsTower tower(fourvect);
00074     // cannot use MidPoint trick of misusing one of the indices for
00075     // tracking, since the JetClu implementation _does_ seem to make
00076     // use of these indices 
00077     //tower.calTower.iEta = i;
00078     towers.push_back(tower);
00079   }
00080 
00081   // prepare the CDF algorithm
00082   JetCluAlgorithm j(seed_threshold(), cone_radius(), adjacency_cut(),
00083                     max_iterations(), iratch(), overlap_threshold());
00084     
00085   // run the CDF algorithm
00086   std::vector<Cluster> jets;
00087   j.run(towers,jets);
00088 
00089 
00090   // now transfer the jets back into our own structure -- we will
00091   // mimic the cone code with a sequential recombination sequence in
00092   // which the jets are built up by adding one particle at a time
00093 
00094   // NB: with g++-4.0, the reverse iterator code gave problems, so switch
00095   //     to indices instead
00096   //for(vector<Cluster>::const_reverse_iterator jetIter = jets.rbegin(); 
00097   //                                    jetIter != jets.rend(); jetIter++) {
00098   //  const vector<PhysicsTower> & tower_list = jetIter->towerList;
00099   //  int jet_k = jetmap[tower_list[0].fourVector.E];
00100   //
00101   //  int ntow = int(jetIter->towerList.size());
00102 
00103   for(int iCDFjets = jets.size()-1; iCDFjets >= 0; iCDFjets--) {
00104     const vector<PhysicsTower> & tower_list = jets[iCDFjets].towerList;
00105     int jet_k = jetmap[tower_list[0].fourVector.E];
00106   
00107     int ntow = int(tower_list.size());
00108     for (int itow = 1; itow < ntow; itow++) {
00109       int jet_i = jet_k;
00110       // retrieve our misappropriated index for the jet
00111       //int jet_j = tower_list[itow].calTower.iEta;
00112       int jet_j = jetmap[tower_list[itow].fourVector.E];
00113       // do a fake recombination step with dij=0
00114       double dij = 0.0;
00115       // JetClu does E-scheme recombination so we can stick with the
00116       // simple option
00117       clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
00118       //if (itow != ntow) {
00119       //  clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, jet_k);
00120       //} else {
00121       //  clust_seq.plugin_record_ij_recombination(jet_i, jet_j, dij, 
00122       //       PseudoJet(jetIter->fourVector.px,jetIter->fourVector.py,
00123       //                 jetIter->fourVector.pz,jetIter->fourVector.E),
00124       //                                           jet_k);
00125       //}
00126     }
00127   
00128     // NB: put a sensible looking d_iB just to be nice...
00129     double d_iB = clust_seq.jets()[jet_k].perp2();
00130     clust_seq.plugin_record_iB_recombination(jet_k, d_iB);
00131   }
00132 
00133 
00134   // following code is for testing only
00135   //cout << endl;
00136   //for(vector<Cluster>::const_iterator jetIter = jets.begin(); 
00137   //                                    jetIter != jets.end(); jetIter++) {
00138   //  cout << jetIter->fourVector.pt() << " " << jetIter->fourVector.y() << endl;
00139   //}
00140   //cout << "-----------------------------------------------------\n";
00141   //vector<PseudoJet> ourjets(clust_seq.inclusive_jets());
00142   //for (vector<PseudoJet>::const_iterator ourjet = ourjets.begin();
00143   //     ourjet != ourjets.end(); ourjet++) {
00144   //  cout << ourjet->perp() << " " << ourjet->rap() << endl;
00145   //}
00146   //cout << endl;
00147 }
00148 
00149 
00150 void CDFJetCluPlugin::_insert_unique(PseudoJet & jet, 
00151                                      map<double,int> & jetmap) const {
00152   while (jetmap.find(jet.E()) != jetmap.end()) {
00153     // deal with cases where something else has the same energy, and
00154     // also with situation where that energy is zero.
00155     if (jet.E() != 0.0) {
00156       jet *= 1.0+1e-12;
00157     } else {
00158       jet += PseudoJet(0.0,0.0,0.0,1e-300);
00159     }
00160   }
00161   jetmap[jet.E()] = jet.cluster_hist_index();
00162 }
00163 
00164 
00165 FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh

Generated on Thu Jan 3 19:04:30 2008 for fastjet by  doxygen 1.5.2