CORSIKA-IW: a Modified Version of CORSIKA for Cascade Simulations in Ice or Water Part I : User’s Guide & Technical Considerations

J. Bolmont December 9, 2008

Abstract This note document a modified version of the simulation program CORSIKA. Modifications were done to allow the simulation of particle interactions in ice or salt water instead of air. The new version is called CORSIKA-IW, IW standing for “Ice & Water”. In this first part, after describing the origin of this work, I will give details about how to install and run the . I will describe in details the modifications I made to the original code and the features of this new version. I will compare some results of CORSIKA-IW with the ones of other simulation packages in the second part.

Contents

1 Introduction2 1.1 Origins of the project...... 2 1.2 Why CORSIKA ?...... 2 1.3 Limits of Sloan’s modified version of CORSIKA...... 3 1.4 Overview of this note...... 4

2 Running CORSIKA-IW4 2.1 Download and installation...... 4 2.2 Running a simple simulation...... 7

3 Technical details8 3.1 Principles of CORSIKA configuration...... 8 3.2 Changes in the code...... 9 3.2.1 configure.in...... 10 3.2.2 config.h.in...... 11 3.2.3 .h...... 12 3.2.4 corsika.F...... 12 3.3 EGS...... 18

4 Conclusion and present status of the code 18

1 1 Introduction 1.1 Origins of the project When high energy interact in a dense medium like ice or water, they interact producing an electromagnetic cascade. Below ∼100 PeV, the cross sections of the processes involved in cascades development (mainly bremsstrahlung and pair production) are well represented by Bethe-Heitler equations [3]. At these energies, the length of the cascades grows linearly with the logarithm of the energy. However, at high energies (above ∼100 PeV in ice or water) or for high density materials, bremsstrahlung and pair-production prosseses are supressed by a mech- anism formulated by Landau, Pomeranchuck and Migdal [4,5]. This effect, known as the “LPM effect”, is due to multiple Coulomb scattering by neighbouring atoms and is responsible for a decrease of the bremsstrahlung (BS) and pair production (PP) cross sections. As the cross sections decrease, the particles need more time to lose their energy and the cascades are longer. For example, a 100 EeV cascade can be ∼200 m long. The initial idea leading to the development of CORSIKA-IW was to be able to take into account the LPM elongation of the cascades in the IceCube simulation software, to check if the elongation would lead to a better angular resolution for very high energy νe events. After investigating the possible use of different simulation packages, it turned out that CORSIKA was the best solution to carry out such high energy simulations including the LPM effect. CORSIKA [6] is a tool devoted to the simulation of extensive air showers. It is largely used by the ground based gamma-ray astronomy community. Modifications were necessary to make the code work in ice or water. The two basic requirements were: • Possibility to simulate cascades in the LPM regime (E > ∼100 PeV); • Possibility to simulate cascades at very high energies up to ∼100 EeV.

1.2 Why CORSIKA ? The first question that the reader will have at this point is: “Why using COR- SIKA instead of GEANT ?”. It is essential to understand that my first goal was to simulate cascades in the LPM regime. So the answer to the question is simply that does not simulate the LPM effect for pair-production. In addition, CORSIKA is a program which is much simpler than GEANT, thus allowing a faster development process.

GEANT4 CORSIKA ZHS EM processes O(TeV) ∼100 EeV ∼100 EeV Had. processes ∼20 TeV ∼100 EeV - LPM effect BS only yes yes

Table 1. Comparison of highest energies that can be simulated by GEANT4, CORSIKA and ZHS for electromagnetic (EM) and hadronic (Had.) processes. ZHS does not simulate hadronic processes.

2 corsika.car

CMZ option selection: THIN, QGSJET, etc.

cmfor.f

Sloan’s modifications in the code

cors_h2o.f

compilation + link

corsika

Figure 1. Schematic view of the Sloan’s version development process. With COR- SIKA 6204, CMZ was used to select the main options, turning the car file into a F77 file. The use of CMZ has been replaced by the use of C preprocessor commands. The file obtained is modified to include changes for salt water and compiled to give the main executable file.

Before coming to CORSIKA, I started by looking at different simulation tools as GEANT4, MARS, etc. and I noticed that none of them was able to simulate completly the LPM effect. Another tool called ZHS [7] (after the name of the developpers Zas, Halzen and Stanev) is able to simulate the LPM effect both for pair-production and bremsstrahlung, but it does not simulate hadronic interactions. In addition, the energy range in which the simulations can be done is much wider in CORSIKA (cf. Tab.1). Another important reason to justify the choice of CORSIKA is the work done by the ACoRNE collaboration [8]. One of the member of ACoRNE, T. Slaon, modified the version 6204 of CORSIKA to allow simulations in water or salt water. This modified version is the base for CORSIKA-IW, which brings some important improvements, as described in the next section.

1.3 Limits of Sloan’s modified version of CORSIKA One interesting feature of CORSIKA is the possibility to use many different hadronic interaction packages and many different options. The user selects which package he wants to use during the configuration process. As will be explained later, the configuration step turns a master file corsika.F into a regular F77 file corsika.f where different parts of the code are enabled or disabled depending on the choices of the user and the options he selected. The main limitation of Sloan’s verision of CORSIKA is that the choice of the options is already done and cannot be changed by the user. For example, the hadronic package QGSJET is selected, and the use of any other hadronic interaction model is simply impossible. A schematic view of the Sloan’s version development process is given by Fig.1.

