How to know spot size for as each tilt&decenter at detector in NSC mode

  • 5 August 2022
  • 6 replies

When Source and detector’s position are fixed and mirror’s tilt/decenter are only changing, I want to know the spot size and centroid position for as each tilt(θx,θy,θz) & decenter(X,Y,Z) of mirror at Detector.
(I want FWHM spot size. But if it is impossible, RMS spot size is ok.)


How can I know it by using tolerancing? If it is impossible, how can I do?



Best answer by David.Nguyen 11 August 2022, 16:44

View original

6 replies

Userlevel 6
Badge +2

Hi YoungDae,


Have you tried the procedure described in this article, which shows you how to include a Merit Function Operand in the tolerance report?

Regarding the FWHM Spot Size, I don’t think it is readily available in OpticStudio, but it is something you could potentially program in a User-Defined Operand. You might need to consider the case of an elliptic spot rotated at an arbitrary angle, which might not be straightforward, but it really depends on what kind of assumptions you can make on your specific spot.

I hope this helps, and take care,



Hi David. Nguyen,


I had tried to calculate them by using ‘user script’, but I counldn’t because I didn’t know how to calculate FWHM by using ‘user script’…. In the end, I did all of them one by one.

Can you show me how to get the FWHM for me by using ‘user script’?

If I ever need to do it again, we'll use your method.

Thanks for your all helps!

Userlevel 6
Badge +2

Hi YoungDae,


Can you tell me how you calculated the FWHM in your case? I can think of a general solution to finding the FWHM by fitting a rotated 2D Gaussian function, but it is not straightforward to implement. If you only care about the size along the X and Y axes, it makes the problem easier.

Take care,



Hi David.Nguyen, 


I calculated the FWHMs by using “Cross section row” and “Cross section column” in Rectangular Detector.

After tilt and position of Mirror changing, I checked the beam center at first.

I changed the mirror’s parameters as above, and then checked Peak Irradiance and found a point 50% of peak.

Userlevel 6
Badge +2

Hi YoungDae,


That is exactly why I asked. When you make the assumption that the spot is aligned with X and Y, it is easier to calculate the FWHM.

If we make another assumption: The Spot has a Gaussian shape. Then it becomes even easier, to the point where I actually programmed a User-Operand for you.

I will not copy the source code here for visibility, but you can find it on my GitHub here. This is what the code does in short:

  1. Retrieve detector half-widht and pixel #
  2. Retrieve the centroid location (using NSDD and Data equal to -6 and -7, like in your screenshot)
  3. Calculate the row and column indexes based on the centroid location and detector size
  4. Calculate the standard deviation of the centroid row and index (in pixel size)
  5. Multiply the standard deviation by the pixel size to have it in lens unit
  6. Multiply the standard deviation by 2.355 to obtain the FWHM (assuming the spot is Gaussian-shaped)

The User-Defined operand is UDOC03.exe (UDOC01 and UDOC02 were already used in my case, feel free to change it to whatever number suits you).

This operand has a single input parameter: the Detector Number (note that I have only tested with Detector Rectangle so far).

This operand returns up to 6 parameters:

  1. X-FWHM [lens unit]
  2. Y-FWHM [lens unit]
  3. X-sigma [lens unit]
  4. Y-sigma [lens unit]
  5. X centroid location [lens unit]
  6. y centroid location [lens unit]

I have made a dummy example with a Source Gaussian (Beam Size = 0.2 mm in radius at 1/e^2) for demonstration purposes:

This is the result in the Merit Function:

Notice that Hx is 2 for the first UDOC operand (it is the detector number). Also remember that the UDOC is only computed once in this instance despite the presence of five additional UDOC operands (that are only here to display the other results calculated in the UDOC executable).

The first two UDOC operands are the X/Y FWHM. The UDOC operands with Data = 2/3 are the X/Y sigma, and remember that 2 * sigma gives you the 1/e^2. So, it is relatively accurate (0.101 instead of 0.100). The last two UDOC operands have the X/Y centroid locations that match the Source Gaussian X and Y Position.

We made two big assumptions that are important to keep in mind, and also all my interpolations are to the neirest neighbor. Despite all that, it should give you a good idea of the FWHM.

Please let me know if you try it. Take care,

PS: Please also double-check the results of the code yourself, I might have made a mistake in writting it, this is just a draft to illustrate how you could calculate the FWHM from your Detector Rectangle.

PSPS: if more people find it useful perhaps we can refine the code and have it in the Code Exchange at a later stage, what do you think @Sandrine Auriol?



Userlevel 6
Badge +2

By the way, I’ve just realized @Allie wrote a ZPL operand that also calculates the FWHM. I’ve not compared both, but perhaps you can also give it a shot.

Take care,