コード例 #1
0
        private static void writeAsXML(IHistogram3D h, String filename)
        {
            using (StreamWriter writer = new StreamWriter(filename))
            {
                writer.WriteLine(new Converter().ToString(h));
                //System.out.println(new Converter().toXML(h));

                /*
                 * try
                 * {
                 *  PrintWriter out = new PrintWriter(new FileWriter(filename));
                 *  out.println(new Converter().toXML(h));
                 *  out.close();
                 * }
                 * catch (IOException x) { x.printStackTrace(); }
                 */
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns an array[h.XAxis.Bins][h.YAxis.Bins][h.ZAxis.Bins]; ignoring extra bins.
        ////
        protected double[][][] ToArrayHeights(IHistogram3D h)
        {
            int xBins = h.XAxis.Bins;
            int yBins = h.YAxis.Bins;
            int zBins = h.ZAxis.Bins;
            //double[][][] array = new double[xBins][][];
            var array = (new double[xBins, yBins, zBins]).ToJagged();

            for (int j = xBins; --j >= 0;)
            {
                //array[j] = new double[yBins][];
                for (int i = yBins; --i >= 0;)
                {
                    //array[j][i] = new double[zBins];
                    for (int k = zBins; --k >= 0;)
                    {
                        array[j][i][k] = h.BinHeight(j, i, k);
                    }
                }
            }
            return(array);
        }
コード例 #3
0
        /// <summary>
        /// Returns a string representation of the given argument.
        ////
        public String ToString(IHistogram3D h)
        {
            String columnAxisName = "X";
            String rowAxisName    = "Y";
            String sliceAxisName  = "Z";

            Hep.Aida.Bin.BinFunction1D[] aggr = { Hep.Aida.Bin.BinFunctions1D.Sum };
            String format = "G"; //"%G"

            //String format = "%1.2G";

            Cern.Colt.Matrix.Former f = new Cern.Colt.Matrix.Implementation.FormerFactory().Create(format);
            String sep = "\n\r"; //System.getProperty("line.separator");

            int[]  minMaxBins = h.MinMaxBins;
            String title      = h.Title + ":" + sep +
                                "   Entries=" + Form(f, h.Entries) + ", ExtraEntries=" + Form(f, h.ExtraEntries) + sep +
                                "   MeanX=" + Form(f, h.MeanX) + ", RmsX=" + Form(f, h.RmsX) + sep +
                                "   MeanY=" + Form(f, h.MeanY) + ", RmsY=" + Form(f, h.RmsX) + sep +
                                "   MeanZ=" + Form(f, h.MeanZ) + ", RmsZ=" + Form(f, h.RmsZ) + sep +
                                "   MinBinHeight=" + Form(f, h.BinHeight(minMaxBins[0], minMaxBins[1], minMaxBins[2])) + ", MaxBinHeight=" + Form(f, h.BinHeight(minMaxBins[3], minMaxBins[4], minMaxBins[5])) + sep +

                                "   xAxis: " +
                                "Bins=" + Form(f, h.XAxis.Bins) +
                                ", Min=" + Form(f, h.XAxis.LowerEdge) +
                                ", Max=" + Form(f, h.XAxis.UpperEdge) + sep +

                                "   yAxis: " +
                                "Bins=" + Form(f, h.YAxis.Bins) +
                                ", Min=" + Form(f, h.YAxis.LowerEdge) +
                                ", Max=" + Form(f, h.YAxis.UpperEdge) + sep +

                                "   zAxis: " +
                                "Bins=" + Form(f, h.ZAxis.Bins) +
                                ", Min=" + Form(f, h.ZAxis.LowerEdge) +
                                ", Max=" + Form(f, h.ZAxis.UpperEdge);

            String[] xEdges = new String[h.XAxis.Bins];
            for (int i = 0; i < h.XAxis.Bins; i++)
            {
                xEdges[i] = Form(f, h.XAxis.BinLowerEdge(i));
            }

            String[] yEdges = new String[h.YAxis.Bins];
            for (int i = 0; i < h.YAxis.Bins; i++)
            {
                yEdges[i] = Form(f, h.YAxis.BinLowerEdge(i));
            }
            new List <Object>(yEdges).Reverse(); // keep coordd system

            String[] zEdges = new String[h.ZAxis.Bins];
            for (int i = 0; i < h.ZAxis.Bins; i++)
            {
                zEdges[i] = Form(f, h.ZAxis.BinLowerEdge(i));
            }
            new List <Object>(zEdges).Reverse(); // keep coordd system

            DoubleMatrix3D heights = new DenseDoubleMatrix3D(ToArrayHeights(h));

            heights = heights.ViewDice(2, 1, 0).ViewSliceFlip().ViewRowFlip(); // keep the histo coordd system
                                                                               //heights = heights.ViewPart(1,1,heights.Rows()-2,heights.columns()-2); // ignore under&overflows

            //Cern.Colt.Matrix.DoubleMatrix2D errors = new Cern.Colt.Matrix.DenseDoubleMatrix2D(toArrayErrors(h));
            //errors = errors.ViewDice().ViewRowFlip(); // keep the histo coord system
            ////errors = errors.ViewPart(1,1,errors.Rows()-2,errors.columns()-2); // ignore under&overflows

            return(title + sep +
                   "Heights:" + sep +
                   new Formatter().ToTitleString(
                       heights, zEdges, yEdges, xEdges, sliceAxisName, rowAxisName, columnAxisName, "", aggr));

            /*
             + sep +
             +          "Errors:" + sep +
             +          new Cern.Colt.Matrix.doublealgo.Formatter().ToTitleString(
             +                  errors,yEdges,xEdges,rowAxisName,columnAxisName,null,aggr);
             */
        }