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 06/2010 <mailto:daniela.dorner@unige.ch>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2010
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script is launching ceres for corsika runs.
|
---|
28 | #
|
---|
29 | # The ceres.rc and other setup files are stored in the setup directory.
|
---|
30 | #
|
---|
31 |
|
---|
32 | source `dirname $0`/sourcefile
|
---|
33 | printprocesslog "INFO starting $0"
|
---|
34 | program=ceres
|
---|
35 | step=Ceres
|
---|
36 |
|
---|
37 | set -C
|
---|
38 |
|
---|
39 | # get sequence #
|
---|
40 | gettodo "1"
|
---|
41 | run=${primaries[0]}
|
---|
42 | cereskey=${primaries[1]}
|
---|
43 |
|
---|
44 | # lock sequ for cal
|
---|
45 | lockfile=$lockpath/lock-$step-$run.$cereskey.txt
|
---|
46 | checklock
|
---|
47 |
|
---|
48 | cd $mars
|
---|
49 |
|
---|
50 | # run calibration for sequence
|
---|
51 | printprocesslog "INFO starting $program for run $run and ceres-setup $cereskey"
|
---|
52 |
|
---|
53 | setstatus "start"
|
---|
54 |
|
---|
55 | setupfile=$setuppath/$program/`printf %03d $cereskey`/ceres.rc
|
---|
56 |
|
---|
57 | query="SELECT fRunTypeKEY FROM CeresInfo WHERE fRunNumber="$run" AND fCeresSetupKEY="$cereskey
|
---|
58 | runkey=`sendquery`
|
---|
59 |
|
---|
60 | case $runkey in
|
---|
61 | 2) printprocesslog "INFO run $run is a data run (key="$runkey")"
|
---|
62 | printprocesslog "INFO getting file numbers for run "$run
|
---|
63 | query="SELECT CONCAT('"$mcpath"/corsika/', RIGHT(LPAD(CeresInfo.fRunNumber, 8, '0'), 4),"
|
---|
64 | query=$query" '"$mcpath"/corsika/', LEFT(LPAD(CeresInfo.fRunNumber, 8, '0'), 4), '/cer000'"
|
---|
65 | query=$query" RIGHT(LPAD(CeresInfo.fFileNumber, 6, '0'), 3)) from CeresInfo "
|
---|
66 | query=$query" WHERE fRunNumber="$run" AND fCeresSetupKEY="$cereskey
|
---|
67 | inputfiles=`sendquery`
|
---|
68 | outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`
|
---|
69 | makedir $outpath
|
---|
70 | log=$outpath/ceres`printf %08d $run `
|
---|
71 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run $inputfiles"
|
---|
72 | printprocesslog "INFO executing "$command
|
---|
73 | $command
|
---|
74 | check1=$?
|
---|
75 | ;;
|
---|
76 | 3) printprocesslog "INFO run $run is a pedestal run (key="$runkey")"
|
---|
77 | drun=`echo "$run + 2 " | bc -l`
|
---|
78 | outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8`
|
---|
79 | makedir $outpath
|
---|
80 | log=$outpath/ceres`printf %08d $run `
|
---|
81 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run pedestal"
|
---|
82 | printprocesslog "INFO executing "$command
|
---|
83 | $command
|
---|
84 | check1=$?
|
---|
85 | ;;
|
---|
86 | 4) printprocesslog "INFO run $run is a calibration run (key="$runkey")"
|
---|
87 | drun=`echo "$run + 1 " | bc -l`
|
---|
88 | outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8`
|
---|
89 | makedir $outpath
|
---|
90 | log=$outpath/ceres`printf %08d $run `
|
---|
91 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run calibration"
|
---|
92 | printprocesslog "INFO executing "$command
|
---|
93 | $command
|
---|
94 | check1=$?
|
---|
95 | ;;
|
---|
96 | *) printprocesslog "WARN not valid fRunTypeKEY ("$runkey")was queried from the DB."
|
---|
97 | finish
|
---|
98 | ;;
|
---|
99 | esac
|
---|
100 |
|
---|
101 | case $check1 in
|
---|
102 | 0) printprocesslog "INFO $program finished successfully for run $run, cereskey $cereskey, runtype $runkey (check1=$check1)"
|
---|
103 | ;;
|
---|
104 | *) printprocesslog "ERROR $program failed for run $run, cereskey $cereskey, runtype $runkey (check1=$check1)"
|
---|
105 | check=$check1
|
---|
106 | ;;
|
---|
107 | esac
|
---|
108 |
|
---|
109 | setstatus "stop"
|
---|
110 |
|
---|
111 | finish
|
---|
112 |
|
---|