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 | file=${primaries[1]} |
---|
43 | cereskey=${primaries[2]} |
---|
44 | |
---|
45 | # lock sequ for cal |
---|
46 | lockfile=$lockpath/lock-$step-$run.$file.$cereskey.txt |
---|
47 | checklock |
---|
48 | |
---|
49 | cd $mars |
---|
50 | |
---|
51 | # run calibration for sequence |
---|
52 | printprocesslog "INFO starting $program for run $run and file $file and ceres-setup $cereskey" |
---|
53 | |
---|
54 | setstatus "start" |
---|
55 | |
---|
56 | setupfile=$setuppath/$program/`printf %03d $cereskey`/ceres.rc |
---|
57 | |
---|
58 | query="SELECT fRunTypeKEY FROM CeresInfo WHERE fRunNumber="$run" AND fFileNumber="$file" AND fCeresSetupKEY="$cereskey |
---|
59 | runkey=`sendquery` |
---|
60 | |
---|
61 | case $runkey in |
---|
62 | 2) printprocesslog "INFO run $run and file $file is a data run (key="$runkey")" |
---|
63 | inputfile=$mcpath/corsika/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8`/cer000`printf %06d $file | cut -c 4-6` |
---|
64 | outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $run | cut -c 1-4`/`printf %08d $run | cut -c 5-8` |
---|
65 | makedir $outpath |
---|
66 | log=$outpath/ceres`printf %08d $run `"."`printf %06d $file | cut -c 4-6` |
---|
67 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run $inputfile" |
---|
68 | printprocesslog "INFO executing "$command |
---|
69 | $command |
---|
70 | check1=$? |
---|
71 | ;; |
---|
72 | 3) printprocesslog "INFO run $run and file $file is a pedestal run (key="$runkey")" |
---|
73 | drun=`echo "$run + 2 " | bc -l` |
---|
74 | $outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8` |
---|
75 | makedir $outpath |
---|
76 | log=$outpath/ceres`printf %08d $run `"."`printf %06d $file | cut -c 4-6` |
---|
77 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run pedestal" |
---|
78 | printprocesslog "INFO executing "$command |
---|
79 | $command |
---|
80 | check1=$? |
---|
81 | ;; |
---|
82 | 4) printprocesslog "INFO run $run and file $file is a calibration run (key="$runkey")" |
---|
83 | drun=`echo "$run + 1 " | bc -l` |
---|
84 | $outpath=$mcpath/ceres/`printf %03d $cereskey`/`printf %08d $drun | cut -c 1-4`/`printf %08d $drun | cut -c 5-8` |
---|
85 | makedir $outpath |
---|
86 | log=$outpath/ceres`printf %08d $run `"."`printf %06d $file | cut -c 4-6` |
---|
87 | command="./ceres -b -q -f --config=$setupfile --out=$outpath --log=$log.log --html=$log.html --run-number=$run calibration" |
---|
88 | printprocesslog "INFO executing "$command |
---|
89 | $command |
---|
90 | check1=$? |
---|
91 | ;; |
---|
92 | *) printprocesslog "WARN not valid fRunTypeKEY ("$runkey")was queried from the DB." |
---|
93 | finish |
---|
94 | ;; |
---|
95 | esac |
---|
96 | |
---|
97 | case $check1 in |
---|
98 | 0) printprocesslog "INFO $program finished successfully for run $run file $file cereskey $cereskey runtype $runkey (check1=$check1)" |
---|
99 | ;; |
---|
100 | *) printprocesslog "ERROR $program failed for run $run file $file cereskey $cereskey runtype $runkey (check1=$check1)" |
---|
101 | check=$check1 |
---|
102 | ;; |
---|
103 | esac |
---|
104 | |
---|
105 | setstatus "stop" |
---|
106 | |
---|
107 | finish |
---|
108 | |
---|