public XYData GenerateChromatogram(Run run, double targetMz, double elutionTimeCenter = 0.5, Globals.ElutionTimeUnit elutionTimeUnit = Globals.ElutionTimeUnit.NormalizedElutionTime)
        {
            var targetMzList = new List <double> {
                targetMz
            };

            return(GenerateChromatogram(run, targetMzList, elutionTimeCenter, elutionTimeUnit));
        }
        public XYData GenerateChromatogram(Run run, IsotopicProfile theorProfile, double elutionTimeCenter = 0.5, Globals.ElutionTimeUnit elutionTimeUnit = Globals.ElutionTimeUnit.NormalizedElutionTime)
        {
            if (ChromatogramGeneratorMode == Globals.ChromatogramGeneratorMode.MZ_BASED)
            {
                throw new NotSupportedException("Don't use this method for MZ_BASED chromatogram generation. Use a different overload");
            }
            var targetMZList = GetTargetMzList(theorProfile);

            return(GenerateChromatogram(run, targetMZList, elutionTimeCenter, elutionTimeUnit));
        }
        public XYData GenerateChromatogram(Run run, List <double> targetMzList, double elutionTimeCenter = 0.5, Globals.ElutionTimeUnit elutionTimeUnit = Globals.ElutionTimeUnit.NormalizedElutionTime)
        {
            var lowerScan = run.MinLCScan;
            var upperScan = run.MaxLCScan;

            if (elutionTimeUnit == Globals.ElutionTimeUnit.NormalizedElutionTime)
            {
                float minNetVal;
                float maxNetVal;
                if (run.NETIsAligned)
                {
                    minNetVal = (float)(elutionTimeCenter - ChromWindowWidthForAlignedData);
                    maxNetVal = (float)(elutionTimeCenter + ChromWindowWidthForAlignedData);
                }
                else
                {
                    minNetVal = (float)(elutionTimeCenter - ChromWindowWidthForNonAlignedData);
                    maxNetVal = (float)(elutionTimeCenter + ChromWindowWidthForNonAlignedData);
                }

                if (minNetVal < 0)
                {
                    minNetVal = 0;
                }
                if (maxNetVal > 1)
                {
                    maxNetVal = 1;
                }

                lowerScan = (int)Math.Floor(run.NetAlignmentInfo.GetScanForNet(minNetVal));
                if (lowerScan == -1)
                {
                    lowerScan = run.MinLCScan;
                }

                upperScan = (int)Math.Ceiling(run.NetAlignmentInfo.GetScanForNet(maxNetVal));
                if (upperScan == -1)
                {
                    upperScan = run.MaxLCScan;
                }
            }
            else if (elutionTimeUnit == Globals.ElutionTimeUnit.ScanNum)
            {
                if (run.NETIsAligned)
                {
                    lowerScan = (int)(elutionTimeCenter - ChromWindowWidthForAlignedData);
                    upperScan = (int)(elutionTimeCenter + ChromWindowWidthForAlignedData);
                }
                else
                {
                    lowerScan = (int)(elutionTimeCenter - ChromWindowWidthForNonAlignedData);
                    upperScan = (int)(elutionTimeCenter + ChromWindowWidthForNonAlignedData);
                }
            }

            if (lowerScan == -1)
            {
                lowerScan = run.MinLCScan;
            }
            if (upperScan == -1)
            {
                upperScan = run.MaxLCScan;
            }

            var midScan = (int)((lowerScan + (double)upperScan) / 2);

            if (run.MassIsAligned)
            {
                for (var i = 0; i < targetMzList.Count; i++)
                {
                    targetMzList[i] = getAlignedMZValue(targetMzList[i], run, midScan);
                }
            }

            var chromValues = _chromGen.GenerateChromatogram(run.ResultCollection.MSPeakResultList, lowerScan, upperScan, targetMzList, Tolerance, ToleranceUnit);

            chromValues = FilterOutDataBasedOnMsMsLevel(run, chromValues, 1, false);

            return(chromValues);
        }