public static double CalcAverageMz(Peak peak, int[] indx, double[,] mzCalibrationPar, double[,] intensityCalibrationPar, double absoluteCalibration) { if (double.IsNaN(absoluteCalibration)) { absoluteCalibration = 0; } double norm1 = 0; double m = 0; if (mzCalibrationPar == null) { foreach (int index0 in indx) { norm1 += peak.origIntensity[index0]; double mz = peak.centerMz[index0]; m += peak.origIntensity[index0] * mz; } m /= norm1; return(m); } foreach (int index0 in indx) { norm1 += peak.origIntensity[index0]; double mz = peak.centerMz[index0] * (1 + 1e-6 * NumUtil.RelativeCorrection(peak.centerMz[index0], mzCalibrationPar, intensityCalibrationPar, peak.origIntensity[index0], peak.massRange[index0]) + 1e-6 * absoluteCalibration); m += peak.origIntensity[index0] * mz; } m /= norm1; return(m); }