Index: /trunk/Mars/msimreflector/MOptics.cc
===================================================================
--- /trunk/Mars/msimreflector/MOptics.cc	(revision 19636)
+++ /trunk/Mars/msimreflector/MOptics.cc	(revision 19637)
@@ -168,5 +168,5 @@
         return false;
 
-    u.fRealPart *= n1/n2;
+    u.fRealPart *= n2/n1;
     return true;
 }
@@ -258,5 +258,11 @@
 // n1 is always the medium where the photon comes from.
 //
-// Uses Fresnel's equation for calculating reflection
+// Uses Fresnel's equation for calculating reflection. Total internal
+// reflection above the critical angle will always take place. Fresnel
+// reflection will only be calculated if 'fresnel' is set to true (default).
+// For Fresnel reflection, a random number is produced according to the
+// calculated reflectivity to decide whether the ray is reflected or
+// refracted.
+//
 //
 // The direction of the normal vector does not matter, it is automatically
@@ -276,5 +282,5 @@
 //  4 refraction applied
 //
-int MOptics::ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2)
+int MOptics::ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2, bool fresnel)
 {
     if (n1==n2)
@@ -309,5 +315,5 @@
     const double reflectivity = (Rt*Rt + Rp*Rp)/2;
 
-    if (gRandom->Uniform()<reflectivity)
+    if (fresnel && gRandom->Uniform()<reflectivity)
     {
         // ----- Case of reflection ----
@@ -327,13 +333,13 @@
     const int rc = ApplyTransitionFast(u.fVectorPart, n, n1, n2);
     if (rc>=3)
-        u.fRealPart *= n1/n2;
+        u.fRealPart *= n2/n1;
     return rc;
 }
 
-int MOptics::ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2)
-{
-    const int rc = ApplyTransition(u.fVectorPart, n, n1, n2);
+int MOptics::ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2, bool fresnel)
+{
+    const int rc = ApplyTransition(u.fVectorPart, n, n1, n2, fresnel);
     if (rc>=3)
-        u.fRealPart *= n1/n2;
+        u.fRealPart *= n2/n1;
     return rc;
 }
Index: /trunk/Mars/msimreflector/MOptics.h
===================================================================
--- /trunk/Mars/msimreflector/MOptics.h	(revision 19636)
+++ /trunk/Mars/msimreflector/MOptics.h	(revision 19637)
@@ -35,6 +35,6 @@
     static int ApplyTransitionFast(MQuaternion &u, const TVector3 &n, double n1, double n2);
 
-    static int ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2);
-    static int ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2);
+    static int ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2, bool fresnel=true);
+    static int ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2, bool fresnel=true);
 
     ClassDef(MOptics, 1) // Base class for optics (reflector, lens)
