# Setting the BBCal and HCal thresholds

## BBCal Discriminator threshold conversion fator

The conversion (rough) between the BBCal sum trigger discriminator threshold in mV to energy deposited in the lead glass in MeV is approximately 7.2 MeV/mV for SBS-8 configuration.

## HCal Discriminator threshold conversion factor

The conversion between the HCal sum trigger discriminator threshold in mV to energy deposited in the scintillators in MeV is approximately 6.914 MeV/mV.

This was calculated using cosmic rays. The average cosmic ray deposits ~14 MeV in scintillators for a single PMT and this corresponds to an fADC integral of roughly 8 pC. If a spectrum of the cosmic rays' amplitudes is made the peak is at 18 mV in the fADC. Now we track this 18 mV at the fADC back in the electronics to the PMT output. First the 18 mV is multiplied by 2.5 which is the approximate amplitude attenuation due to the 100 m cables connecting the DAQ and FE electronics. This gives a 45 mV signal out of the FE amplifiers. These are 10x amps so this equated to 4.5 mV signals out of the PMTs for the average cosmic ray which deposited 14 MeV in the scintillator.

Now we track the signal forward from the PMT to the HCal sum trigger discriminator on the FE. We have 4.5 mV off the PMT multiplied 10x to 45 mV out of the FE amplifier. This then passes through a 50-50 splitter panel leaving 22.5 mV. This signal then passes through the FE summing modules which attenuate the signal by a factor of 0.09 giving 2.025 mV that enters the HCal sum discriminator. This 2.025 mV signal corresponds to 14 MeV deposited in the scintillators. This gives a conversion factor of 6.914 MeV/mV.

Example: Say the kinetic energy of the elastic nucleons is 5.3 GeV and you want a threshold of 50% of this energy. First calculate the amount of energy the nucleons deposit in HCal's scintillators, which is ~7.95% of the total energy. 5.3 GeV * 0.0795 = 0.42135 GeV deposited in the HCal scintillators. The target threshold is half this energy, or 210.675 MeV. Now divide by the conversion factor. 210.675 MeV/ 6.914 MeV/mV = 30.47 mV for our discriminator threshold setting. Note that this is the discriminator threshold readback value and not the DAC voltage setting, which will need to be tuned to give the proper readback.

## How to adjust BBCal and HCal discriminator thresholds

• From any Hall A counting hall machine open a terminal execute the following command:
``` vncviewer adaq1:7
```

• Failure Modes:
1. The GUI is not up on the vnc window: In such a case please follow the instructions written below to relaunch the GUI.
2. The vncserver is non-existing: In such a case please do not waste time in setting up another vncserver, instead go ahead and open a terminal on the computer you are on and follow the instructions written below to launch the GUI. Afterwards notify an expert.

If due to some reason the DAC control GUI is not up in the vnc window then please open a terminal inside the vnc window and follow the instruction written below.

``` ssh sbs-onl@adaq1
```
• To set the environment variables do:
``` source setup.sh
```
• Execute the following command to open the DAC control GUI:
``` python3 DAC_Control_GUI.py
```
• After executing the command, the a new DAC GUI should pop up which has instructions to load, initialize and save the settings and adjust the thresholds. The terminal in which the command was executed should also print the previous settings of all the channels.
``` caget SBSDaqPi1:thresh1 - for HCAL threshold