Пример #1
0
  /**
   * Specifies the region in the 2D histogram with those attributes
   *
   * @param name The name of the histogram
   * @param bx_start The x coordinate beginning
   * @param bx_end The x coordinate end
   * @param by_start The y coordinate beginning
   * @param by_end The y coordinate end
   * @return A 2D histogram with the entered specifications
   */
  public H2D getRegion(String name, int bx_start, int bx_end, int by_start, int by_end) {
    double xBinWidth = xAxis.getBinWidth(bx_start);
    double newXMin = xAxis.min() + (xBinWidth * bx_start);
    double newXMax = xAxis.min() + (xBinWidth * bx_end);

    double yBinWidth = yAxis.getBinWidth(by_start);
    double newYMin = yAxis.min() + (yBinWidth * by_start);
    double newYMax = yAxis.min() + (yBinWidth * by_end);
    H2D regHist =
        new H2D(name, bx_end - bx_start, newXMin, newXMax, by_end - by_start, newYMin, newYMax);

    double content = 0.0;
    for (int y = by_start; y < by_end; y++) {
      for (int x = bx_start; x < bx_end; x++) {
        content = this.getBinContent(x, y);
        regHist.setBinContent(x, y, content);
      }
    }
    return regHist;
  }
Пример #2
0
  /**
   * Creates a 1-D Histogram slice of the specified y Bin
   *
   * @param xBin the bin on the y axis to create a slice of
   * @return a slice of the x bins on the specified y bin as a 1-D Histogram
   */
  public H1D sliceX(int xBin) {
    String name = "Slice of " + xBin + " X Bin";
    double xMin = yAxis.min();
    double xMax = yAxis.max();
    int xNum = yAxis.getNBins();
    H1D sliceX = new H1D(name, name, xNum, xMin, xMax);

    for (int x = 0; x < xNum; x++) {
      sliceX.setBinContent(x, this.getBinContent(xBin, x));
    }
    return sliceX;
  }
Пример #3
0
  /**
   * Creates a 1-D Histogram slice of the specified x Bin
   *
   * @param yBin the bin on the x axis to create a slice of
   * @return a slice of the y bins on the specified x bin as a 1-D Histogram
   */
  public H1D sliceY(int yBin) {
    String name = "Slice of " + yBin + " Y Bin";
    double xMin = xAxis.min();
    double xMax = xAxis.max();
    int xNum = xAxis.getNBins();
    H1D sliceY = new H1D(name, name, xNum, xMin, xMax);

    for (int y = 0; y < xNum; y++) {
      sliceY.setBinContent(y, this.getBinContent(y, yBin));
    }

    return sliceY;
  }
Пример #4
0
  /**
   * Creates a projection of the 2D histogram onto the Y Axis, adding up all the x bins for each y
   * bin
   *
   * @return a H1D object that is a projection of the Histogram2D object onto the y-axis
   */
  public H1D projectionY() {
    String name = "Y Projection";
    double yMin = yAxis.min();
    double yMax = yAxis.max();
    int yNum = yAxis.getNBins();
    H1D projY = new H1D(name, yNum, yMin, yMax);

    double height = 0.0;
    for (int y = 0; y < yAxis.getNBins(); y++) {
      height = 0.0;
      for (int x = 0; x < xAxis.getNBins(); x++) {
        height += this.getBinContent(x, y);
      }
      projY.setBinContent(y, height);
    }

    return projY;
  }
Пример #5
0
  /**
   * Creates a projection of the 2D histogram onto the X Axis, adding up all the y bins for each x
   * bin
   *
   * @return a H1D object that is a projection of the Histogram2D object onto the x-axis
   */
  public H1D projectionX() {
    String name = "X Projection";
    double xMin = xAxis.min();
    double xMax = xAxis.max();
    int xNum = xAxis.getNBins();
    H1D projX = new H1D(name, xNum, xMin, xMax);

    double height = 0.0;
    for (int x = 0; x < xAxis.getNBins(); x++) {
      height = 0.0;
      for (int y = 0; y < yAxis.getNBins(); y++) {
        height += this.getBinContent(x, y);
      }
      projX.setBinContent(x, height);
    }

    return projX;
  }