The "Carbon contamination" rules for xps4xps

The features of the Carbon contamination rules are

whether Carbon is present in the spectrum
IsCarbonPresent (Spectrum) 
{
   HasPeakInRangeBE(Spectrum, 282, 288) //Carbon line(s) present
}
whether Carbon KLL Auger is present in the spectrum
IsCarbonAugerPresent (Spectrum) 
{
    HasPeakInrangeKE(Spectrum, 269, 275) //KLL Auger present
}
whether Ruthenium is present in the spectrum
IsRutheniumPresent (Spectrum) 
{
    HasPeakInRangeBE(Spectrum, 458, 462) //ruthenium present
}
whether Carbon 1s line is present
HasCarbon1sPeak (Spectrum) =
{
        IsCarbonPresent(Spectrum)
        AND
        IsCarbonAugerPresent(Spectrum)
        AND
        NOT IsRutheniumPresent(Spectrum)
}
The rule IsCarbonContaminationConsensus is a consensus-type rule, which uses five subrules and calculates a percentage ratio as the subrules vote. Depending on the percentage ratio, returns True, False or Unknown.
IsCarbonContaminationConsensus( Spectrum )
{
	Norm = 0; Sum = 0;
	Norm = Norm + 20;
	if( IsCarbonEnergySeparationOK(Spectrum) )
		Sum = Sum + 20;
	Norm = Norm + 40;
	if( !DoesSampleContainCarbon(Spectrum) )
		Sum = Sum + 40;
	Norm = Norm + 25;
	if( IsCarbonShirleyTailHigh(Spectrum) )
		Sum = Sum + 25;
	Norm = Norm + 25;
	if( IsCarbonPostPeakSlopeBiggest(Spectrum) )
		Sum = Sum + 25;
	Norm = Norm + 20;
	if( IsCarbonAngleRatioBiggest(Spectrum) )
		Sum = Sum + 20;
	if( Sum*100/Norm > 70)
		True;
	else if(Sum*100/Norm < 25)
		False;
	else
		Unknown;
}
The subrules used here are:
IsCarbonEnergySeparationOK(Spectrum) =
{
	EnergySeparation < 20
	AND
	EnergySeparation > 15
}
DoesSampleContainCarbon(Spectrum) =
{
	Spectrum->GetSample()->GetContainsCarbon()
}
IsCarbonShirleyTailHigh(Spectrum) =
{

	Spectrum->GetC1sPeak()->GetShirleyTailHeight() > 0.1
}
IsCarbonPostPeakSlopeBiggest(Spectrum) =
{
	for Peak in AllPeaks
	{
		if(Peak->GetPostPeakSlope() > PeakC1s->GetPostPeakSlope()
			False;
	}
	True;
}
IsCarbonAngleRatioBiggest(Spectrum) =
{
	for Peak in AllPeaks
	{
		if(Peak->GetAngleRatio() > PeakC1s->GetAngleRatio()
			False;
	}
	True;
}