source: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk@ 7669

Last change on this file since 7669 was 7486, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.3 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 checks which files are on disk and updates the database
28# accordingly. It is not yet running automatically.
29#
30# It is checking the:
31# - ccfiles
32# - cacofiles
33# this includes also the search for missing cacofiles:
34# Sometimes the DAQ aborts a run and starts itself a new one. In this
35# cases the camera controll doesn't start a new file, as the command to
36# start a new run was not sent by the central control. So the caco
37# information is stored in the previous caco file, which has a
38# different runnumber. To be able to merpp the information into the
39# calibrated data file, the runnumber of the file containing the
40# information has to be found.
41# In this script the search and inserting into the database is done
42# using the macros findcacofiles.C and insertcacofile.C
43# - rawfiles
44# The update in the database is done using the macro resetallruns.C
45#
46
47user=`whoami`
48source /home/$user/Mars/datacenter/scripts/sourcefile
49
50cd $mars
51date=`date +%F`
52
53subsystemdir=/magic/subsystemdata
54filesondisklogpath=$logpath/filesondisk/`date +%Y`
55makedir $filesondisklogpath
56
57
58echo "checking disk for ccfiles..."
59filename=$filesondisklogpath/ccfilesondisk-$date.txt
60column=fCCFileAvail
61find $subsystemdir/cc/ -name '*_S.rep' | cut -d_ -f2 > $filename
62
63echo "resetting runs..."
64check3=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
65
66case $check3 in
67 1) echo "check3=$check3 -> everything ok -> reset is done";;
68 *) echo "check3=$check3 -> ERROR -> something went wrong while resetting";;
69esac
70
71
72echo "checking disk for cacofiles..."
73filename=$filesondisklogpath/cacofilesondisk-$date.txt
74column=fCaCoFileAvail
75find $subsystemdir/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
76
77echo "resetting runs..."
78check0=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
79
80case $check0 in
81 1) echo "check0=$check0 -> everything ok -> reset is done";;
82 *) echo "check0=$check0 -> ERROR -> something went wrong while resetting";;
83esac
84
85echo "checking missing cacofiles..."
86check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$date.log | grep int | sed -e 's/(int)//'`
87
88case $check1 in
89 1) echo "check1=$check1 -> everything ok -> missing cacofiles are found";;
90 *) echo "check1=$check1 -> ERROR -> something went wrong while resetting";;
91esac
92
93missingcacoruns=(`cat $filesondisklogpath/findcacofiles-$date.txt`)
94for missingcacorun in ${missingcacoruns[@]}
95do
96 runno=$missingcacorun
97 echo "no cacofile found for run "$runno
98 echo "finding cacofile"
99 ccfile=`find $subsystemdir/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
100 echo "ccfile: "$ccfile
101 if [ "$ccfile" = "" ]
102 then
103 echo "no ccfile found for run "$runno
104 continue
105 fi
106 for (( i = 0; i <= 10; i++ ))
107 do
108 newrun=`echo $runno - $i | bc`
109 path=`dirname $ccfile`
110 path=`echo $path | sed -e 's/cc/caco/'`
111 cacofile=`find $path -name *$newrun*`
112 if [ "$cacofile" = "" ]
113 then
114 continue
115 else
116 echo "inserting cacofile $file for run $missingcacorun..."
117 check2=`root -q -b $macrospath/insertcacofile.C+\("\"$runno\""\,"\"$newrun\""\) | tee $filesondisklogpath/insertcacofile-$missingcacorun.log | grep int | sed -e 's/(int)//'`
118
119 case $check2 in
120 1) echo "check2=$check2 -> everything ok -> insert is done";;
121 *) echo "check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun;;
122 esac
123 break
124 fi
125 done
126 echo "cacofile: "$cacofile
127
128done
129
130
131echo "checking disk for rawfiles..."
132filename=$filesondisklogpath/rawfilesondisk-$date.txt
133column=fRawFileAvail
134find $datapath -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
135
136echo "resetting runs..."
137check4=`root -q -b $macrospath/resetallruns.C+\("\"$filename\""\,"\"$column\""\) | tee $filesondisklogpath/resetall-$column-$date.log | grep int | sed -e 's/(int)//'`
138
139case $check4 in
140 1) echo "check4=$check4 -> everything ok -> reset is done";;
141 *) echo "check4=$check4 -> ERROR -> something went wrong while resetting";;
142esac
143
144
Note: See TracBrowser for help on using the repository browser.