Hi Dan,
Remember you need to de-normalize all intensities to raw counts and the standard intensity is for the pure element standard.
If you put the software into debug mode using the Output | DebugMode menu, you will see all the intermediate steps in this calculation.
Also, here is the actual code I am using:
Function ConvertDetectionLimits2(samplerow As Integer, chan As Integer, tRowUnkCors() As Single, tRowStdCts() As Single, analysis As TypeAnalysis, sample() As TypeSample) As Single
' Calculate detection limit for a single element
ierror = False
On Error GoTo ConvertDetectionLimits2Error
Dim temp As Single
' Default is zero
ConvertDetectionLimits2! = 0#
' Normalize standard counts to pure element counts by apply std k-factor
If CorrectionFlag% = 0 Or CorrectionFlag% = 4 Then
If analysis.StdAssignsKrats!(chan%) = 0# Then Exit Function
stdcps100! = tRowStdCts!(samplerow%, chan%) / analysis.StdAssignsKrats!(chan%)
' Alpha-Factors (calculate alpha k-fac = conc/beta)
ElseIf CorrectionFlag% > 0 Then
If analysis.StdAssignsBetas!(chan%) = 0# Then Exit Function
temp! = (analysis.StdAssignsPercents!(chan%) / 100#) / analysis.StdAssignsBetas!(chan%)
If temp! = 0# Then Exit Function
stdcps100! = tRowStdCts!(samplerow%, chan%) / temp! ' leave std counts in cps/nominal beam
End If
' Determine background count time for unknown
If sample(1).BackgroundTypes%(chan%) <> 1 Then ' 0=off-peak, 1=MAN, 2=multipoint
' 0=linear, 1=average, 2=high only, 3=low only, 4=exponential, 5=slope hi, 6=slope lo, 7=polynomial, 8=multi-point
If sample(1).OffPeakCorrectionTypes%(chan%) = 2 Then
bgdtime! = sample(1).HiTimeData!(samplerow%, chan%) ' high only
ElseIf sample(1).OffPeakCorrectionTypes%(chan%) = 3 Then
bgdtime! = sample(1).LoTimeData!(samplerow%, chan%) ' low only
Else
bgdtime! = sample(1).HiTimeData!(samplerow%, chan%) + sample(1).LoTimeData!(samplerow%, chan%) ' all other off peak types
End If
Else
bgdtime! = sample(1).OnTimeData!(samplerow%, chan%) ' use on-peak time for MAN
End If
' Determine unknown beam current for each element
If Not sample(1).CombinedConditionsFlag Then
bgdbeam! = sample(1).OnBeamData!(samplerow%, chan%) ' use OnBeamData in case of aggregate intensity calculation (use average aggregate beam)
Else
bgdbeam! = sample(1).OnBeamDataArray!(samplerow%, chan%) ' use OnBeamDataArray in case of aggregate intensity calculation (use average aggregate beam)
End If
' De-normalize unknown background counts for time and beam
bgdcount! = sample(1).BgdData(samplerow%, chan%) * bgdtime!
Call DataCorrectDataBeamDrift2(bgdcount!, bgdbeam!)
If ierror Then Exit Function
' Take square root to get gaussian standard deviation of background
If bgdcount! < 0# Then Exit Function
bgddevraw! = Sqr(bgdcount!)
' Re-normalize background deviation to cps and nominal beam again
If bgdtime! <= 0# Then Exit Function
bgddevcps! = bgddevraw! / bgdtime!
Call DataCorrectDataBeamDrift(bgddevcps!, bgdbeam!)
If ierror Then Exit Function
' Calculate detection limit (three times the standard deviation of the background)
If stdcps100! <> 0# Then
ConvertDetectionLimits2! = 3# * bgddevcps! / stdcps100! * 100# * tRowUnkCors!(samplerow%, chan%)
End If
Exit Function
' Errors
ConvertDetectionLimits2Error:
MsgBox Error$, vbOKOnly + vbCritical, "ConvertDetectionLimits2"
ierror = True
Exit Function
End Function