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

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