Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

fastjet_subtraction.cc

Go to the documentation of this file.
00001 
00002 //STARTHEADER
00003 // $Id: fastjet_subtraction.cc 432 2007-01-23 12:12:59Z salam $
00004 //
00005 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
00006 //
00007 //----------------------------------------------------------------------
00008 // This file is part of FastJet.
00009 //
00010 //  FastJet is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU General Public License as published by
00012 //  the Free Software Foundation; either version 2 of the License, or
00013 //  (at your option) any later version.
00014 //
00015 //  The algorithms that underlie FastJet have required considerable
00016 //  development and are described in hep-ph/0512210. If you use
00017 //  FastJet as part of work towards a scientific publication, please
00018 //  include a citation to the FastJet paper.
00019 //
00020 //  FastJet is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU General Public License
00026 //  along with FastJet; if not, write to the Free Software
00027 //  Foundation, Inc.:
00028 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029 //----------------------------------------------------------------------
00030 //ENDHEADER
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 //----------------------------------------------------------------------
00039 // fastjet subtraction example program. 
00040 //
00041 // Compile it with: make fastjet_subtraction
00042 // run it with    : ./fastjet_subtraction < data/Pythia-dijet-ptmin100-lhc-pileup-1ev.dat
00043 //
00044 //----------------------------------------------------------------------
00045 #include "fastjet/PseudoJet.hh"
00046 #include "fastjet/ClusterSequenceActiveArea.hh"
00047 #include<iostream> // needed for io
00048 #include<sstream>  // needed for internal io
00049 #include<vector> 
00050 
00051 using namespace std;
00052 
00053 // A declaration of a function that pretty prints a list of jets
00054 // The subtraction is also performed inside this function
00055 void print_jets (const fastjet::ClusterSequenceActiveArea &, 
00056                  const vector<fastjet::PseudoJet> &);
00057 
00059 int main (int argc, char ** argv) {
00060   
00061   // since we use here simulated data we can split the hard event
00062   // from the full (i.e. with pileup added) one
00063   vector<fastjet::PseudoJet> hard_event, full_event;
00064   
00065   // maximum rapidity that we accept for the input particles
00066   double etamax = 6.0;
00067   
00068   // read in input particles. Keep the hard event generated by PYTHIA
00069   // separated from the full event, so as to be able to gauge the
00070   // "goodness" of the subtraction from the full event which also
00071   // includes pileup
00072   string line;
00073   int  nsub  = 0;
00074   while (getline(cin, line)) {
00075     istringstream linestream(line);
00076     // take substrings to avoid problems when there are extra "pollution"
00077     // characters (e.g. line-feed).
00078     if (line.substr(0,4) == "#END") {break;}
00079     if (line.substr(0,9) == "#SUBSTART") {
00080       // if more sub events follow, make copy of hard one here
00081       if (nsub == 1) hard_event = full_event;
00082       nsub += 1;
00083     }
00084     if (line.substr(0,1) == "#") {continue;}
00085     valarray<double> fourvec(4);
00086     linestream >> fourvec[0] >> fourvec[1] >> fourvec[2] >> fourvec[3];
00087     fastjet::PseudoJet psjet(fourvec);
00088     psjet.set_user_index(0);
00089     // push event onto back of full_event vector
00090     if (abs(psjet.rap()) < etamax) {full_event.push_back(psjet);}
00091   }
00092 
00093   // if we have read in only one event, copy it across here...
00094   if (nsub == 1) hard_event = full_event;
00095 
00096   // if there was nothing in the event 
00097   if (nsub == 0) {
00098     cerr << "Error: read empty event\n";
00099     exit(-1);
00100   }
00101   
00102   
00103   // create an object that represents your choice of jet finder and 
00104   // the associated parameters
00105   double R = 0.7;
00106   fastjet::Strategy strategy = fastjet::Best;
00107   fastjet::JetDefinition jet_def(fastjet::kt_algorithm, R, strategy);
00108 
00109   // create an object that specifies how we to define the (active) area
00110   double ghost_etamax = 6.0;
00111   int    active_area_repeats = 1;
00112   double ghost_area    = 0.01;
00113   fastjet::ActiveAreaSpec area_spec(ghost_etamax, active_area_repeats, 
00114                                     ghost_area);
00115 
00116   // run the jet clustering with the above jet definition. hard event first
00117   fastjet::ClusterSequenceActiveArea clust_seq(hard_event, 
00118                                                jet_def, area_spec);
00119 
00120 
00121   // extract the inclusive jets with pt > 5 GeV, sorted by pt
00122   double ptmin = 5.0;
00123   vector<fastjet::PseudoJet> inclusive_jets = clust_seq.inclusive_jets(ptmin);
00124 
00125   // print them out
00126   cout << "" <<endl;
00127   cout << "Hard event only"<<endl;
00128   cout << "Number of input particles: "<<hard_event.size()<<endl;
00129   cout << "Strategy used: "<<clust_seq.strategy_string()<<endl;
00130   cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV\n";
00131   cout << "---------------------------------------\n";
00132   print_jets(clust_seq, inclusive_jets);
00133   cout << endl;
00134 
00135 
00136   // repeat everything on the full event
00137 
00138   // run the jet clustering with the above jet definition
00139   fastjet::ClusterSequenceActiveArea clust_seq_full(full_event, 
00140                                                     jet_def, area_spec);
00141 
00142   // extract the inclusive jets with pt > 20 GeV, sorted by pt
00143   ptmin = 20.0;
00144   inclusive_jets = clust_seq_full.inclusive_jets(ptmin);
00145 
00146   // print them out
00147   cout << "Full event, with pileup, and its subtraction"<<endl;
00148   cout << "Number of input particles: "<<full_event.size()<<endl;
00149   cout << "Strategy used: "<<clust_seq_full.strategy_string()<<endl;
00150   cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV (before subtraction)\n";
00151   cout << "---------------------------------------\n";
00152   print_jets(clust_seq_full, inclusive_jets);
00153   cout << endl;
00154 
00155 
00156 }
00157 
00158 
00159 //----------------------------------------------------------------------
00162 void print_jets (const fastjet::ClusterSequenceActiveArea & clust_seq, 
00163                  const vector<fastjet::PseudoJet> & unsorted_jets ) {
00164 
00165   // sort jets into increasing pt
00166   vector<fastjet::PseudoJet> jets = sorted_by_pt(unsorted_jets);  
00167 
00168   // the corrected jets will go in here
00169   vector<fastjet::PseudoJet> corrected_jets(jets.size());
00170   
00171   // get median pt per unit area
00172   // NB pt_per_unit_area exists only in ClusterSequenceActiveArea, and
00173   // not in the base class ClusterSequenceWithArea.
00174   // This might change in a future release
00175   double median_pt_per_area = clust_seq.pt_per_unit_area();
00176 
00177   printf(" ijet     rap     phi        Pt    area  Pt corr  (rap corr phi corr Pt corr)ext\n");
00178   for (size_t j = 0; j < jets.size(); j++) {
00179 
00180     // get area of each jet
00181     double area     = clust_seq.area(jets[j]);
00182 
00183     // "standard" correction. Subtract only the Pt
00184     double pt_corr  = jets[j].perp() - area*median_pt_per_area;
00185 
00186     // "extended" correction
00187     fastjet::PseudoJet area_4vect = 
00188                        median_pt_per_area*clust_seq.area_4vector(jets[j]);
00189     if (area_4vect.perp2() >= jets[j].perp2() || 
00190         area_4vect.E()     >= jets[j].E()) {
00191       // if the correction is too large, set the jet to zero
00192       corrected_jets[j] =  0.0 * jets[j];
00193     } else {
00194       // otherwise do an E-scheme subtraction
00195       corrected_jets[j] = jets[j] - area_4vect;
00196     }
00197     // NB We could also leave out the above "if": 
00198     // corrected_jets[j] = jets[j] - area_4vect;
00199     // but the result would be different, since we would not avoid
00200     // jets with negative Pt or energy
00201     
00202     printf("%5u %7.3f %7.3f %9.3f %7.3f %9.3f %7.3f %7.3f %9.3f\n",
00203      j,jets[j].rap(),jets[j].phi(),jets[j].perp(), area, pt_corr,
00204      corrected_jets[j].rap(),corrected_jets[j].phi(), corrected_jets[j].perp());
00205   }
00206 
00207   cout << endl;
00208   cout << "median pt_over_area = " << median_pt_per_area << endl << endl;
00209 
00210 
00211 }
00212 
00213 
00214 
00215 
00216 
00217 
00218 

Generated on Mon Apr 2 20:57:48 2007 for fastjet by  doxygen 1.4.2