Index: /trunk/WuerzburgSoft/Thomas/mphys/Changelog
===================================================================
--- /trunk/WuerzburgSoft/Thomas/mphys/Changelog	(revision 1358)
+++ /trunk/WuerzburgSoft/Thomas/mphys/Changelog	(revision 1359)
@@ -5,4 +5,5 @@
      - added a primitive theta dependancy to DoInvCompton
      - added DrawInteractionLength
+     - changed algorithm in ZofR and RofZ
      
    * MParticle.[h,cc]:
Index: /trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc
===================================================================
--- /trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc	(revision 1358)
+++ /trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc	(revision 1359)
@@ -29,4 +29,16 @@
 Double_t MParticle::ZofR(Double_t *x, Double_t *k)
 {
+    /*
+     const Double_t c  = 299792458;        // [m/s]
+     const Double_t H0 = 50./3.0857e19;    // [km / Mpc s] --> [s^-1]
+
+     const Double_t ly = 3600.*24.*365.*c; // [m/ly]
+     const Double_t pc = 1./3.258;         // [pc/ly]
+     const Double_t r  = x[0] /pc*ly*1e3;  // [m]
+
+     const Double_t R = r*H0/c;            // [1]
+
+     return (R+1+sqrt(R*2+1))/2 - 1;
+    */
     const Double_t c  = 299792458;        // [m/s]
     const Double_t H0 = 50./3.0857e19;    // [km / Mpc s] --> [s^-1]
@@ -36,22 +48,36 @@
     const Double_t r  = x[0] /pc*ly*1e3;  // [m]
 
-    const Double_t R = r*H0/c;            // [1]
+    const Double_t R = 1./(1-r*H0/c/2);   // [1]
 
-    return (R+1+sqrt(R*2+1))/2 - 1;
+
+    return R*R - 1;
 }
 
 Double_t MParticle::RofZ(Double_t *x, Double_t *k)
 {
-    Double_t z1 = x[0] + 1;
+    /*
+     Double_t z1 = x[0] + 1;
 
-    const Double_t c  = 299792458;                 // [m/s]
-    const Double_t H0 = 50./3.0857e19;             // [km / Mpc s] --> [s^-1]
+     const Double_t c  = 299792458;                 // [m/s]
+     const Double_t H0 = 50./3.0857e19;             // [km / Mpc s] --> [s^-1]
 
-    const Double_t ly = 3600.*24.*365.*c;          // [m/ly]
-    const Double_t pc = 1./3.258;                  // [pc/ly]
+     const Double_t ly = 3600.*24.*365.*c;          // [m/ly]
+     const Double_t pc = 1./3.258;                  // [pc/ly]
 
-    const Double_t R = c/H0 * 2 * (z1 - sqrt(z1)); // [m]
+     const Double_t R = c/H0 * 2 * (z1 - sqrt(z1)); // [m]
 
-    return  R * pc/ly/1e3;                   // [kpc]
+     return  R * pc/ly/1e3;                   // [kpc]
+     */
+     Double_t z1 = x[0] + 1;
+
+     const Double_t c  = 299792458;                 // [m/s]
+     const Double_t H0 = 50./3.0857e19;             // [km / Mpc s] --> [s^-1]
+
+     const Double_t ly = 3600.*24.*365.*c;          // [m/ly]
+     const Double_t pc = 1./3.258;                  // [pc/ly]
+
+     const Double_t R = c/H0 * 2 * (1 - 1./sqrt(z1)); // [m]
+
+     return  R * pc/ly/1e3;                   // [kpc]
 }
 
