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