1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 | program=StarEventsFilled
|
---|
7 | step=StarEventsFilled
|
---|
8 |
|
---|
9 |
|
---|
10 | # for refilling DB from scratch several processes are useful
|
---|
11 | # therefore two commandline options have been implemented:
|
---|
12 | # numjobs: number of process that are started from FillEvent.sh
|
---|
13 | # numjob: number of the current process [0 to numjobs-1]
|
---|
14 | if [ "$1" != "" ]
|
---|
15 | then
|
---|
16 | numjobs=$1
|
---|
17 | if [ "$2" == "" ]
|
---|
18 | then
|
---|
19 | echo "missing second argument"
|
---|
20 | finish
|
---|
21 | else
|
---|
22 | numjob=$2
|
---|
23 | fi
|
---|
24 | if [ $2 -gt $(($1 - 1)) ]
|
---|
25 | then
|
---|
26 | echo "you cannot start a job with a number larger than the number of jobs you specified"
|
---|
27 | finish
|
---|
28 | fi
|
---|
29 | else
|
---|
30 | numjobs=1
|
---|
31 | numjob=0
|
---|
32 | fi
|
---|
33 |
|
---|
34 |
|
---|
35 | set -C
|
---|
36 |
|
---|
37 | # check if script is already running
|
---|
38 | lockfile=$lockpath/lock-$numjob-$program.txt
|
---|
39 | checklock
|
---|
40 |
|
---|
41 | # get todo list
|
---|
42 | gettodo
|
---|
43 |
|
---|
44 | logfile=$runlogpath"/FillStarEvents-"$numjob"-"$datetime".log"
|
---|
45 | date >> $logfile
|
---|
46 |
|
---|
47 | # get mysql version with which connection is possible
|
---|
48 | export LD_LIBRARY_PATH=/swdev_nfs/mysql++-3.2.4:/swdev_nfs/mysql-5.7.23-linux-glibc2.12-x86_64/lib:/swdev_nfs/libnova/lib/:$LD_LIBRARY_PATH
|
---|
49 |
|
---|
50 | # setup file for root2sql
|
---|
51 | starrc=`ls \`dirname $0\`/../Setup/star.rc`
|
---|
52 |
|
---|
53 | for (( s=0 ; s < $num ; s++ ))
|
---|
54 | do
|
---|
55 | night=${primaries[$s+$s]}
|
---|
56 | runid=${primaries[$s+$s+1]}
|
---|
57 |
|
---|
58 | if [ $(($runid % $numjobs)) -ne $numjob ]
|
---|
59 | then
|
---|
60 | printprocesslog "INFO processing only part of the data (runid "$runid", numjobs "$numjobs", "$numjob") -> continue"
|
---|
61 | continue
|
---|
62 | fi
|
---|
63 |
|
---|
64 | setstatus "start"
|
---|
65 | if [ $numchanged -eq 0 ]
|
---|
66 | then
|
---|
67 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
---|
68 | echo "continue"
|
---|
69 | continue
|
---|
70 | fi
|
---|
71 |
|
---|
72 |
|
---|
73 | echo "INFO filling star events for "$night"_"$runid
|
---|
74 | printprocesslog "INFO filling star events for "$night"_"$runid
|
---|
75 | echo "INFO filling star events for "$night"_"$runid >> $logfile
|
---|
76 | night2=`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
|
---|
77 | starfile=$datapath/star/$night2/$night"_"`printf %03d $runid`"_I.root"
|
---|
78 |
|
---|
79 | # fill star files to DB
|
---|
80 | printprocesslog "INFO /swdev_nfs/FACT++.r19188-bin/root2sql -C $starrc $starfile"
|
---|
81 | /swdev_nfs/FACT++.r19188-bin/root2sql -C $starrc $starfile >> $logfile 2>&1
|
---|
82 | check1=$?
|
---|
83 | case $check1 in
|
---|
84 | 0) printprocesslog "INFO successfully filled "$starfile
|
---|
85 | ;;
|
---|
86 | *) printprocesslog "ERROR could not fill "$starfile
|
---|
87 | check=$check1
|
---|
88 | ;;
|
---|
89 | esac
|
---|
90 |
|
---|
91 | setstatus "stop"
|
---|
92 | done
|
---|
93 |
|
---|
94 | finish
|
---|
95 |
|
---|