[Rivet-svn] r3978 - in branches/2012-06-aidarivet: . include/Rivet/Math

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Sun Nov 11 15:32:02 GMT 2012


Author: buckley
Date: Sun Nov 11 15:32:02 2012
New Revision: 3978

Log:
Various numerical fixes to Vector3::angle and changing the 4 vector mass treatment to permit spacelike virtualities (in some cases even the fuzzy isZero assert check was being violated).

Modified:
   branches/2012-06-aidarivet/ChangeLog
   branches/2012-06-aidarivet/include/Rivet/Math/Vector3.hh
   branches/2012-06-aidarivet/include/Rivet/Math/Vector4.hh

Modified: branches/2012-06-aidarivet/ChangeLog
==============================================================================
--- branches/2012-06-aidarivet/ChangeLog	Sun Nov 11 15:31:07 2012	(r3977)
+++ branches/2012-06-aidarivet/ChangeLog	Sun Nov 11 15:32:02 2012	(r3978)
@@ -1,3 +1,10 @@
+2012-11-11  Andy Buckley  <andy.buckley at cern.ch>
+
+	* include/Math/: Various numerical fixes to Vector3::angle and
+	changing the 4 vector mass treatment to permit spacelike
+	virtualities (in some cases even the fuzzy isZero assert check was
+	being violated).
+
 2012-10-15  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Added CMS_2012_I1107658 analysis

Modified: branches/2012-06-aidarivet/include/Rivet/Math/Vector3.hh
==============================================================================
--- branches/2012-06-aidarivet/include/Rivet/Math/Vector3.hh	Sun Nov 11 15:31:07 2012	(r3977)
+++ branches/2012-06-aidarivet/include/Rivet/Math/Vector3.hh	Sun Nov 11 15:32:02 2012	(r3978)
@@ -79,9 +79,10 @@
     }
 
     double angle(const Vector3& v) const {
-      double localDotOther = unit().dot(v.unit());
-      if(Rivet::isZero(localDotOther - 1.0)) return 0.0;
-      return acos( localDotOther );
+      const double localDotOther = unit().dot(v.unit());
+      if (fuzzyEquals(localDotOther, 1.0)) return 0.0;
+      else if (fuzzyEquals(localDotOther, -1.0)) return M_PI;
+      return acos(localDotOther);
     }
 
     Vector3 unit() const {

Modified: branches/2012-06-aidarivet/include/Rivet/Math/Vector4.hh
==============================================================================
--- branches/2012-06-aidarivet/include/Rivet/Math/Vector4.hh	Sun Nov 11 15:31:07 2012	(r3977)
+++ branches/2012-06-aidarivet/include/Rivet/Math/Vector4.hh	Sun Nov 11 15:32:02 2012	(r3978)
@@ -375,14 +375,17 @@
     /// Set z-component of momentum \f$ p_z \f$.
     FourMomentum& setPz(double pz) { setZ(pz); return *this; }
 
-    /// Get the mass \f$ m = \sqrt{E^2 - p^2} \f$ (the Lorentz self-invariant).
+    /// @brief Get the mass \f$ m = \sqrt{E^2 - p^2} \f$ (the Lorentz self-invariant).
+    ///
+    /// For spacelike momenta, the mass will be -sqrt(|mass2|).
     double mass() const {
-      assert(Rivet::isZero(mass2()) || mass2() > 0);
-      if (Rivet::isZero(mass2())) {
-        return 0.0;
-      } else {
-        return sqrt(mass2());
-      }
+      // assert(Rivet::isZero(mass2()) || mass2() > 0);
+      // if (Rivet::isZero(mass2())) {
+      //   return 0.0;
+      // } else {
+      //   return sqrt(mass2());
+      // }
+      return sign(mass2()) * sqrt(fabs(mass2()));
     }
 
     /// Get the squared mass \f$ m^2 = E^2 - p^2 \f$ (the Lorentz self-invariant).


More information about the Rivet-svn mailing list