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

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