3 Then let us summarise the limits of Sloan’s version: • Static code: all the options are set and the user cannot do anything about it; • As a result of the first point, only QGSJET is available; • The version of CORSIKA used for the modifications is quite old (6204); • The simulations are done in salt walter only; • The size of the simulated volume is fixed to 20 m. CORSIKA-IW was developped to overcome these problems starting from a more recent version of CORSIKA (version 6600, released in april 2007). The most im- portant features are: • The options can be selected during the configuration process; • All CORSIKA hadronic packages are available; • The version of CORSIKA used for the modifications is 6600; • The simulations can be done in salt walter, ice or air. The medium is selected in the configuration step; • The size of the simulated volume is set by an entry in the datacard.

1.4 Overview of this note Section §2 of this note has been written for poeple who do not know CORSIKA. In this section, they will learn the basics of how to configure CORSIKA-IW and how to run a simple simulation. As CORSIKA-IW keeps almost all of the features of the original CORSIKA version, this section does not replace the main CORSIKA User’s Guide. In section §3, I will give more technical details about how the changes in the code were done. This section will help the user in the case he wants to make other modifications. NB: This note does not replace the CORSIKA User’s Guide [1], but comes in addition to it.

2 Running CORSIKA-IW 2.1 Download and installation To use the code, you will only need a F77 compiler, either g77 or the more recent gfortran. Several compilers have been tested under different operating systems. See §3 for more details. CORSIKA-IW can be downloaded on the web [2]. On this web page, the different versions of the code with release notes can be found. Right-click on the version number in the table to download the archive. After downloading the archive and moving it to a work directory, the first thing to do is to un-tar it:

[myhost] Downloads> tar xvfz corsika-6600-wi-v0.81.tar.gz corsika-6600-wi-0.81/ corsika-6600-wi-0.81/configure corsika-6600-wi-0.81/NEWS ... Now, move to the directory and look at its content:

4 [myhost] corsika-6600-wi-0.81> ls -F AUTHORS README configure* lib/ CHANGES_WI README_WI configure.in nexus/ COPYING aclocal.m4 corsika-install* run/ ChangeLog autom4te.cache/ doc/ src/ INSTALL bernlohr/ dpmjet/ urqmd/ Makefile.am cDO_NOT_RUN_CONFIGURE epos/ Makefile.in coast/ herwig/ NEWS config/ include/ This directory tree is similar to the original CORSIKA directory. Only two files have been added: CHANGES WI (list of changes) and README WI (some informa- tions about configuration and compilation). Note that the file README WI could be interesting to read at this point. The directory doc/ contains the original CORSIKA documentation. As CORSI- KA-IW only modifies the medium in which the particles propagate and interact, almost all the original CORSIKA documentation is still valid! Later in this note, the changes are described in more details. The final executable file generated by the compilation procedure will be located in run/. The file cDO NOT RUN CONFIGURE is empty and is just here to remember you that on the contrary to almost all Unix software, you MUST NOT run the script configure directly. Instead, use corsika-install. The word installation is un- proper in the sense that all the products stay in the main directory tree in corsika- 6600-wi-0.81. So, now run corsika-insall:

[myhost] corsika-6600-wi-0.81> ./corsika-install The script will start by looking at your environment to check the presence of some essential utilities. The messages will start with something like 1:

Compile CORSIKA in lib/Darwin/ and copy executable in run/

checking whether to enable maintainer-specific portions of Makefiles... no checking build system type... i686-apple-darwin9.3.0 checking host system type... i686-apple-darwin9.3.0 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk ... One important thing to look at at this step is what the script tells you about your compiler. You will see the following lines:

Following environment variables will be used ... LIBS = -L/path/to/corsika/corsika-6600-wi-0.81/lib/Darwin/lib LDFLAGS = CC = CFLAGS = -g CXX = CXXFLAGS = -g CPP = CPPFLAGS = F77 = i386-apple-darwin9.1.0-gfortran-mp-4.2 FFLAGS = -g Here, you can check which compiler will be used. If for some reason you know that the compiler displayed here does not work properly, or if you want to use a different compiler, you can set the environment variables $F77 and $CORSIKA US- ER COMP before running corsika-insall. After these lines, you will see a lot of other checks, and finally, you will get the following:

1The listings of this note denote the situation for Mac OS X (Darwin). The output will be slightly different for other operating systems.

5 Welcome to the CORSIKA extraction macro ======

create an executable of a specific CORSIKA version

Please read the documentation for a detailed description of the options and how to use it.

Note : press Enter (blank line) to select an option followed by "(default)"

grep: include/config.h: No such file or directory grep: include/config.h: No such file or directory ------

Which material do you want to use ? 1 - AIR (default) 2 - ICE 3 - SALT WATER

r - restart make x - exit make (only one choice possible) Here, you have the choice to select the medium in which the simulation will take place. To select a choice, type the corresponding number and Enter or just Enter if you are happy with the default choice. At each step, you can exit the configuraton script by typing x or retart from the beginning by typing r. Here you can see that ’AIR’ is the default option: by selecting this choice, you will get the original version of CORSIKA 6600 for air. If you select ’ICE’ by typing 2 and Enter, you will see a warning message:

