コード例 #1
0
ファイル: H2D.java プロジェクト: KrishnaAdhikari/clas12
 public void divide(H2D h) {
   if (h.getXAxis().getNBins() == this.getXAxis().getNBins()
       && h.getYAxis().getNBins() == this.getYAxis().getNBins()) {
     for (int loop = 0; loop < this.hBuffer.length; loop++) {
       if (h.hBuffer[loop] == 0) {
         this.hBuffer[loop] = 0.0;
       } else {
         this.hBuffer[loop] = this.hBuffer[loop] / h.hBuffer[loop];
       }
     }
   } else {
     System.err.println("[H2D::divide] error the bins in 2d histogram do not match");
   }
 }
コード例 #2
0
ファイル: H2D.java プロジェクト: KrishnaAdhikari/clas12
 public void add(H2D h) {
   if (h.getXAxis().getNBins() == this.getXAxis().getNBins()
       && h.getYAxis().getNBins() == this.getYAxis().getNBins()) {
     for (int loop = 0; loop < this.hBuffer.length; loop++) {
       this.hBuffer[loop] = this.hBuffer[loop] + h.hBuffer[loop];
     }
   } else {
     System.out.println(
         "[warning] ---> error adding histograms "
             + this.getName()
             + "  "
             + h.getName()
             + ". inconsistent bin numbers");
   }
 }
コード例 #3
0
ファイル: H2D.java プロジェクト: KrishnaAdhikari/clas12
  /**
   * 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;
  }