# Description of the Simulations {#sec:description} The simulation process consists of the following steps: 1. Air shower and Cherenkov light production using the CORSIKA simulation code [@Heck:1998vt]: 1. Extensive air shower simulation: The interaction of a primary particle (very high-energy $\gamma$-ray or background cosmic ray) in the atmosphere and the development of the particle cascade through the atmosphere is simulated 2. Cherenkov light production and propagation: Cherenkov photons emitted by the particles traversing the atmosphere are traced to the ground taking into account scattering and absorption in the atmosphere by molecules and aerosols. For efficiency purposes, Cherenkov photons are not simulated one by one but in bunches. Only those photons expected to fall within a fiducial sphere centred on the rotation angle of the telescopes and with a radius larger then that of the telescope dish are recorded (see Fig. [1]. ![[\[fig:sphere\]]{#fig:sphere label="fig:sphere"} Definition of grid cells at the detection level to which a detector sphere gets linked for detailed inspection of intersections of photon bunches with the sphere. The shadow of a sphere is large enough to include all Cherenkov light emitted up to 10 degrees from the shower direction and intersecting the sphere. Figure taken from Ref. [@Bernlohr:2008kv]. ](../_figures/iact3d-nt.pdf){#fig:sphere width="60%"} For each event the following parameters are available at the end of this step: The type and energy of the primary particle; a list of Cherenkov photons with their position on the ground or the telescope level, wavelength, incident angle, emission height, arrival time (counted since entrance of the primary particle into the atmosphere) and the Cherenkov photon bunch size. This list of photons hitting the fiducial sphere is passed to the package [@Bernlohr:2008kv] for a detailed simulation of the telescope. 2. Simulation of the detector response using the package [@Bernlohr:2008kv]: 1. Extinction (absorption and scattering) losses of Cherenkov photons traversing the atmosphere. 2. Ray-tracing of the Cherenkov photons through the telescope optics (more details below). 3. Camera simulation, trigger, and readout (more details below). This step includes the addition of noise photons from the night-sky background. ## Optics The propagation of Cherenkov photons through the telescope optics includes the effects of shadowing, the simulation of reflection (wavelength dependent) and scattering of photons off individual mirrors. A precise ray-tracing of both incoming and reflected photons, taking into account the shadowing due to masts, trusses and camera lid can be performed using , but is not done in standard production as it requires a lot of computing time. Therefore, only the shadowing of the camera, controlled by the parameters (actual flat-to-flat distance for square and hexagonal shapes) and , and the shadowing of the secondary mirror and its baffle (if applicable) is handled explicitly. The shape of the camera can be circular, square or hexagonal, controlled with the parameter. The effect of shadowing by other elements, like the masts, is taken into account by parametrising the fraction of photons lost as a function of off-axis angle. The parameters are passed to through the parameters set. ### Reflectivity The mirror reflectivity is considered in the simulation as a function of the photon wavelength and (optionally) the photon incidence angle. It is passed to through the parameter. If the reflectivity is given only as a function of the photon wavelength, then it should be given for the typical (average) incident angle. For dual mirror optics a different reflectivity for the secondary mirror can be specified with . Only specular reflectivity is considered in the simulation of Cherenkov light. Total reflectivity (the combination of specular and diffuse reflection) is only required for the calculation of the night-sky background rates. ## Camera The simulation of the photon detectors takes into account collection efficiencies, amplitude fluctuations, signal shapes, after-pulsing (specific for photomultipliers), optical cross talk (specific for SiPM), and the dynamic range due to the finite number of cells per device. The camera simulation also include efficiency and gain variations between pixels. It is worth noting here that it is assumed that structural noise in the camera is calibrated out on the fly; what remains, and what is simulated here, is the cell-wise uncorrelated Gaussian noise that remains. ### Quantum efficiency The main relevant efficiency parameter for the camera is the quantum efficiency (photon detection efficiency for SiPM) as a function of wavelength, given in table form in a file passed to through the parameter . The quantum efficiency can vary between the photo detectors. The magnitude of the variation is set by a wavelength-independent parameter, . There is an option to set the photo-detector collection efficiency, (this is generally set to 1.0, as the non-amplified photo-electrons are included in the amplitude distribution of the single-p.e. spectrum). Average gain and gain variation of the photo detectors are set through and respectively. The is only relevant for the DC current as it is checked to turn pixels with star light off. ## Transit time The simulation includes the mean transit time through the detector () and the transit time jitter of individual photons The trigger time for the signal is calculated from the median of the photon arrival times. The time defining the signal is calculated from the median of the photo arrival times. A fixed time delay () can also be added. Finally, the transit time also includes a correction factor to include the quantum efficiency and voltage variation, along with variation of the FADC amplitude resulting from gain variation, such that $$\text{TRANSIT} = \ \hyperref[par:pm-transit-time]{\textbf{pm\_transit\_time}} \times (-1+\frac{1}{\sqrt{\zeta \cdot v}}) + \text{RandGauss}(0, \hyperref[par:transit-error]{\textbf{transit\_error}}) \, , \label{eq:transitTime}$$ where the voltage relative to the expected average is $$v = \text{RandGauss}(1, \hyperref[par:pm-voltage-variation]{\textbf{pm\_voltage\_variation}}) \, . \label{eq:voltageVar}$$ Generally, from equations [\[eq:transitTime\]](eq:transitTime){reference-type="eqref" reference="eq:transitTime"} and [\[eq:voltageVar\]](q:voltageVar){reference-type="eqref" reference="eq:voltageVar"}, higher than nominal voltage leads to a negative delay, while lower voltage results in positive delay. The quantity $\zeta$ is defined as $$\zeta = \ (g_{\text{rel}})^{(1/\hyperref[par:pm-gain-index]{\textbf{pm\_gain\_index}})}$$ if $\hyperref[par:pm-gain-index]{\textbf{pm\_gain\_index}} > 0$, and $$\zeta = \ 1$$ otherwise. The value of the random relative pixel gain, $g_{\text{rel}}$, is set as $$g_{\text{rel}} = \ \text{RandGauss}(1, \hyperref[par:gain-variation]{\textbf{gain\_variation}})/ \text{RandGauss}(1, \hyperref[par:qe-variation]{\textbf{qe\_variation}})) \, ,$$ when flatfielding is used ( = 1), or as $$g_{\text{rel}} = \ \text{RandGauss}(1, \hyperref[par:gain-variation]{\textbf{gain\_variation}})$$ without flatfielding ( = 0). The signal amplitude scales (, and ) are set separately, but they are all scaled by the same $g_{\text{rel}}$. The parameter should be set in case transit time differences are compensated by programmable delays. The compensation itself is done in nanosecond steps set by with an assumed accuracy in its evaluation of . With TRANSIT defined as the per-channel delay, the compensation is applied as follows: $$\begin{aligned} \text{TRANSIT} &= \ \text{TRANSIT} - \hyperref[par:transit-time-compensate-step]{\textbf{transit\_time\_compensate\_step}} \times \nonumber \\ &\times \frac{ \text{TRANSIT} + \text{RandGauss}(0, \hyperref[par:transit-time-compensate-error]{\textbf{transit\_time\_compensate\_error}}) }{ \hyperref[par:transit-time-compensate-step]{\textbf{transit\_time\_compensate\_step}} + 0.5 } \, . \label{eq:delayCompensation}\end{aligned}$$ ## Photo-detector response The single photo-electron amplitude is randomly drawn from the response spectrum set by . The same is done for the night-sky background (NSB) photons, however these are sampled from the single photo-electron spectrum which includes after-pulsing. The amount of NSB in each pixel is set by multiplied by and then drawn from a Poisson distribution around this value. Once it has been determined whether or not the photons were detected, the simulation of the electronics begins (trigger and readout). The electronics in are described by way of a comparator/discriminator for the trigger and an FADC for the readout. ## Trigger Three different trigger logics are available in the simulations, analog and digital sum, and a majority trigger logic (selected with ). The input signal sent to the discriminator is calculated from the list of photoelectrons, each assigned an amplitude defined by the parameter , scaled to include the gain variation () and quantum efficiency variations , $$\begin{aligned} A_{\text{DISC}} =& \ \hyperref[par:discriminator-amplitude]{\textbf{discriminator\_amplitude}} \\ \times & \text{RandGauss}(1, \hyperref[par:gain-variation]{\textbf{gain\_variation}})/\hyperref[par:qe-variation]{\textbf{qe\_variation}} \, .\end{aligned}$$ The shape of each pulse signal is generated from the input discriminator pulse shape file () and added to the total discriminator signal, shifted by the appropriate time. The input signal to the discriminator is oversampled with respect to the FADC sampling. Typically, the sampling rate in the simulation of discriminator input signals is four times higher than the FADC sampling rate (). The discriminator logic is applied to the resulting waveform. ## Readout The FADC signal is treated in a similar fashion as the discriminator signal, with the amplitude set by (scaled with the quantum efficiency and , similarly to the discriminator amplitude), $$\begin{aligned} A_{\text{FADC}} &= \ \hyperref[par:fadc-amplitude]{\textbf{fadc\_amplitude}} \\ & \times \text{RandGauss}(1, \hyperref[par:gain-variation]{\textbf{gain\_variation}})/ \hyperref[par:qe-variation]{\textbf{qe\_variation}} \, . \label{E:fadcamp}\end{aligned}$$ The FADC pulse shape is set by a table passed to through the parameter. The number of bins to be simulated for the FADC signal is set by the parameter . The number of readout bins is defined by , starting before the actual trigger (Note that the number of simulated bins needs to be large enough to allow the readout bins to shift in order to keep the trigger in the same time bin, this will be obvious in events with a large time gradient). The maximum signal level in an FADC channel can be set with or . Each time bin is assigned a pedestal value defined by the parameter . The optional channel-to-channel variation is set with (random Gaussian). Along with the pedestal, Gaussian noise set with is added in the digitization process to each bin (note once again that there is no implementation of structured noise within the camera). # Derived MC parameters The following parameters are derived from dedicated simulations runs in combination with several parameters of the MC Model: - **night\_sky\_background**\ The photo-electron rate per pixel due to night-sky background is calculated using the nominal NSB rate and spectrum (see [CTA glossary on Jama](https://jama.cta-observatory.org/perspective.req#/items/28364?projectId=11)), taking into account the mirror area, reflectivity, shadowing, camera window transmission, light guides, and photo-detection efficiency. See for the value obtained for . - **trigger\_threshold**\ The trigger threshold are derived from MC simulations using the safe threshold definition, which is applied in a similar way to all CTA telescopes types. The safe threshold is defined as the intersection point of the trigger rate curve for night-sky background (at 2$\times$ dark conditions) and 1.5$\times$ the trigger rate from cosmic-ray protons. For the reference spectra for NSB and cosmic-ray protons, see the CTA Glossary on the Jama system ([NSB definition](https://jama.cta-observatory.org/perspective.req#/items/28364?projectId=11); [reference proton flux](https://jama.cta-observatory.org/perspective.req#/items/28381?projectId=11)).