File: main.cpp

package info (click to toggle)
siscone 3.0.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,748 kB
  • sloc: cpp: 5,012; sh: 4,163; makefile: 94
file content (117 lines) | stat: -rw-r--r-- 4,290 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
///////////////////////////////////////////////////////////////////////////////
// File: main.cpp                                                            //
// Description: main program that runs siscone from the command line         //
// This file is part of the SISCone project.                                 //
// For more details, see http://projects.hepforge.org/siscone                //
//                                                                           //
// Copyright (c) 2006 Gavin Salam and Gregory Soyez                          //
//                                                                           //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
//                                                                           //
// This program is distributed in the hope that it will be useful,           //
// but WITHOUT ANY WARRANTY; without even the implied warranty of            //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             //
// GNU General Public License for more details.                              //
//                                                                           //
// You should have received a copy of the GNU General Public License         //
// along with this program; if not, write to the Free Software               //
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
//                                                                           //
// $Revision:: 320                                                          $//
// $Date:: 2011-11-15 09:54:50 +0100 (Tue, 15 Nov 2011)                     $//
///////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include "siscone/momentum.h"
#include "siscone/siscone.h"
#include "options.h"

using namespace std;
using namespace siscone;

int main(int argc, char *argv[]){
  vector<Cmomentum> particles;
  Csiscone siscone;
  int i,N;
  double px,py,pz,E;
  Coptions opts;
  char fline[512];

  if (opts.parse_options(argc, argv))
    exit(1);

  // deal with help message
  if (opts.help_flag){
    opts.print_help();
    exit(0);
  }

  // deal with version flag
  if (opts.version_flag){
    opts.print_version();
    exit(0);
  }

  // various files used to read input data and store results
  FILE *flux;
  FILE *fpart;

  // read particles
  if (opts.verbose_flag) cout << "reading particles" << endl;
  flux = fopen(opts.ev_name, "r");
  if (flux==NULL){
    cerr << "cannot read event '" << opts.ev_name << "'" << endl;
    cerr << "specify the event to read using the -e option" << endl;
    return 1;
  }

  N=0;
  fpart = fopen("particles.dat", "w+");
  while ((opts.N_stop!=0) && (fgets(fline, 512, flux)!=NULL)){
    if (fline[0]!='#'){ // skip lines beginning with '#'
      if (sscanf(fline, "%le%le%le%le", &px, &py, &pz, &E)==4){    
	particles.push_back(Cmomentum(px, py, pz, E));
	fprintf(fpart, "%e\t%e\n",   particles[N].eta, particles[N].phi);
	N++;
	opts.N_stop--;
      } else {
	cout << "error in reading event file Giving up." << endl;
	fclose(flux);
	fclose(fpart);
	exit(2);
      }
    }
  }
  fclose(flux);
  fclose(fpart);
  if (opts.verbose_flag) 
    cout << "  working with " << N << " particles" << endl;

  // compute jets
  if (opts.verbose_flag) cout << "computing jet contents" << endl;
  i=siscone.compute_jets(particles, opts.R, opts.f, opts.npass, opts.ptmin, opts.SM_var);
  if (opts.verbose_flag){
    unsigned int pass;
    for (pass=0;pass<siscone.protocones_list.size();pass++)
      cout << "    pass " << pass << " found " << siscone.protocones_list[pass].size()
	   << " stable cones" << endl;
    cout << "  Final result: " << i << " jets found" << endl;
  }

  // save jets
  if (opts.verbose_flag) 
    cout << "saving result" << endl;
  flux = fopen("jets.dat", "w+");
  siscone.save_contents(flux);
  fclose(flux);

  if (opts.verbose_flag) 
    cout << "bye..." << endl;

  return 0;
}