source: trunk/Mars/datacenter/scripts/runsimtel@ 11862

Last change on this file since 11862 was 11862, checked in by Daniela Dorner, 13 years ago
added observation level and moon
  • Property svn:executable set to *
File size: 5.3 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of CheObs, the Modular 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 appears 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 01/2009 <mailto:daniela.dorner@unige.ch>
21#
22# Copyright: CheObs Software Development, 2000-2009
23#
24#
25# ========================================================================
26#
27# This script runs corsika and simtelarray.
28#
29
30source `dirname $0`/sourcefile
31printprocesslog "INFO starting $0"
32program=corsikasimtel
33column=fCorsikaSimTelarray
34
35# todo:
36# evtl trennung v corsika u simtel
37
38set -C
39
40simdir=$mcpath/software/simtel
41
42export CORSIKA_PATH=$simdir/corsika-6735/run/
43export SIM_TELARRAY_PATH=$simdir/sim_telarray
44export MCDATA_PATH=$mcpath
45export CORSIKA_DATA="${MCDATA_PATH}/corsika"
46export SIM_TELARRAY_DATA="${MCDATA_PATH}/simtel"
47
48# printing input card to stdout
49function printinputcard()
50{
51 # Run number
52 echo "RUNNR "$run
53 # Number of simulated events
54 echo "NSHOW "$numevts
55 # Seed values for simulation
56 echo "SEED "$run" 0 0 "
57 echo "SEED "$run" 0 0 "
58 echo "SEED "$run" 0 0 "
59 echo "SEED "$run" 0 0 "
60 # Observation level
61 echo "OBSLEV "$obslev".E2"
62 # output directory
63 echo "DIRECT "$outpath"/ "
64 cat $inputcardpart
65}
66
67
68# get hostname
69prodhost=`echo $HOSTNAME | sed -e 's/compute-0-//' -e 's/[.]local//'`
70
71diskusage=( `df $mcpath | grep $mcpath` )
72# continue only if more than 90 GB are left on /state/cta
73if [ ${diskusage[3]} -lt 90000000 ]
74then
75 printprocesslog "WARN less than 90 GB left on $mcpath on node $prodhost "
76 finish
77else
78 printprocesslog "INFO still ${diskusage[3]} left on $mcpath on node $prodhost "
79fi
80
81
82# get sequence #
83gettodo "1"
84run=${primaries[0]}
85
86# lock sequ
87lockfile=$lockpath/lock-$table-$column-$run.txt
88checklock
89
90printprocesslog "INFO starting $program for run $run"
91
92# get values for inputcard
93query="SELECT fParticleTypeName FROM MCRunData LEFT JOIN ParticleType using (fParticleTypeKEY) where fMCRunNumber="$run
94primparticle=`sendquery`
95query="SELECT fNumEvents FROM MCRunData where fMCRunNumber="$run
96numevts=`sendquery`
97
98# get observation level for the script to be begun for sim_telarray
99query="SELECT fObsLevel FROM MCRunData WHERE fMCRunNumber="$run
100obslev=`sendquery`
101# export $OBSLEVEL for the script sim_telarray/cta-ultra2_run.sh or sim_telarray/cta-ultra2-moon_run.sh
102export OBSLEVEL=$obslev
103
104# get moon condition for the script to be begun for sim_telarray
105query="SELECT fMoonConditionKEY FROM MCRunData where fMCRunNumber="$run
106mooncase=`sendquery`
107# export $moon for the script sim_telarray/multi/multi_cta-ultra3.cfg
108case $mooncase in
109 0) export moon=''
110 ;;
111 1) export moon="-moon"
112 ;;
113 *) printprocesslog "ERROR $program failed to retrieve the moon condition"
114 finish
115 ;;
116esac
117
118# for MC for 5at5
119if [ "$obslev" == "5000" ]
120then
121 export moon="-5at5"
122 inputcardpart=$setuppath/INPUTS_CTA_ULTRA3_${primparticle}_part_5at5
123else
124 inputcardpart=$setuppath/INPUTS_CTA_ULTRA3_${primparticle}_part
125fi
126
127
128# path and logs
129outpath=$mcpath"/corsika/"`printf %06d $run`
130logfile=$outpath/$program"-"`printf %06d $run`".log"
131inputcard=$outpath/$program"-"`printf %06d $run`".card"
132makedir $outpath
133
134# insert host into db
135query="UPDATE MCRunProcessStatus set fProductionHostKEY=$prodhost where fMCRunNumber="$run
136if ! sendquery $query
137then
138 printprocesslog "inserting host failed"
139 finish
140fi
141
142setstatus "start"
143
144cd $CORSIKA_PATH
145
146printprocesslog "INFO create inputcard for run $run"
147
148#
149# starting corsika with pipe to simtelarray
150# in the inputcard the path to the script is defined:
151# ${SIM_TELARRAY_PATH}/run_sim_cta-ultra3 (i.e. run_sim_hessarray_generic)
152# in this script a setup file is chosen:
153# multicfg="multi/multi_${cfg}.cfg"
154# in multi/multi_cta-ultra3.cfg one can choose whether to store
155# the corsika files:
156# gzip > ${CORSIKA_DATA}/run${CORSIKA_RUN}.corsika.gz
157# and multi/multi_cta-ultra3.cfg starts the script
158# ${SIM_TELARRAY_PATH}/cta-ultra2_run.sh (i.e. generic_run.sh)
159# in which e.g. path and file name are set
160#
161printinputcard >| $inputcard
162#./corsika < $inputcard >| $logfile 2>&1
163./corsika6735Linux_QGSJET_urqmd < $inputcard >| $logfile 2>&1
164check1=$?
165
166case $check1 in
167 0) printprocesslog "INFO finished corsika and simtelarray without error (check1=$check1) "
168 if ! grep 'END OF RUN' $logfile
169 then
170 printprocesslog "ERROR could not find 'END OF RUN' in $logfile => unknown error for run $run"
171 com=$Fcorsikasimtel
172 check=2
173 else
174 printprocesslog "INFO $program finished successfully for mc run number $run"
175 fi
176 ;;
177 *) printprocesslog "ERROR $program failed for mc run number $run (check1=$check1)"
178 com=$Fcorsikasimtel
179 check=$check1
180 ;;
181esac
182
183setstatus "stop"
184
185finish
186
Note: See TracBrowser for help on using the repository browser.