XPS domain specific rules in xps4xps

The package comprises several XPS domain specific simple rules. They are the followings: (in a meta-programming language format)


whether exists a peak in the binding energy range

HasPeakInRangeBE(Spectrum,BELow,BEHigh) =
{   found = false;
    for ((Peak in Spectrum.Peaks) or found)
    {
        found = found
                OR
                IsPeakInRangeBE(Peak,BELow,BEHigh)
    }
}


whether exists a peak in the kinetic energy range

HasPeakInRangeKE(Spectrum,KELow,KEHigh) =
{   found = false;
    for ((Peak in Spectrum.Peaks) or found)
    {
        found = found
                OR
                IsPeakInRangeKE(Peak,KELow,KEHigh)
      }
}


whether the energy data are available on binding energy scale

IsEnergyAvailBE =
{    IsEnergyBE(Spectrum)        
      OR
        IsEnergyKE(Spectrum) 
         AND 
        IsXEnergyKnown(Spectrum) 
}


whether the energy data are available on kinetic energy scale

IsEnergyAvailKE =
{    IsEnergyKE(Spectrum)        
       OR
         IsEnergyBE(Spectrum) 
          AND 
         IsXEnergyKnown(Spectrum) 
}


whether the energy data are given on binding energy scale

IsEnergyBE =
{   Spectrum.EnergyBE == True;
}


whether the energy data are given on kinetic energy scale

IsEnergyKE =
{   Spectrum.EnergyBE == False;
}
whether there is a peak in the binding energy region
IsPeakInRangeBE(Peak,BLow,BHigh) =
{    // Transform Peak.Energy  if on kinetic scale
     IsRegionMeasuredBE(Spectrum,BLow-E4Background,BHigh+E4Background)
        AND
    BLow <= Peak.Energy <= BHigh
}
whether there is a peak in the kinetic energy region
IsPeakInRangeKE(Peak,KLow,KHigh) =
{    // Transform Peak.Energy  if on binding scale
     IsRegionMeasuredKE(Spectrum,KLow-E4Background,KHigh+E4Background)
        AND
    KLow <= Peak.Energy <= KHigh
}
(In the rules above, the parameter E4Background is used to determine if sufficient length on both sides of the peak is available for background determination)


whether a binding energy region is measured

IsRegionMeasuredBE(Spectrum,BLow,BHigh) =
{    // Transform Spectrum.MinEnergy and Spectrum.MaxEnergy,
     // if on kinetic scale
    Spectrum.MinEnergy <= BLow <= Spectrum.MaxEnergy
        AND
    Spectrum.MinEnergy <= BHigh <= Spectrum.MaxEnergy
}


whether a kinetic energy region is measured

IsRegionMeasuredKE(Spectrum,KLow,KHigh) =
{    // Transform Spectrum.MinEnergy and Spectrum.MaxEnergy,
     // if on binding scale
    Spectrum.MinEnergy <= KLow <= Spectrum.MaxEnergy
        AND
    Spectrum.MinEnergy <= KHigh <= Spectrum.MaxEnergy
}


whether the exciting energy is known

IsXEnergyKnown =
{   Spectrum.XEnergyKnown == True;
}