public void calibrateCircularMask() {
   this.setup(Layer.circular);
   String filename = FileUtil.getcwd() + "/" + "Circular Mask Calibration" + ".dat";
   MeasurementPlotter mPlot =
       new MeasurementPlotter(
           "Circular Mask Calibration",
           numIDs,
           filename,
           new Range(0, 254),
           new Rectangle(10, 10, 400, 300));
   // minimize, i.e. find max. extinction
   double[] targets = new double[] {0, 0};
   double[] a = new double[numIDs];
   double[] b = new double[numIDs];
   for (int i = 0; i < a.length; i++) {
     a[i] = (double) SLMModel.HuntRangeMasksMin_a;
     b[i] = (double) SLMModel.HuntRangeMasksMin_b;
   }
   this.minimizeToTargets(a, b, slmModel.getTolCoarse(), targets, mPlot);
   slmCtrl.setCircularExtinctSettings(this.getSettings());
   // Maximize, i.e. fine max. transmission
   targets = new double[] {254, 254};
   for (int i = 0; i < a.length; i++) {
     a[i] = (double) SLMModel.HuntRangeMasksMax_a;
     b[i] = (double) SLMModel.HuntRangeMasksMax_b;
   }
   this.minimizeToTargets(a, b, slmModel.getTolCoarse(), targets, mPlot);
   slmCtrl.setCircularTransmitSettings(this.getSettings());
 }
  //    class TaskMeasureSetting1
  //            extends SwingWorker {
  //
  //        MeasurementPlotter mPlot;
  //
  //
  //        public TaskMeasureSetting1(MeasurementPlotter mPlot) {
  //            this.mPlot = mPlot;
  //        }
  //
  //
  //        final MultiSectorMeasurer acquireImageAndMeasure = new MultiSectorMeasurer();
  //
  //
  //        @Override
  //        public Object doInBackground() {
  //
  //            System.out.println("measure setting 1");
  //            int step = (int) ((SLMConstants.startMax - SLMConstants.startMin) /
  // SLMConstants.numPoints);
  //            for (int s = 0; s < SLMConstants.numPoints; s++) { // for each setting
  //                int setTo = (int) (SLMConstants.startMin + s * step);
  //                for (int i = 0; i < numIDs; i++) { //for each sector
  //                    settings[i] = setTo;
  //                }
  //                acquireImageAndMeasure.run();
  //                for (int i = 0; i < numIDs; i++) {
  //                    mPlot.recordData(i, s, measurements[i]);
  //                }
  //
  //            }
  //            return null;
  //        }
  //
  //
  //    }
  private void matchSettingN(int n, MeasurementPlotter mPlot) {

    double[] a = new double[numIDs];
    double[] b = new double[numIDs];

    this.setup(Layer.retarderA);
    for (int i = 0; i < a.length; i++) {
      a[i] = slmCtrl.settings.retardSetA[n][i] - SLMModel.deltaExtinct;
      b[i] = slmCtrl.settings.retardSetA[n][i] + SLMModel.deltaExtinct;
    }
    this.minimizeToTargets(a, b, slmModel.getTolCoarse(), measuredIntensity1, mPlot);
    slmCtrl.setCalibratedRetarderASettings(n, this.getSettings());

    this.setup(Layer.retarderB);
    for (int i = 0; i < a.length; i++) {
      a[i] = slmCtrl.settings.retardSetB[n][i] - SLMModel.deltaExtinct;
      b[i] = slmCtrl.settings.retardSetB[n][i] + SLMModel.deltaExtinct;
    }
    this.minimizeToTargets(a, b, slmModel.getTolCoarse(), measuredIntensity1, mPlot);
    slmCtrl.setCalibratedRetarderBSettings(n, this.getSettings());
    // @todo repeat with tolFine
  }
  public void findExtinction(MeasurementPlotter mPlot) {
    slmCtrl.setAllRetarderATo(SLMModel.extA);
    slmCtrl.setAllRetarderBTo(SLMModel.extB);

    double[] a = new double[numIDs];
    double[] b = new double[numIDs];

    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> findExtinction A coarse ...");
    for (int i = 0; i < a.length; i++) {
      a[i] = (double) SLMModel.HuntRangeRetarderA_a;
      b[i] = (double) SLMModel.HuntRangeRetarderA_b;
    }
    findExtinctionA(mPlot, a, b, slmModel.getTolCoarse());

    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> findExtinction B coarse ...");
    for (int i = 0; i < a.length; i++) {
      a[i] = (double) SLMModel.HuntRangeRetarderB_a;
      b[i] = (double) SLMModel.HuntRangeRetarderB_b;
    }
    findExtinctionB(mPlot, a, b, slmModel.getTolCoarse());

    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> findExtinction A fine ...");
    for (int i = 0; i < a.length; i++) {
      a[i] = (double) slmCtrl.settings.retardSetA[0][i] - SLMModel.deltaExtinct;
      b[i] = (double) slmCtrl.settings.retardSetA[0][i] + SLMModel.deltaExtinct;
    }
    findExtinctionA(mPlot, a, b, slmModel.getTolFine());

    System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> findExtinction B fine ...");
    for (int i = 0; i < a.length; i++) {
      a[i] = (double) slmCtrl.settings.retardSetB[0][i] - SLMModel.deltaExtinct;
      b[i] = (double) slmCtrl.settings.retardSetB[0][i] + SLMModel.deltaExtinct;
    }
    findExtinctionB(mPlot, a, b, slmModel.getTolFine());

    measuredIntensity0 = this.getMeasuredValues().clone();
  }