[Rivet-svn] r3977 - in trunk: . include/Rivet/Math src/Analyses

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Sun Nov 11 15:31:07 GMT 2012


Author: buckley
Date: Sun Nov 11 15:31:07 2012
New Revision: 3977

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). The angle check allows a clean-up of some workaround code in MC_VH2BB.

Modified:
   trunk/ChangeLog
   trunk/include/Rivet/Math/Vector3.hh
   trunk/include/Rivet/Math/Vector4.hh
   trunk/src/Analyses/MC_VH2BB.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Tue Oct 30 10:10:29 2012	(r3976)
+++ trunk/ChangeLog	Sun Nov 11 15:31:07 2012	(r3977)
@@ -1,3 +1,11 @@
+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). The angle check allows a clean-up of some
+	workaround code in MC_VH2BB.
+
 2012-07-17  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Cleanup and multiple fixes in CMS_2011_S9120041

Modified: trunk/include/Rivet/Math/Vector3.hh
==============================================================================
--- trunk/include/Rivet/Math/Vector3.hh	Tue Oct 30 10:10:29 2012	(r3976)
+++ trunk/include/Rivet/Math/Vector3.hh	Sun Nov 11 15:31:07 2012	(r3977)
@@ -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: trunk/include/Rivet/Math/Vector4.hh
==============================================================================
--- trunk/include/Rivet/Math/Vector4.hh	Tue Oct 30 10:10:29 2012	(r3976)
+++ trunk/include/Rivet/Math/Vector4.hh	Sun Nov 11 15:31:07 2012	(r3977)
@@ -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).

Modified: trunk/src/Analyses/MC_VH2BB.cc
==============================================================================
--- trunk/src/Analyses/MC_VH2BB.cc	Tue Oct 30 10:10:29 2012	(r3976)
+++ trunk/src/Analyses/MC_VH2BB.cc	Sun Nov 11 15:31:07 2012	(r3977)
@@ -53,15 +53,7 @@
       double angle1 = b1BOOSTED.angle(virtualVBMomentumBOOSTED);
       double angle2 = b2BOOSTED.angle(virtualVBMomentumBOOSTED);
 
-      double cosbb = b1BOOSTED.vector3().unit().dot(b2BOOSTED.vector3().unit());
-      double test = 1.+cosbb;
-      double anglebb;
-      if(test<0.&&test>-1e-10) {
-        anglebb = M_PI;
-      }
-      else {
-        anglebb = acos(cosbb);
-      }
+      double anglebb = b1BOOSTED.angle(b2BOOSTED);
 
       vector<double> toReturn;
       toReturn.push_back(angle1 < angle2 ? angle1 : angle2);


More information about the Rivet-svn mailing list