Joint ICTP-IAEA School on Novel Experimental Methodologies for Synchrotron Radiation Applications in Nano-science and Environmental Monitoring

Evaluation of XRF Spectra

from basics to advanced systems

Piet Van Espen [email protected]

20 Nov 2014

1 Content

1. Introduction: some concepts 2. Simple peak integration 3. Method of least squares 4. Fitting of x-ray spectra 5. Improvements to the model 6. Final remarks

2 Some basic concepts

Nature and science: a personal view

Nature = Signal + Noise

Science = Model + Statistics

3 Why spectrum evaluation?

element concentrations ⇔ net intensity of fluorescence lines

interference free continuum corrected

But: frequent peak overlap presence of a continuum

Especially in energy-dispersive spectra

4 4 Information content of a spectrum

Spectrum contains • Information: energy and intensity of x-rays the signal

• Amplitude noise: due to Poisson statistics ► fluctuations in the spectrum the noise • Energy noise: finite resolution of the detector ► nearly Gaussian peaks with a width of ~160 eV

5 Amplitude noise Counting events involves Poisson statistics

Poisson probability density function: The probability to observe N counts if the true number is µ

Property:

Poisson distribution ≅ µ µ and σ2 = µ

approximation is very good for µ (or N) ≥ 9

Poisson : P(N | µ=3) Normal : P(x | µ=3 σ2 = 3)

6 2 Spectrum analysis Energy Noise Resolution of ED-XRF spectrometers

2.35⇥ F E (9) Full Width at Half Maximum (FWHM) of a peak

2 2 2 FWHMPeak = FWHMElec + FWHMDet (10) 2 Spectrum analysis Electronic noise Intrinsic contribution ~100 eV 2.35⇥ F E (9) FWHM2 = FWHM2 +Det2 (10) Peakϵ energy to createElec e-h pairPealk 3.85 eV F Fano factor ~0.114 E x-ray energy in eV

Mn Kα @ 5.895 keV

FWHMDet = 120 eV

FWHMElec = 100 eV

=> FWHMPeak = 156 eV

7

2

2 Energy Noise Resolution of ED-XRF spectrometers

Cr – Mn – Fe overlap at ~20 eV Cr – Mn – Fe overlap at ~160 eV

8 Without amplitude noise (counting statistics) there would be NO PROBLEM

But it is part of the nature We can only measure longer or with a more efficient system

Without energy noise there would be LITTLE PROBLEM

The natural line width of x-rays is only a few eV!!! The observed peak width is the result of the detection process with a fundamental limitation imposed by the Fano factor

9 Information content of a spectrum

If no energy noise or no amplitude noise ► could determine the “information” unambiguously

Need methods to extract information in a optimum way These methods rely on “addition” information (knowledge) to extract the useful information

Not the method itself is important (if implemented correctly) but the correctness of the additional information.

10 10 2. Simple peak integration

11 Simple peak integration

Estimate

Uncertainty

As good as is can get We have to make assumptions if the assumptions (model) are correct! integration limits linear background no interference

12 3. Method of Least Squares

13 Method of least squares

Need to “estimate” the net peak area with highest possible • correctness (no systematic error) • precision (smallest random error)

Least-squares estimation (fitting): • unbiased • minimum

Limiting factors: • counting statistical fluctuations (precision) • accuracy of the fitting model

14 Method of least squares, straight line

2 SpectrumData: analysis {xi,yi}, i=1, 2, …, N 2 SpectrumModel: y(i analysis) = b + b x noise 2.35p0 1F i E (9) ⇥ ⇥ 2.35p F E (9) Fitting the model: ⇥ ⇥ estimating2 b0 and2 b1 2 FWHMPeak = FWHMElec + FWHMDet (10) 2 2 2 FWHMPeak = FWHMElec + FWHMDet (10) Criterion: SS = [y y(i)]2 = [y b b x ]2 = min (11) i i 0 1 i i SS = [y y(ii)]2 = [y b b x ]2 = min (11) X i X i 0 1 i Xi Xi ⇤SS Set of 2 equations in 2 unknowns b and b =0⇤SS yi = b0n + b1 xi (12) 0 1 ⇤b0 ! =0i yi = b0in + b1 xi Normal equations(12) ⇤b X ! X 0 i i ⇤SS X X 2 =0 xiyi = b0 xi + b1 x (13) ⇤b ⇤SS! i Direct2 analytical solution 1 =0i xiyi = b0 xii + b1 xi (13) ⇤b1 X ! X X Xi X Xi

