source: trunk/MagicSoft/Mars/datacenter/scripts/runcorsika@ 9603

Last change on this file since 9603 was 9603, checked in by Daniela Dorner, 14 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 7.8 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 05/2007 <mailto:daniela.dorner@unige.ch>
21#
22# Copyright: MAGIC Software Development, 2000-2010
23#
24#
25# ========================================================================
26#
27# This script runs corsika.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32program=corsika
33step=Corsika
34
35set -C
36
37export FLUPRO=$corsikapath'/fluka2008_3'
38
39# printing input card to stdout
40function printinputcard()
41{
42 # Run number
43 echo "RUNNR "$file
44 # Starting event number
45 echo "EVTNR 1"
46 # Number of simulated events
47 echo "NSHOW "$numevts
48 # Seed values for simulation
49 echo "SEED "$seed1" 0 0 "
50 echo "SEED "$seed2" 0 0 "
51 echo "SEED "$seed3" 0 0 "
52 # Primary particle
53 echo "PRMPAR "$primparticle
54 echo "ERANGE "$erange
55 echo "ESLOPE "$slope
56 # Simulation range (theta, phi, view cone, starting altitude)
57 echo "THETAP "$zdrange
58 echo "PHIP "$azrange
59 echo "VIEWCONE 0. "$viewconemax
60 echo "FIXCHI "$startalt
61 # Observation level, magnetic field, atmosphere
62 echo "OBSLEV "$obslev".E2"
63 # From www.noaa.gov/geomagmodels roughly for January 2009. (was 29.5 and 23.0)
64 # MAGNET BX BZ (BX is the horizontal component (muT) to the x-direction of
65 # the detector, BZ is the vertical component (muT) downwards)
66 echo "MAGNET "$magnet
67 # Rotation angle between array x-direction and magnetic north direction
68 # positive if array x-direction points to the west
69 echo "ARRANG "$magnetrot
70 # Atmosphere (model, true/false for atmospheric refraction of cer-photons)
71 # Atmosphere read from atmprof11.dat
72 # My current understanding is that only refraction (bending of light
73 # but no absorption of photons is taken into account) setting T.
74 echo "ATMOSPHERE "$atm" T"
75
76 # Current boundaries in reflector program
77 # echo "ATMLAY 400000 1000000 4000000 10000000"
78
79 # Boundaries as determined by CORSIKA
80 # Until we can read the result from the corsika fit we fix the
81 # values which come out of the fit. This is not ideal but forces
82 # things to be consistent. Be careful is using a different model -
83 # the fit might not be ideal.
84 echo "ATMLAY 775000 1650000 5000000 10500000"
85
86 # Other parameters
87 echo "RADNKG 200.E2"
88 echo "ECUTS 0.3 0.3 0.02 0.02"
89 echo "ECTMAP 1.E4"
90 echo "STEPFC 0.1"
91 # Don't add muon particle data to output
92 echo "MUADDI F"
93 # Enable muon multiple scattering
94 echo "MUMULT T"
95 # Wavelength range (was originally 600)
96 echo "CWAVLG "$wavelengths
97 # MMCS
98 echo "CSCAT 1 0. "$impactmax
99 # CORSIKA
100 # echo "CSCAT "$reuse" "$impactmax" 0."
101 echo "CERSIZ 1."
102 # Write Cherenkov photons to cer-file
103 echo "CERFIL T"
104 # Number of telescopes
105 echo "CERTEL 1"
106 # MMCS
107 echo " 0. 0. 0. 0. 0. "$diameter" "$diameter
108 # CORSIKA (x, y, z, r)
109 # echo "TELESCOPE 0. 0. 0. "$diameter
110 # This keyword has no relevance but allows to store the
111 # maximum simulated impact parameter. The "magic" is that
112 # ceres interpretes the third and fourth argument as
113 # maximum simulated impact if they are identical and
114 # the other four arguments are 1
115 # echo "CERARY 1 1 "$diameter" "$diameter" 1 1"
116 # How the longitudinal shower development is sampled
117 # echo "LONGI T 10. T F"
118 echo "LONGI F 20 0 F F"
119 # Maximum number of detailed particles to print
120 echo "MAXPRT 0"
121 # Suppress file with partciles reaching ground (DATnnnnnn)
122 # FIXME: Should we make this switchable by the database?
123 echo "PAROUT F F"
124 # Don't write a database file
125 echo "DATBAS F"
126 # Switch off all debugging output
127 echo "DEBUG F 6 F 1000000"
128 # Output path
129 echo "DIRECT "$outpath
130 # DIRECT /dev/null
131 # TELFIL filename
132 # TELFIL | gzip
133 # TELESCOPE X Y Z R
134 # User and host (for convenience)
135 echo "USER "`whoami`
136 echo "HOST "`hostname`
137 # End of input card
138 echo "EXIT"
139}
140
141
142# get sequence #
143gettodo "1"
144run=${primaries[0]}
145file=${primaries[1]}
146
147# lock sequ
148lockfile=$lockpath/lock-$step-$run.$file.txt
149checklock
150
151printprocesslog "INFO starting $program for run $run and file $file"
152
153setstatus "start"
154
155printprocesslog "INFO run $program for run $run and file $file"
156printprocesslog "INFO create input card for run $run and file $file"
157
158# get values for inputcard
159query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
160primparticle=`sendquery`
161query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
162erange=`sendquery`
163query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
164numevts=`sendquery`
165query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
166slope=`sendquery`
167query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
168zdrange=`sendquery`
169# Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
170query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
171azrange=`sendquery`
172query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
173seed1=`sendquery`
174query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
175seed2=`sendquery`
176query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
177seed3=`sendquery`
178query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
179impactmax=`sendquery`
180query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
181viewconemax=`sendquery`
182query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
183startalt=`sendquery`
184query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
185diameter=`sendquery`
186query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
187atm=`sendquery`
188query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
189obslev=`sendquery`
190query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
191magnet=`sendquery`
192query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
193magnetrot=`sendquery`
194query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
195wavelengths=`sendquery`
196
197outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
198makedir $outpath
199logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log"
200
201cd $corsikapath
202
203printprocesslog "INFO executing 'printinputcard | ./cc6501p-linux >| $logfile 2>&1' in directory $corsikapath "
204printinputcard | ./cc6501p-linux >| $logfile 2>&1
205
206check1=$?
207case $check1 in
208 0) printprocesslog "INFO $program finished successfully for run $run file $file (check1=$check1)"
209 ;;
210 *) printprocesslog "ERROR $program failed for run $run file $file (check1=$check1)"
211 com=$Fcorsika
212 check=$check1
213 ;;
214esac
215
216# removing empty datnnnnnn file
217rm -f $outpath/dat`printf %06d $file`
218
219setstatus "stop"
220
221finish
222
Note: See TracBrowser for help on using the repository browser.