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-2007
|
---|
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 |
|
---|
53 | # query failed callistos (returncode 13) from DB
|
---|
54 | query="SELECT fSequenceFirst, fTelescopeNumber from SequenceProcessStatus where fReturnCode=13 and fProgramId=14"
|
---|
55 | primaries=( `sendquery` )
|
---|
56 | echo ${primaries[@]}
|
---|
57 | if [ ${#primaries[@]} -eq 0 ]
|
---|
58 | then
|
---|
59 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
60 | finish >> $scriptlog 2>&1
|
---|
61 | fi
|
---|
62 | num=`expr ${#primaries[@]} / 2 `
|
---|
63 |
|
---|
64 | cd $mars
|
---|
65 |
|
---|
66 | printprocesslog "INFO linking callisto.rc files"
|
---|
67 | for (( s=0 ; s < $num ; s++ ))
|
---|
68 | do
|
---|
69 | sequence=${primaries[$s+$s]}
|
---|
70 | telnum=${primaries[$s+$s+1]}
|
---|
71 | callistorc=$datapath/callisto/`printf %08d $sequence | cut -c 0-4`/`printf %08d $sequence`/$callistorcseq
|
---|
72 | if ! ls -l $callistorc 2>/dev/null | grep $callistorcnew >> $scriptlog 2>&1
|
---|
73 | then
|
---|
74 | printprocesslog "INFO linking $callistorcnew to $callistorc for sequ $sequence"
|
---|
75 | # resetting the calibration
|
---|
76 | echo "resetting the callisto for sequence $sequence" >> $scriptlog 2>&1
|
---|
77 |
|
---|
78 | query="UPDATE SequenceProcessStatus set fStartTime=NULL, fFailedTime=NULL, fProgramId=NULL, fReturnCode=NULL where fSequenceFirst=$sequence and fTelescopeNumber=$telnum"
|
---|
79 | if ! sendquery >> $scriptlog 2>&1
|
---|
80 | then
|
---|
81 | printprocesslog "ERROR resetting calibration failed for sequence $sequence"
|
---|
82 | continue
|
---|
83 | else
|
---|
84 | printprocesslog "INFO resetted calibration successfully for sequence $sequence"
|
---|
85 | fi
|
---|
86 |
|
---|
87 | #linking callisto.rc
|
---|
88 | if ln -vfs $setuppath/callisto/$callistorcnew $callistorc >> $scriptlog 2>&1
|
---|
89 | then
|
---|
90 | printprocesslog "INFO link callisto.rc successfully for sequence $sequence"
|
---|
91 | else
|
---|
92 | printprocesslog "ERROR linking callisto.rc failed for sequence $sequence"
|
---|
93 | fi
|
---|
94 |
|
---|
95 | fi
|
---|
96 | done
|
---|
97 |
|
---|
98 | finish >> $scriptlog 2>&1
|
---|
99 |
|
---|