15

2 2 4. Fitting X-ray Spectra

16 Least-squares estimate of x-ray spectrum parameters position area

1 (x x )2 Peak described by a Gaussian y(i)=b + A exp i p p2⇡ 22  linear parameter continuum width non-linear

n2 2 1 1 2 Criterion, agreement between model and data = [y(i) yi] (1) ⌫ wi iX=n1

y(i)=yCont(i)+ Aj RijP (i, Eij) (2) " # Minimum:Xj Xk

No direct analytical solution 2 Gain 2 1 E(i) Ejk P = G(i, Ejk)=Search χ exp for minimum (3) p2⇡ 2 jk jk " ✓ ◆ #

E(i)=Zero + Gain i (4) ⇥

17 1/2 Noise 2 = + ✏ FanoE (5) jk p jk "✓2 2 ln 2◆ #

Gain E(i) Ejk E(i) Ejk 1 T (i, Ejk)= exp erfc + 2 exp 1 p2 p2 22   h i

Gain E(i) Ejk S(i, Ejk)= erfc 2Ejk p2 

P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (6)

fS(Ejk)=µDet(Ejk)(a0 + a1Ejk)

fTK↵(Ejk)=b0 + b1µDet(Ejk)

fTK(Ejk)=c0 + c1µDet(Ejk)

(Ejk)=d0 + d1Ejk

Gain E1(i) E ↵ K jk , L jkp2⇡ jkp2 2jkp2!

K(x, y)=Re exp( z2)erfc( iz) z = x + iy (7) ⇥ ⇤

1 We can still apply the concept of least squares minimising the square of the differences between the model and the data

2 2 1 1 2 = (b, h, x0,w)= [yi y(xi,b,h,x0,w)] ⌫ i yi P The sum of squares is a function of the values of the parameters and for a given set of values should be minimum

In this case SS describes a 4 dimensional hyper-surface in a 5- dimension space We can only “see” in 3-dimensions but mathematically we can search in a higher dimensional space to locate the minimum h Starting from some initial values we can modify the parameter values until the minimum is reached. w

18 General form of such a search algorithm

1. Select starting values for all parameters bj = (b) and calculate the ch-square

2. Obtain (calculate, guess...) a change (increment or decrement) Δbj such that one (b +b) <(b) moves towards the minimum:

3. Replace the old parameter values with the new ones b ← b + Δb

4. repeat step 2 until the “true” minimum is found

Iterative process

AXIL = Analysis of X-ray spectra by Iterative Least-squares

19 n2 2 1 1 2 = [y(i) yi] (1) ⌫ wi iX=n1

Analytically important parameters: net peak areas y(i)=yCont(i)+ Aj RijP (i, Eij) (2) " # Xj Xk Statistical optimal estimate: 2 using correct weight (PoissonGain statistics w1 i =E yi()i) Ejk P = G(i, Ejk)= exp (3) p2⇡ 2 jk jk " ✓ ◆ # In general y(i) is non-linear → Marquardt – Leverberg algorithm Gradient search ↔ linearisationE(i)=Zero + Gain i (4) Reliable error estimated ⇥ But unstable 1/2 Noise 2 = + ✏ FanoE (5) jk p jk "✓2 2 ln 2◆ #

Gain E(i) Ejk E(i) Ejk 1 T (i, Ejk)= exp erfc + 2 exp 1 20 p2 p2 22   h i

Gain E(i) Ejk S(i, Ejk)= erfc 2Ejk p2 

P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (6)

fS(Ejk)=µDet(Ejk)(a0 + a1Ejk)

fTK↵(Ejk)=b0 + b1µDet(Ejk)

