SISCone  2.0.5
area.cpp
1 
2 // File: main.cpp //
3 // Description: main program that runs siscone from the command line //
4 // This file is part of the SISCone project. //
5 // For more details, see http://projects.hepforge.org/siscone //
6 // //
7 // Copyright (c) 2006 Gavin Salam and Gregory Soyez //
8 // //
9 // This program is free software; you can redistribute it and/or modify //
10 // it under the terms of the GNU General Public License as published by //
11 // the Free Software Foundation; either version 2 of the License, or //
12 // (at your option) any later version. //
13 // //
14 // This program is distributed in the hope that it will be useful, //
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
17 // GNU General Public License for more details. //
18 // //
19 // You should have received a copy of the GNU General Public License //
20 // along with this program; if not, write to the Free Software //
21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
22 // //
23 // $Revision:: 171 $//
24 // $Date:: 2007-06-19 10:26:05 -0400 (Tue, 19 Jun 2007) $//
26 
27 #include <stdio.h>
28 #include <iostream>
29 #include <cstdlib>
30 #include "siscone/momentum.h"
31 #include "siscone/siscone.h"
32 #include "siscone/area.h"
33 #include "options.h"
34 
35 using namespace std;
36 using namespace siscone;
37 
38 int main(int argc, char *argv[]){
39  vector<Cmomentum> particles;
40  Carea siscone_with_area;
41  int i,N;
42  double px,py,pz,E;
43  Coptions opts;
44  char fline[512];
45 
46  if (opts.parse_options(argc, argv))
47  exit(1);
48 
49  // deal with help message
50  if (opts.help_flag){
51  opts.print_help();
52  exit(0);
53  }
54 
55  // deal with version flag
56  if (opts.version_flag){
57  opts.print_version();
58  exit(0);
59  }
60 
61  // various files used to read input data and store results
62  FILE *flux;
63  FILE *fpart;
64 
65  // read particles
66  if (opts.verbose_flag) cout << "reading particles" << endl;
67  flux = fopen(opts.ev_name, "r");
68  if (flux==NULL){
69  cerr << "cannot read event" << endl;
70  return 1;
71  }
72 
73  N=0;
74  fpart = fopen("particles.dat", "w+");
75  while ((opts.N_stop!=0) && (fgets(fline, 512, flux)!=NULL)){
76  if (fline[0]!='#'){ // skip lines beginning with '#'
77  if (sscanf(fline, "%le%le%le%le", &px, &py, &pz, &E)==4){
78  particles.push_back(Cmomentum(px, py, pz, E));
79  fprintf(fpart, "%e\t%e\n", particles[N].eta, particles[N].phi);
80  N++;
81  opts.N_stop--;
82  } else {
83  cout << "error in reading event file Giving up." << endl;
84  fclose(flux);
85  fclose(fpart);
86  exit(2);
87  }
88  }
89  }
90  fclose(flux);
91  fclose(fpart);
92  if (opts.verbose_flag)
93  cout << " working with " << N << " particles" << endl;
94 
95  // compute jets
96  if (opts.verbose_flag) cout << "computing jet contents" << endl;
97  i=siscone_with_area.compute_areas(particles, opts.R, opts.f, opts.npass, opts.SM_var);
98  if (opts.verbose_flag){
99  unsigned int pass;
100  for (pass=0;pass<siscone_with_area.protocones_list.size();pass++)
101  cout << " pass " << pass << " found " << siscone_with_area.protocones_list[pass].size()
102  << " stable cones" << endl;
103  cout << " Final result: " << i << " jets found" << endl;
104  }
105 
106  // save jets
107  if (opts.verbose_flag)
108  cout << "saving result" << endl;
109  flux = fopen("jets_with_area.dat", "w+");
110  vector<Cjet_area>::iterator ja;
111  for (ja=siscone_with_area.jet_areas.begin();ja!=siscone_with_area.jet_areas.end();ja++){
112  fprintf(flux, "%e\t%e\t%e\t%e\t%e\n",
113  ja->v.perp(), ja->v.eta, ja->v.phi,
114  ja->active_area, ja->passive_area);
115  }
116 
117  fclose(flux);
118 
119  if (opts.verbose_flag)
120  cout << "bye..." << endl;
121 
122  return 0;
123 }
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Wed Mar 19 2014 21:30:25 for SISCone by  Doxygen 1.8.1.2