Index: trunk/MagicSoft/Simulation/Detector/Reflector/reflector.cxx
===================================================================
--- trunk/MagicSoft/Simulation/Detector/Reflector/reflector.cxx	(revision 336)
+++ trunk/MagicSoft/Simulation/Detector/Reflector/reflector.cxx	(revision 337)
@@ -20,7 +20,7 @@
 //
 // $RCSfile: reflector.cxx,v $
-// $Revision: 1.3 $
-// $Author: harald $ 
-// $Date: 2000-01-03 12:41:26 $
+// $Revision: 1.4 $
+// $Author: blanch $ 
+// $Date: 2000-01-14 16:30:39 $
 //
 ////////////////////////////////////////////////////////////////////////
@@ -3496,12 +3496,14 @@
   float sin_iphi, cos_iphi;
   float iphi;
-
-  // for the moment, we only simulate an uniform distribution,
-  // since our theta distribution in the generation of events is
-  // already uniform for hadrons, which are the main targets for
-  // using this option
-
-  it = RandomNumber * range;
+  float range_aux;
+  int i;
+
+  //Random position of the CT. Theta distribution 
+  //follows sin(theta) and ohi distribution is flat
+
+  range_aux=1.0-sin(M_PI/2-range);
+  Nit = RandomNumber * range_aux;
   ip = RandomNumber * 2.0 * M_PI;
+  it = M_PI/2-asin((1.0-Nit));
 
   sin_theta = sin(theta);
@@ -3511,10 +3513,12 @@
   *newtheta = acos( cos_newtheta );
   sin_newtheta = sin( *newtheta );
-
-  sin_iphi = sin(it)*sin(ip) / sin_newtheta;
-  cos_iphi = (( cos(it) - cos_newtheta * cos_theta ) /
-              ( sin_newtheta * sin_theta ));
-
-  iphi = atan2( sin_iphi, cos_iphi );
+  
+  if(theta!=0){
+    sin_iphi = sin(it)*sin(ip)/sin_newtheta;
+    cos_iphi = ((cos(it)-cos_newtheta*cos_theta)/(sin_newtheta*sin_theta));
+    
+    iphi = atan2( sin_iphi, cos_iphi );
+  }
+  else iphi=ip;
 
   *newphi = phi + iphi;
@@ -3531,4 +3535,16 @@
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.4 2000/01/04 blanch
+// Sin(theta) distribution has been implemented in the
+// get_new_ct_pointing subroutine.
+// 
+// Revision 1.3  2000/01/03 12:41:26  harald
+// There was a small mistake with +/- signs in the prevois versions. This
+// line was founded by Jose Carlos. His remark is following:
+//
+// Look for the comment I include here in this block: you will see that
+// now the following expression has a +- sign, where before it was only
+// + (or -, I don't remember, but only one)
+//
 // Revision 1.2  1999/11/01 11:05:54  harald
 // Small changes to comile the reflector program under linux.
