source: trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets@ 7336

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