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