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 |
|
---|
29 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
---|
30 |
|
---|
31 | set -C
|
---|
32 |
|
---|
33 | cd $mars
|
---|
34 |
|
---|
35 | datetime=`date +%F-%H-%M-%S`
|
---|
36 | year=`date +%Y`
|
---|
37 |
|
---|
38 | scriptlogpath=$logpath/run/insertdatasets/`date +%Y/%m`
|
---|
39 | if [ ! -d $scriptlogpath ]
|
---|
40 | then
|
---|
41 | mkdir -pv $scriptlogpath
|
---|
42 | if [ ! -d $scriptlogpath ]
|
---|
43 | then
|
---|
44 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
45 | exit
|
---|
46 | fi
|
---|
47 | fi
|
---|
48 |
|
---|
49 | scriptlog=$scriptlogpath/insertdatasets-$datetime.log
|
---|
50 |
|
---|
51 | date >> $scriptlog 2>&1
|
---|
52 |
|
---|
53 | date > $lockpath/lock-insertdatasets.txt >> $scriptlog 2>&1
|
---|
54 | checklock0=$?
|
---|
55 | case $checklock0 in
|
---|
56 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
57 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
58 | echo "-> getting list for callisto is running -> exit" >> $scriptlog 2>&1
|
---|
59 | date >> $scriptlog 2>&1
|
---|
60 | exit;;
|
---|
61 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
62 | esac
|
---|
63 |
|
---|
64 |
|
---|
65 | datasetfiles=(`ls /magic/datasets/*/*`)
|
---|
66 | echo "datasetfiles: "${datasetfiles[@]} >> $scriptlog 2>&1
|
---|
67 | echo "" >> $scriptlog 2>&1
|
---|
68 |
|
---|
69 | for datasetfile in ${datasetfiles[@]}
|
---|
70 | do
|
---|
71 | no=`echo $datasetfile | cut -d/ -f5 | cut -c8-99 | cut -d. -f1`
|
---|
72 | no2=`grep 'AnalysisNumber:' $datasetfile | sed -e 's/AnalysisNumber://g' | sed -e 's/ //g'`
|
---|
73 | no3=`printf %08d $no2`
|
---|
74 | if [ "$no" = "$no3" ]
|
---|
75 | then
|
---|
76 | echo "number in filename and in file are the same -> continue" >> $scriptlog 2>&1
|
---|
77 | else
|
---|
78 | echo "number in filename and in file are not the same " >> $scriptlog 2>&1
|
---|
79 | echo " -> continue with next dataset" >> $scriptlog 2>&1
|
---|
80 | continue
|
---|
81 | fi
|
---|
82 | source=`grep 'SourceName:' $datasetfile | sed -e 's/SourceName://g' | sed -e 's/ //g' | sed -e 's/#//g'` >> $scriptlog 2>&1
|
---|
83 | mode=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
84 | mode2=`echo $mode | grep ^\#` >> $scriptlog 2>&1
|
---|
85 | if [ "$mode2" = "" ]
|
---|
86 | then
|
---|
87 | wobble="Y" >> $scriptlog 2>&1
|
---|
88 | else
|
---|
89 | wobble="N" >> $scriptlog 2>&1
|
---|
90 | fi
|
---|
91 | echo "file: "$datasetfile >> $scriptlog 2>&1
|
---|
92 | echo " datasetno: "$no2 >> $scriptlog 2>&1
|
---|
93 | echo " sourcename: "$source >> $scriptlog 2>&1
|
---|
94 | echo " wobble: "$wobble >> $scriptlog 2>&1
|
---|
95 | echo " " >> $scriptlog 2>&1
|
---|
96 |
|
---|
97 | insertdatasetpath=$logpath/insertdataset/$no3
|
---|
98 | if [ ! -d $insertdatasetpath ]
|
---|
99 | then
|
---|
100 | mkdir -pv $insertdatasetpath >> $scriptlog 2>&1
|
---|
101 | if [ ! -d $insertdatasetpath ]
|
---|
102 | then
|
---|
103 | echo "could not make insertdatasetpath "$insertdatasetpath >> $scriptlog 2>&1
|
---|
104 | continue
|
---|
105 | fi
|
---|
106 | fi
|
---|
107 | insertdatasetlog=$insertdatasetpath/insertdataset-$no3.log
|
---|
108 | check0=`root -q -b $macrospath/insertdataset.C+\("\"$no2\""\,"\"$source\""\,"\"$wobble\"",kFALSE\) | tee $insertdatasetlog | grep int | sed -e 's/(int)//'`
|
---|
109 | case $check0 in
|
---|
110 | 1) echo "check0=$check0 -> everthing ok " >> $scriptlog 2>&1 ;;
|
---|
111 | *) echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 ;;
|
---|
112 | esac
|
---|
113 | done
|
---|
114 |
|
---|
115 | rm -v $todofile >> $scriptlog 2>&1
|
---|
116 | rm -v $lockpath/lock-insertdatasets.txt >> $scriptlog 2>&1
|
---|
117 |
|
---|
118 | set +C
|
---|
119 |
|
---|
120 | date >> $scriptlog 2>&1
|
---|
121 |
|
---|