source: trunk/DataCheck/Processing/FillAnalysisResults.sh@ 20112

Last change on this file since 20112 was 19494, checked in by Daniela Dorner, 5 years ago
fixed typo
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/bin/bash
2
3source `dirname $0`/../Sourcefile.sh
4printprocesslog "INFO starting $0"
5
6
7
8# for refilling DB from scratch several processes are useful
9# therefore two commandline options have been implemented:
10# numjobs: number of process that are started from FillAnalysisResults.sh
11# numjob: number of the current process [0 to numjobs-1]
12if [ "$2" != "" ]
13then
14 numjobs=$2
15 if [ "$3" == "" ]
16 then
17 echo "missing third argument (numjob)"
18 finish
19 else
20 numjob=$3
21 fi
22 if [ $3 -gt $(($2 - 1)) ]
23 then
24 echo "you cannot start a job with a number larger than the number of jobs you specified"
25 finish
26 fi
27else
28 numjobs=1
29 numjob=0
30fi
31
32
33
34# to run this script for different analyses, a command line
35# option has been implemented:
36# analysis: name of the analysis
37if [ "$1" != "" ]
38then
39 analysis=$1
40else
41 echo "You have to give the name of the analysis that you want to fill into the DB."
42 echo " Currently available: CutsLC"
43 finish
44fi
45
46# setup for script
47program="Analysis"$analysis
48step="Analysis"$analysis
49# setup for mysql DB
50sql=`dirname $0`"/../Setup/get_results_"$analysis".sql"
51resulttable="AnalysisResultsRun"$analysis
52
53# setup for rootifysql
54prog="/swdev_nfs/FACT++.r19193-bin/rootifysql"
55config="--config="`dirname $0`"/../Setup/rootifysql.eth.rc"
56
57
58
59set -C
60
61# check if script is already running
62lockfile=$lockpath/lock-$numjob-$program.txt
63checklock
64
65logfile=$runlogpath"/FillAnalysisResults"$analysis"-"$numjob"-"$datetime".log"
66date >> $logfile
67
68# get todo list
69gettodo
70
71for (( s=0 ; s < $num ; s++ ))
72do
73 night=${primaries[$s+$s]}
74 runid=${primaries[$s+$s+1]}
75 #fileid=fileid=`echo $night | cut -c 3-8``printf %03d $runid`
76
77 if [ $(($runid % $numjobs)) -ne $numjob ]
78 then
79 printprocesslog "INFO processing only part of the data (runid "$runid", numjobs "$numjobs", "$numjob") -> continue"
80 continue
81 fi
82
83 setstatus "start"
84 if [ $numchanged -eq 0 ]
85 then
86 printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
87 continue
88 fi
89
90 # get file-id
91 query="SELECT FileID FROM CalcSourceStatus WHERE fNight="$night" AND fRunID="$runid
92 fileid=`sendquery`
93 #echo "INFO calculating source position for "$fileid
94 printprocesslog "INFO filling results ("$analysis") for "$fileid
95 echo "INFO filling results ("$analysis") for "$fileid >> $logfile
96 #echo "INFO filling results ("$analysis") for "$fileid #>> $logfile
97
98 outpath=$datapath/analysis_CutsLC/`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
99 makedir $outpath >> $logfile
100 txt=$outpath/$fileid.txt
101 log=$outpath/$fileid.log
102
103 # run rootfiysql
104 printprocesslog "DEBUG $prog $config $sql --delimiter , -w $txt --var.fileid=$fileid > $log 2>&1"
105 $prog $config $sql --delimiter , -w $txt --var.fileid=$fileid -n >| $log 2>&1
106 check1=$?
107
108
109 case $check1 in
110 0) printprocesslog "INFO successfully got analysis results ("$analysis") for "$fileid
111 vals=`cat $txt | grep -v '#'`
112 query="REPLACE INTO "$resulttable" (fNight, fRunID, fNumSigEvts, fNumBgEvts, fNumExcEvts) VALUES("$vals")"
113 #mysql --defaults-file=/home/dorner/.mysql.pw.local -s -e "$query"
114 sendquery >> $logfile
115 # remark: in case this sendquery fails, the job appears as crashed
116 ;;
117 *) printprocesslog "ERROR could not get analysis results ("$analysis") for "$fileid
118 check=$check1
119 ;;
120 esac
121
122 setstatus "stop"
123
124done
125
126finish
127
Note: See TracBrowser for help on using the repository browser.