Example #1
0
        /// <summary>
        /// Returns an array[h.XAxis.Bins]; ignoring extra bins.
        ////
        protected double[] ToArrayHeights(IHistogram1D h)
        {
            int xBins = h.XAxis.Bins;

            double[] array = new double[xBins];
            for (int j = xBins; --j >= 0;)
            {
                array[j] = h.BinHeight(j);
            }
            return(array);
        }
Example #2
0
        public int MaxBin(IHistogram1D h)
        {
            int    maxBin   = -1;
            double maxValue = Double.MinValue;

            for (int i = h.XAxis.Bins; --i >= 0;)
            {
                double value = h.BinHeight(i);
                if (value > maxValue)
                {
                    maxValue = value;
                    maxBin   = i;
                }
            }
            return(maxBin);
        }
Example #3
0
        /// <summary>
        /// Returns a string representation of the given argument.
        ////
        public String ToString(IHistogram1D h)
        {
            String columnAxisName = null; //"X";
            String rowAxisName    = null;

            Hep.Aida.Bin.BinFunction1D[] aggr = null; //{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"; //"\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 +
                                "   Mean=" + Form(f, h.Mean) + ", Rms=" + Form(f, h.Rms) + sep +
                                "   MinBinHeight=" + Form(f, h.BinHeight(minMaxBins[0])) + ", MaxBinHeight=" + Form(f, h.BinHeight(minMaxBins[1])) + sep +
                                "   Axis: " +
                                "Bins=" + Form(f, h.XAxis.Bins) +
                                ", Min=" + Form(f, h.XAxis.LowerEdge) +
                                ", Max=" + Form(f, h.XAxis.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[] { "Data" };

            Cern.Colt.Matrix.DoubleMatrix2D heights = new DenseDoubleMatrix2D(1, h.XAxis.Bins);
            heights.ViewRow(0).Assign(ToArrayHeights(h));
            //Cern.Colt.Matrix.DoubleMatrix2D errors = new Cern.Colt.Matrix.DenseDoubleMatrix2D(1,h.XAxis.Bins);
            //errors.ViewRow(0).Assign(toArrayErrors(h));

            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);
             */
        }