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

Last change on this file since 7572 was 7545, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.9 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 launches the inserting of the datasets into the db.
28#
29# Extract information (dataset number, source name, comment, observation
30# mode) from dataset file and insert it into the database in the table
31# DataSets using the macro insertdataset.C
32#
33
34user=`whoami`
35program=insertdatasets
36source /home/$user/Mars/datacenter/scripts/sourcefile
37
38set -C
39
40cd $mars
41
42datetime=`date +%F-%H-%M-%S`
43lockfile=$lockpath/lock-insertdatasets.txt
44
45scriptlogpath=$logpath/run/insertdatasets/`date +%Y/%m`
46makedir $scriptlogpath
47
48scriptlog=$scriptlogpath/insertdatasets-$datetime.log
49
50date >> $scriptlog 2>&1
51
52# check if script is already running
53checklock >> $scriptlog 2>&1
54
55# get all datasetfiles
56datasetfiles=(`ls $datasetpath/*/*.txt`)
57echo "datasetfiles: "${datasetfiles[@]} >> $scriptlog 2>&1
58echo "" >> $scriptlog 2>&1
59
60# extract information from dataset file and insert it into db with the macro insertdataset.C
61for datasetfile in ${datasetfiles[@]}
62do
63 # get datasetnumber from filename
64 no=`echo $datasetfile | cut -d/ -f5 | cut -c8-99 | cut -d. -f1`
65 # get datasetnumber from file and get it with 8 digits
66 no2=`grep 'AnalysisNumber:' $datasetfile | sed -e 's/AnalysisNumber://g' | sed -e 's/ //g'`
67 no3=`printf %08d $no2`
68 # compare the two datasetnumber
69 # continue only if number is the same
70 if [ "$no" = "$no3" ]
71 then
72 echo "number in filename and in file are the same -> continue" >> $scriptlog 2>&1
73 else
74 echo "number in filename and in file are not the same " >> $scriptlog 2>&1
75 echo " -> continue with next dataset" >> $scriptlog 2>&1
76 continue
77 fi
78 # get source name, comment and observation mode from dataset file
79 source=`grep 'SourceName:' $datasetfile | sed -e 's/SourceName://g' | sed -e 's/ //g' | sed -e 's/#//g'` >> $scriptlog 2>&1
80 comment=`grep 'Comment:' $datasetfile | sed -e 's/Comment://g'` >> $scriptlog 2>&1
81 mode=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
82 mode2=`echo $mode | grep ^\#` >> $scriptlog 2>&1
83 if [ "$mode2" = "" ]
84 then
85 wobble="Y" >> $scriptlog 2>&1
86 else
87 wobble="N" >> $scriptlog 2>&1
88 fi
89 echo "file: "$datasetfile >> $scriptlog 2>&1
90 echo " datasetno: "$no2 >> $scriptlog 2>&1
91 echo " sourcename: "$source >> $scriptlog 2>&1
92 echo " wobble: "$wobble >> $scriptlog 2>&1
93 echo " comment: "$comment >> $scriptlog 2>&1
94 echo " " >> $scriptlog 2>&1
95
96 insertdatasetpath=$logpath/insertdataset/$no3
97 makedir $insertdatasetpath >> $scriptlog 2>&1
98 insertdatasetlog=$insertdatasetpath/insertdataset-$no3.log
99
100 # insert information into db
101 check0=`root -q -b $macrospath/insertdataset.C+\("\"$no2\""\,"\"$source\""\,"\"$wobble\""\,"\"$comment\""\,kFALSE\) | tee $insertdatasetlog | grep int | sed -e 's/(int)//'`
102 case $check0 in
103 1) echo "check0=$check0 -> everything ok " >> $scriptlog 2>&1 ;;
104 *) echo "check0=$check0 -> ERROR " >> $scriptlog 2>&1 ;;
105 esac
106done
107
108rm -v $lockfile >> $scriptlog 2>&1
109
110set +C
111
112date >> $scriptlog 2>&1
113
Note: See TracBrowser for help on using the repository browser.