|
SISCone
2.0.5
|
00001 00002 // File: main.cpp // 00003 // Description: main program that runs siscone from the command line // 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:: 320 $// 00024 // $Date:: 2011-11-15 09:54:50 +0100 (Tue, 15 Nov 2011) $// 00026 00027 #include <stdio.h> 00028 #include <iostream> 00029 #include <cstdlib> 00030 #include "siscone/momentum.h" 00031 #include "siscone/siscone.h" 00032 #include "options.h" 00033 00034 using namespace std; 00035 using namespace siscone; 00036 00037 int main(int argc, char *argv[]){ 00038 vector<Cmomentum> particles; 00039 Csiscone siscone; 00040 int i,N; 00041 double px,py,pz,E; 00042 Coptions opts; 00043 char fline[512]; 00044 00045 if (opts.parse_options(argc, argv)) 00046 exit(1); 00047 00048 // deal with help message 00049 if (opts.help_flag){ 00050 opts.print_help(); 00051 exit(0); 00052 } 00053 00054 // deal with version flag 00055 if (opts.version_flag){ 00056 opts.print_version(); 00057 exit(0); 00058 } 00059 00060 // various files used to read input data and store results 00061 FILE *flux; 00062 FILE *fpart; 00063 00064 // read particles 00065 if (opts.verbose_flag) cout << "reading particles" << endl; 00066 flux = fopen(opts.ev_name, "r"); 00067 if (flux==NULL){ 00068 cerr << "cannot read event '" << opts.ev_name << "'" << endl; 00069 cerr << "specify the event to read using the -e option" << endl; 00070 return 1; 00071 } 00072 00073 N=0; 00074 fpart = fopen("particles.dat", "w+"); 00075 while ((opts.N_stop!=0) && (fgets(fline, 512, flux)!=NULL)){ 00076 if (fline[0]!='#'){ // skip lines beginning with '#' 00077 if (sscanf(fline, "%le%le%le%le", &px, &py, &pz, &E)==4){ 00078 particles.push_back(Cmomentum(px, py, pz, E)); 00079 fprintf(fpart, "%e\t%e\n", particles[N].eta, particles[N].phi); 00080 N++; 00081 opts.N_stop--; 00082 } else { 00083 cout << "error in reading event file Giving up." << endl; 00084 fclose(flux); 00085 fclose(fpart); 00086 exit(2); 00087 } 00088 } 00089 } 00090 fclose(flux); 00091 fclose(fpart); 00092 if (opts.verbose_flag) 00093 cout << " working with " << N << " particles" << endl; 00094 00095 // compute jets 00096 if (opts.verbose_flag) cout << "computing jet contents" << endl; 00097 i=siscone.compute_jets(particles, opts.R, opts.f, opts.npass, opts.ptmin, opts.SM_var); 00098 if (opts.verbose_flag){ 00099 unsigned int pass; 00100 for (pass=0;pass<siscone.protocones_list.size();pass++) 00101 cout << " pass " << pass << " found " << siscone.protocones_list[pass].size() 00102 << " stable cones" << endl; 00103 cout << " Final result: " << i << " jets found" << endl; 00104 } 00105 00106 // save jets 00107 if (opts.verbose_flag) 00108 cout << "saving result" << endl; 00109 flux = fopen("jets.dat", "w+"); 00110 siscone.save_contents(flux); 00111 fclose(flux); 00112 00113 if (opts.verbose_flag) 00114 cout << "bye..." << endl; 00115 00116 return 0; 00117 }