Index: trunk/MagicSoft/Simulation/Detector/Starfield/convertcorsika.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Starfield/convertcorsika.cxx	(revision 785)
+++ trunk/MagicSoft/Simulation/Detector/Starfield/convertcorsika.cxx	(revision 786)
@@ -10,8 +10,10 @@
 CORParticle cerphot;
 CORStatfile cerstat;
+float outbuf[273];
 
 int convertcorsika(int id, int photnum, photon phot[], float inttime_s, int verbose,char output_name[]){
 
   int i,filenum;
+  int lastblock;
   float x_cm, y_cm, u, v, lambda_nm, t_ns;
   char cor_dir[60];
@@ -39,11 +41,16 @@
   
   ofstream cerfile;
+  //FILE cerfilec;
   
   if(!cerfile) {
-    cerr<<"Cannot create cerenkov file.\n";
+     cerr<<"Cannot create cerenkov file.\n";
     exit(1);
-  }  
+    } 
   
   cerfile.open(cor_dir, ios::out);
+  /*if((cerfilec=fopen(cor_dir,"wb"))==NULL){
+    printf("C-style::Cannot create cerenkov file.\n");
+    exit(1);
+    }*/
   
   //____________________________________________________________________________________
@@ -63,8 +70,10 @@
 		0.0,
 		0.0);
-
+  strcpy(cerevth.EVTH, "RUNH");
 		
   cerevth.write(cerfile);
-		
+
+  strcpy(cerevth.EVTH, "EVTH");
+  cerevth.write(cerfile);
 		
   // Here we fill the information for each photon as a corsika particle. 
@@ -72,5 +81,5 @@
   // u cosine director, v cosine director, time since first interaction (ns), 
   // height (cm) of first interaction.		
-
+  //photnum=0;
   for(i=0;i<photnum;i++){  
     
@@ -78,9 +87,10 @@
     x_cm = phot[i].x_m * 100.0;
     y_cm = phot[i].y_m * 100.0;
+ 
     u = phot[i].u;
     v = phot[i].v;  
     t_ns = phot[i].arrtime_sec * 1e9;
 
-    cerphot.fill(lambda_nm,
+    /*cerphot.fill(lambda_nm,
 		 x_cm,
 		 y_cm,
@@ -89,11 +99,27 @@
 		 t_ns,
 		 1.e7); 
-	
+    */
+    //64.523102 796.339600,0.058999,0.330647
+    cerphot.fill(lambda_nm,
+		 64.523102,
+		 796.339600,
+		 0.058999,
+		 0.330647,
+		 t_ns,
+		 1.e7);
+     
     cerphot.write(cerfile);
   }
-  
+  lastblock=39-photnum%39;
+
+  for(i=0;i<lastblock;i++){
   cerphot.fill(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
   cerphot.write(cerfile);  
-  
+  }
+  strcpy(cerevth.EVTH, "EVTE");
+  cerevth.write(cerfile);
+  strcpy(cerevth.EVTH, "RUNE");
+  cerevth.write(cerfile);
+
   cerfile.close();  
   
