source: trunk/MagicSoft/Mars/datacenter/scripts/correcttime@ 7460

Last change on this file since 7460 was 7460, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.7 KB
Line 
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 runs the timing correction for all run, that need the timing
28# correction
29#
30# After checking, if the script is already running, the todolist is
31# written by using the macro getdolist.C
32# Then for each run the timing correction is done
33# If this was successful, the status is inserted into the database using
34# the macro setstatus.C
35#
36# This script was needed for the data between 06/2004 and 02/2005 (including
37# this months).
38#
39
40user=`whoami`
41source /home/$user/Mars/datacenter/scripts/sourcefile
42
43table=RunProcessStatus
44column=fTimingCorrection
45date=NULL
46datetime=`date +%F_%T`
47year=`date +%Y`
48
49getstatuslogpath=$logpath/getstatus/correct_raw_time/$year
50getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
51makedir $getstatuslogpath >> $scriptlog 2>&1
52
53if [ -e $listpath/ToDo-$table-$column.txt ]
54then
55 echo "correct_raw_time is already running -> exit"
56 exit
57fi
58
59cd $mars
60
61echo "getting list..."
62check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
63
64case $check0 in
65 1) echo "check0=$check0 -> everything ok -> run correct_raw_time";;
66 *) echo "check0=$check0 -> ERROR -> step has to be repeated";;
67esac
68
69# retrieving runs from todo file
70runs=(`cat $listpath/ToDo-$table-$column.txt`)
71if [ "$runs" = "" ]
72then
73 echo "nothing to do -> exit"
74 rm -v $listpath/ToDo-$table-$column.txt
75 exit
76fi
77
78echo "runs: "${runs[@]}
79for run in ${runs[@]}
80do
81 echo "getting path for run $run ... "
82 infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
83 echo "infile:"$infile
84 outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
85 echo "outfile:"$outfile
86 outpath=`dirname $outfile`
87 echo "outpath:"$outpath
88 makedir $outpath
89
90 timecorrpath=$outpath"/timecorrlogs"
91 echo "timecorrpath: "$timecorrpath
92 makedir $timecorrpath
93
94 check1=0
95 echo "run correct_raw_time..."
96 /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/correct_raw_time-$run.log
97 check1=$?
98
99 case $check1 in
100 1) echo "check1=$check1 -> everything ok -> setting status..."
101 no=`printf %08d $run | cut -c 1-5`
102 setstatuspath=$logpath/setstatus/correct_raw_time/$no
103 echo "setstatuspath: "$setstatuspath
104 makedir $setstatuspath
105
106 check2=`root -q -b $macrospath/setstatus.C+\("\"$run\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuspath/setstatus-correct_raw_time-$run.log | grep int | sed -e 's/(int)//'`
107 case $check2 in
108 0) echo "check2=0 -> ERROR -> step could not be set";;
109 1) echo "check2=1 -> everything ok, status has been set";;
110 esac
111 ;;
112 *) echo "check1=$check1 -> ERROR -> step has to be repeated";;
113 esac
114done
115
116rm -v $listpath/ToDo-$table-$column.txt
117
Note: See TracBrowser for help on using the repository browser.