reimplemented the ratio amount
[physik/nlsop.git] / parse_trim_collision.c
index 5469bfa..743a711 100644 (file)
@@ -17,7 +17,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#define MAXION 5000
+#define MAXION 8300
 #define MAXZ 233
 
 typedef struct s_z {
@@ -30,12 +30,13 @@ int main(int argc,char **argv) {
 
        int fd,ion,i,j;
        int z,skipped;
+       int avg1,avg2;
        double en;
        double max_e;
        int max_chfi,max_th;
        t_z Z[MAXZ];
        unsigned char hit[MAXZ];
-       char buf[256],*p,value[6],value2[10];
+       char buf[256],*p,value[6],value2[11];
 
        i=0;
 
@@ -49,6 +50,8 @@ int main(int argc,char **argv) {
 
        ion=1;
        skipped=0;
+       avg1=0;
+       avg2=0;
        for(i=0;i<MAXZ;i++) {
                Z[i].cell_hits_from_ions=0;
                Z[i].total_hits=0;
@@ -73,12 +76,19 @@ int main(int argc,char **argv) {
                                        if(Z[i].energy>max_e) max_e=Z[i].energy;
                                        if(Z[i].total_hits>max_th) max_th=Z[i].total_hits;
                                        if(Z[i].cell_hits_from_ions>max_chfi) max_chfi=Z[i].cell_hits_from_ions;
+                                       avg1+=Z[i].total_hits;
+                                       avg2+=Z[i].cell_hits_from_ions;
                                }
                                for(i=0;i<MAXZ;i++) 
-                                       printf("%d %f %f %f\n",i*3,1.0*Z[i].total_hits/max_th,
-                                                               Z[i].energy/max_e,
-                                                               1.0*Z[i].cell_hits_from_ions/max_chfi);
+                                       printf("%d %f %f %f\n",i*3,
+                                              1.0*Z[i].total_hits/max_th,
+                                              Z[i].energy/max_e,
+                                       1.0*Z[i].cell_hits_from_ions/max_chfi);
+                                       // printf("%d %f\n",i*3,1.0*Z[i].total_hits/max_th); // hits
+                                       // printf("%d %f\n",i*3,1.0*Z[i].energy/max_e); // energy
+                                       // printf("%d %f\n",i*3,1.0*Z[i].cell_hits_from_ions/max_chfi); // hits/ion
                                printf("skipped = %d\n",skipped);
+                               printf("average hits per ion %d / %d\n",avg1/ion,avg2/ion);
                                return 1;
                        }
                        if(buf[i]=='\n') break;
@@ -86,7 +96,7 @@ int main(int argc,char **argv) {
                }
 
                /* parse line */
-               if((buf[0]=='³')&&(buf[1]!='=')) {
+               if((buf[0]=='³')&&(buf[1]!='=')&&(buf[1]!=' ')) {
                        p=strtok(buf,"³");
                        value[0]=p[0];
                        value[1]=p[1];
@@ -121,9 +131,9 @@ int main(int argc,char **argv) {
                        z=(int)(atof(value2)/30.);
                        if(z>232) skipped+=1;
                        else {
-                               Z[z].energy+=en;
-                               Z[z].total_hits+=1;
-                               hit[z]=1;
+                               //Z[z].energy+=en;
+                               //Z[z].total_hits+=1;
+                               // hit[z]=1;
                        }
                        if(ion!=atoi(value)) {
                                /* new ion */
@@ -131,12 +141,41 @@ int main(int argc,char **argv) {
                                memset(hit,0,MAXZ);
                                ion=atoi(value);
                        }
-                       // printf("%d %d %f %d\n",z*3,Z[z].total_hits,
-                       //      Z[z].energy,Z[z].cell_hits_from_ions);
-                       // return 0;
                }
-
-
+               if((buf[0]=='Û')&&(buf[1]==' ')) {
+                       value2[0]=buf[25];
+                       value2[1]=buf[26];
+                       value2[2]=buf[27];
+                       value2[3]=buf[28];
+                       value2[4]='.';
+                       value2[5]=buf[30];
+                       value2[6]=buf[31];
+                       value2[7]=buf[32];
+                       value2[8]=buf[33];
+                       value2[9]='\0';
+                       z=(int)(atof(value2)/30.);
+                       value2[0]=buf[14];
+                       value2[1]=buf[15];
+                       value2[2]=buf[16];
+                       value2[3]=buf[17];
+                       value2[4]=buf[18];
+                       value2[5]='.';
+                       value2[6]=buf[20];
+                       value2[7]=buf[21];
+                       value2[8]=buf[22];
+                       value2[9]=buf[23];
+                       value2[10]='\0';
+                       en=atof(value2);
+                       if(z>232) skipped+=1;
+                       else {
+                               // energy > displacement energy
+                               if(en>=10) {
+                                       Z[z].energy+=en;
+                                       Z[z].total_hits+=1;
+                                       hit[z]=1;
+                               }
+                       }
+               }
        }
        return 0;
 }