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/momentum.h"
00035 #include "siscone/siscone.h"
00036
00037 #define Nruns 32
00038 #define R 0.7
00039 #define f 0.5
00040
00041 using namespace std;
00042 using namespace siscone;
00043
00044 timeval time_start, time_end;
00045
00046
00047 int time_spent(){
00048 timeval time_diff;
00049
00050
00051 time_diff.tv_sec = time_end.tv_sec-time_start.tv_sec;
00052 if (time_end.tv_usec > time_start.tv_usec){
00053 time_diff.tv_usec = time_end.tv_usec-time_start.tv_usec;
00054 } else {
00055 time_diff.tv_sec--;
00056 time_diff.tv_usec = (1000000+time_end.tv_usec)-time_start.tv_usec;
00057 }
00058
00059 return 1000000*time_diff.tv_sec+time_diff.tv_usec;
00060 }
00061
00062
00063
00064 int main(){
00065 vector<Cmomentum> particles;
00066 Csiscone siscone;
00067 double eta,phi;
00068
00069
00070 int i, N;
00071 int n_ev, part_inc;
00072
00073
00074 int time_siscone;
00075
00076
00077 FILE *flux;
00078
00079
00080 cout << "initialise random number generator" << endl;
00081 timeval timestamp;
00082
00083 gettimeofday(×tamp, NULL);
00084 srand(timestamp.tv_usec);
00085
00086 flux = fopen("times.dat", "w+");
00087
00088 N = 1;
00089 part_inc = 1;
00090 do{
00091 fprintf(stdout, "\r%5d particles\n", N);
00092 time_siscone=0;
00093
00094 for (n_ev=0;n_ev<Nruns;n_ev++){
00095
00096 particles.clear();
00097 for (i=0;i<N;i++){
00098 eta = -3.0+6.0*rand()/(RAND_MAX+1.0);
00099 phi = 2.0*M_PI*rand()/(RAND_MAX+1.0);
00100 particles.push_back(Cmomentum(cos(phi), sin(phi), tanh(eta), 1.0));
00101 }
00102
00103
00104 gettimeofday(&time_start, NULL);
00105 siscone.compute_jets(particles, R, f);
00106 gettimeofday(&time_end, NULL);
00107 time_siscone+=time_spent();
00108 }
00109
00110 fprintf(flux, "%d\t%le\n", N, time_siscone/(1.0*Nruns));
00111
00112 N+=part_inc;
00113 if (N==(part_inc<<3))
00114 part_inc <<= 1;
00115
00116 } while (N<=1024);
00117
00118 fclose(flux);
00119 fprintf(stdout, "\n");
00120
00121 cout << "bye..." << endl;
00122
00123 return 0;
00124 }