siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
test.cpp
1
2// File: test.cpp //
3// Description: example program that implements tests with random particles //
4// and output various informations //
5// //
6// Note: for a usage example of SISCone, we advise looking at main.cpp //
7// or http://projects.hepforge.org/siscone/usage.html //
8// //
9// This file is part of the SISCone project. //
10// For more details, see http://projects.hepforge.org/siscone //
11// //
12// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
13// //
14// This program is free software; you can redistribute it and/or modify //
15// it under the terms of the GNU General Public License as published by //
16// the Free Software Foundation; either version 2 of the License, or //
17// (at your option) any later version. //
18// //
19// This program is distributed in the hope that it will be useful, //
20// but WITHOUT ANY WARRANTY; without even the implied warranty of //
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
22// GNU General Public License for more details. //
23// //
24// You should have received a copy of the GNU General Public License //
25// along with this program; if not, write to the Free Software //
26// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
27// //
28// $Revision:: $//
29// $Date:: $//
31
32#include <stdio.h>
33#include <stdlib.h>
34#include <time.h>
35#include <sys/time.h>
36#include <iostream>
37#include <math.h>
38
39#include "siscone/momentum.h"
40#include "siscone/siscone.h"
41
42#define N_default 500
43#define R 0.7
44#define F 0.75
45
46using namespace std;
47using namespace siscone;
48
49int main(int argc, char* argv[]){
50 vector<Cmomentum> particles;
51 Cmomentum *v;
52 double phi=0, eta=0, pt=1;
53 unsigned int N;
54
55 unsigned int i;
56 FILE *flux;
57
58 if (argc==1){
59 //cout << "using default number of particles" << endl;
60 N = N_default;
61 } else {
62 sscanf(argv[1], "%u", &N);
63 //cout << "using " << N << " particles" << endl;
64 }
65
66 // Initialise random number generator
67 timeval timestamp;
68 gettimeofday(&timestamp, NULL);
69 srand(timestamp.tv_usec);
70
71 // build particle list
72 cout << "build particle list" << endl;
73 flux = fopen("particles.dat", "w+");
74 for (i=0;i<N;i++){
75 // uniform eta between -5 and 5
76 eta = -5.0+10.0*rand()/(RAND_MAX+1.0);
77
78 // uniform azimuth
79 phi = 2.0*M_PI*rand()/(RAND_MAX+1.0);
80
81 // logarithmically uniform pt (between 1e-3 and 100 GeV)
82 pt = exp(log(0.001)+log(1e5)*rand()/(RAND_MAX+1.0));
83
84 particles.push_back(Cmomentum(pt*cos(phi), pt*sin(phi), pt*sinh(eta), pt*cosh(eta)));
85
86 fprintf(flux, "%e\t%e\t%e\n", particles[i].eta, particles[i].phi,particles[i].perp());
87 }
88 fclose(flux);
89
90 cout << "SISCone: initialise engine" << endl;
91 Csiscone siscone;
92
93 // cluster the event
94 cout << "cluster the event" << endl;
95 siscone.compute_jets(particles, R, F);
96
97#ifdef DEBUG_STABLE_CONES
98 cout << "hash_candidates=" << siscone.nb_hash_cones_total << " in " << siscone.nb_hash_occupied_total << " cells" << endl;
99#endif
100 // save list of stable cones
101 cout << "save stable cone results:" << endl;
102 unsigned int pass;
103 flux = fopen("protocones.dat", "w+");
104 for (pass=0;pass<siscone.protocones_list.size();pass++){
105 cout << " pass " << pass << " found " << siscone.protocones_list[pass].size()
106 << " stable cones" << endl;
107 fprintf(flux, "# pass %d: %u stable cones\n", pass,
108 (unsigned int) siscone.protocones_list[pass].size());
109 for (i=0;i<siscone.protocones_list[pass].size();i++){
110 v = &(siscone.protocones_list[pass][i]);
111 fprintf(flux, "%e\t%e\t%e\n", v->eta, v->phi, v->perp());
112 }
113 }
114 fclose(flux);
115
116 cout << "bye..." << endl;
117
118 return 0;
119}
base class for dynamic coordinates management
Definition: momentum.h:49
double eta
particle pseudo-rapidity
Definition: momentum.h:114
double perp() const
computes pT
Definition: momentum.h:64
double phi
particle azimuthal angle
Definition: momentum.h:115
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

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