Index: trunk/MagicSoft/Simulation/Detector/ReflectorII/reflector.c
===================================================================
--- trunk/MagicSoft/Simulation/Detector/ReflectorII/reflector.c	(revision 869)
+++ trunk/MagicSoft/Simulation/Detector/ReflectorII/reflector.c	(revision 870)
@@ -33,5 +33,4 @@
 static long writep = 0L;	/*  write ptr (on rflfile)	*/
 
-
 extern CerHeader *cheadp;	/*  var inited in header.c	*/
 extern RflHeader *rheadp;	/*  var inited in header.c	*/
@@ -43,4 +42,7 @@
 static int ProcessEvent(CerHeader *cheadp, FILE *cerfile, FILE *rflfile);
 
+FILE *chkf = NULL;     /**********************/
+long myloop;     /**********************/
+
 void main(void)
 {   long event = 0L;		/*  event counter	*/
@@ -48,4 +50,5 @@
     /*  Read init & geometry parms, init files and vars */
     init(NULL);
+    chkf = fopen("check", "w");     /**********************/
 
     /*	Processing loop	*/
@@ -61,4 +64,5 @@
     Log(RFLF_CLOSE_LOG);
     fclose(rflfile);
+    fclose(chkf);     /**********************/
 
     /*  Clean memory and exit  */
@@ -78,4 +82,5 @@
     extern void makeOmegaI(float theta, float phi);
 
+
     /*  Various counters: phs = absphs + refphs[0..3] + cphs  */
     long phs,		/*  Number of incoming photons	*/
@@ -134,6 +139,6 @@
 		    1.f - Photons[ph].u*Photons[ph].u
 			- Photons[ph].v*Photons[ph].v));
+
 	    /*	Check absorption  */
-
 	    if (absorption(wlen, Photons[ph].h, theta))
 		absphs++;
@@ -141,9 +146,15 @@
 	    /*	Check reflection  */
 	    else if (0 != (ref_type =
-			   ph2cph(&Photons[ph], &CPhotons[cphs]))) 
+			   ph2cph(&Photons[ph], &CPhotons[cphs])))
 		refphs[ref_type-1]++; 
-
 	    else    /*	Photon passed	*/
 	    {
+	    Debug("Ph %d\t%f\t%f\t%f\t%f\t%f\n",ph,
+		   Photons[ph].x,Photons[ph].y,
+		   Photons[ph].u,Photons[ph].v,theta);
+	    Debug("CPh %d\t%d\t%f\t%f\n\n",cphs,ph,CPhotons[cphs].x,
+		   CPhotons[cphs].y);
+
+
 		/*  Update first/last arrival times  */
 		if (first > CPhotons[cphs].t) first = CPhotons[cphs].t;
@@ -166,5 +177,5 @@
 
 		}   /*  if overflow  */
-	    }  /*  else (=Photon passed)  */
+	    }   /*  else (=Photon passed)  */
 	}   /*  end of loop inside datablock	*/
     }   /*  end of loop on datablocks		*/
@@ -191,4 +202,7 @@
 	rheadp->CPhotons     = (long) overflow * NR_OF_CPHOTONS + cphs;
 	fwrite(rheadp, sizeof(RflHeader), 1, rflfile);
+        for (myloop=0; myloop<sizeof(RflHeader)/4; myloop++)
+            fprintf(chkf, "%e ", *((float *)rheadp+myloop)); 
+        fputc('\n', chkf);
 
 	/*  If there was an overflow, append data from tempfile   */
@@ -252,6 +266,6 @@
 	    /*  Ok: set found at TRUE and exit loop  */
 	    if (strncmp(cheadp->EVTH, "EVTH", 4) == 0
-	     && first_Event <= cheadp->EvtNumber
-	     &&		       cheadp->EvtNumber <= last_Event
+	     && first_Event <= (long)cheadp->EvtNumber
+	     &&		       (long)cheadp->EvtNumber <= last_Event
 	     &&    low_Ecut <= cheadp->Etotal
 	     &&		       cheadp->Etotal <= high_Ecut)
