|
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:: 171 $// 00024 // $Date:: 2007-06-19 10:26:05 -0400 (Tue, 19 Jun 2007) $// 00026 00027 #include <stdio.h> 00028 #include <iostream> 00029 #include <cstdlib> 00030 #include "siscone/momentum.h" 00031 #include "siscone/siscone.h" 00032 #include "siscone/area.h" 00033 #include "options.h" 00034 00035 using namespace std; 00036 using namespace siscone; 00037 00038 int main(int argc, char *argv[]){ 00039 vector<Cmomentum> particles; 00040 Carea siscone_with_area; 00041 int i,N; 00042 double px,py,pz,E; 00043 Coptions opts; 00044 char fline[512]; 00045 00046 if (opts.parse_options(argc, argv)) 00047 exit(1); 00048 00049 // deal with help message 00050 if (opts.help_flag){ 00051 opts.print_help(); 00052 exit(0); 00053 } 00054 00055 // deal with version flag 00056 if (opts.version_flag){ 00057 opts.print_version(); 00058 exit(0); 00059 } 00060 00061 // various files used to read input data and store results 00062 FILE *flux; 00063 FILE *fpart; 00064 00065 // read particles 00066 if (opts.verbose_flag) cout << "reading particles" << endl; 00067 flux = fopen(opts.ev_name, "r"); 00068 if (flux==NULL){ 00069 cerr << "cannot read event" << 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_with_area.compute_areas(particles, opts.R, opts.f, opts.npass, opts.SM_var); 00098 if (opts.verbose_flag){ 00099 unsigned int pass; 00100 for (pass=0;pass<siscone_with_area.protocones_list.size();pass++) 00101 cout << " pass " << pass << " found " << siscone_with_area.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_with_area.dat", "w+"); 00110 vector<Cjet_area>::iterator ja; 00111 for (ja=siscone_with_area.jet_areas.begin();ja!=siscone_with_area.jet_areas.end();ja++){ 00112 fprintf(flux, "%e\t%e\t%e\t%e\t%e\n", 00113 ja->v.perp(), ja->v.eta, ja->v.phi, 00114 ja->active_area, ja->passive_area); 00115 } 00116 00117 fclose(flux); 00118 00119 if (opts.verbose_flag) 00120 cout << "bye..." << endl; 00121 00122 return 0; 00123 }