fTK(Ejk)=c0 + c1µDet(Ejk)

(Ejk)=d0 + d1Ejk

Gain E(i) E ↵ K jk , L jkp2⇡ jkp2 2jkp2!

K(x, y)=Re exp( z2)erfc( iz) z = x + iy (7) ⇥ ⇤

1 10 peaks ⇒ > 30 parameters !!!! WANT WORK in practice!!!! Need parsimony!!! But we can do better

2 We known the energies of the x-ray lines (in most cases)1 (xi xp) y(i)=b +1 A (expx x )2 Where they are depends on the energy calibration p2⇡ i p 22 y(i)=b + A exp  2 2 (the same applies to the width of the peaks: resolutionp2⇡ 1 calibration)2(xi xp) y(i)=b + A exp 2 p2⇡ 2 2 Gain  (Ei E(i)) ⇒ Add additional information to the modelG(i, E)= exp 2 Gain(E)p2⇡(Ei E(2i))2(E) G(i, E)= Gainexp (E E)2 Gaussian peak shape G(i, E(E)=)p2⇡ exp22(Ei ) (E)p2⇡ 22(E)  E(i)=Zero + Gain i ⇥ Energy relation: E(i)=Zero + Gain i ⇥ 1/2 Noise 2 Resolution relation: (E)= 2 + ✏FanoE1/2 Noise" 2p2 ln 2 # (E)= ✓ + ✏◆FanoE p Only 4 non-linear parameters"✓ 2 2 ln 2◆ # For 10 peaks only 14 parameters

21

1 1

1 1 (x x )2 y(i)=b + A exp i p p2⇡ 22  2 1 (xi xp) 2 y(i)=bGain+ A exp(E E(i))2 G(i, E)= pexp2⇡ i 2 (E)p2⇡ 22(E)  Gain (E E(i))2 G(i, E)= exp i E(i)=(ZeroE)p2+⇡Gain i 22(E) ⇥

Already better, but we know more 1/2 E(iNoise)=Zero2 + Gain i (E)= + ✏FanoE⇥ p We know (to some extend)"✓2 2 lnthe 2 ◆ratio between# lines of an element 1/2 Noise 2 (E)=IK↵2 IK + ✏FanoE ,p ... I"K✓↵12 2I lnK↵ 2◆ #

I I We can group lines togetherK↵2 (“peakgroup”), K ... with one “area” and fixed intensity ratiosIK↵1 IK↵

y(i)=yCont(i)+ Aj RjkP (i, Ejk) ( ) Xj Xk

Continuum Area Line Peak function ratio shape

for j elements (or peak groups)

10 elements ⇒ 10 Area’s + 4 calibration parameters

22

1

1 Further refinements: escape peaks Known position (energy) intensity (escape probability)

23 Sum peaks Known position relative intensity

24 And more Different background models polynomial exponential polynomial Bremsstrahlung background filter background

Parameter constraining

and more... 25 26 Highly flexible method • Fit individual lines, multiplets, elements… • Different parametric and non-parametric continuum models • Include escape and sum peaks Quality criteria • Chi-square of fit • uncertainty estimate of parameters Statistically correct • unbiased, minimum variance estimate of the parameters

“Resolving power” is only limited by the noise (counting statistic) BUT THE MODEL MUST BE ACCURATE

27 5. Improvements to the model

28 Incorrectness of the model

Not all peaks follow the energy calibration relation - incoherent (Compton) scatter peaks - spurious peaks (, γ-rays) - even the relation might not be linear

Not all peaks follow the resolution calibration relation - incoherent scatter peaks (are wider) - spurious peaks

Peaks are certainly not perfect Gaussians - shelf (step) due to detector effects (incomplete charge collection) - tailing due to radiative effects and detector effects - deviation due to natural line width (Lorentzian)

29 Incorrect fitting model ⇒ biased results

especially for trace elements

Solution Adapt the model Very inconvenient (fitting region, which lines to include...) when analyzing for each particular case many spectra

30 y(i)=yCont(i)+ Aj RijP (i, Eij) (1) " # Xj Xk

