** **

**CHERENKOV CODE **

This description of the cherenkf code is taken from "I.S.U.-Style Cascade Simulations: Dublin User's Manual" written by Javier Bussons Gordo, May 1997. We have made modifications bringing the description current to v7.1 of cherenkf.c

cherenkov: generates an appropriate number of Cherenkov photons from the output of thekascadeprogram and tracks them to the ground. It loops over all showers first and then over all segments in each shower after the core has been relocated (offset). For each segment one needs to calculate the average direction cosines and the number of photons emitted (Jelley formula and Poisson deviate). For each photon one needs to get its wavelength, find the direction of the emitted photon, randomly choose the emission point within the segment, work out the corresponding altitude and see if the photon survives the atmosphere and hits any detector. Calculations of the atmospheric density and the index of refraction are also carried out.

The code calculates the time for the photon to reach the ground relative to the time for the primary to strike the ground. Since the relative time at the start of the segment and the times for the primary to travel over the height of the segment and the time for the secondary to travel over the segment are available from kascade output, the code can determine the relative time of photon emission at randomly selected points along the segment. Subsequent timing calculations from emission point to ground includes using the index of refraction as a function of atmospheric density.

Showers are uniformly scattered in impact parameter about the area between rmin and rmax: in the case of vertical incidence, a circle if rmin=0 or an annulus if rmin>0; for oblique incidence, an ellipse with minor_axis=rmax and major_axis=rmax/cosq if rmin=0 or the area between two co-focal ellipses with minor axes equal to rmin, rmax (and major axes scaled as above) if rmin>0. Thesedisplacements of the cores are simulated here sincekascadeproduces showers with their cores fixed through the origin.

At present the code does not include telescope arrays with telescopes outside the z=0 ground plane. This code is able to handle primaries not coming from the zenith and segments with arbitrary directions. The code includes options to apply reflectivity and PMT quantum efficiency to reduce the number of photons in the output file. We chose to apply these reductions in grisudet.c

The file, kextinct.dat, contains 51 values for each wavelength between 180 and 900 nm in steps of 5 nm which are used if the atmospheric extinction is on.

Cherenkf uses these procedures: we'll add a detailed flow chart later.

atm_passcalculates the probabiltity of a photon surviving the atmosphere on the basis of altitude of emission, observatory altitude and photon wavelength.betareturns the speed of a particle relative to that of lightdc_averageaverages direction cosines at the beginning and end of a showerdetanddet2return the number of the detector hit by a photonenergy_binbins by particle energyeta_seareturns the index of refraction minus one at sea level for a given wavelength (nm)extract_tokens.hconverts a string to a token arrayget_energyfinds, for a given energy bin, the corresponding midpoint energygammlnperforms some logarithmic calculationsget_time.hdetermines a current time and date stringgmsgives the optical depth (g/cm2) as a function of altitude (m).helpprints out the usage/help messageinitializeinitializes the 2-dimensional arraysintersectreturns the number of the detector seen as first hit by light from one segmentmtxmltpost-multiplies matricesnormalizeis used by the AVERAGE logging function to normalize the log counts to the total number of showerspeapplies a reflectivity cut and, possibly, the PMT quantum efficiency to determine whether a photoelectron is produced from a photon.photonsworks out the number of Cherenkov photons emitted at a given segment, using Jelley's formula and a Poissonian deviation and also returns the Cherenkov angle.poidevis used for the Poissonian deviationprtphotprints a photon-by-photon listqereturns the quantum efficiency of Hamamatsu 1398 UV glass tubes at a given wavelengthread_extintreads in the extinction coefficients set inkextinct.dat.ran3_aandran3_bare random number generatorsrel_gammacalculates the relativistic gamma factor as a function of kinetic energy and massread_array.hreads the telescope configuration fileread_headerreads and writes header information from the segment filerel_time calculates the relative time to ground for the photonrhogives the density (g/cm3) at a certain altituderotatedetermines the new direction cosines of an emitted Cherenkov photonscatterartificially offsets the shower cores location as explained earliertype_binclassifies particles by their typewrite_headerwrites cherenkf header information to the photon output filewrite_logwrites the log output to a file named on the command line (default is defined in LOGFILE)ydsreturns the altitude (m) at a certain depth (g/cm2)