select ICE Warning : you are about to configure Corsika for use in ice ! This material is not supported in the official release of Corsika. If you think you found a bug, try first the version for air in the same conditions: - If the bug is still here, contact corsika developpers. - If the bug is no more here, contact J. Bolmont . (press ’Enter’ to continue ...) Then press Enter again to go on with the configuration. The following questions that will be asked to you are from the original version of CORSIKA, so I am not going to describe them here. You will have to chose which models you want to use for low and high energy hadronic interactions and which routine you want to use for date and time. Next, you will be able to select a set of options:

Which program version do you like ? Warning : some options have been desabled because you use version for ice ! 0 - standard version (flat detector) : reset options

1 - Cherenkov version for rectangular detector grid 5 - THINning version 6 - version 7 - shower PLOT version (PLOTSH) (only for single events) 72 - shower PLOT version 2 (PLOTSH2) (only for single events) 8 - interaction test version (only for 1st interaction) d - ANAlysis HISTos & THIN (instead of particle file) e - Auger-info file instead of dbase file f - Auger-histo file & THIN g - Auger Cherenkov longitudinal distribution j - COMPACT particle output file l - LPM-effect without thinning n - primary neutrino version with HERWIG p - ROOT particle OUTput file

o - FINISH SELECTION (default)

r - restart make t - test version x - exit make (combinations of options are possible) You can see here that some numbers or letters are missing in the list of choices. The reason for that is that some of the options are not relevant for simulations in ice or water. A list of these desabled options is given in table2 in section3. At this point, to be able to run CORSIKA-IW with the sample datacard given in the next section, select only the option “5 - THINning version” and finish the selection with o.

6 After the choice is done, the script asks you a couple of other questions: whether you want to compile or not and whether you want to save the main source file. Of course, we want to compile, so the script goes on with

configure: creating ./config.status config.status: creating Makefile config.status: creating bernlohr/Makefile config.status: creating coast/Makefile ... and if everything went smoothly, it ends with

...

--> "corsika6600_ICE_Darwin_QGSJET_gheisha" successfully installed in : /path/to/corsika//corsika-6600-wi-0.81/run/

--> You can run CORSIKA in /path/to/corsika/corsika-6600-wi-0.81/run/ using for instance : ./corsika6600_ICE_Darwin_QGSJET_gheisha < all-inputs > output.txt

make[2]: Nothing to be done for ‘install-data-am’. [myhost] corsika-6600-wi-0.81> As indicated, the name of the executable file is corsika6600 ICE Darwin QG- SJET gheisha. The keyword ICE in the name makes possible to identify the program very easilly. The fact to have a different name for ice and air versions is also interesting because you can have these two versions in the same directory tree.

2.2 Running a simple simulation Once the compilation is done, it is time to check that the program works with a simple datacard. Several sample datacards are given in the directory run/, where the executable file is located. The example below corresponds to the file “inputs Sloan”.

RUNNR 19 numberofrun EVTNR 1 numberoffirstshowerevent SEED 100 0 0 seedfor1.randomnumbersequence SEED 200 0 0 seedfor2.randomnumbersequence SEED 300 0 0 seedfor3.randomnumbersequence NSHOW 1 numberofshowerstogenerate PRMPAR 3 particletypeofprim.particle ESLOPE -2.7 slopeofprimaryenergyspectrum ERANGE 1.E10 1.E10 energy range of primary particle THETAP 0. 0. rangeofzenithangle(degree) PHIP 0. 360. rangeofazimuthangle(degree) FIXCHI 0. startingaltitude(g/cm**2) FIXHEI 0. 0 firstinteractionheight&target QGSJET T 0 useDPMJETforhighenergyhadrons QGSSIG T useDPMJEThadroniccrosssections HADFLG 0 0 0 0 0 2 flags hadr.interact.&fragmentation ELMFLG T T em.interactionflags(NKG,EGS) THIN 1.e-4 1.e7 300. STEPFC 1.0 mult.scatteringsteplengthfact. RADNKG 200.E2 outer radius for NKG lat.dens.distr. MAGNET 20.0 42.8 magnetic field centr. Europe ECUTS 0.3 0.3 0.003 0.003 energy cuts for particles LONGI T 20. T T longit.distr.&stepsize&fit&out VOLHEI 2.E4 heightofthesimulatedvolume MUMULT F muonmultiplescatteringangle MUADDI F additionalinfoformuons OBSLEV 0.E0 observationlevel(incm) ARRANG 0. rotationofarraytonorth MAXPRT 100 max.numberofprintedevents ECTMAP 1.E9 cutongammafactorforprintout DATBAS F write.dbasefile DEBUG F 6 F 1000000 debug flag and log.unit for out DIRECT ./ outputdirectory EXIT terminatesinput Here I will just give some basic information about the most important entries. For more information, please have a look in the main CORSIKA user’s guide [1]. Page numbers are given in addition.

• RUNNR: the number of the run. This number is used to name output files. This number have to be in the range [0, 999999]. Page 49.

