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

Last change on this file since 9343 was 9343, checked in by tbretz, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.7 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:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2008
23#
24#
25# ========================================================================
26#
27# This script runs corsika.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32program=corsika
33column=fCorsikaFileAvail
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 "$corsikarunno
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 2200.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 30.3 24.1"
67 # Rotation angle between array x-direction and magnetic north direction
68 # positive if array x-direction points to the west
69 echo "ARRANG -7.0"
70 # Atmosphere
71 echo "ATMOSPHERE 11 T"
72 # Other parameters
73 echo "RADNKG 200.E2"
74 echo "ECUTS 0.3 0.3 0.02 0.02"
75 echo "ECTMAP 1.E4"
76 echo "STEPFC 0.1"
77 # Don't add muon particle data to output
78 echo "MUADDI F"
79 # Enable muon multiple scattering
80 echo "MUMULT T"
81 # Cherenkov telescope options
82 echo "CWAVLG 290. 600."
83 echo "CSCAT "$reuse" 0. "$impactmax
84 echo "CERSIZ 1."
85 echo "CERFIL T"
86 echo "CERTEL 1"
87 echo " 0. 0. 0. 0. 0. "$diameter" 1700."
88 # How the longitudinal shower development is sampled
89 # echo "LONGI T 10. T F"
90 echo "LONGI F 20 0 F F"
91 # Maximum number of detailed particles to print
92 echo "MAXPRT 0"
93 # Suppress file with partciles reaching ground (DATnnnnnn)
94 # FIXME: Should we make this switchable by the database?
95 echo "PAROUT F F"
96 # Don't write a database file
97 echo "DATBAS F"
98 # Switch off all debugging output
99 echo "DEBUG F 6 F 1000000"
100 # Output path
101 echo "DIRECT "$outpath
102 # User and host (for convinience)
103 echo "USER "`whoami`
104 echo "HOST "`hostname`
105 # End of input card
106 echo "EXIT"
107}
108
109
110scriptlog=$runlogpath/run$program-$datetime.log
111date >> $scriptlog 2>&1
112
113# get sequence #
114gettodo "1" >> $scriptlog 2>&1
115run=${primaries[0]}
116# get corsika runno
117query="SELECT fCorsikaRunNumber FROM MCRunData where fMCRunNumber="$run
118# to be changed later again, when additional tables are available
119#corsikarunno=`sendquery`
120corsikarunno=$run
121
122# lock sequ
123lockfile=$lockpath/lock-$table-$column-$corsikarunno.txt
124checklock >> $scriptlog 2>&1
125
126echo "run $program for run $run..." >> $scriptlog 2>&1
127printprocesslog "INFO starting $program for run $run"
128
129setstatus "start" >> $scriptlog 2>&1
130
131echo "run $program for run $run " >> $scriptlog 2>&1
132echo "create input card... " >> $scriptlog 2>&1
133
134# get values for inputcard
135query="SELECT fParticleTypeKEY FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
136primparticle=`sendquery`
137query="SELECT fEnergyMin, fEnergyMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
138erange=`sendquery`
139query="SELECT fNumEvents FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
140numevts=`sendquery`
141query="SELECT fEnergySlope FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
142slope=`sendquery`
143query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
144zdrange=`sendquery`
145# Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West)
146query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
147azrange=`sendquery`
148query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
149date=`sendquery`
150outpath=$mcpath"/"$program"/"$date
151query="SELECT fCorsikaSeed FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
152seed1=`sendquery`
153query="SELECT fCorsikaSeed+1 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
154seed2=`sendquery`
155query="SELECT fCorsikaSeed+2 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
156seed3=`sendquery`
157query="SELECT fImpactMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
158impactmax=`sendquery`
159query="SELECT fViewConeMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
160viewconemax=`sendquery`
161query="SELECT fNumReUseShower FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
162reuse=`sendquery`
163query="SELECT fStartingAltitude FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
164startalt=`sendquery`
165query="SELECT fMirrorDiameter FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
166diameter=`sendquery`
167
168echo "" >> $scriptlog 2>&1
169echo "INPUTCARD:" >> $scriptlog 2>&1
170echo "----------" >> $scriptlog 2>&1
171echo "" >> $scriptlog 2>&1
172echo "" >> $scriptlog 2>&1
173printinputcard >> $scriptlog 2>&1
174
175logfile=$outpath/$program"-"`printf %06d $corsikarunno`".log"
176makedir $outpath >> $scriptlog 2>&1
177
178cd $corsikapath
179
180echo "INPUTCARD:" >| $logfile 2>&1
181printinputcard >> $logfile 2>&1
182echo "" >> $logfile 2>&1
183echo "" >> $logfile 2>&1
184printinputcard | ./cc6501p-linux >> $logfile 2>&1
185
186rm -f $outpath/dat`printf %06d $corsikarunno`
187
188check1=$?
189
190case $check1 in
191 0) echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
192 printprocesslog "INFO $program finished successfully for corsika run number $corsikarunno"
193 ;;
194 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
195 printprocesslog "ERROR $program failed for corsika run number $corsikarunno"
196 com=$Fcorsika
197 check=$check1
198 ;;
199esac
200
201setstatus "stop" >> $scriptlog 2>&1
202
203finish >> $scriptlog 2>&1
204
Note: See TracBrowser for help on using the repository browser.