CORSIKA: Difference between revisions

From Mu2eWiki
Jump to navigation Jump to search
(Info about simple CORSIKA analyzer)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://www.ikp.kit.edu/corsika/ CORSIKA] ('''CO'''smic '''R'''ay '''SI'''mulations for '''KA'''scade) is a program for detailed simulation of extensive air showers initiated by high energy cosmic ray particles. It has many options and can produce very detailed results. Here we will list just the most important ones, compared to other cosmic-ray generators used in Mu2e:
[https://www.ikp.kit.edu/corsika/ CORSIKA] ('''CO'''smic '''R'''ay '''SI'''mulations for '''KA'''scade) is a program for the simulation of extensive air showers initiated by high energy cosmic ray particles. It has many options and can produce very detailed results. Here we will list just the most important ones, compared to other cosmic-ray generators used in Mu2e:


* Elevation can be set at the Fermilab one (226 m) and the particles flux is adjusted automatically accordingly.
* Elevation can be set at the Fermilab one (226 m) and the particles flux is automatically adjusted accordingly.
* Different models for cosmic shower evolutions can be tested (e.g. [http://www.fluka.org/fluka.php FLUKA], GHEISHA).
* Different models for cosmic shower evolutions can be tested (e.g. [http://www.fluka.org/fluka.php FLUKA], GHEISHA).
* No binning effects in the energy spectra of the particles.
* No binning effects in the energy spectra of the particles.
Line 14: Line 14:
In order to work together with FLUKA, it requires gfortran v8_2_0. Moreover, the <code>FLUFOR</code> environment variable must be set to <code>gfortran</code> and the <code>FLUPRO</code> environment variable must point to the installed FLUKA directory.
In order to work together with FLUKA, it requires gfortran v8_2_0. Moreover, the <code>FLUFOR</code> environment variable must be set to <code>gfortran</code> and the <code>FLUPRO</code> environment variable must point to the installed FLUKA directory.


The compilation is run by an interactive script called <code>coconut</code>, which produces the CORSIKA executable in the <code>run</code> folder. As additional CORSIKA program options you might want to select the option <code>g</code> (COMPACT particle output file), which produces output files 40x smaller than the default. If you choose the QGSJET as high-energy hadronic model and FLUKA as low-energy hadronic model, the executable will be called <code>corsika77100Linux_QGSJET_fluka</code>. Thus, the CORSIKA output is created by launching the command:
The compilation is run by an interactive script called <code>coconut</code>, which produces the CORSIKA executable in the <code>run</code> folder. As additional CORSIKA program options you might want to select the option <code>g</code> (COMPACT particle output file), which produces output files 40x smaller than the default. If you choose the QGSJET as high-energy hadronic model and FLUKA as low-energy hadronic model, the executable will be called <code>corsika77100Linux_QGSJET_fluka</code>.  
 
 
A compiled version of CORSIKA is already available as a ups product and can be loaded with:
 
<nowiki>setup corsika</nowiki>
 
This product will make available two CORSIKA executables <code>corsika77100Linux_QGSJET_fluka</code>, compiled with the COMPACT option, and <code>corsika77100Linux_QGSJET_fluka_nocompact</code> compiled without the COMPACT option.
 
The CORSIKA output is created by launching the command:
 
  <nowiki>./corsika77100Linux_QGSJET_fluka < corsika_configuration</nowiki>
  <nowiki>./corsika77100Linux_QGSJET_fluka < corsika_configuration</nowiki>


Line 46: Line 56:
ECTMAP  1.E2                          cut on gamma factor for printout
ECTMAP  1.E2                          cut on gamma factor for printout
MAXPRT  0                              max. number of printed events
MAXPRT  0                              max. number of printed events
DIRECT  ./                             output directory
DIRECT  /mu2e/app/users/srsoleti      output directory
DATDIR  /cvmfs/mu2e.opensciencegrid.org/artexternals/corsika/v7_7710/Linux64bit+3.10-2.17/run 
DATBAS  F                              write .dbase file
DATBAS  F                              write .dbase file
USER    srsoleti                      user
USER    srsoleti                      user
Line 53: Line 64:
</nowiki>
</nowiki>


The output file will be called DAT110001 (where 110001 is the run number RUNNR). The size of the output file is around 100MB for 2000000 primary nucleons, which in turn produce around 6000 showers with at least one particle at Fermilab elevation.
It is necessary to set the <code>DIRECT</code> keyword to the chosen output directory and the <code>DATDIR</code> keyword to the CORSIKA directory, that can be obtained with:


<nowiki>
dirname `which corsika77100Linux_QGSJET_fluka`</nowiki>
The output file will be called DAT110001 (where 110001 is the run number RUNNR). The size of the output file is around 100MB for 2000000 primary nucleons in the COMPACT version, which in turn produce around 6000 showers with at least one particle at Fermilab elevation.


=== Using CORSIKA in the Mu2e Offline ===
=== Using CORSIKA in the Mu2e Offline ===
Line 66: Line 81:


A FCL example is available at <code>EventGenerator/test/corsikaTest.fcl</code>.
A FCL example is available at <code>EventGenerator/test/corsikaTest.fcl</code>.
=== Plot CORSIKA generated particles ===
A simple analyzer is available at <code>Analyses/src/CORSIKAGenPlots_module.cc</code>. The module produces few histograms and a TTree containing information about the <code>GenParticleCollection</code> stored in the file at generation stage (so after <code>EventGenerator/src/CORSIKAEventGenerator_module.cc</code>).

Latest revision as of 23:37, 19 May 2020

CORSIKA (COsmic Ray SImulations for KAscade) is a program for the simulation of extensive air showers initiated by high energy cosmic ray particles. It has many options and can produce very detailed results. Here we will list just the most important ones, compared to other cosmic-ray generators used in Mu2e:

  • Elevation can be set at the Fermilab one (226 m) and the particles flux is automatically adjusted accordingly.
  • Different models for cosmic shower evolutions can be tested (e.g. FLUKA, GHEISHA).
  • No binning effects in the energy spectra of the particles.
  • Magnetic field can be set to the value measured at Fermilab (Bx = 19.066 μT, Bz = 50.628 μT).
  • Different particles can be used as primaries (protons, helium, heavy nuclei).

The MicroBooNE collaboration has performed a detailed comparison of the CORSIKA and CRY expected fluxes at Fermilab elevation. In particular, the flux of neutrons (protons) with CORSIKA+FLUKA is 3.35x (2.50x) higher than CRY.

CORSIKA installation

The CORSIKA source code is available, previous registration, on the CORSIKA website.

In order to work together with FLUKA, it requires gfortran v8_2_0. Moreover, the FLUFOR environment variable must be set to gfortran and the FLUPRO environment variable must point to the installed FLUKA directory.

The compilation is run by an interactive script called coconut, which produces the CORSIKA executable in the run folder. As additional CORSIKA program options you might want to select the option g (COMPACT particle output file), which produces output files 40x smaller than the default. If you choose the QGSJET as high-energy hadronic model and FLUKA as low-energy hadronic model, the executable will be called corsika77100Linux_QGSJET_fluka.


A compiled version of CORSIKA is already available as a ups product and can be loaded with:

setup corsika

This product will make available two CORSIKA executables corsika77100Linux_QGSJET_fluka, compiled with the COMPACT option, and corsika77100Linux_QGSJET_fluka_nocompact compiled without the COMPACT option.

The CORSIKA output is created by launching the command:

./corsika77100Linux_QGSJET_fluka < corsika_configuration

The corsika_configuration file is a text file containing the setup of the cosmic rays we want to simulate. We report here an example:

RUNNR   110001                         run number
EVTNR   1                              number of first shower event
NSHOW   2000000                        number of showers to generate
PRMPAR  14                             particle type of prim. particle  (14=p)
ESLOPE  -2.7                           slope of primary energy spectrum
ERANGE  1.3 100000                     energy range of primary (GeV)
THETAP  0.  90.                        range of zenith angle (degree)
PHIP    -180.  180.                    range of azimuth angle (degree)
SEED    110001   0  0                  seed for 1. random number sequence
SEED    100110001   0  0               seed for 2. random number sequence
QGSJET  T   0		               QGSJET for high energy & debug level
QGSSIG  T			       QGSJET cross-sections enable
OBSLEV  228E2                          observation level (in cm)
MAGNET  19.066  50.628                 Earth's mag. field at detector- Bx & Bz (22/09/2014)
HADFLG  0  0  0  0  0  2               flags hadr.interact.&fragmentation
ECUTS   0.05 0.05 0.05 0.05            energy cuts for particles
MUADDI  F                              additional info for muons
MUMULT  T                              muon multiple scattering angle
ELMFLG  F   T                          em. interaction flags (NKG,EGS)
STEPFC  1.0                            mult. scattering step length fact.
RADNKG  200.E2                         outer radius for NKG lat.dens.distr.
ARRANG  0                              rotation of array to north
ATMOD   1			       U.S. standard atmosphere (1-Linsley; 22-Keilhauer)
LONGI   F  20.  F  F                   longit.distr. & step size & fit & out
ECTMAP  1.E2                           cut on gamma factor for printout
MAXPRT  0                              max. number of printed events
DIRECT  /mu2e/app/users/srsoleti       output directory
DATDIR  /cvmfs/mu2e.opensciencegrid.org/artexternals/corsika/v7_7710/Linux64bit+3.10-2.17/run  
DATBAS  F                              write .dbase file
USER    srsoleti                       user
DEBUG   F  6  F  1000000               debug flag and log.unit for out
EXIT                                   terminates input

It is necessary to set the DIRECT keyword to the chosen output directory and the DATDIR keyword to the CORSIKA directory, that can be obtained with:

dirname `which corsika77100Linux_QGSJET_fluka`

The output file will be called DAT110001 (where 110001 is the run number RUNNR). The size of the output file is around 100MB for 2000000 primary nucleons in the COMPACT version, which in turn produce around 6000 showers with at least one particle at Fermilab elevation.

Using CORSIKA in the Mu2e Offline

The Mu2e Offline contains a Source module Sources/src/FromCorsikaBinary_source.cc which takes as input a CORSIKA output file. The output file can be both in the compact and in the full format. The Source module will produce art events with a single GenParticleCollection data product.

Particles coming from the same primary nucleon can be stored in different art events if they fall outside tha target top area (plus a customizable padding).

The particles are generated just above a target box, whose size is specified in the FCL parameters. The same random spatial offset is applied to the particles coming from a single primary nucleon, in order to span the box target area with the same probability. The particles will belong to a single art event (thus to the same GenParticleCollection) if they are within the target top area, plus a showerAreaExtension padding (specified as well in the FCL file and allows to store the cosmic rays impinging on the target box at a low angle). If there are particles outside this area, they will belong to a different art event, as shown in the diagram on the right.

The Producer module EventGenerator/src/CORSIKAEventGenerator_module.cc can run after the Source module in the same chain. This module will backtrack the particles in the GenParticleCollection to the Mu2e world borders and it will calculate the corresponding live-time of the simulated events.

A FCL example is available at EventGenerator/test/corsikaTest.fcl.

Plot CORSIKA generated particles

A simple analyzer is available at Analyses/src/CORSIKAGenPlots_module.cc. The module produces few histograms and a TTree containing information about the GenParticleCollection stored in the file at generation stage (so after EventGenerator/src/CORSIKAEventGenerator_module.cc).