7 • EVTNR: event number of the first shower. Page 49. • NSHOW: number of shower to be generated in each run. Page 50. • PRMPAR: primary particle ID. 1 for gamma, 3 for electrons, 14 for protons, etc. (see [1], page 82 for the full list). Page 50. • ERANGE: energy range (in GeV). Here, the minimum and maximum energy are the same so that the energy is fixed. Page 51. • ECUTS: low energy cut-off (in GeV), for (without π0), muons, electrons and photons (including π0). Page 66. • LONGI: if true (first ’T’), the longitudinal profiles (energy deposition, number of gamma, electrons, positrons...) is given in the output file ’DATnnnnnn.long’. The number (here 20.0) is the vertical step size for sampling of the longitudinal development (in g/cm2). Page 67. • VOLHEI: height of the simulated ice/water volume. This entry is specific for the IW version. • THETAP, PHIP: zenith angle and azimuth angle of incoming particles. In ice/wa- ter, these two parameters are not really relevant and should not be changed. Pages 51 and 52. • DIRECT: name of the output directory, ended by ’/’. Page 70. Once you have chosen your parameters, you just have to run the simulation:

[myhost] run> ./corsika6600_ICE_Darwin_QGSJET_gheisha < inputs_Sloan You will see a lot of information displayed on the screen. In particular, you will see a header and a footer for each event generated. You can chose to re-direct these messages to a file by doing:

[myhost] run> ./corsika6600_ICE_Darwin_QGSJET_gheisha < inputs_Sloan > output.txt

3 Technical details

This section gives more technical details about the modifications made in the code. It has been written for poeple who wants to understand how the modifications were done or for poeple who wants to improve the code.

3.1 Principles of CORSIKA configuration Before going into the details of the modifications I made in the code, it is nec- essary to have a basic knowledge about the way CORSIKA configuration works. By ’configuration’, I mean getting a given version of a code depending on differ- ent choices made by the user. CORSIKA offer such options, e.g. to select which hadronic interaction model should be used. The configuration process goes like this: • The user runs the sh script corsika-install; • corsika-install call the configuration script configure giving the standards arguments prefix, bindir and libdir; • configure asks the user which options he wants to use (see the previous section) and turns the main source code template file corsika.F into a regular F77 file compilefile.f using the C preprocessor cpp;

8 corsika.F ... #if __ICE__ C Code for ice ... #endif ...

corsika-install with options ICE, THIN, etc.

corsika.f ... C Code for ice ......

compilation + link

corsika6600_ICE_Linux_QGSJET_geisha

Figure 2. Schematic view of the CORSIKA 6600 configuration procedure. The script corsika-install configure the code given a list of options selected by the user and using C preprocessor commands. The file obtained is then compiled to give the main executable file. The changes for ice are embeded in C preprocessor commands #if...#endif in order to be able to enable or disable them during the configuration process. Note that the executable file has a different name than the one for air.

• Once the script configure has exited, corsika-install starts the compila- tion using make. compilefile.f and other files are compiled and linked to generate the final executable. Note that compilefile.f is deleted after the compilation by the script corsika-install. However, a question during the configuration process allows to keep a copy of it.

3.2 Changes in the code Four files have been modified in order to get a version that works in air, ice and salt water in addition to air: • configure.in: configuration process is modified to allow the user to chose between air/ice/salt water; • config.h.in: preprocessor commands to enable/desable parts of the code are defined in this file; • corsika.h: definition of new variables; • corsika.F: main source code file. NB: Line numbers are given as an indication only. They can vary a little bit depending on further modifications in the code.

9 3.2.1 configure.in Modifications start at line 637. The script configure is generated from the file configure.in using the utility autoreconf. It is necessary to run autoreconf after modifying configure.in, otherwise the changes will not be taken into account. The first modification consists on adding a block to allow the user to configure Corsika with the option AIR, ICE or SALTWATER. The output of this change has been presented on page6. AIR selects the default version of Corsika and ICE select the modified version for ice (same for SALTWATER). As I explained earlier, the user has to make choices for the different options he wants. If he has already run the configuration script, the previous choices are considered as default. This is done in configure.in by looking into the file include/config.h with lines such as

if test "‘grep __ICE__ include/config.h | cut -d ’ ’ -f 1‘" = "#define" ; then default="ICE" fi If the configuration has never been run before, the file include/config.h does not exist. Then, the lists of choices are generated with

if test "$default" = "ICE" ; then echo ’ 2 - ICE (default)’ else echo ’ 2 - ICE’ fi When a particular option is selected, variables are set with

case $yesno in 1 ) echo ’ select AIR’ ; air="AIR" ;; 2 ) echo ’ select ICE’ ; ice="ICE" ;; 3 ) echo ’ select SALTWATER’ ; saltwater="SALTWATER" ;; If for example the user selected option ICE, the variable ice is set to "ICE" and the other variables air and saltwater are empty. Starting around line 1189, all the options which are not relevant for use with ice or saltwater are discarded. For this, a test is made to check if option AIR is selected. If it is, the original code is used:

if test "$air" = "AIR" ; then if test "‘grep __VOLUMEDET__ include/config.h | cut -d ’ ’ -f 1‘" = "#define" ; then volumedet="VOLUMEDET" else volumedet = fi if test "‘grep __VOLUMECORR__ include/config.h | cut -d ’ ’ -f 1‘" = "#define" ; then volumecorr="VOLUMECORR" else volumecorr= fi else volumedet = volumecorr= fi If AIR is not selected, the options are neutralized. In our example, volumedet and volumecorr. Starting around line 1825, the script asks the user to select different options. These options are not all relevant for ice or saltwater so they are desabled with a code like:

