FastJet 3.0beta1
|
00001 //---------------------------------------------------------------------- 00002 /// \file 00003 /// \page Example07old 07 - subtracting jet background contamination (old version) 00004 /// 00005 /// fastjet subtraction example program. 00006 /// 00007 /// Note that this example is deprecated --- see 07-subtraction.cc 00008 /// for the newest version --- so it is not built by default 00009 /// 00010 /// run it with : ./07-subtraction-old < data/Pythia-Zp2jets-lhc-pileup-1ev.dat 00011 /// 00012 /// Source code: 07-subtraction-old.cc 00013 //---------------------------------------------------------------------- 00014 00015 //STARTHEADER 00016 // $Id: 07-subtraction-old.cc 2409 2011-07-08 15:58:15Z soyez $ 00017 // 00018 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin Salam and Gregory Soyez 00019 // 00020 //---------------------------------------------------------------------- 00021 // This file is part of FastJet. 00022 // 00023 // FastJet is free software; you can redistribute it and/or modify 00024 // it under the terms of the GNU General Public License as published by 00025 // the Free Software Foundation; either version 2 of the License, or 00026 // (at your option) any later version. 00027 // 00028 // The algorithms that underlie FastJet have required considerable 00029 // development and are described in hep-ph/0512210. If you use 00030 // FastJet as part of work towards a scientific publication, please 00031 // include a citation to the FastJet paper. 00032 // 00033 // FastJet is distributed in the hope that it will be useful, 00034 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00035 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00036 // GNU General Public License for more details. 00037 // 00038 // You should have received a copy of the GNU General Public License 00039 // along with FastJet; if not, write to the Free Software 00040 // Foundation, Inc.: 00041 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00042 //---------------------------------------------------------------------- 00043 //ENDHEADER 00044 00045 #include "fastjet/PseudoJet.hh" 00046 #include "fastjet/ClusterSequenceArea.hh" 00047 #include <iostream> // needed for io 00048 00049 using namespace std; 00050 00051 int main (int argc, char ** argv) { 00052 00053 // read in input particles 00054 // 00055 // since we use here simulated data we can split the hard event 00056 // from the full (i.e. with pileup added) one 00057 //---------------------------------------------------------- 00058 00059 vector<fastjet::PseudoJet> hard_event, full_event; 00060 00061 // read in input particles. Keep the hard event generated by PYTHIA 00062 // separated from the full event, so as to be able to gauge the 00063 // "goodness" of the subtraction from the full event, which also 00064 // includes pileup 00065 double particle_maxrap = 5.0; 00066 00067 string line; 00068 int nsub = 0; // counter to keep track of which sub-event we're reading 00069 while (getline(cin, line)) { 00070 istringstream linestream(line); 00071 // take substrings to avoid problems when there are extra "pollution" 00072 // characters (e.g. line-feed). 00073 if (line.substr(0,4) == "#END") {break;} 00074 if (line.substr(0,9) == "#SUBSTART") { 00075 // if more sub events follow, make copy of first one (the hard one) here 00076 if (nsub == 1) hard_event = full_event; 00077 nsub += 1; 00078 } 00079 if (line.substr(0,1) == "#") {continue;} 00080 double px,py,pz,E; 00081 linestream >> px >> py >> pz >> E; 00082 // you can construct 00083 fastjet::PseudoJet particle(px,py,pz,E); 00084 00085 // push event onto back of full_event vector 00086 if (abs(particle.rap()) <= particle_maxrap) full_event.push_back(particle); 00087 } 00088 00089 // if we have read in only one event, copy it across here... 00090 if (nsub == 1) hard_event = full_event; 00091 00092 // if there was nothing in the event 00093 if (nsub == 0) { 00094 cerr << "Error: read empty event\n"; 00095 exit(-1); 00096 } 00097 00098 00099 // create a jet definition for the clustering 00100 // We use the anti-kt algorithm with a radius of 0.5 00101 //---------------------------------------------------------- 00102 double R = 0.5; 00103 fastjet::JetDefinition jet_def(fastjet::antikt_algorithm, R); 00104 00105 // create an area definition for the clustering 00106 //---------------------------------------------------------- 00107 // ghosts should go up to the acceptance of the detector or 00108 // (with infinite acceptance) at least 2R beyond the region 00109 // where you plan to investigate jets. 00110 double ghost_maxrap = 6.0; 00111 fastjet::GhostedAreaSpec area_spec(ghost_maxrap); 00112 fastjet::AreaDefinition area_def(fastjet::active_area, area_spec); 00113 00114 // run the jet clustering with the above jet and area definitions 00115 // for both the hard and full event 00116 // 00117 // We retrieve the jets above 7 GeV in both case (note that the 00118 // 7-GeV cut we be applied again later on after we subtract the jets 00119 // from the full event) 00120 // ---------------------------------------------------------- 00121 fastjet::ClusterSequenceArea clust_seq_hard(hard_event, jet_def, area_def); 00122 fastjet::ClusterSequenceArea clust_seq_full(full_event, jet_def, area_def); 00123 00124 double ptmin = 7.0; 00125 vector<fastjet::PseudoJet> hard_jets = sorted_by_pt(clust_seq_hard.inclusive_jets(ptmin)); 00126 vector<fastjet::PseudoJet> full_jets = sorted_by_pt(clust_seq_full.inclusive_jets(ptmin)); 00127 00128 // Now turn to the estimation of the background (for the full event) 00129 // 00130 // This also requires a ClusterSequenceArea. 00131 // In general, this ClusterSequenceArea does not need to be the same 00132 // as the one used (above) to cluster and extract the jets from the 00133 // event: 00134 // - We strongly recommend using the kt or Cambridge/Aachen algorithm 00135 // (a warning will be issued otherwise) 00136 // - The choice of the radius is a bit more subtle. R=0.4 has been 00137 // chosen to limit the impact of hard jets; in samples of 00138 // dominantly sparse events it may cause the UE/pileup to be 00139 // underestimated a little, a slightly larger value (0.5 or 0.6) 00140 // may be better. 00141 // - For the area definition, we recommend the use of explicit 00142 // ghosts (i.e. active_area_explicit_ghosts) 00143 // As mentionned in the area example (06-area.cc), ghosts should 00144 // extend sufficiently far in rapidity to cover the jets used in 00145 // the computation of the background (see also the comment below) 00146 // 00147 // ---------------------------------------------------------- 00148 fastjet::JetDefinition jet_def_bkgd(fastjet::kt_algorithm, 0.4); 00149 fastjet::GhostedAreaSpec area_spec_bkgd(ghost_maxrap); 00150 fastjet::AreaDefinition area_def_bkgd(fastjet::active_area_explicit_ghosts, area_spec_bkgd); 00151 fastjet::ClusterSequenceArea clust_seq_bkgd(full_event, jet_def_bkgd, area_def_bkgd); 00152 00153 // Once you have the ClusterSequenceArea, you can compute the 00154 // background. This is estimated over a given range 00155 // (RangeDefinition) i.e. only jets within that range will be used 00156 // to estimate the background. You shold thus make sure the ghosts 00157 // extend far enough in rapidity to cover the range, a warning will 00158 // be issued otherwise. 00159 // 00160 // The simplest way to define a RangeDefinition is through its 00161 // maximal |y| extent but other options are possible e.g. through a 00162 // minimal and maximal rapidity and minimal and maximal azimuthal 00163 // angle. If needed, you can even define your own ranges (a few are 00164 // provided with FastJet) 00165 // 00166 // Finally, the estimation of the background properties rho (the 00167 // average density per unit area) and sigma (the average 00168 // fluctuations per unit area) is done using 00169 // ClusterSequenceArea::get_median_rho_and_sigma(). This takes 00170 // 2 main parameters: the range discussed above and a boolean 00171 // controlling the use of 4-vector or scalar areas (we suggest using 00172 // 4-vector areas) 00173 // 00174 // ---------------------------------------------------------- 00175 double range_maxrap = 4.5; // we have a ghost_maxrap of 6.0, particles up to 5 00176 fastjet::RangeDefinition range(range_maxrap); 00177 00178 bool use_4vector_area = true; 00179 00180 double rho, sigma; 00181 clust_seq_bkgd.get_median_rho_and_sigma(range, use_4vector_area, rho, sigma); 00182 00183 // show a summary of what was done so far 00184 // - the description of the algorithms, areas and ranges used 00185 // - the background properties 00186 // - the jets in the hard event 00187 //---------------------------------------------------------- 00188 cout << "Main clustering:" << endl; 00189 cout << " Ran: " << jet_def.description() << endl; 00190 cout << " Area: " << area_def.description() << endl; 00191 cout << " Particles up to |y|=" << particle_maxrap << endl; 00192 cout << endl; 00193 00194 cout << "Background estimation:" << endl; 00195 cout << " Ran " << jet_def_bkgd.description() << endl; 00196 cout << " Area: " << area_def_bkgd.description() << endl; 00197 cout << " Range: " << range.description() << endl; 00198 cout << " Giving, for the full event" << endl; 00199 cout << " rho = " << rho << endl; 00200 cout << " sigma = " << sigma << endl; 00201 cout << endl; 00202 00203 cout << "Jets above " << ptmin << " GeV in the hard event (" << hard_event.size() << " particles)" << endl; 00204 cout << "---------------------------------------\n"; 00205 printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt", "area"); 00206 for (unsigned int i = 0; i < hard_jets.size(); i++) { 00207 printf("%5u %15.8f %15.8f %15.8f %15.8f\n", i, 00208 hard_jets[i].rap(), hard_jets[i].phi(), hard_jets[i].perp(), 00209 hard_jets[i].area()); 00210 } 00211 cout << endl; 00212 00213 // Once the background properties have been computed, subtraction 00214 // can be applied on the jets 00215 // 00216 // This uses ClusterSequenceArea::subtracted_jet(jet, rho), with the 00217 // ClusterSequence used to cluster the jet and the background 00218 // density we have just computed 00219 // 00220 // (Note that when using scalar areas, subtracted_pt should be used 00221 // instead of subtracted_jet) 00222 // 00223 // We output the jets before and after subtraction 00224 // ---------------------------------------------------------- 00225 cout << "Jets above " << ptmin << " GeV in the full event (" << full_event.size() << " particles)" << endl; 00226 cout << "---------------------------------------\n"; 00227 printf("%5s %15s %15s %15s %15s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt", "area", "rap_sub", "phi_sub", "pt_sub"); 00228 unsigned int idx=0; 00229 for (unsigned int i=0; i<full_jets.size(); i++){ 00230 // get the subtracted jet 00231 fastjet::PseudoJet subtracted_jet = clust_seq_full.subtracted_jet(full_jets[i], rho); 00232 00233 // re-apply the pt cut 00234 if (subtracted_jet.perp2() >= ptmin*ptmin){ 00235 printf("%5u %15.8f %15.8f %15.8f %15.8f %15.8f %15.8f %15.8f\n", idx, 00236 full_jets[i].rap(), full_jets[i].phi(), full_jets[i].perp(), 00237 full_jets[i].area(), 00238 subtracted_jet.rap(), subtracted_jet.phi(), 00239 subtracted_jet.perp()); 00240 idx++; 00241 } 00242 } 00243 00244 return 0; 00245 }