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 |
|
---|
30 | if [ "$SOURCEFILEPATH" = "" ]
|
---|
31 | then
|
---|
32 | source `dirname $0`/sourcefile
|
---|
33 | else
|
---|
34 | source $SOURCEFILEPATH/sourcefile
|
---|
35 | fi
|
---|
36 | printprocesslog "INFO starting $0"
|
---|
37 | program=corsika
|
---|
38 | step=Corsika
|
---|
39 |
|
---|
40 | set -C
|
---|
41 |
|
---|
42 | export FLUPRO=$corsikapath'/fluka2008_3'
|
---|
43 |
|
---|
44 | # printing input card to stdout
|
---|
45 | function printinputcard()
|
---|
46 | {
|
---|
47 | # Run number
|
---|
48 | echo "RUNNR "$file
|
---|
49 | # Starting event number
|
---|
50 | echo "EVTNR 1"
|
---|
51 | # Number of simulated events
|
---|
52 | echo "NSHOW "$numevts
|
---|
53 | # Seed values for simulation
|
---|
54 | echo "SEED "$seed1" 0 0 "
|
---|
55 | echo "SEED "$seed2" 0 0 "
|
---|
56 | echo "SEED "$seed3" 0 0 "
|
---|
57 | # Primary particle
|
---|
58 | echo "PRMPAR "$primparticle
|
---|
59 | echo "ERANGE "$erange
|
---|
60 | echo "ESLOPE "$slope
|
---|
61 | # Simulation range (theta, phi, view cone, starting altitude)
|
---|
62 | echo "THETAP "$zdrange
|
---|
63 | echo "PHIP "$azrange
|
---|
64 | echo "VIEWCONE 0. "$viewconemax
|
---|
65 | echo "FIXCHI "$startalt
|
---|
66 | # Observation level, magnetic field, atmosphere
|
---|
67 | echo "OBSLEV "$obslev".E2"
|
---|
68 | # From www.noaa.gov/geomagmodels roughly for January 2009. (was 29.5 and 23.0)
|
---|
69 | # MAGNET BX BZ (BX is the horizontal component (muT) to the x-direction of
|
---|
70 | # the detector, BZ is the vertical component (muT) downwards)
|
---|
71 | echo "MAGNET "$magnet
|
---|
72 | # Rotation angle between array x-direction and magnetic north direction
|
---|
73 | # positive if array x-direction points to the west
|
---|
74 | echo "ARRANG "$magnetrot
|
---|
75 | # Atmosphere (model, true/false for atmospheric refraction of cer-photons)
|
---|
76 | # Atmosphere read from atmprof11.dat
|
---|
77 | # My current understanding is that only refraction (bending of light
|
---|
78 | # but no absorption of photons is taken into account) setting T.
|
---|
79 | echo "ATMOSPHERE "$atm" T"
|
---|
80 |
|
---|
81 | # Current boundaries in reflector program
|
---|
82 | # echo "ATMLAY 400000 1000000 4000000 10000000"
|
---|
83 |
|
---|
84 | # Boundaries as determined by CORSIKA
|
---|
85 | # Until we can read the result from the corsika fit we fix the
|
---|
86 | # values which come out of the fit. This is not ideal but forces
|
---|
87 | # things to be consistent. Be careful is using a different model -
|
---|
88 | # the fit might not be ideal.
|
---|
89 | echo "ATMLAY 775000 1650000 5000000 10500000"
|
---|
90 |
|
---|
91 | # Other parameters
|
---|
92 | echo "RADNKG 200.E2"
|
---|
93 | echo "ECUTS 0.3 0.3 0.02 0.02"
|
---|
94 | echo "ECTMAP 1.E4"
|
---|
95 | # Don't add muon particle data to output
|
---|
96 | echo "MUADDI F"
|
---|
97 | # Enable muon multiple scattering
|
---|
98 | echo "MUMULT T"
|
---|
99 | # Wavelength range (was originally 600)
|
---|
100 | echo "CWAVLG "$wavelengths
|
---|
101 | # MMCS
|
---|
102 | echo "CSCAT "$numreuse" 0. "$impactmax
|
---|
103 | # CORSIKA
|
---|
104 | # echo "CSCAT "$numreuse" "$impactmax" 0."
|
---|
105 | echo "CERSIZ 1."
|
---|
106 | # Write Cherenkov photons to cer-file
|
---|
107 | echo "CERFIL T"
|
---|
108 | # Number of telescopes
|
---|
109 | echo "CERTEL 1"
|
---|
110 | # MMCS
|
---|
111 | echo " 0. 0. 0. 0. 0. "$diameter" "$diameter
|
---|
112 | # CORSIKA (x, y, z, r)
|
---|
113 | # echo "TELESCOPE 0. 0. 0. "$diameter
|
---|
114 | # This keyword has no relevance but allows to store the
|
---|
115 | # maximum simulated impact parameter. The "magic" is that
|
---|
116 | # ceres interpretes the third and fourth argument as
|
---|
117 | # maximum simulated impact if they are identical and
|
---|
118 | # the other four arguments are 1
|
---|
119 | # echo "CERARY 1 1 "$diameter" "$diameter" 1 1"
|
---|
120 | # How the longitudinal shower development is sampled
|
---|
121 | # echo "LONGI T 10. T F"
|
---|
122 | echo "LONGI F 20 0 F F"
|
---|
123 | # Maximum number of detailed particles to print
|
---|
124 | echo "MAXPRT 0"
|
---|
125 | # Suppress file with partciles reaching ground (DATnnnnnn)
|
---|
126 | # FIXME: Should we make this switchable by the database?
|
---|
127 | echo "PAROUT F F"
|
---|
128 | # Don't write a database file
|
---|
129 | echo "DATBAS F"
|
---|
130 | # Switch off all debugging output
|
---|
131 | echo "DEBUG F 6 F 1000000"
|
---|
132 | # Output path
|
---|
133 | echo "DIRECT "$outpath
|
---|
134 | # DIRECT /dev/null
|
---|
135 | # TELFIL filename
|
---|
136 | # TELFIL | gzip
|
---|
137 | # TELESCOPE X Y Z R
|
---|
138 | # User and host (for convenience)
|
---|
139 | echo "USER "`whoami`
|
---|
140 | echo "HOST "`hostname`
|
---|
141 | # End of input card
|
---|
142 | echo "EXIT"
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | # get sequence #
|
---|
147 | gettodo "1"
|
---|
148 | run=${primaries[0]}
|
---|
149 | file=${primaries[1]}
|
---|
150 |
|
---|
151 | # lock sequ
|
---|
152 | lockfile=$lockpath/lock-$step-$run.$file.txt
|
---|
153 | checklock
|
---|
154 |
|
---|
155 | printprocesslog "INFO starting $program for run $run and file $file"
|
---|
156 |
|
---|
157 | setstatus "start"
|
---|
158 |
|
---|
159 | printprocesslog "INFO run $program for run $run and file $file"
|
---|
160 | printprocesslog "INFO create input card for run $run and file $file"
|
---|
161 |
|
---|
162 | # get values for inputcard
|
---|
163 | query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
164 | primparticle=`sendquery`
|
---|
165 | query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
166 | erange=`sendquery`
|
---|
167 | query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
168 | numevts=`sendquery`
|
---|
169 | query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
170 | slope=`sendquery`
|
---|
171 | query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
172 | zdrange=`sendquery`
|
---|
173 | # Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
|
---|
174 | query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
175 | azrange=`sendquery`
|
---|
176 | query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
177 | seed1=`sendquery`
|
---|
178 | query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
179 | seed2=`sendquery`
|
---|
180 | query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
181 | seed3=`sendquery`
|
---|
182 | query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
183 | impactmax=`sendquery`
|
---|
184 | query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
185 | viewconemax=`sendquery`
|
---|
186 | query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
187 | startalt=`sendquery`
|
---|
188 | query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
189 | diameter=`sendquery`
|
---|
190 | query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
191 | atm=`sendquery`
|
---|
192 | query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
193 | obslev=`sendquery`
|
---|
194 | query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
195 | magnet=`sendquery`
|
---|
196 | query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
197 | magnetrot=`sendquery`
|
---|
198 | query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
199 | wavelengths=`sendquery`
|
---|
200 | query="SELECT fNumReUseShowers FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file"
|
---|
201 | numreuse=`sendquery`
|
---|
202 |
|
---|
203 | outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
|
---|
204 | makedir $outpath
|
---|
205 | logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log"
|
---|
206 |
|
---|
207 | cd $corsikapath
|
---|
208 |
|
---|
209 | printprocesslog "INFO executing 'printinputcard | ./cc6501p-linux >| $logfile 2>&1' in directory $corsikapath "
|
---|
210 | printinputcard | ./cc6501p-linux >| $logfile 2>&1
|
---|
211 |
|
---|
212 | check1=$?
|
---|
213 | case $check1 in
|
---|
214 | 0) printprocesslog "INFO $program finished successfully for run $run file $file (return code $check1)"
|
---|
215 | if [ $file -gt 999 ]
|
---|
216 | then
|
---|
217 | 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`
|
---|
218 | corsikafileold=$mcpath/$program/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer`printf %06d $file`
|
---|
219 | if ! mv $corsikafileold $corsikafilenew
|
---|
220 | then
|
---|
221 | printprocesslog "ERROR could not mv $corsikafileold to $corsikafilenew"
|
---|
222 | check=2
|
---|
223 | fi
|
---|
224 | fi
|
---|
225 | if ! grep 'END OF RUN' $logfile
|
---|
226 | then
|
---|
227 | printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run file $file "
|
---|
228 | check=2
|
---|
229 | fi
|
---|
230 | ;;
|
---|
231 | *) printprocesslog "ERROR $program failed for run $run file $file (return code $check1)"
|
---|
232 | check=$check1
|
---|
233 | ;;
|
---|
234 | esac
|
---|
235 |
|
---|
236 | # removing empty datnnnnnn file
|
---|
237 | rm -f $outpath/dat`printf %06d $file`
|
---|
238 |
|
---|
239 | setstatus "stop"
|
---|
240 |
|
---|
241 | finish
|
---|
242 |
|
---|