siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
sample.cpp
1
2// File: sample.cpp //
3// Description: example program for the Csiscone class (see documentation) //
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 <iomanip>
30#include "siscone/momentum.h"
31#include "siscone/siscone.h"
32
33#define R 0.7
34#define f 0.5
35#define f_alt 0.75
36
37using namespace std;
38using namespace siscone;
39
40int main(){
41 vector<Cmomentum> particles; // list of particles
42 Csiscone siscone; // main object for the cone algorithm
43 int i; // loop index
44 int N; // number of particles
45 double px,py,pz,E; // particles 4-momentum
46 char fline[512]; // line to read from a file
47
48 // read particles
49 FILE *flux;
50 flux = fopen("events/single-event.dat", "r");
51 if (flux==NULL){
52 cerr << "cannot read event" << endl;
53 return 1;
54 }
55
56 N=0;
57 while (fgets(fline, 512, flux)!=NULL){
58 if (fline[0]!='#'){ // skip lines beginning with '#'
59 if (sscanf(fline, "%le%le%le%le", &px, &py, &pz, &E)==4){
60 particles.push_back(Cmomentum(px, py, pz, E));
61 N++;
62 } else {
63 cout << "error in reading event file Giving up." << endl;
64 fclose(flux);
65 return 2;
66 }
67 }
68 }
69 fclose(flux);
70
71 // compute jets
72 // first compute with multiple passes (default)
73 i=siscone.compute_jets(particles, R, f);
74 cout << " " << i << " jets found in multi-pass run" << endl;
75
76 // then, recompute it with a different f
77 i=siscone.recompute_jets(f_alt);
78 cout << " " << i << " jets found with alternative f" << endl;
79
80 // one pass
81 i=siscone.compute_jets(particles, R, f, 1);
82 cout << " " << i << " jets found in single-pass run" << endl;
83
84 // show jets
85 vector<Cjet>::iterator it_j;
86 int i1;
87 fprintf(stdout, "# pT eta phi px py pz E \n");
88 for (it_j = siscone.jets.begin(), i1=0 ;
89 it_j != siscone.jets.end() ; it_j++, i1++){
90 fprintf(stdout, "Jet %3d: %10.3f %8.3f %8.3f %10.3f %10.3f %10.3f %10.3f\n",
91 i1, it_j->v.perp(), it_j->v.eta, it_j->v.phi, it_j->v.px, it_j->v.py, it_j->v.pz, it_j->v.E);
92 }
93
94 return 0;
95}
base class for dynamic coordinates management
Definition: momentum.h:49
final class: gather everything to compute the jet contents.
Definition: siscone.h:48
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 recompute_jets(double _f, double _ptmin=0.0, Esplit_merge_scale _split_merge_scale=SM_pttilde)
recompute the jets with a different overlap parameter.
Definition: siscone.cpp:216
std::vector< Cjet > jets
list of jets
Definition: split_merge.h:360

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