\section{Filter\_gen: A general filter using a transmission table}
\label{filter-gen}
\index{Optics!Filter}
\index{Sources!from 1D table input}

%\component{Filter\_gen}{System}{$x_{min}$, $x_{max}$, $y_{min}$, $y_{max}$, $file$}{$options$}{validated, flat filter}
\mcdoccomp{optics/Filter.parms}

This component is an ideal flat filter
that changes the neutron flux according to a 1D input table (text file).

\textbf{Filter\_gen} may act as a source ($options$="set")
or a filter ($options$="multiply", default mode).
The table itself is a 2 column free format file which accept comment lines.
The first table column represents wavevector, energy, or wavelength,
as specified in the $options$ parameter,
whereas the second column is the transmission/weight modifier.

A usage example as a source would use
\verb+options="wavelength, set"+, if the first column in the data
is supposted to be $\lambda$ (in \AA ).
Another example using the component as a filter would be
\verb+options="energy, multiply"+ if the first column is $E$ (in meV).

The input parameters are the filter window size
$x_{min}$, $x_{max}$, $y_{min}$, $y_{max}$,
the behaviour specification string $options$ and the file to use $file$.
Additionally, rescaling can be made automatic with the $scaling$
and relative $thickness$ parameters. If for instance the transmission data file
corresponds to a 5 cm thick filter, and one would like to simulate a 10 cm thick filter,
then use $thickness = 2$.

Some example data files are given with \MCS in the
\verb+MCSTAS/data+ directory as \verb+*.trm+ files for transmission.

\begin{table}
  \begin{center}
  {\let\my=\\
    \begin{tabular}{|l|p{0.7\textwidth}|}
    \hline
    File name & Description \\
    \hline
    Be.trm       & Berylium filter for cold neutron spectrometers (e.g. $k < 1.55$  \AA$^{-1}$) \\
    HOPG.trm     & Highly oriented pyrolithic graphite for $\lambda/2$ filtering (e.g. thermal beam at $k$ = 1.64, 2.662, and 4.1 \AA$^{-1}$) \\
    Sapphire.trm & Sapphire (Al$_2$O$_3$) filter for fast neutrons ($k > 6$ \AA$^{-1}$) \\
    \hline
    \end{tabular}
    \caption{Some transmission data files to be used with e.g. the Filter\_gen component}
    \label{t:source-params}
  }
  \end{center}
\end{table}

The filter geometry is a flat plane. A geometry with finite thickness can be simulated by
surrounding this component with two slits.
