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

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