if test "$air" = "AIR" ; then echo ’ 2 - Cherenkov version for telescope system (using bernlohr C-routines)’ echo ’ 3 - apply atm. absorption, mirror reflectivity & quantum eff.’ echo ’ 4 - external atmosphere functions (table interpolation)’ echo ’ (using bernlohr C-routines)’ fi

10 ATMEXT STACEE CEFFIC STACKIN CURVED UPWARD IACT VIEWCONE IACTEXT VOLUMEDET PRESHOWER VOLUMECORR SLANT

Table 2. List of options that are NOT available in CORSIKA-IW.

Table2 gives a list of the options which are desabled. Around line 2532, the configuration variables ICE and SALTWATER are defined:

if test "$ice" = "ICE" ; then ICEEXE=’_ICE_’ ICENAME=’_ICE’ AC_DEFINE(__ICE__,1,[material : ice]) fi

if test "$saltwater" = "SALTWATER" ; then SWEXE=’_SWATER_’ SWNAME=’_SWATER’ AC_DEFINE(__SALTWATER__,1,[material : salt water]) fi This simply means that if the user has selected option ICE, the C preprocessor variable ICE will be set to 1. This is done in the file config.h, which is included at the beginning of the file corsika.F. Then, each C preprocessor condition like

#if __ICE__ ... # endif in corsika.F will be fulfilled and the corresponding code will be compiled. When the code is compiled for ice or saltwater, the final executable file has a different name than when it is compiled for air. This is done in configure.in using the variables ICEEXE and SWEXE for the executable file and ICENAME and SWNAME for the source file. The binary file name is defined at line 2842 by

BINNAME=$PACKAGE$VERSION$ICEEXE$SWEXE$USEROS$HIMODEL$LOMODEL$INTT The name of the source file is defined at line 2875 by

name=$PACKAGE$VERSION$ICENAME$SWNAME$HIMODEL$LOMODEL$INTT"_compilefile.f"

3.2.2 config.h.in The file config.h.in is parsed during the configuration process and turned into config.h. config.h is included at the beginning of the main source file corsika.F. Two simple additions are made in config.h.in to include the two new C pre- processor conditions for ice and saltwater. Line 120:

/* material : ice */ #undef __ICE__ and line 186:

/* material : salt water */ #undef __SALTWATER__

11 3.2.3 corsika.h The file corsika.h is located in the directory src/. It contains all the global variables used in the commons of the program. Which commons are used depends on the option choice, so the definition of the commons are placed within C preprocessor #if...#endif statements. We will see later that in corsika.F, corsika.h is included at the beginning of each functions, after a series of #define statements. This is the way chosen by CORSIKA developpers to deal with common blocks. That way, all the common blocks are located in a single file and different blocks can be selected for each function. Changes begin at line 2995 where two common blocks are added to contain constants for ice and water. Currently, there is only one constant, the density:

#ifdef __CONSTICE__ COMMON/ICECONS/RHOICE DOUBLEPRECISIONRHOICE #undef __CONSTICE__ # endif

#ifdef __CONSTSWATER__ COMMON/SWATCONS/RHOSWATER DOUBLEPRECISIONRHOSWATER #undef __CONSTSWATER__ # endif As a result, a #define statement for CONSTICE and CONSTSWATER has to be placed in all functions were the variables RHOICE and RHOSWATER are used. The second modification is made to add a table containing collision probabilities for hydrogen. Hydrogen is not taken into account into CORSIKA, due to its loaw concentration in the atmosphere. However, it has to be added for ice and water versions. The modifications are done at line 3152: #if __ICE__ || __SALTWATER__ COMMON /CRGNUPR/ SE1,SE14,SE16,SE40 DOUBLE PRECISION SE1(3,1),SE14(3,14),SE16(3,16),SE40(3,40) # else COMMON /CRGNUPR/ SE14,SE16,SE40 DOUBLE PRECISION SE14(3,14),SE16(3,16),SE40(3,40) # endif At line 3470, the variable VOLHEI is added in the common block CROBSPAR. VOLHEI contains the height of the volume considered in the simulation. It is set by the user in the datacard. #if __ICE__ || __SALTWATER__ *VOLHEI, # endif Then, VOLHEI is declared with a double precision type: #if __ICE__ || __SALTWATER__ DOUBLEPRECISIONVOLHEI # endif

3.2.4 corsika.F corsika.F is the main source code of CORSIKA. It is really a huge file with more than 65 000 lines. Changes are all done within C preprocessor conditions, so they can easilly be located. The preprocessor condition used typically is

#if __ICE__ c Code for ice ... #elif __SALTWATER__ c Code for salt water ... # else c Code for atmosphere ... # endif

12 26 functions, subroutines or data blocks have been modified. Two new subrou- tines were added. Table3 gives a list of all the subroutines that have been modified and added. More details are given in the following.

AAMAIN AAMAIN is the main program. There is only minor changes in this function since most the real physical work is done in other subroutines. The variables for ice and saltwater are included at the beginning:

#if __ICE__ #define __CONSTICE__ #elif __SALTWATER__ #define __CONSTSWATER__ # endif #include "corsika.h" The format of the output file for longitudinal profiles is modified. This has to be done to allow depths greater than 9999 g/cm2 to be displayed correctly. Other changes were done in comments.

