AppendToDifference() public method

public AppendToDifference ( double x, double y ) : void
x double
y double
return void
示例#1
0
        public void HandleDataPoint(DataEventArgs e)
        {
            Profile currentProfile = Controller.GetController().ProfileManager.CurrentProfile;

            // update the TOF graphs

            if (currentProfile.GUIConfig.average)
            {
                if (shotCounter % currentProfile.GUIConfig.updateTOFsEvery == 0)
                {
                    if (avOnTofs != null)
                    {
                        for (int i = 0; i < avOnTofs.Count; i++)
                        {
                            avOnTofs[i] = ((TOF)avOnTofs[i]) / onAverages;
                        }
                        window.PlotOnTOF(avOnTofs);
                        if (avOnTofs.Count > 1)
                        {
                            // integral between the signal gates minus the integral between the background gates (adjusted for the relative width of the two gates)
                            double normVal = (((TOF)avOnTofs[1]).Integrate(NormSigGateLow, NormSigGateHigh)) - (((TOF)avOnTofs[1]).Integrate(NormBgGateLow, NormBgGateHigh)) * (NormSigGateHigh - NormSigGateLow) / (NormBgGateHigh - NormBgGateLow);
                            window.PlotNormedOnTOF(((TOF)avOnTofs[0]) / normVal);
                        }
                    }
                    avOnTofs   = e.point.AverageOnShot.TOFs;
                    onAverages = 1;

                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                    {
                        if (avOffTofs != null)
                        {
                            for (int i = 0; i < avOffTofs.Count; i++)
                            {
                                avOffTofs[i] = ((TOF)avOffTofs[i]) / offAverages;
                            }
                            window.PlotOffTOF(avOffTofs);
                            if (avOffTofs.Count > 1)
                            {
                                double normVal = (((TOF)avOffTofs[1]).Integrate(NormSigGateLow, NormSigGateHigh)) - (((TOF)avOffTofs[1]).Integrate(NormBgGateLow, NormBgGateHigh)) * (NormSigGateHigh - NormSigGateLow) / (NormBgGateHigh - NormBgGateLow);
                                window.PlotNormedOffTOF(((TOF)avOffTofs[0]) / normVal);
                            }
                        }
                        avOffTofs   = e.point.AverageOffShot.TOFs;
                        offAverages = 1;
                    }
                }
                else                 // do the averaging
                {
                    if (avOnTofs != null)
                    {
                        //avOnTof = avOnTof + ((TOF) e.point.AverageOnShot.TOFs[0]);
                        for (int i = 0; i < avOnTofs.Count; i++)
                        {
                            avOnTofs[i] = (TOF)avOnTofs[i] + ((TOF)e.point.AverageOnShot.TOFs[i]);
                        }
                        onAverages++;
                    }
                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"] && avOffTofs != null)
                    {
                        //avOffTof = avOffTof + ((TOF) e.point.AverageOffShot.TOFs[0]);
                        for (int i = 0; i < avOffTofs.Count; i++)
                        {
                            avOffTofs[i] = (TOF)avOffTofs[i] + ((TOF)e.point.AverageOffShot.TOFs[i]);
                        }
                        offAverages++;
                    }
                }
            }

            else              // if not averaging
            {
                if (shotCounter % currentProfile.GUIConfig.updateTOFsEvery == 0)
                {
                    ArrayList currentTofs = e.point.AverageOnShot.TOFs;
                    window.PlotOnTOF(currentTofs);
                    if (currentTofs.Count > 1)
                    {
                        double normVal = (((TOF)currentTofs[1]).Integrate(NormSigGateLow, NormSigGateHigh)) - (((TOF)currentTofs[1]).Integrate(NormBgGateLow, NormBgGateHigh)) * (NormSigGateHigh - NormSigGateLow) / (NormBgGateHigh - NormBgGateLow);
                        window.PlotNormedOnTOF(((TOF)currentTofs[0]) / normVal);
                    }
                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                    {
                        currentTofs = e.point.AverageOffShot.TOFs;
                        window.PlotOffTOF(currentTofs);
                        if (currentTofs.Count > 1)
                        {
                            double normVal = (((TOF)currentTofs[1]).Integrate(NormSigGateLow, NormSigGateHigh)) - (((TOF)currentTofs[1]).Integrate(NormBgGateLow, NormBgGateHigh)) * (NormSigGateHigh - NormSigGateLow) / (NormBgGateHigh - NormBgGateLow);
                            window.PlotNormedOffTOF(((TOF)currentTofs[0]) / normVal);
                        }
                    }
                }
            }


            // update the spectra
            pointsToPlot.Points.Add(e.point);
            if (shotCounter % currentProfile.GUIConfig.updateSpectraEvery == 0)
            {
                if (pointsToPlot.AnalogChannelCount >= 1)
                {
                    window.AppendToAnalog1(pointsToPlot.ScanParameterArray, pointsToPlot.GetAnalogArray(0));
                }
                if (pointsToPlot.AnalogChannelCount >= 2)
                {
                    window.AppendToAnalog2(pointsToPlot.ScanParameterArray, pointsToPlot.GetAnalogArray(1));
                }
                window.AppendToPMTOn(pointsToPlot.ScanParameterArray,
                                     pointsToPlot.GetTOFOnIntegralArray(0,
                                                                        startTOFGate, endTOFGate));
                if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                {
                    window.AppendToPMTOff(pointsToPlot.ScanParameterArray,
                                          pointsToPlot.GetTOFOffIntegralArray(0,
                                                                              startTOFGate, endTOFGate));
                    window.AppendToDifference(pointsToPlot.ScanParameterArray,
                                              pointsToPlot.GetDifferenceIntegralArray(0,
                                                                                      startTOFGate, endTOFGate));
                }
                // update the spectrum fit if in shot mode.
                if (spectrumFitMode == FitMode.Shot)
                {
                    Scan currentScan = Controller.GetController().DataStore.CurrentScan;
                    if (currentScan.Points.Count > 10)
                    {
                        FitAndPlotSpectrum(currentScan);
                    }
                }
                pointsToPlot.Points.Clear();
            }
            shotCounter++;
        }
