[HepData-svn] r1354 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Jun 4 18:46:48 BST 2010


Author: buckley
Date: Fri Jun  4 18:46:57 2010
New Revision: 1354

Log:
Fixing problem in alternative formattings where the y axis has fewer points than the x axis has bins

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Wed May 12 15:17:03 2010	(r1353)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Fri Jun  4 18:46:57 2010	(r1354)
@@ -75,7 +75,9 @@
                     s.append("    <dataPoint>\n");
                     StringTemplate xtag = new StringTemplate("<measurement value=\"$val$\" errorPlus=\"$dplus$\" errorMinus=\"$dminus$\"/>");
                     Bin b = x.getBin(r);
-                    if (b != null) {
+                    Point p = y.getPoint(r);
+                    if (b != null && p != null) {
+
                         Double xval = b.getFocus();
                         Double dxminus = b.getDMinus();
                         Double dxplus = b.getDPlus();
@@ -85,7 +87,6 @@
                             dxplus = 0.5;
                         }
 
-
                         // Guesstimate bin widths by hand if needed
                         if (b.getWidth() == 0) {
                             // If there are several bins, make the internal
@@ -124,11 +125,8 @@
                         xtag.setAttribute("dplus", dxplus);
                         xtag.setAttribute("dminus", dxminus);
                         s.append("      " + xtag.toString() + '\n');
-                    }
 
-                    StringTemplate ytag = new StringTemplate("<measurement value=\"$val$\" errorPlus=\"$dplus$\" errorMinus=\"$dminus$\"/>");
-                    Point p = y.getPoint(r);
-                    if (p != null) {
+                        StringTemplate ytag = new StringTemplate("<measurement value=\"$val$\" errorPlus=\"$dplus$\" errorMinus=\"$dminus$\"/>");
                         Double dyminus = p.getQuadCombinedMinusError();
                         Double dyplus = p.getQuadCombinedPlusError();
                         Double yval = p.getValue();

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java	Wed May 12 15:17:03 2010	(r1353)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PyRootFormatter.java	Fri Jun  4 18:46:57 2010	(r1354)
@@ -68,16 +68,14 @@
                         String sep = ", ";
                         if (r == d.getMaxPointId()) sep = "])";
                         Bin b = x.getBin(r);
-                        if (b != null) {
+                        Point p = y.getPoint(r);
+                        if (b != null && p != null) {
                             Double xval = b.getFocus();
                             xv.append(xval.toString() + sep);
                             Double dxminus = b.getDMinus();
                             xem.append(dxminus.toString() + sep);
                             Double dxplus = b.getDPlus();
                             xep.append(dxplus.toString() + sep);
-                        }
-                        Point p = y.getPoint(r);
-                        if (p != null) {
                             Double yval = p.getValue();
                             yv.append(yval.toString() + sep);
                             Double dyminus = p.getQuadCombinedMinusError();

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java	Wed May 12 15:17:03 2010	(r1353)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YodaFormatter.java	Fri Jun  4 18:46:57 2010	(r1354)
@@ -43,16 +43,15 @@
                     for (int r = 1; r <= d.getMaxPointId(); ++r) {
                         StringTemplate row = new StringTemplate("$xlow$\t$xhigh$\t$yval$\t$yerr$");
                         Bin b = x.getBin(r);
-                        if (b != null) {
+                        Point p = y.getPoint(r);
+                        if (b != null && p != null) {
                             Double xlow = b.getLowValue();
-                            Double xhigh = b.getHighValue();
                             row.setAttribute("xlow", xlow);
+                            Double xhigh = b.getHighValue();
                             row.setAttribute("xhigh", xhigh);
-                        }
-                        Point p = y.getPoint(r);
-                        if (p != null) {
+                            Double yval = p.getValue();
                             row.setAttribute("yval", p.getValue());
-                            double yerr = p.getQuadCombinedPlusMinusError();
+                            Double yerr = p.getQuadCombinedPlusMinusError();
                             row.setAttribute("yerr", yerr);
                         }
                         s.append(row.toString() + "\n");


More information about the HepData-svn mailing list