Index: /trunk/MagicSoft/Simulation/Detector/ReflectorII/ph2cph.c
===================================================================
--- /trunk/MagicSoft/Simulation/Detector/ReflectorII/ph2cph.c	(revision 868)
+++ /trunk/MagicSoft/Simulation/Detector/ReflectorII/ph2cph.c	(revision 869)
@@ -122,4 +122,22 @@
   h    = ph->h; 
 
+  /* CBC */
+  Debug("@0 x r %f %f %f %f %f %f\n", x[0], x[1], x[2], 
+	                              r[0], r[1], r[2]);
+
+  /* 
+  x[0] = 125.0; 
+  x[1] = 125.0; 
+  x[2] = 0.0;  */                          /* ground => obs. level =>  z=0   */
+
+  /*  get director cosines x,y on ground */  
+
+  /*
+  r[0] = 0.0;     
+  r[1] = 0.0;    
+  r[2] = 1.0;    
+  */
+  /* CBC */
+
   /*!@'
 
@@ -140,5 +158,5 @@
   /*  find data point to be used in Lagrange interpolation (-> k) */ 
 
-  FindLagrange(Reflectivity,k,wl,nReflectivity);
+  FindLagrange(Reflectivity,k,wl);
           
   /*  if random > reflectivity then goes to the TOP of the loop again */
@@ -160,5 +178,5 @@
   -- */ 
 
-  Debug("@1 %f %f %f %f %f %f\n", x[0], x[1], x[2], r[0], r[1], r[2]);
+  Debug("@1 x r %f %f %f %f %f %f\n", x[0], x[1], x[2], r[0], r[1], r[2]);
  
   /*  change to the system of the CT */ 
@@ -166,4 +184,10 @@
   applyMxV( OmegaCT, x, xCT );
   applyMxV( OmegaCT, r, rCT );        
+
+  /* CBC */
+  Debug("@2 xCT rCT %f %f %f %f %f %f\n", xCT[0], xCT[1], xCT[2], 
+	rCT[0], rCT[1], rCT[2]);
+  /* CBC */
+
 
   /* 
@@ -246,4 +270,8 @@
   xcut[1] = xCT[1] + rCT[1]/rCT[2]*(xcut[2]-xCT[2]);
 
+  /* CBC */
+  Debug("@3 xcut %f %f\n", xcut[0], xcut[1]);
+  /* CBC */ 
+
   /*  convert to Curvilinear distance over the parabolic dish */ 
           
@@ -251,4 +279,8 @@
   sy = Lin2Curv( xcut[1] );
           
+  /* CBC */
+  Debug("@4 sx sy %f %f\n", sx, sy);
+  /* CBC */ 
+
   /*  is it outside the dish? */ 
           
@@ -289,4 +321,9 @@
   }
             
+  /* CBC */
+  Debug("@5 theta phi %f %f\n", ct_data[i_mirror].theta, 
+	                        ct_data[i_mirror].phi);
+  /* CBC */ 
+
   /*  calculate matrices for the mirror */ 
         
@@ -298,4 +335,10 @@
   /* change to the system of the mirror */
         
+  /* CBC */
+  Debug("@6 mirror %f %f %f\n",ct_data[i_mirror].x,
+	                    ct_data[i_mirror].y,
+	                    ct_data[i_mirror].z);
+  /* CBC */ 
+
   /* first translation... */
 
@@ -303,9 +346,19 @@
   xmm[1] = xCT[1] - ct_data[i_mirror].y;
   xmm[2] = xCT[2] - ct_data[i_mirror].z;
-        
+ 
+
+  /* CBC */
+  Debug("@7 xmm %f %f %f\n", xmm[0], xmm[1], xmm[2]);
+  /* CBC */ 
+       
   /* ...then rotation */ 
 
   applyMxV( Omega, xmm, xm );
   applyMxV( Omega, rCT, rm );