示例#2
0
        public void HandleDataPoint(DataEventArgs e)
        {
            Profile currentProfile = Controller.GetController().ProfileManager.CurrentProfile;

            // update the TOF graphs

            if (currentProfile.GUIConfig.average)
            {
                if (shotCounter % currentProfile.GUIConfig.updateTOFsEvery == 0)
                {
                    if (avOnTof != null)
                    {
                        window.PlotOnTOF(avOnTof / onAverages);
                    }
                    avOnTof    = (TOF)e.point.AverageOnShot.TOFs[0];
                    onAverages = 1;

                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                    {
                        if (avOffTof != null)
                        {
                            window.PlotOffTOF(avOffTof / offAverages);
                        }
                        avOffTof    = (TOF)e.point.AverageOffShot.TOFs[0];
                        offAverages = 1;
                    }
                }
                else                 // do the averaging
                {
                    if (avOnTof != null)
                    {
                        avOnTof = avOnTof + ((TOF)e.point.AverageOnShot.TOFs[0]);
                        onAverages++;
                    }
                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"] && avOffTof != null)
                    {
                        avOffTof = avOffTof + ((TOF)e.point.AverageOffShot.TOFs[0]);
                        offAverages++;
                    }
                }
            }

            else              // if not averaging
            {
                if (shotCounter % currentProfile.GUIConfig.updateTOFsEvery == 0)
                {
                    window.PlotOnTOF((TOF)e.point.AverageOnShot.TOFs[0]);
                    if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                    {
                        window.PlotOffTOF((TOF)e.point.AverageOffShot.TOFs[0]);
                    }
                }
            }


            // update the spectra
            pointsToPlot.Points.Add(e.point);
            if (shotCounter % currentProfile.GUIConfig.updateSpectraEvery == 0)
            {
                if (pointsToPlot.AnalogChannelCount >= 1)
                {
                    window.AppendToAnalog1(pointsToPlot.ScanParameterArray, pointsToPlot.GetAnalogArray(0));
                }
                if (pointsToPlot.AnalogChannelCount >= 2)
                {
                    window.AppendToAnalog2(pointsToPlot.ScanParameterArray, pointsToPlot.GetAnalogArray(1));
                }
                if (sdisplayMode == ScanDisplayMode.Integral)
                {
                    window.AppendToPMTOn(pointsToPlot.ScanParameterArray,
                                         pointsToPlot.GetTOFOnIntegralArray(0,
                                                                            startTOFGate, endTOFGate));
                }
                if (sdisplayMode == ScanDisplayMode.IofAbs)
                {
                    window.AppendToPMTOn(pointsToPlot.ScanParameterArray,
                                         pointsToPlot.GetTOFOnAbsValIntegralArray(0,
                                                                                  startTOFGate, endTOFGate));
                }
                if ((bool)currentProfile.AcquisitorConfig.switchPlugin.Settings["switchActive"])
                {
                    if (sdisplayMode == ScanDisplayMode.Integral)
                    {
                        window.AppendToPMTOff(pointsToPlot.ScanParameterArray,
                                              pointsToPlot.GetTOFOffIntegralArray(0,
                                                                                  startTOFGate, endTOFGate));
                        window.AppendToDifference(pointsToPlot.ScanParameterArray,
                                                  pointsToPlot.GetDifferenceIntegralArray(0,
                                                                                          startTOFGate, endTOFGate));
                    }
                    if (sdisplayMode == ScanDisplayMode.IofAbs)
                    {
                        window.AppendToPMTOff(pointsToPlot.ScanParameterArray,
                                              pointsToPlot.GetTOFOffAbsValIntegralArray(0,
                                                                                        startTOFGate, endTOFGate));
                        window.AppendToDifference(pointsToPlot.ScanParameterArray,
                                                  pointsToPlot.GetDifferenceAbsValIntegralArray(0,
                                                                                                startTOFGate, endTOFGate));
                    }
                }
                // update the spectrum fit if in shot mode.
                if (spectrumFitMode == FitMode.Shot)
                {
                    Scan currentScan = Controller.GetController().DataStore.CurrentScan;
                    if (currentScan.Points.Count > 10)
                    {
                        FitAndPlotSpectrum(currentScan);
                    }
                }
                pointsToPlot.Points.Clear();
            }
            shotCounter++;
        }