SISCone  2.0.6
area.cpp
1 // 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 }
Coptions
Definition: options.h:37
siscone::Csiscone::protocones_list
std::vector< std::vector< Cmomentum > > protocones_list
list of protocones found pass-by-pass
Definition: siscone.h:96
Coptions::f
double f
split/merge threshold
Definition: options.h:65
siscone::Cmomentum
base class for dynamic coordinates management
Definition: momentum.h:49
Coptions::SM_var
siscone::Esplit_merge_scale SM_var
variable for split-merge
Definition: options.h:71
Coptions::verbose_flag
int verbose_flag
do we need to print the help message
Definition: options.h:60
Coptions::ev_name
char * ev_name
event to read
Definition: options.h:67
Coptions::version_flag
int version_flag
do we need to print the version description
Definition: options.h:59
Coptions::print_version
int print_version()
print program version
Definition: options.cpp:230
Coptions::parse_options
int parse_options(int argc, char **argv)
parse oprions
Definition: options.cpp:79
Coptions::print_help
int print_help()
print the help message
Definition: options.cpp:203
siscone::Carea::compute_areas
int compute_areas(std::vector< Cmomentum > &_particles, double _radius, double _f, int _n_pass_max=0, Esplit_merge_scale _split_merge_scale=SM_pttilde, bool _hard_only=false)
compute the jet areas from a given particle set.
Definition: area.cpp:125
siscone::Carea::jet_areas
std::vector< Cjet_area > jet_areas
jets with their areas
Definition: area.h:135
Coptions::npass
int npass
number of passes (0 for \infty)
Definition: options.h:68
Coptions::help_flag
int help_flag
do we need to print the help message
Definition: options.h:58
siscone::Carea
Definition: area.h:72
Coptions::N_stop
int N_stop
maximum number of particle
Definition: options.h:63
Coptions::R
double R
cone radius
Definition: options.h:64
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated for SISCone by  Doxygen 1.8.17