[yoda-svn] yoda: 3 new changesets

YODA Mercurial yoda at projects.hepforge.org
Wed Nov 18 00:30:02 GMT 2015


details:   https://yoda.hepforge.org/hg/yoda/rev/8d434c75ee38
branches:  
changeset: 1173:8d434c75ee38
user:      Andy Buckley <andy at insectnation.org>
date:      Mon Nov 16 22:28:04 2015 +0000
description:
Fix bug in toTH2D(const Histo2D& h) as used with ROOT6. Thanks to Tim Martin.  Add toScatter3D ROOT->YODA, and toNew* YODA->ROOT conversion routines.

details:   https://yoda.hepforge.org/hg/yoda/rev/d160aca74252
branches:  
changeset: 1174:d160aca74252
user:      Andy Buckley <andy at insectnation.org>
date:      Tue Nov 17 23:36:12 2015 +0000
description:
Map new to-ROOT functions, including TGraph ones, to Python. PLus some bugfixing in recent ROOTCnv commits.

details:   https://yoda.hepforge.org/hg/yoda/rev/a8e2b4ee930a
branches:  
changeset: 1175:a8e2b4ee930a
user:      Andy Buckley <andy at insectnation.org>
date:      Wed Nov 18 00:26:39 2015 +0000
description:
Map ROOT-to-YODA (as scatter) functions to Python. Phew.

diffs (truncated from 475 to 50 lines):

--- a/ChangeLog	Thu Nov 05 12:34:16 2015 +0000
+++ b/ChangeLog	Wed Nov 18 00:26:39 2015 +0000
@@ -1,3 +1,17 @@
+2015-11-17  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Map ROOT-to-YODA (as scatter) functions to Python. Phew.
+
+	* Map new to-ROOT functions, including TGraph ones, to Python.
+
+2015-11-16  Andy Buckley  <andy.buckley at cern.ch>
+
+	* ROOTCnv.h: Add toScatter3D ROOT->YODA, and toNew* YODA->ROOT
+	conversion routines.
+
+	* ROOTCnv.h: Fix bug in toTH2D(const Histo2D& h) as used with
+	ROOT6. Thanks to Tim Martin.
+
 2015-11-05  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Fix double-dealloc in new Point class hierarchy Python mapping.
--- a/include/YODA/ROOTCnv.h	Thu Nov 05 12:34:16 2015 +0000
+++ b/include/YODA/ROOTCnv.h	Wed Nov 18 00:26:39 2015 +0000
@@ -68,19 +68,24 @@
   /////////////////////
 
 
-  /// Convert a ROOT 1D histogram (including TProfile) to a YODA Scatter2D
+  /// Convert a ROOT 1D histogram (excluding TProfile) to a YODA Scatter2D
   ///
-  /// @todo Add a bool flag for whether or not to divide y vals/errs by bin width.
-  inline Scatter2D toScatter2D(const TH1& th1) {
+  /// The optional bool arg specifies whether or not to divide y vals/errs by bin width.
+  inline Scatter2D toScatter2D(const TH1& th1, bool scalebywidth=true) {
     Scatter2D rtn;
-    for (int i = 1; i <= th1.GetNbinsX(); ++i) {
-      const double x = th1.GetBinCenter(i);
-      const double exminus = x - th1.GetBinLowEdge(i);
-      const double explus = th1.GetBinLowEdge(i+1) - x;
-      const double width = exminus + explus;
-      rtn.addPoint(x, th1.GetBinContent(i)/width,
+    for (int ix = 1; ix <= th1.GetNbinsX(); ++ix) {
+      const TAxis& axx = *th1.GetXaxis();
+      const double x = axx.GetBinCenter(ix);
+      const double exminus = x - axx.GetBinLowEdge(ix);
+      const double explus = axx.GetBinUpEdge(ix) - x;
+      const double xwidth = axx.GetBinWidth(ix);
+      //
+      const double val = th1.GetBinContent(ix) / (scalebywidth ? xwidth : 1);
+      const double evalminus = th1.GetBinErrorLow(ix) / (scalebywidth ? xwidth : 1);
+      const double evalplus = th1.GetBinErrorUp(ix) / (scalebywidth ? xwidth : 1);


More information about the yoda-svn mailing list