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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Nov 13 10:42:09 GMT 2009


Author: buckley
Date: Fri Nov 13 10:42:08 2009
New Revision: 1313

Log:
Adding edge guessing to AIDA formatter, for Rivet use

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

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Tue Nov 10 20:19:34 2009	(r1312)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/AidaFormatter.java	Fri Nov 13 10:42:08 2009	(r1313)
@@ -77,8 +77,6 @@
                     Bin b = x.getBin(r);
                     if (b != null) {
                         Double xval = b.getFocus();
-                        // System.out.println("@ " + xval.toString() + "+" + b.getDPlus().toString() + "-" + b.getDMinus().toString());
-                        // System.out.println("# " + b.getLowValue().toString() + "--" + xval.toString() + "--" + b.getHighValue().toString());
                         Double dxminus = b.getDMinus();
                         Double dxplus = b.getDPlus();
                         if (xval == null) {
@@ -88,43 +86,39 @@
                         }
 
 
-
-                        // // Calc bin widths by hand if needed
-                        // if (getMaxPointId() > 1) {
-                        //     for (int i = 1; i < n; ++i) {
-                        //         double ithgap = Math.abs(xCentres[i] - xCentres[i-1]);
-                        //         if (xErrsPlus[i-1] == 0) {
-                        //             // Try to use surrounding edges first
-                        //             if (xErrsMinus[i] != 0) {
-                        //                 double nextLowEdge = xCentres[i] - xErrsMinus[i];
-                        //                 xErrsPlus[i-1] = nextLowEdge - xCentres[i-1];
-                        //             } else {
-                        //                 xErrsPlus[i-1] = ithgap/2.0;
-                        //             }
-                        //         }
-                        //         if (xErrsMinus[i] == 0) {
-                        //             // Try to use surrounding edges first
-                        //             if (xErrsPlus[i-1] != 0) {
-                        //                 double prevHighEdge = xCentres[i-1] + xErrsPlus[i-1];
-                        //                 xErrsMinus[i] = xCentres[i] - prevHighEdge;
-                        //             } else {
-                        //                 xErrsMinus[i] = ithgap/2.0;
-                        //             }
-                        //         }
-
-                        //     }
-                        //     // Deal with ends specially
-                        //     if (xErrsMinus[0] == 0.0) xErrsMinus[0] = xErrsPlus[0];
-                        //     if (xErrsPlus[n-1] == 0.0) xErrsPlus[n-1] = xErrsMinus[n-1];
-                        // } else {
-                        //     // If there's only one bin and it has no width, give
-                        //     // it unit width so that it can be filled and the height
-                        //     // doesn't go mad when Rivet tries to use it.
-                        //     if (xErrsMinus[0] == 0.0 && xErrsPlus[0] == 0.0) {
-                        //         xErrsMinus[0] = 0.5;
-                        //         xErrsPlus[0] = 0.5;
-                        //     }
-                        // }
+                        // Guesstimate bin widths by hand if needed
+                        if (b.getWidth() == 0) {
+                            // If there are several bins, make the internal
+                            // edges match, and the external edges duplicate
+                            // their +/- partners
+                            if (d.getMaxPointId() > 1) {
+                                if (r > 1) {
+                                    Bin bbefore = x.getBin(r-1);
+                                    if (bbefore.getDPlus() > 0) {
+                                        dxminus = Math.abs(xval - bbefore.getHighValue());
+                                    } else {
+                                        dxminus = Math.abs(xval - bbefore.getFocus())/2.0;
+                                    }
+                                }
+                                if (r < d.getMaxPointId()) {
+                                    Bin bafter = x.getBin(r+1);
+                                    if (bafter.getDMinus() > 0) {
+                                        dxplus = Math.abs(bafter.getLowValue() - xval);
+                                    } else {
+                                        dxplus = Math.abs(bafter.getFocus() - xval)/2.0;
+                                    }
+                                }
+                                // Set outer edges of end bins
+                                if (r == 1) dxminus = dxplus;
+                                if (r == d.getMaxPointId()) dxplus = dxminus;
+                            } else {
+                                // If there's only one bin and it has no width, give
+                                // it unit width so that it can be filled and the height
+                                // doesn't go mad when Rivet tries to use it.
+                                dxminus = 0.5;
+                                dxplus = 0.5;
+                            }
+                        }
 
                         xtag.setAttribute("val", xval);
                         xtag.setAttribute("dplus", dxplus);


More information about the HepData-svn mailing list