BLOCK1 BLOCK1 is called from AAMAIN to initialize all the variables. Constants for ice and saltwater are included at the beginning. The composition of the medium is defined here:

#if __ICE__ CPUREWATER CONLYTHECHEMICALCOMPOSITIONISIMPORTANTATTHISPOINT! CHO DATA COMPOS / 0.66667D0, 0.33333D0, 0.D0 / DATA PROBTA / 0.66667D0, 1.D0, 1.D0 / DATA AVERAW / 6.00509D0 / #elif __SALTWATER__ CSALTWATERASDEFINEDBYT.SLOAN DATA COMPOS / 0.66173D0, 0.33087D0, 0.00740D0 / DATA PROBTA / 0.66173D0, 0.99224D0, 1.D0 / DATA AVERAW / 6.17025D0 / # else CAIR DATA COMPOS / 0.78479D0, 0.21052D0, 0.00469D0 / DATA PROBTA / 0.78479D0, 0.99531D0, 1.D0 / DATA AVERAW / 14.543D0 / # endif In CORSIKA, the atmopshere is defined as containing only nytrogen, oxygen and argon. For pure ice, we use only two chemical components: hydrogen and oxygen. For saltwater, the salt is considered as a single element. COMPOS(3) is the composition of the medium, in atomic fractions. PROBTA(3) is the integrated atomic fraction. AVERAW is the averageatmoic weight of the medium. As an example, for pure water (H2O), we have 2/3 of H and 1/3 of O. The average atomic mass is then given by 2/3*1.00794 + 1/3*15.9994 (atomic masses taken from [9]). In CORSIKA, the atmopshere is devided into 5 layers. In ice or saltwater, we need only one of these layers. Parameters are changed in the table HLAY to reflect this new definition. In particular, the height of the simulated volume will be put in the the last column (see routine START). Density of ice and saltwater are defined by:

DATA RHOICE / 0.918D0 / DATA RHOSWATER / 1.025D0 /

BOX2 BOX2 determines the point of interaction or decay for any particle. Target atoms are changed here with

#if __ICE__ CPAIRPRODUCTIONWITHHYDROGEN LT = 1 TAR = 1. D0 ELSE CPAIRPRODUCTIONWITHOXYGEN

13 PROGRAM AAMAIN BLOCK DATA BLOCK1 SUBROUTINE BOX2 SUBROUTINE DATAC DOUBLE PRECISION FUNCTION DPRSGM( JJMAT ) DOUBLE PRECISION FUNCTION HEIGH( ARG ) SUBROUTINE MUBREM SUBROUTINE MUNUCL SUBROUTINE MUPINI SUBROUTINE MUPRPR SUBROUTINE PRANGE( ARG ) DOUBLE PRECISION FUNCTION RHOF( ARG ) SUBROUTINE SDPM( LTA ) SUBROUTINE START DOUBLE PRECISION FUNCTION THICK( ARG ) SUBROUTINE UPDATE( HNEW,THCKHN,IPAS ) SUBROUTINE BREMSLPM( FPASS ) or BREMS (**) SUBROUTINE EGSIN1 SUBROUTINE EGSIN2 SUBROUTINE ELECTR( IRCODE ) SUBROUTINE PAIRLPM( FPASS ) or PAIR (**) SUBROUTINE PHOTON( IRCODE ) SUBROUTINE CGHINI SUBROUTINE TARINT SUBROUTINE QGSSIGINI SUBROUTINE QGSSIG( ELAB, ICZ ) subroutine Lossy(GAMMA,AM,dEdx) (*) subroutine Lossye(EIN,dEdx) (*)

Table 3. List of modified and added (*) functions. Functions with (**) have two different names depending if the option LPM is selected or not.

ATMOD ATMC ATMA ATMLAY ATMB CERARY

Table 4. List of datacard entries that are NOT available in CORSIKA-IW.

14 LT = 2 TAR = 16. D0 ENDIF #elif __SALTWATER__ CPAIRPRODUCTIONWITHHYDROGEN LT = 1 TAR = 1. D0 ELSEIF ( RD(1)*SIGPRM .LE. FRPTNO ) THEN CPAIRPRODUCTIONWITHOXYGEN LT = 2 TAR = 16. D0 ELSE CPAIRPRODUCTIONWITHNACL LT = 3 TAR = 29.2 D0 ENDIF # else ... # endif Please note that salt is considered as only one nucleus, with the atomic mass M = 29.2 being the mean value of MCl = 35.45 and MNa = 22.99. This approach is used following T. Sloan. The same modifications are done for bremsstrahlung.

DATAC DATAC reads the data card. As already mentionned before, there is one entry added in the datacard. This entry, VOLHEI, is used to change the height of the simulated volume. First, the default value is given:

#if __ICE__ || __SALTWATER__ VOLHEI = 1.D4 # endif If the entry is in the datacard, it is read with:

#if __ICE__ || __SALTWATER__ CGETHEIGHTOFSIMULATEDVOLUME ELSEIF ( LINE(1:6) .EQ. ’VOLHEI’ ) THEN CALL DTCDBL( LINE,IS,VOLHEI,’VOLHEI’,1 ) IF ( VOLHEI .LE. 0 ) VOLHEI = 1.D4 # endif As you can see, the default value for the height is 104 cm = 100 m. When using the version for ice or saltwater, a set of datacard entries are not needed anymore. These entries are given in table4.

