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

Last change on this file since 6982 was 6934, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.1 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-2004
23#
24#
25# ========================================================================
26#
27#
28
29export ROOTSYS=/opt/root_v3.10.02
30export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
31export PATH=$PATH:$ROOTSYS/bin
32
33mars=/home/operator/Mars
34macrospath=$mars/datacenter/macros
35
36table=RunProcessStatus
37column=fTimingCorrection
38date=NULL
39datetime=`date +%F_%T`
40year=`date +%Y`
41
42listdir=/magic/datacenter/lists
43logpath=/magic/datacenter/autologs
44getstatuslogpath=$logpath/getstatus/correct_raw_time/$year
45getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
46
47if [ ! -d $getstatuslogpath ]
48then
49 mkdir -pv $getstatuslogpath
50 if [ ! -d $getstatuslogpath ]
51 then
52 echo "could not make getstatuslogpath "$getstatuslogpath
53 exit
54 fi
55fi
56
57
58if [ -e $listdir/ToDo-$table-$column.txt ]
59then
60 echo "correct_raw_time is already running -> exit"
61 exit
62fi
63
64cd $mars
65
66echo "getting list..."
67check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
68
69case $check0 in
70 1) echo "check0=$check0 -> everthing ok -> run correct_raw_time";;
71 *) echo "check0=$check0 -> ERROR -> step has to be repeated";;
72esac
73
74runs=(`cat $listdir/ToDo-$table-$column.txt`)
75
76if [ "$runs" = "" ]
77then
78 echo "nothing to do -> exit"
79 rm -v $listdir/ToDo-$table-$column.txt
80 exit
81fi
82
83echo "runs: "${runs[@]}
84
85for run in ${runs[@]}
86do
87 echo "getting path for run $run ... "
88 infile=`find /magic/data/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
89 echo "infile:"$infile
90 outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
91 echo "outfile:"$outfile
92 outpath=`dirname $outfile`
93 echo "outpath:"$outpath
94 if [ ! -d $outpath ]
95 then
96 mkdir -pv $outpath
97 if [ ! -d $outpath ]
98 then
99 echo "could not make outpath "$outpath
100 continue
101 fi
102 fi
103 timecorrpath=$outpath"/timecorrlogs"
104 echo "timecorrpath: "$timecorrpath
105 if [ ! -d $timecorrpath ]
106 then
107 mkdir -pv $timecorrpath
108 if [ ! -d $timecorrpath ]
109 then
110 echo "could not make timecorrpath "$timecorrpath
111 continue
112 fi
113 fi
114
115 check1=0
116 echo "run correct_raw_time..."
117 /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/correct_raw_time-$run.log
118 check1=$?
119
120 case $check1 in
121 1) echo "check1=$check1 -> everthing ok -> setting status..."
122 no=`printf %08d $run | cut -c 1-5`
123 setstatuspath=$logpath/setstatus/correct_raw_time/$no
124 echo "setstatuspath: "$setstatuspath
125 if [ ! -d $setstatuspath ]
126 then
127 mkdir -pv $setstatuspath
128 if [ ! -d $setstatuspath ]
129 then
130 echo "could not make setstatuspath $setstatuspath -> continue "
131 continue
132 fi
133 fi
134 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)//'`
135 case $check2 in
136 0) echo "check2=0 -> ERROR -> step could not be set";;
137 1) echo "check2=1 -> everthing ok, status has been set";;
138 esac
139 ;;
140 *) echo "check1=$check1 -> ERROR -> step has to be repeated";;
141 esac
142done
143
144rm -v $listdir/ToDo-$table-$column.txt
145
Note: See TracBrowser for help on using the repository browser.