Пример #1
0
        /// <summary>
        /// Returns an array[h.XAxis.Bins][h.YAxis.Bins]; ignoring extra bins.
        ////
        protected double[][] ToArrayHeights(IHistogram2D h)
        {
            int xBins = h.XAxis.Bins;
            int yBins = h.YAxis.Bins;
            //double[][] array = new double[xBins][];
            var array = (new double[xBins, yBins]).ToJagged();

            for (int i = yBins; --i >= 0;)
            {
                //array[i] = new double[yBins];
                for (int j = xBins; --j >= 0;)
                {
                    array[j][i] = h.BinHeight(j, i);
                }
            }
            return(array);
        }
Пример #2
0
        /// <summary>
        /// Returns the indexY of the in-range bin containing the MaxBinHeight.
        /// </summary>
        /// <param name="h"></param>
        /// <returns></returns>
        public int MaxBinY(IHistogram2D h)
        {
            double maxValue = Double.MinValue;
            int    maxBinX  = -1;
            int    maxBinY  = -1;

            for (int i = h.XAxis.Bins; --i >= 0;)
            {
                for (int j = h.YAxis.Bins; --j >= 0;)
                {
                    double value = h.BinHeight(i, j);
                    if (value > maxValue)
                    {
                        maxValue = value;
                        maxBinX  = i;
                        maxBinY  = j;
                    }
                }
            }
            return(maxBinY);
        }
Пример #3
0
        /// <summary>
        /// Returns a string representation of the given argument.
        ////
        public String ToString(IHistogram2D h)
        {
            String columnAxisName = "X";
            String rowAxisName    = "Y";

            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 +
                                "   MinBinHeight=" + Form(f, h.BinHeight(minMaxBins[0], minMaxBins[1])) + ", MaxBinHeight=" + Form(f, h.BinHeight(minMaxBins[2], minMaxBins[3])) + 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);

            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

            Cern.Colt.Matrix.DoubleMatrix2D heights = new DenseDoubleMatrix2D(ToArrayHeights(h));
            heights = heights.ViewDice().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, yEdges, xEdges, rowAxisName, columnAxisName, null, aggr));

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