return 1;
}
-int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio)
+int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio,u32 rj_m,u32 *rj_g)
{
u32 x,y,z;
int i,j,k,c;
x=get_rand(d3_l->max_x);
y=get_rand(d3_l->max_y);
// printf("nd: %d %d\n",x,y);
- z=get_rand_lgp(d3_l->max_z,my_info->a_cd,my_info->b_cd);
- // printf("ld: %d\n",z);
+ // z=get_rand_lgp(d3_l->max_z,my_info->a_cd,my_info->b_cd);
+ z=get_rand_reject(d3_l->max_z,rj_m,rj_g);
+ // printf("%d\n",z);
*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1;
(my_info->cc)++;
}
return 1;
}
-int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) {
+u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) {
double a,b;
int i,j,k;
int fd;
char buf[32],*p;
unsigned char *flag;
+ u32 max;
+ max=0;
if((fd=open(file,O_RDONLY))<0)
{
puts("cannot open file to calculate rejection graph");
}
/* do (linear) interpolation here! */
i=0;
+ a=0;
while(i<d3_l->max_z)
{
- a=0;
-
- // WEITER HIER !!
-
+ /* graph[0] is 0! */
+ j=i;
+ i++;
+ while(flag[i]==0&&i<d3_l->max_z) i++;
+ for(k=j+1;k<i;k++) graph[k]=(int)((k-j)*((int)graph[i]-(int)graph[j])/(i-j))+graph[j];
+ if(graph[i]>max) max=graph[i];
}
- printf("%s graph:\n",file);
- for(i=0;i<d3_l->max_z;i++) printf("%02d | %d\n",i,graph[i]);
+ free(flag);
- return 1;
+ // printf("debug: (interpolated c profile)\n");
+ // for(i=0;i<d3_l->max_z;i++) printf("%d %d\n",i,graph[i]);
+
+ return max;
}
int main(int argc,char **argv)
#endif
u32 *c_profile;
u32 *n_e_loss;
+ u32 ne_max,ip_max;
d3_l.max_x=X;
d3_l.max_y=Y;
convert=0;
strcpy(r_file,"");
mode=0;
+ ne_max=0;
+ ip_max=0;
for(i=1;i<argc;i++)
{
puts("failed allocating memory for nuclear energy loss graph");
return -1;
}
- if(get_reject_graph(&my_info,&d3_l,p_file,c_profile)!=1)
- {
- puts("failed to get reject graph");
- return -1;
- }
+ ip_max=get_reject_graph(&my_info,&d3_l,p_file,c_profile);
- /* break here for testing ... */
- return 23;
+#ifdef DEBUG_RAND
+ while(1)
+ {
+ printf("%d\n",get_rand_reject(d3_l.max_z,ip_max,c_profile));
+ }
+#endif
i=(c_step?c_step:0);
while((i<my_info.steps) && (quit==0) && (escape==0))
x_c=get_rand(d3_l.max_x);
y_c=get_rand(d3_l.max_y);
z_c=get_rand_lgp(d3_l.max_z,my_info.a_el,my_info.b_el);
+ // printf("%d\n",z_c);
process_cell(&d3_l,x_c,y_c,z_c,&my_info);
}
- distrib_c(&d3_l,&my_info,i,c_ratio);
+ distrib_c(&d3_l,&my_info,i,c_ratio,ip_max,c_profile);
#ifdef USE_DFB_API
if(i%refresh==0)
{