+
+  /* CBC */
+  Debug("@8 xm rm %f %f %f %f %f %f\n", xm[0], xm[1], xm[2], 
+	                          rm[0], rm[1], rm[2]);
+  /* CBC */ 
 
   /* 
@@ -318,4 +371,8 @@
   rm[1] /= rnorm;
   rm[2] /= rnorm;
+
+  /* CBC */
+  Debug("@9 rm-norm %f %f %f\n", rm[0], rm[1], rm[2]);
+  /* CBC */ 
 
   /* 
@@ -400,4 +457,8 @@
   xcut[1] = xm[1] + rm[1]/rm[2]*(xcut[2]-xm[2]);
 
+  /* CBC */
+  Debug("@10 xcut %f %f %f\n", xcut[0], xcut[1], xcut[2]);
+  /* CBC */ 
+
   /* 
   ++
@@ -424,8 +485,16 @@
   rnor[2] = (float) (2.0*(xcut[2] - 2.0*ct_Focal[i_mirror]));
 
+  /* CBC */
+  Debug("@11 rnor %f %f %f\n", rnor[0], rnor[1], rnor[2]);
+  /* CBC */ 
+
   rnorm    = -NORM( rnor );
   rnor[0] /= rnorm;
   rnor[1] /= rnorm;
   rnor[2] /= rnorm;
+
+  /* CBC */
+  Debug("@12 rnor-norm %f %f %f\n", rnor[0], rnor[1], rnor[2]);
+  /* CBC */ 
 
   /* 
@@ -440,4 +509,8 @@
 
   calpha = (float) fabs(rnor[0]*rm[0] + rnor[1]*rm[1] + rnor[2]*rm[2]);
+
+  /* CBC */
+  Debug("@13 calpha %f\n", calpha);
+  /* CBC */ 
         
   /*  finally!!! we have the reflected trajectory of the photon */ 
@@ -446,4 +519,8 @@
   rrefl[1] = (float) (2.0*rnor[1]*calpha - rm[1]);
   rrefl[2] = (float) (2.0*rnor[2]*calpha - rm[2]);
+
+  /* CBC */
+  Debug("@14 rrefl %f %f %f\n", rrefl[0], rrefl[1], rrefl[2]);
+  /* CBC */ 
 
   rnorm     = NORM( rrefl );
@@ -452,4 +529,8 @@
   rrefl[2] /= rnorm;
 
+  /* CBC */
+  Debug("@15 rrefl-norm %f %f %f\n", rrefl[0], rrefl[1], rrefl[2]);
+  /* CBC */ 
+
   /*  let's go back to the coordinate system of the CT */ 
 
@@ -458,4 +539,9 @@
   applyMxV( OmegaI, xcut, xcutCT);
   applyMxV( OmegaI, rrefl, rreflCT);
+
+  /* CBC */
+  Debug("@16 xcutCT rreflCT %f %f %f %f %f %f\n", xcutCT[0], xcutCT[1], 
+	xcutCT[2], rreflCT[0], rreflCT[1], rreflCT[2]);
+  /* CBC */ 
 
   /*  ...then translation */ 
@@ -464,4 +550,8 @@
   xcutCT[1] += ct_data[i_mirror].y;
   xcutCT[2] += ct_data[i_mirror].z;
+
+  /* CBC */
+  Debug("@17 xcutCT %f %f %f\n", xcutCT[0], xcutCT[1], xcutCT[2]);
+  /* CBC */ 
  
   /*
@@ -475,4 +565,8 @@
   xcam[1] = xcutCT[1] + rreflCT[1]*t;
   xcam[2] = xcutCT[2] + rreflCT[2]*t;
+
+  /* CBC */
+  Debug("@18 xcam %f %f %f\n", xcam[0], xcam[1], xcam[2]);
+  /* CBC */ 
      
   /* 
@@ -486,4 +580,8 @@
   xcam[1] += AxisDeviation[1][i_mirror];
 
+  /* CBC */
+  Debug("@19 xcam-AD %f %f \n", xcam[0], xcam[1]);
+  /* CBC */ 
+
   /* 
   ++
@@ -500,4 +598,8 @@
   xcam[0] += (float) (NormalRandomNumbers[0] * ct_PSpread_mean);
   xcam[1] += (float) (NormalRandomNumbers[1] * ct_PSpread_mean);
+
+  /* CBC */
+  Debug("@20 xcam-SM %f %f \n", xcam[0], xcam[1]);
+  /* CBC */ 
 
   /*  check whether the photon goes out of the camera */ 
@@ -548,7 +650,8 @@
   /*  show it */ 
 
-  Debug("@2 %f %f %f %f %f %f %f %f %f\n"
-	"@3 %f %f %d %f %f %f %f\n"
-	"@4 %f %f %f %f\n",
+  Debug("@22 %f %f %f\n" 
+	"@23 %f %f %f %f %f %f\n"
+	"@24 %f %f %d %f %f %f %f\n"
+	"@25 %f %f %f %f\n\n",
 	xCT[0], xCT[1], xCT[2], rCT[0], rCT[1], rCT[2],
 	    xcut[0], xcut[1], xcut[2],
