[Rivet-svn] rivet: Add deltaR2 functions for squared distances

Rivet Mercurial rivet at projects.hepforge.org
Tue Sep 26 00:00:02 BST 2017


details:   https://rivet.hepforge.org/hg/rivet/rev/2b8234c72987
branches:  
changeset: 6040:2b8234c72987
user:      Andy Buckley <andy at insectnation.org>
date:      Mon Sep 25 23:27:21 2017 +0100
description:
Add deltaR2 functions for squared distances

diffs (truncated from 432 to 50 lines):

--- a/ChangeLog	Sun Sep 10 11:55:10 2017 +0100
+++ b/ChangeLog	Mon Sep 25 23:27:21 2017 +0100
@@ -1,3 +1,7 @@
+2017-09-25  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Add deltaR2 functions for squared distances.
+
 2017-09-10  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Add white backgrounds to make-plots main and ratio plot frames.
--- a/analyses/pluginMC/MC_ZINC.cc	Sun Sep 10 11:55:10 2017 +0100
+++ b/analyses/pluginMC/MC_ZINC.cc	Mon Sep 25 23:27:21 2017 +0100
@@ -43,9 +43,7 @@
     /// Do the analysis
     void analyze(const Event & e) {
       const ZFinder& zfinder = apply<ZFinder>(e, "ZFinder");
-      if (zfinder.bosons().size()!=1) {
-        vetoEvent;
-      }
+      if (zfinder.bosons().size() != 1) vetoEvent;
       const double weight = e.weight();
 
       FourMomentum zmom(zfinder.bosons()[0].momentum());
@@ -54,7 +52,7 @@
       _h_Z_pT_peak->fill(zmom.pT()/GeV, weight);
       _h_Z_y->fill(zmom.rapidity(), weight);
       _h_Z_phi->fill(zmom.phi(), weight);
-      foreach (const Particle& l, zfinder.constituents()) {
+      for (const Particle& l : zfinder.constituents()) {
         _h_lepton_pT->fill(l.pT()/GeV, weight);
         _h_lepton_eta->fill(l.eta(), weight);
       }
--- a/include/Rivet/Math/MathUtils.hh	Sun Sep 10 11:55:10 2017 +0100
+++ b/include/Rivet/Math/MathUtils.hh	Mon Sep 25 23:27:21 2017 +0100
@@ -559,11 +559,17 @@
     return fabs(y1 - y2);
   }
 
+  /// Calculate the squared distance between two points in 2D rapidity-azimuthal
+  /// ("\f$ \eta-\phi \f$") space. The phi values are given in radians.
+  inline double deltaR2(double rap1, double phi1, double rap2, double phi2) {
+    const double dphi = deltaPhi(phi1, phi2);
+    return sqr(rap1-rap2) + sqr(dphi);
+  }
+
   /// Calculate the distance between two points in 2D rapidity-azimuthal
   /// ("\f$ \eta-\phi \f$") space. The phi values are given in radians.
   inline double deltaR(double rap1, double phi1, double rap2, double phi2) {
-    const double dphi = deltaPhi(phi1, phi2);
-    return sqrt( sqr(rap1-rap2) + sqr(dphi) );


More information about the Rivet-svn mailing list