source: trunk/DataCheck/Processing/FillEvents.sh@ 19846

Last change on this file since 19846 was 19399, checked in by Daniela Dorner, 6 years ago
improved logging, added ignore-option for filling events
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=StarEventsFilled
7step=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]
14if [ "$1" != "" ]
15then
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
29else
30 numjobs=1
31 numjob=0
32fi
33
34
35set -C
36
37# check if script is already running
38lockfile=$lockpath/lock-$numjob-$program.txt
39checklock
40
41# get todo list
42gettodo
43
44logfile=$runlogpath"/FillStarEvents-"$numjob"-"$datetime".log"
45date >> $logfile
46
47# get mysql version with which connection is possible
48export 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
51starrc=`ls \`dirname $0\`/../Setup/star.rc`
52
53for (( s=0 ; s < $num ; s++ ))
54do
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 continue
69 fi
70
71 # get file id and star-file name
72 #echo "INFO filling star events for "$night"_"$runid
73 printprocesslog "INFO filling star events for "$night"_"$runid
74 echo "INFO filling star events for "$night"_"$runid >> $logfile
75 night2=`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
76 starfile=$datapath/star/$night2/$night"_"`printf %03d $runid`"_I.root"
77
78 # some runs have problems, e.g. double event numbers
79 # these have an ignore-errors flag set in the DB
80 ignoreoption=""
81 query="SELECT fIgnoreErrors FROM StarEventsFilledStatus WHERE fNight="$night" AND fRunID="$runid
82 ignore=`sendquery`
83 if [ $ignore -eq 1 ]
84 then
85 ignoreoption="--ignore-errors"
86 fi
87
88 # fill star files to DB
89 printprocesslog "INFO /swdev_nfs/FACT++.r19188-bin/root2sql -C $starrc $starfile"
90 /swdev_nfs/FACT++.r19188-bin/root2sql -C $starrc $ignoreoption $starfile >> $logfile 2>&1
91 check1=$?
92 case $check1 in
93 0) printprocesslog "INFO successfully filled "$starfile
94 ;;
95 *) printprocesslog "ERROR could not fill "$starfile
96 check=$check1
97 ;;
98 esac
99
100 setstatus "stop"
101done
102
103finish
104
Note: See TracBrowser for help on using the repository browser.