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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script links a special callisto.rc for data, for which the
|
---|
28 | # calibration with the standard callisto.rc failes.
|
---|
29 | #
|
---|
30 | # The sequences with failing calibration are searched by searching for the
|
---|
31 | # reason of failure in the callisto.log Then the special callisto.rc is
|
---|
32 | # linked to the directory of the sequence.
|
---|
33 | #
|
---|
34 |
|
---|
35 | source `dirname $0`/sourcefile
|
---|
36 | printprocesslog "INFO starting $0"
|
---|
37 | program=makecallistolinks
|
---|
38 | column=fCallisto
|
---|
39 | table=SequenceProcessStatus
|
---|
40 |
|
---|
41 | set -C
|
---|
42 |
|
---|
43 | scriptlog=$runlogpath/$program`date +%F`.log
|
---|
44 | date >> $scriptlog 2>&1
|
---|
45 |
|
---|
46 | # check if script is already running
|
---|
47 | lockfile=$lockpath/lock-$program.txt
|
---|
48 | checklock >> $scriptlog 2>&1
|
---|
49 |
|
---|
50 | callistorcseq=callisto.rc
|
---|
51 | callistorcnew=callisto_Dec04Jan05.rc
|
---|
52 | # reason why calibration with standard callisto.rc fails
|
---|
53 | #reason1="Pulse is too much to the right, cannot go beyond logain limits!"
|
---|
54 | #.* == hi or lo
|
---|
55 | reason1="Pulse is too much to the right, out of .*-gain range"
|
---|
56 | reason2="No entry for resource id '2[45]' found in"
|
---|
57 | echo "reason1: "$reason1 >> $scriptlog 2>&1
|
---|
58 | echo "reason2: "$reason2 >> $scriptlog 2>&1
|
---|
59 |
|
---|
60 | # find files containing reason
|
---|
61 | files=`find $datapath/callisto/ -name callisto*.log`
|
---|
62 | if [ "$files" = "" ]
|
---|
63 | then
|
---|
64 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
65 | finish >> $scriptlog 2>&1
|
---|
66 | fi
|
---|
67 |
|
---|
68 | cd $mars
|
---|
69 |
|
---|
70 | # make links for callisto.rc for which the callisto.log contains reason
|
---|
71 | printprocesslog "INFO linking callisto.rc files"
|
---|
72 | for file in $files
|
---|
73 | do
|
---|
74 | pulse=`cat $file | grep "$reason1\|$reason2"`
|
---|
75 | sequ=`echo $file | cut -d/ -f6`
|
---|
76 | path=`dirname $file`
|
---|
77 | callistorc=$path/$callistorcseq
|
---|
78 |
|
---|
79 | if [ ! "$pulse" = "" ]
|
---|
80 | then
|
---|
81 | if ! ls -l $callistorc | grep $callistorcnew >> $scriptlog 2>&1
|
---|
82 | then
|
---|
83 | printprocesslog "INFO linking $callistorcnew to $callistorc for sequ $sequ"
|
---|
84 | # resetting the calibration
|
---|
85 | echo "resetting the callisto for sequence $sequ" >> $scriptlog 2>&1
|
---|
86 | echo " reason: $pulse" >> $scriptlog 2>&1
|
---|
87 | resetlogpath=$logpath/resetcallisto
|
---|
88 | makedir $resetlogpath >> $scriptlog 2>&1
|
---|
89 | resetlog=$resetlogpath/reset-callisto-$sequ.log
|
---|
90 |
|
---|
91 | check1=`root -q -b $macrospath/resetcolumn.C+\("\"$column\""\,"\"$table\""\,"\"$sequ\""\,"\"$sequ\""\,kFALSE\) | tee $resetlog | intgrep`
|
---|
92 | case $check1 in
|
---|
93 | 1) echo " check1=$check1 -> everything ok, callisto has been reset " >> $scriptlog 2>&1
|
---|
94 | printprocesslog "INFO resetted calibration successfully for sequence $sequ"
|
---|
95 | ;;
|
---|
96 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
97 | printprocesslog "WARN connection to DB failed"
|
---|
98 | check="no"
|
---|
99 | ;;
|
---|
100 | *) echo " check1=$check1 -> ERROR -> step could not be resetted -> continue " >> $scriptlog 2>&1
|
---|
101 | printprocesslog "ERROR resetcolumn.C failed for fCallisto for sequ $sequ"
|
---|
102 | continue
|
---|
103 | ;;
|
---|
104 | esac
|
---|
105 | #linking callisto.rc
|
---|
106 | ln -vfs $setuppath/callisto/$callistorcnew $callistorc >> $scriptlog 2>&1
|
---|
107 | fi
|
---|
108 | fi
|
---|
109 | done
|
---|
110 |
|
---|
111 | finish >> $scriptlog 2>&1
|
---|
112 |
|
---|