00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <time.h>
00030 #include <sys/time.h>
00031 #include <iostream>
00032 #include <math.h>
00033
00034 #include "siscone/ranlux.h"
00035 #include "siscone/momentum.h"
00036 #include "siscone/protocones.h"
00037 #include "siscone/split_merge.h"
00038 #include "siscone/siscone.h"
00039
00040 #define N_default 500
00041 #define R 0.7
00042 #define F 0.75
00043
00044 using namespace std;
00045 using namespace siscone;
00046
00047 int main(int argc, char* argv[]){
00048 vector<Cmomentum> particles;
00049 Cmomentum *v;
00050 double phi=0, eta=0, pt=1;
00051 unsigned int N;
00052
00053 unsigned int i, nb_stable;
00054 FILE *flux;
00055
00056 if (argc==1){
00057 cout << "using default number of particles" << endl;
00058 N = N_default;
00059 } else {
00060 sscanf(argv[1], "%d", &N);
00061 cout << "using " << N << " particles" << endl;
00062 }
00063
00064
00065 cout << "initialise random number generator" << endl;
00066 timeval timestamp;
00067
00068 gettimeofday(×tamp, NULL);
00069 srand(timestamp.tv_usec);
00070
00071
00072
00073 cout << "build particle list" << endl;
00074 flux = fopen("particles.dat", "w+");
00075 ranlux_init();
00076 for (i=0;i<N;i++){
00077
00078 phi = 0.9*sin(2.0*i*M_PI/N);
00079 if (phi<-M_PI) phi+=2.0*M_PI;
00080 if (phi> M_PI) phi-=2.0*M_PI;
00081 eta = 1.1*cos(2.0*i*M_PI/N);
00082
00083
00084 eta = -5.0+10.0*rand()/(RAND_MAX+1.0);
00085 phi = 2.0*M_PI*rand()/(RAND_MAX+1.0);
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 pt = 1.0;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 particles.push_back(Cmomentum(pt*cos(phi), pt*sin(phi), pt*sinh(eta), pt*cosh(eta)));
00107
00108 fprintf(flux, "%le\t%le\n", particles[i].eta, particles[i].phi);
00109 }
00110 fclose(flux);
00111
00112 cout << "stable cones: initialise engine" << endl;
00113 Cstable_cones *engine;
00114 engine = new Cstable_cones(particles);
00115
00116
00117 cout << "stable cones: retreive stable cones" << endl;
00118 nb_stable = engine->get_stable_cones(R);
00119 cout << " found " << nb_stable << " stable cones" << endl;
00120
00121
00122 cout << "stable cones: save result" << endl;
00123 flux = fopen("protocones.dat", "w+");
00124 for (i=0;i<nb_stable;i++){
00125 v = &(engine->protocones[i]);
00126 fprintf(flux, "%le\t%le\n", v->eta, v->phi);
00127 }
00128 fclose(flux);
00129
00130
00131 cout << "split and merge: init" << endl;
00132 Csplit_merge sm;
00133 sm.init(particles, &(engine->protocones), R*R);
00134 delete engine;
00135
00136 cout << "split and merge: perform" << endl;
00137 nb_stable = sm.perform(F);
00138 cout << " found " << nb_stable << " jets" << endl;
00139 flux = fopen("jets.dat", "w+");
00140 sm.save_contents(flux);
00141 fclose(flux);
00142
00143 Csiscone *siscone;
00144 siscone = new Csiscone;
00145 delete siscone;
00146
00147 cout << "bye..." << endl;
00148
00149 return 0;
00150 }