2 Gain 1 E(i) Ejk P = G(i, Ejk)= exp (2) p2⇡ 2 jk jk " ✓ ◆ #

E(i)=Zero + Gain i (3) ⇥

2 1/2 Noisey(i)=yCont(i)+ Aj RijP (i, Eij) (1) jk = + ✏ FanoEjk (4) p j " k # "✓2 2 ln 2◆ X # X y(i)=yCont(i)+ Aj RijP (i, Eij) (1) " # 2 Xj Xk Gain 1 E(i) Ejk Gain P = G(i, EEjk(i))=Ejk expE(i) Ejk 1 (2) T (i, Ejk)= exp jkperfc2⇡ "2 + jk # 1 2 p2 ✓ p2 ◆ 2 exp Gain22  1 E(i) Ejk P = G(i, Ejk)= exp (2) hjkpi2⇡ "2 jk # E✓(i)=Zero◆+ Gain i (3) Gain E(i) E ⇥ ImprovementsS(i, E )= erfc jk E(i)=jkZero2+EGain i p (3) jk ⇥ Improve 2 the peak profile  1/2 Noise 2 jk = + ✏ FanoEjk (4) Peak P (i, Ejk)=G(i, Ejk2 )+fSS(i, Ejk)+1/2fT T (i, Ejk) (5) Noise " 2p2 ln 2 # = + ✏ FanoE✓ ◆ (4) jk p jk "✓2 2 ln 2◆ #

Gain E(i) Ejk E(i) Ejk 1 Tail T (i, Ejk)= exp erfc + Gain E(i) Ejk1 E(i) Ejk 1 p2 p2 T (i, Ejk)= exp2 exp 22erfc  +  2 exp 1 p2 p2 22  h i  h i Gain E(i) Ejk Gain S(i,E E(ijk) )=Ejk erfc Step S(i, Ejk)= erfc 2Ejk p2 2Ejk p2  

P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (5) Adding 1 non-linear and 2 linear parameters for each peak!!!

Where is my parsimony gone!!!

1 31

1

1 Step parameterisation

Step fraction fS is related to the MAC of the detector crystal

Step is a fundamental aspect of the detector (charge loss by photo-electrons near the surface of the detector)

Tail fraction parameterisation

Tail fraction fT is related to the MAC of the detector and the type of radiation (Kα and Kβ)

The tail has a component due to the detector and a radiative component

32 y(i)=yCont(i)+ Aj RijP (i, Eij) (1) " # Xj Xk

2 Gain 1 E(i) Ejk P = G(i, Ejk)= exp (2) p2⇡ 2 jk jk " ✓ ◆ #

E(i)=Zero + Gain i (3) ⇥

1/2 Noise 2 = + ✏ FanoE (4) jk p jk Tail width parameteris"ation✓2 2 ln 2◆ #

similar magnitude overGain the entire E(i) Ejk E(i) Ejk 1 T (i, E )= exp erfc + energyjk range 2 exp 1 p2 p2 22   h i

Gain E(i) Ejk S(i, Ejk)= erfc 2Ejk p2 

P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (5)

⇒ Fitting parameters a0, a1, b0, b1, c0, c1, d0, d1

fS(Ejk)=µDet(Ejk)(a0 + a1Ejk)

fTK↵(Ejk)=b0 + b1µDet(Ejk)

fTK(Ejk)=c0 + c1µDet(Ejk)

(Ejk)=d0 + d1Ejk

(compare to Zero, Gain, Noise and Fano)

33

1 improvement

Fit of a NIST SRM 1106 Brass spectrum (SpecTrace 5000, Rh tube)

34 2 1 (xi xp) y(i)=b + A exp p 22 2⇡ 