DPRSGM DPRSGM calculates the muon pair production cross-sections. This function is modified to correct a bug, initially found by T. Sloan. This bug is responsible for the divergence of the function when the energy is lower than 0.3 GeV.

HEIGH HEIGH computes the height depending on the thickness of the medium. The argument is the mass overlay in g/cm2. Here, we have to take into account the density of ice or saltwater, defined in BLOCK1.

#if __ICE__ C RHOICE IS DEFINED IN BLOCK1 HEIGH = HLAY(5) - (ARG/RHOICE) #elif __SALTWATER__ C RHOSWATER IS DEFINED IN BLOCK1 HEIGH = HLAY(5) - (ARG/RHOSWATER) # else ... # endif

MUBREM MUBREM deals with muon bremsstrahlung. Here the target material (given with the Z number) is changed. For NaCl, we use the mean value ¡Z¿ = (11+17)/2= 14. The values of the index LT are 1 or 2 in case of pure ice and 1, 2 or 3 for salt water and air.

15 #if __ICE__ CSETMATERIALCONSTANTSCMUON(.)ACCORDINGTO C TARGET INDEX LT (1=H, 2=O) WHICH HAS BEEN SET IN BOX2 IF (LT.EQ.1) THEN Z = 1. D0 ELSEIF ( LT .EQ. 2 ) THEN Z = 8. D0 ELSE WRITE(MONIOU,*) ’MUBREM: WRONG TARGET LT=’,LT,’ STOP’ STOP ENDIF #elif __SALTWATER__ CSETMATERIALCONSTANTSCMUON(.)ACCORDINGTO C TARGET INDEX LT (1=H, 2=O, 3=NACL) WHICH HAS BEEN SET IN BOX2 IF (LT.EQ.1) THEN Z = 1. D0 ELSEIF ( LT .EQ. 2 ) THEN Z = 8. D0 ELSE Z = 14. D0 ENDIF # else ...# endif

MUNUCL MUNUCL treats muon nuclear interactions. Here again, we change the target material.

MUPINI MUPINI initializes muon parameters fr multiple scattering. The target material is given with numbers A and Z. As before, we replace Ar by NaCl for saltwater with ANaCl = 29.2 and ZNaCl = 29.2. For ice, the third component is not used and we set A = Z = 0. This is not critical as the third number in composition table COMPOS is set to 0 for ice. In MUPINI, the constant for density effects for ionization losses is defined. We used the value for pure water (δ = 0.030145) for ice and saltwater. The difference between the values of δ for ice and saltwater are negligible. Table CMUON, which contains the numbers Z had to be changed.

MUPRPR MUPRPR treats muon pair production. Once again, the composition is changed. It is given here with the number Z.

PRANGE PRANGE determines the mean free path for decaying particles. All the code of this function is replaced to get the decay distances right in water or ice. The new code was originally written by T. Sloan. The values of the parameters are the same for ice and water since the ranges are expressed in g/cm2. Only the density is changed between ice and salt water.

RHOF RHOF calculates the density of the atmosphere depending on the height. The density is considered as a constant and is set to the values RHOICE or RHOSWATER.

SDPM SDPM is a part of the dual parton model initialization and determines the target nucleus. Target nuclei are changed accordingly for ice or saltwater.

THICK THICK calculates the thickness of the atmosphere depending on the height. Layers used in the atmosphere are not needed for ice or saltwater. We change the thickness definition with

16 #if __ICE__ THICK=(HLAY(5)-ARG)*RHOICE #elif __SALTWATER__ THICK=(HLAY(5)-ARG)*RHOSWATER # else ... # endif where HLAY(5) is the thickness of the ice or salt water volume.

UPDATE UPDATE updates the particle parameters till the next observation level or to the decay or interaction point. Energy losses are computed by Sloan’s routine Lossy. I addition, the energy above which the LPM effect is taken into account is lowered from 1016 eV to 1012 eV. The LPM effect has to be taken into account at lower energies for denser materials.

BREMS or BREMSLPM BREMS or BREMSLPM are an implementation of the Bethe-Heitler model with LPM included or not. The LPM effect threshold (i.e. the energy above which CORSIKA check if the LPM has to be taken into account) is decreased to 1012 eV. The same change is done in the subroutine PAIRLPM (or PAIR).

ELECTR ELECTR treats the e+/e− transport. In this function, Sternheimer correction of density dependent ionization energy loss is discarded. In order to do that, parameters ALTEXP and DISC are changed. 24. corsika.F - PHOTON Lines 36509-36519: ALTEXP and DISC. Lines 36644- 36648: DISC. 38. corsika.F - PHOTON Lines 36064-36074: Density correction for meaan free path modified, like in ELECTR. Lines 36199-36203: Id.

CGHINI CGHINI initializes the variables for the hadronic package GHEISHA (Gamma Interaction SHower code) [10]. GHEISHA is used to calculate the elastic and inelastic cross-sections of hadrons below 80 GeV. The composition of the target material is added for ice and salt water. The number of elements is given by KK. KK is set to 2 for pure ice and to 3 for saltwater.

