source: trunk/Mars/datacenter/scripts/runcorsika@ 9969

Last change on this file since 9969 was 9927, checked in by Daniela Dorner, 14 years ago
removed STEPFC from input card
  • Property svn:executable set to *
File size: 8.5 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 # Don't add muon particle data to output
91 echo "MUADDI F"
92 # Enable muon multiple scattering
93 echo "MUMULT T"
94 # Wavelength range (was originally 600)
95 echo "CWAVLG "$wavelengths
96 # MMCS
97 echo "CSCAT 1 0. "$impactmax
98 # CORSIKA
99 # echo "CSCAT "$reuse" "$impactmax" 0."
100 echo "CERSIZ 1."
101 # Write Cherenkov photons to cer-file
102 echo "CERFIL T"
103 # Number of telescopes
104 echo "CERTEL 1"
105 # MMCS
106 echo " 0. 0. 0. 0. 0. "$diameter" "$diameter
107 # CORSIKA (x, y, z, r)
108 # echo "TELESCOPE 0. 0. 0. "$diameter
109 # This keyword has no relevance but allows to store the
110 # maximum simulated impact parameter. The "magic" is that
111 # ceres interpretes the third and fourth argument as
112 # maximum simulated impact if they are identical and
113 # the other four arguments are 1
114 # echo "CERARY 1 1 "$diameter" "$diameter" 1 1"
115 # How the longitudinal shower development is sampled
116 # echo "LONGI T 10. T F"
117 echo "LONGI F 20 0 F F"
118 # Maximum number of detailed particles to print
119 echo "MAXPRT 0"
120 # Suppress file with partciles reaching ground (DATnnnnnn)
121 # FIXME: Should we make this switchable by the database?
122 echo "PAROUT F F"
123 # Don't write a database file
124 echo "DATBAS F"
125 # Switch off all debugging output
126 echo "DEBUG F 6 F 1000000"
127 # Output path
128 echo "DIRECT "$outpath
129 # DIRECT /dev/null
130 # TELFIL filename
131 # TELFIL | gzip
132 # TELESCOPE X Y Z R
133 # User and host (for convenience)
134 echo "USER "`whoami`
135 echo "HOST "`hostname`
136 # End of input card
137 echo "EXIT"
138}
139
140
141# get sequence #
142gettodo "1"
143run=${primaries[0]}
144file=${primaries[1]}
145
146# lock sequ
147lockfile=$lockpath/lock-$step-$run.$file.txt
148checklock
149
150printprocesslog "INFO starting $program for run $run and file $file"
151
152setstatus "start"
153
154printprocesslog "INFO run $program for run $run and file $file"
155printprocesslog "INFO create input card for run $run and file $file"
156
157# get values for inputcard
158query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
159primparticle=`sendquery`
160query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
161erange=`sendquery`
162query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
163numevts=`sendquery`
164query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
165slope=`sendquery`
166query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
167zdrange=`sendquery`
168# Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
169query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
170azrange=`sendquery`
171query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
172seed1=`sendquery`
173query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
174seed2=`sendquery`
175query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
176seed3=`sendquery`
177query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
178impactmax=`sendquery`
179query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
180viewconemax=`sendquery`
181query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
182startalt=`sendquery`
183query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
184diameter=`sendquery`
185query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
186atm=`sendquery`
187query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
188obslev=`sendquery`
189query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
190magnet=`sendquery`
191query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
192magnetrot=`sendquery`
193query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
194wavelengths=`sendquery`
195
196outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
197makedir $outpath
198logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log"
199
200cd $corsikapath
201
202printprocesslog "INFO executing 'printinputcard | ./cc6501p-linux >| $logfile 2>&1' in directory $corsikapath "
203printinputcard | ./cc6501p-linux >| $logfile 2>&1
204
205check1=$?
206case $check1 in
207 0) printprocesslog "INFO $program finished successfully for run $run file $file (return code $check1)"
208 if [ $file -gt 999 ]
209 then
210 corsikafilenew=$mcpath/$program/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer000`printf %06d $file | cut -c 4-6`
211 corsikafileold=$mcpath/$program/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer`printf %06d $file`
212 if ! mv $corsikafileold $corsikafilenew
213 then
214 printprocesslog "ERROR could not mv $corsikafileold to $corsikafilenew"
215 check=2
216 fi
217 fi
218 if ! grep 'END OF RUN' $logfile
219 then
220 printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run file $file "
221 check=2
222 fi
223 ;;
224 *) printprocesslog "ERROR $program failed for run $run file $file (return code $check1)"
225 check=$check1
226 ;;
227esac
228
229# removing empty datnnnnnn file
230rm -f $outpath/dat`printf %06d $file`
231
232setstatus "stop"
233
234finish
235
Note: See TracBrowser for help on using the repository browser.