2 Gain (Ei E(i)) G(i, E )= exp p 22(E) (E) 2⇡  1 (x x )2 y(i)=b + A exp i p p2⇡ 22 E(i)=Zero+ Gain i  ⇥ Gain (E E(i))2 G(i, E)= exp i 2 (E)p21⇡/2 22(E) Noise  (E)= + ✏FanoE p "✓2 2 ln 2 ◆ # E(i)=Zero + Gain i ⇥ I I K↵2 , K ... IK↵1 IK↵ 1/2 To account for peak shift and peak broadeningNoise 2 (E)= + ✏FanoE p "✓2 2 ln 2◆ # y(i)=yCont(i)+ Aj RjkP (i, E jk) Need to make the peak profile still a bit more complicated ) j ( k I I X X K↵2 , K ... IK↵1 IK↵ 2 Gain (Ei E(i)+E) G(i, E )= exp p 22(E) (E) 2⇡  y(i)=yCont(i)+ Aj RjkP (i, Ejk) j ( k ) δE peak shift Eparameterini (normallyE E 0.00)Eini + XE X   Gain (E E(i)+E)2 γ peak broadening parameterG(i, E(normally)= 1.00) exp i p 2 ini(E+)2⇡ 2 (E) ini   

Eini E E Eini + E These parameters are constrained   to vary within a certain range + ini   ini

35

1

1 y(i)=yCont(i)+ Aj RijP (i, Eij) (1) y(i)=yCont(i)+ Aj RijP (i, Eij) (1) j "" k ## XXj XXk

2 GainGain 11 EE((ii)) EEjkjk P P==G(Gi,( Ei,jk Ejk)=)= expexp (2)(2) jk pp2⇡2⇡ 22 jkjk jk "" ✓✓ ◆ #

EE(i()=i)=ZeroZero++GainGain ii (3)(3) ⇥⇥

2 11//22 NoiseNoise 2 jkjk== ++✏✏FanoEFanoEjkjk (4)(4) " p2p2 ln 2 # "✓✓2 2 ln 2◆◆ #

GainGain EE(i()i) EEjk EE((ii)) Ejk 11 The last step T (i, Ejk)= exp jk erfc jk + T (i, Ejk)= 1 exp erfc p2 + p2 2 exp 122   p2 p2 2 exp 22   For high Z elements the naturalh linei width becomes substantial relative to the detector resolutionh i Gain E(i) Ejk S(i, Ejk)=Gain erfc E(i) Ejk S(i, Ejk)= 2Ejkerfc p2 2Ejk  p2 

P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (5) P (i, Ejk)=G(i, Ejk)+fSS(i, Ejk)+fT T (i, Ejk) (5)

fS(Ejk)=µDet(Ejk)(a0 + a1Ejk) fS(Ejk)=µDet(Ejk)(a0 + a1Ejk) fTK↵(Ejk)=b0 + b1µDet(Ejk) fTK↵(Ejk)=b0 + b1µDet(Ejk) fTK(Ejk)=c0 + c1µDet(Ejk) f (E )=c + c µ (E ) TK (Ejkjk)=0d0 + 1d1EDetjk jk Replace Gaussian with the (Ejk of)= a Gaussiand0 + d1 Ewithjk a Lorentzian = Voigt profile Gain E(i) E ↵ K jk , L Gain p2⇡ E(i) pE2 2↵ p2 jk K jk jk , jkL ! p2⇡ p2 2 p2 with K(...) the complex error functionjk jk jk !

K(x, y)=Re exp( z2)erfc( iz) z = x + iy (6) ⇥36 ⇤

1

1 Natural line width at high Z elements becomes important e.g. W K ~ 50 eV

Gaussians Voigts

37 Original fit of a geological standard (JG1)

38 Improved fit of the geological standard (JG1)

Mo secondary target No background

39 NIST SRM 1155

40 NIST SRM 1247

41 More Details

Handbook of X-ray Spectrometry R. Van Grieken, A. Markowicz Marcel Decker, N.Y. 2002 ISBN: 0-8247-0600-5

Chapter 4: Spectrum Evaluation

42 Some final remarks: The future

Non-linear least-squares works if you have a good parsimonious model if you have TIME

X-ray fluorescence imaging: 256 x 256 image = 65536 x-ray spectra

@ 1 s / spectrum = 65536 seconds = 1092 minutes = 18 hours !!!!

Need to explore new methods Linear models? Multivariate models?

43 6. Final remarks

44 Thanks for your attention

45