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

Last change on this file since 19382 was 19196, checked in by Daniela Dorner, 6 years ago
added (script to fill star events to DB)
  • Property svn:executable set to *
File size: 2.5 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 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"
92done
93
94finish
95
Note: See TracBrowser for help on using the repository browser.