siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
main.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:: $//
24// $Date:: $//
26
27#include <stdio.h>
28#include <iostream>
29#include <cstdlib>
30#include "siscone/momentum.h"
31#include "siscone/siscone.h"
32#include "options.h"
33
34using namespace std;
35using namespace siscone;
36
37int main(int argc, char *argv[]){
38 vector<Cmomentum> particles;
39 Csiscone siscone;
40 int i,N;
41 double px,py,pz,E;
42 Coptions opts;
43 char fline[512];
44
45 if (opts.parse_options(argc, argv))
46 exit(1);
47
48 // deal with help message
49 if (opts.help_flag){
50 opts.print_help();
51 exit(0);
52 }
53
54 // deal with version flag
55 if (opts.version_flag){
56 opts.print_version();
57 exit(0);
58 }
59
60 // various files used to read input data and store results
61 FILE *flux;
62 FILE *fpart;
63
64 // read particles
65 if (opts.verbose_flag) cout << "reading particles" << endl;
66 flux = fopen(opts.ev_name, "r");
67 if (flux==NULL){
68 cerr << "cannot read event '" << opts.ev_name << "'" << endl;
69 cerr << "specify the event to read using the -e option" << 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.compute_jets(particles, opts.R, opts.f, opts.npass, opts.ptmin, opts.SM_var);
98 if (opts.verbose_flag){
99 unsigned int pass;
100 for (pass=0;pass<siscone.protocones_list.size();pass++)
101 cout << " pass " << pass << " found " << siscone.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.dat", "w+");
110 siscone.save_contents(flux);
111 fclose(flux);
112
113 if (opts.verbose_flag)
114 cout << "bye..." << endl;
115
116 return 0;
117}
options for the 'cone' sample
Definition: options.h:37
int print_version()
print program version
Definition: options.cpp:230
char * ev_name
event to read
Definition: options.h:67
int parse_options(int argc, char **argv)
parse oprions
Definition: options.cpp:79
double R
cone radius
Definition: options.h:64
int verbose_flag
do we need to print the help message
Definition: options.h:60
siscone::Esplit_merge_scale SM_var
variable for split-merge
Definition: options.h:71
int print_help()
print the help message
Definition: options.cpp:203
int help_flag
do we need to print the help message
Definition: options.h:58
int npass
number of passes (0 for \infty)
Definition: options.h:68
double ptmin
minimal pT for jet candidates
Definition: options.h:66
int version_flag
do we need to print the version description
Definition: options.h:59
double f
split/merge threshold
Definition: options.h:65
int N_stop
maximum number of particle
Definition: options.h:63
base class for dynamic coordinates management
Definition: momentum.h:49
final class: gather everything to compute the jet contents.
Definition: siscone.h:48
std::vector< std::vector< Cmomentum > > protocones_list
list of protocones found pass-by-pass (not filled by compute_jets_progressive_removal)
Definition: siscone.h:117
int compute_jets(std::vector< Cmomentum > &_particles, double _radius, double _f, int _n_pass_max=0, double _ptmin=0.0, Esplit_merge_scale _split_merge_scale=SM_pttilde)
compute the jets from a given particle set.
Definition: siscone.cpp:79
int save_contents(FILE *flux)
save final jets

The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Tue Jun 20 2023 18:08:37 for SISCone by  Doxygen 1.9.4