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