# pst-optexp: draw 4f correlator

I recently discovered pst-optexp and am trying to draw my optical setup for an experiment on it before my deadline. I was looking through the docs and it is an amazing package but there is so much in it that I'm finding it very hard to actually draw what I want, and I was hoping someone could help me. I have spent hours fiddling with it trying to get it to work but I haven't got anything useful and it is getting quite frustrating. My setup is a 4f correlator. I have tried to draw something similar to Ex. 11.5 (page 129 of the docs) but I can't position the lens correctly and get the beams to focus the way I want (it's not worth posting my attempt because I don't think it's at all usable).

A crude sketch of my experimental setup is shown below. As you can see there are a lot of lenses and foci to get right.

I know, that the workflow maybe isn't very intuitive and you'll need to workout how you can best work.

Here is a document which reproduces your experimental setup:

\documentclass[margin=5pt, pstricks]{standalone}
\usepackage{pst-optexp}
\begin{document}
\begin{pspicture}(14,3.5)
\psset[optexp]{labeloffset=0.8, labelangle=180}
\pnodes(2,1.5){Start}(12,1.5){End}
\begin{optexp}
\optbox[innerlabel, position=start](Start)(End){Laser}
\lens[lens=-1.5 -1.5 1 0.1, abspos=1, n=2](Start)(End){$D_1$}
\lens[lens=3 3 1.3, abspos=2.5, n=1.7](Start)(End){$C_2$}
\pinhole[abspos=4, phwidth=0.05](Start)(End){$A_3$}
\lens[lens=3 3 1.3, abspos=5.5, n=1.85](Start)(End){$C_4$}
\lens[lens=3 3 1.3, abspos=8.5, n=1.95](Start)(End){$C_5$}
\optbox[innerlabel, position=end](Start)(End){CCD}
\drawwidebeam[beamwidth=0.2]{1-4}
\drawwidebeam[beamwidth=0.1, beamdiv=20]{4-7}
\end{optexp}
\optplate[compname=fourier,
abspos=7, plateheight=1.5,
labelalign=b,
linewidth=0.5\pslinewidth, linestyle=dashed](Start)(End)%
{\begin{tabular}{@{}c@{}}Fourier\\plane\end{tabular}}
\psset{arrows=|*-|*}
\pcline([offset=-1]\oenodeCenter{1})([offset=-1]\oenodeCenter{2})
\ncput*{$f_2$}
\pcline([offset=-1]\oenodeCenter{3})([offset=-1]\oenodeCenter{4})
\ncput*{$f_4$}
\pcline([offset=-1]\oenodeCenter{4})([offset=-1]\oenodeCenter{5})
\ncput*{$f_4$}
\pcline([offset=-1]\oenodeCenter{5})([offset=-1]\oenodeCenter{fourier})
\ncput*{$f_4$}
\pcline([offset=-1]\oenodeCenter{fourier})([offset=-1]\oenodeCenter{6})
\ncput*{$f_5$}
\pcline([offset=-1]\oenodeCenter{6})([offset=-1]\oenodeIn{7})
\ncput*{$f_5$}
\end{pspicture}
\end{document}


In this case my workflow was as follows:

1. Define start and end point.
2. Position all components from left to right using an absolute position (abspos).
3. Get the shape of all lenses like you want them to appear.
5. Adapt the refractive index n for every lens to fit your required beam path.
I wrapped all components and beams inside an optexp environment, so that the beam is drawn below the components. Only the fourier component, which indicates the Fourier plane, is drawn afterwards because it must be over the beam.