TARINT TARINT determines how many interactions occur in a given target. Here we had to add the case of an hydrogen target. The code uses the table SE1 defined around line 4930.

QGSSIGINI QGSSIGINI initialise the inelastic cross sections for the model QGSJET. As already done in other subroutines, we change the target atoms.

QGSSIG QGSSIG calculates inelastic cross-sections. In this function QGSJET routines QGSECT and SECTNU are called to compute cross sections. The target mass number is the third argument of these functions. Mass number of nytrogen is replaced by the mass number of hydrogen. For salt (NaCl), the mass number 29 is used.

17 START START basically prints the header and performs all the initializations. The header printed at the beginning of the execution is modified to clearly indentify the ice or salt water versions. Then, the table HLAY is initialized with ice or saltwater density:

#if __ICE__ CTABLEHLAYISDEFINEDHEREBECAUSEWENEEDTOUSETHEDATACARDENTRY C VOLHEI. RHOICE IS DEFINED IN BLOCK1. WRITE(MONIOU,*) ’====> WE ARE IN ICE !!!’ WRITE(MONIOU,*) ’VOLHEI,RHOICE =’,VOLHEI,RHOICE HLAY(5) = VOLHEI/RHOICE DO J = 0, 9 HLAY0(5,J) = VOLHEI/RHOICE ENDDO #elif __SALTWATER__ CTABLEHLAYISDEFINEDHEREBECAUSEWENEEDTOUSETHEDATACARDENTRY C VOLHEI. RHOSWATER IS DEFINED IN BLOCK1. WRITE(MONIOU,*) ’====> WE ARE IN SALT WATER !!!’ WRITE(MONIOU,*) ’VOLHEI,RHOSWATER =’,VOLHEI,RHOSWATER HLAY(5) = VOLHEI/RHOSWATER DO J = 0, 9 HLAY0(5,J) = VOLHEI/RHOSWATER ENDDO # endif

Lossy and Lossye Lossy and Lossye were added by T. Sloan to deal with the energy losses from Bethe-Bloch formula for electrons in water, including the density effect. Lossy and Lossye have different arguments. Only Lossy is used, but Lossye was kept in the code, just in case of future use.

3.3 EGS CORSIKA 6600 uses the package EGS4 to treat electromagnetic interaction. Here again, the material is changed so that EGS performs the simulation in ice or saltwater. This is done in the subroutine EGSIN1. One more important change was to re-generate the EGS input files for ice and saltwater. Each file EGSDAT5 * corresponds to a given threshold. Files EGSDAT5 3.ICE, and EGSDAT5 3.SALTWATER are used when the thresholds are such that Max(ECUTS(3), ECUTS(4)) > 0.003 GeV in the datacard. File EGSDAT5 1.ICE has been produced for a threshold such that Max(ECUTS(3), ECUTS(4)) > 0.001 GeV (see above page8 for some explanations on ECUTS). If these conditions are not fulfilled in the datacard, the file EGSDAT5 3* will be used. The generation of EGS input file is very tricky. To make the story short, the files are generated by the program PEGS, modified by the developers to meet their special needs for CORSIKA. Unfortunatly, this modified version is unable to compile with recent versions of F77 compilers and presently only works on a computer with a very old version of Suse Linux in Karlsruhe. As a result, it is necessary to contact CORSIKA developpers to get the EGS input files.

4 Conclusion and present status of the code

In this note, we have introduced a modified version of CORSIKA dedicated to the particle interaction simulations in salt water or ice. This version was inspired by T. Sloan version and brings a number of improvements, especially the possibility to use most of the configuration options available in CORSIKA. Present version (0.90) of the code was released on 08/22/2008. As compared to previous verion (0.81), it corrects a bug in QGSJET routine QGSSIG. All the hadronic packages have been tested. Only EPOS and DPMJET do not work properly:

18 • EPOS does not work at all. It cannot consider hydrogen as a target; • DPMJET does not work correctly and ends with a floating exception: it is possible to get the longitudinal profile (in the .long file), but the output binary file is empty. CORSIKA-IW could be of great interest for high energy neutrino optical and accoustic detection simulations. Some applications of the code will be described in the second part of this note.

Aknowledments

The author would like to thank Terry Sloan for his great help in the early stages of the development of CORSIKA-IW. Many thanks also to Dieter Heck and Tanguy Pierrog, developers of the original version of CORSIKA, for their support.

19 References

[1] D. Heck et al., CORSIKA 6600 User’s Guide, available in the directory doc/ [2] http://nuastro-zeuthen.desy.de/e27/e711/index_eng.html [3] W. Heitler, Quantum Theory of Radiation, Dover Press, 1954 [4] L. D. Landau and I. J. Pomeranchuk, Dokl. Akad. Nauk SSR, 92, 535 & 735, 1953 [5] A. B. Migdal, Phys. Rev., 103, 1811, 1956 [6] D. Heck et al., Report FZKA 6019, 1998; available from http://www-ik.fzk.de/ [7] E. Zas, F. Halzen and T. Stanev, Phys. Rev. D, 45, 362, 1992 [8] S. Bevan et al., Astroparticle Physics, 28, 366, 2007 [9] W.-M. Yao et al.,Review of , Journal of Physics G, 33, 1, 2006 [10] H. Fesefeldt, Report PITHA-85/02, RWTH Aachen, 1985

20