# A Two-Dimensional Non-Destructive Beam Monitoring Detector for Ion Beams
## 2 Materials and Methods
It can capture images with a resolution of 3280 \(\times\) 2464 pixels and record videos with a resolution of 1920 \(\times\) 1080 pixels, with a maximum frame rate of 90 FPS. It is connected  
Figure 1: Left: scheme of the \(\pi^{2}\) working principle. The scintillating screen, oriented 45\({}^{\circ}\) with respect to the beam axis, can be moved in and out of the beam path by means of a mechanical actuator. The beam footprint on the scintillating screen is captured by the camera. Right: technical drawing of the device adapted to the DN 40 ISO-KF vacuum standard. The 4-way beam cross enclosure is not shown to allow for the visualisation of the scintillating screen. to the Raspberry Pi's Camera Serial Interface (CSI) port via ribbon cable, as shown in Figure 2 (right). A Python code was developed to optimise the detector operation and to provide an on-line analysis tool. To allow for fast processing, images can be taken and evaluated at a resolution of 640 \(\times\) 480 pixels. The analysis software includes a Graphical User Interface (GUI), for the on-line monitoring of the beam shape, position and intensity. The GUI provides a real-time display of the beam footprint on the scintillator screen, together with its horizontal and vertical projections. Both the horizontal and vertical profiles are automatically fitted to a Gaussian distribution from which the beam position and Full Width Half Maximum (FWHM) are extracted. The images can also be stored for off-line analysis. In order to accurately measure the position and size of the beam, it is important to establish a relationship between distances in the image, which are represented in pixels, and distances in the plane perpendicular to the beam motion, which are measured in millimetres. The challenge in doing so lies in the fact that the foil is inclined at an angle of 45\({}^{\circ}\) with respect to both the beam axis and the camera, causing the beam image to appear distorted as a result of perspective. Features that are located on parts of the foil furthest from the camera appear smaller in comparison to those that are located on closer parts of the foil. To correct this perspective distortion and restore the proper beam profile shape, a linear transformation is applied to the image using the OpenCV Python library for image processing. This transformation is accomplished by using a reference image of a beam that has been collimated into a square shape, as shown in Figure 3. The OpenCV library contains a dedicated routine that calculates the coefficients of the transformation matrix using the coordinates of the four vertices of the collimated beam on the raw image and their corresponding coordinates on the corrected image. After the transformation has been applied, the average resolution on the corrected image can be determined by dividing the length covered by the foil by the number of pixels in the image. The average resolution is 0.086 mm/pixel on the horizontal axis and 0.14 mm/pixel on the vertical axis. To benchmark the \(\pi^{2}\) measurements, experiments were carried out in which both radiochromic films and the UniBEuM detector were used as reference beam profile monitors. The chosen film was the FWT-60 from Far West Technology, Inc. ([22]). After irradiation, the films were scanned with an EPSON V800 flatbed scanner in transmission mode using the red, green and blue (RGB) channels. To evaluate the beam profile, the relative  
Figure 2: Left: \(\pi^{2}\) prototype installed on the BTL. Right: \(\pi^{2}\) read-out system based on a Raspberry Pi micro-controller and V2 camera. luminance, \(Y\), defined in [23], is calculated from the RGB components, scaled from 0 to 1, as follows:  
\[Y=0.2126*R+0.7152*G+0.0722*B. \tag{1}\]  
A calibration was performed to examine the relationship between the change in luminance and the integrated proton flux. The results showed that the relationship was linear for values below \(8\cdot 10^{12}\) cm\({}^{-2}\).