|
SISCone
2.0.5
|
00001 00002 // File: sample.cpp // 00003 // Description: example program for the Csiscone class (see documentation) // 00004 // This file is part of the SISCone project. // 00005 // For more details, see http://projects.hepforge.org/siscone // 00006 // // 00007 // Copyright (c) 2006 Gavin Salam and Gregory Soyez // 00008 // // 00009 // This program 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 // This program is distributed in the hope that it will be useful, // 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00017 // GNU General Public License for more details. // 00018 // // 00019 // You should have received a copy of the GNU General Public License // 00020 // along with this program; if not, write to the Free Software // 00021 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 00022 // // 00023 // $Revision:: 321 $// 00024 // $Date:: 2011-11-15 09:56:39 +0100 (Tue, 15 Nov 2011) $// 00026 00027 #include <stdio.h> 00028 #include <iostream> 00029 #include <iomanip> 00030 #include "siscone/momentum.h" 00031 #include "siscone/siscone.h" 00032 00033 #define R 0.7 00034 #define f 0.5 00035 #define f_alt 0.75 00036 00037 using namespace std; 00038 using namespace siscone; 00039 00040 int main(){ 00041 vector<Cmomentum> particles; // list of particles 00042 Csiscone siscone; // main object for the cone algorithm 00043 int i; // loop index 00044 int N; // number of particles 00045 double px,py,pz,E; // particles 4-momentum 00046 char fline[512]; // line to read from a file 00047 00048 // read particles 00049 FILE *flux; 00050 flux = fopen("events/single-event.dat", "r"); 00051 if (flux==NULL){ 00052 cerr << "cannot read event" << endl; 00053 return 1; 00054 } 00055 00056 N=0; 00057 while (fgets(fline, 512, flux)!=NULL){ 00058 if (fline[0]!='#'){ // skip lines beginning with '#' 00059 if (sscanf(fline, "%le%le%le%le", &px, &py, &pz, &E)==4){ 00060 particles.push_back(Cmomentum(px, py, pz, E)); 00061 N++; 00062 } else { 00063 cout << "error in reading event file Giving up." << endl; 00064 fclose(flux); 00065 return 2; 00066 } 00067 } 00068 } 00069 fclose(flux); 00070 00071 // compute jets 00072 // first compute with multiple passes (default) 00073 i=siscone.compute_jets(particles, R, f); 00074 cout << " " << i << " jets found in multi-pass run" << endl; 00075 00076 // then, recompute it with a different f 00077 i=siscone.recompute_jets(f_alt); 00078 cout << " " << i << " jets found with alternative f" << endl; 00079 00080 // one pass 00081 i=siscone.compute_jets(particles, R, f, 1); 00082 cout << " " << i << " jets found in single-pass run" << endl; 00083 00084 // show jets 00085 vector<Cjet>::iterator it_j; 00086 int i1; 00087 fprintf(stdout, "# pT eta phi px py pz E \n"); 00088 for (it_j = siscone.jets.begin(), i1=0 ; 00089 it_j != siscone.jets.end() ; it_j++, i1++){ 00090 fprintf(stdout, "Jet %3d: %10.3f %8.3f %8.3f %10.3f %10.3f %10.3f %10.3f\n", 00091 i1, it_j->v.perp(), it_j->v.eta, it_j->v.phi, it_j->v.px, it_j->v.py, it_j->v.pz, it_j->v.E); 00092 } 00093 00094 return 0; 00095 }