source: trunk/DataCheck/Processing/FillRates.sh@ 19975

Last change on this file since 19975 was 18935, checked in by Daniela Dorner, 7 years ago
added more values for artificial trigger rate
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2
3# option whether to fill all row or only those where information is missing
4# $doupdate might be given as environment variable
5if [ "$doupdate" = "" ]
6then
7 doupdate="yes" # update all entries (needed when new fields have been added)
8 doupdate="no" # fill only entries which are not yet existing (default)
9fi
10
11source `dirname $0`/../Sourcefile.sh
12printprocesslog "INFO starting $0 with option doupdate="$doupdate
13
14logfile=$runlogpath"/FillAusCamHum-"$datetime".log"
15date >> $logfile
16
17# check if software is available
18if ! ls $factpath/fitsdump >/dev/null 2>&1
19then
20 printprocesslog "ERROR "$factpath"/fitsdump is not available."
21 finish
22fi
23
24# get dates
25if [ "$certaindate" != "" ]
26then
27 getdates $certaindate
28else
29 # get all night
30 #getdates "all"
31 # get last 6 nights
32 getdates 6
33fi
34
35
36printprocesslog "INFO processing the following night(s): "${dates[@]}
37echo `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1
38
39cd $mars
40
41# do filling of aux data
42for date in ${dates[@]}
43do
44 auxdir=$auxdata/$date
45 runnumber=`echo $date | sed -e 's/\///g'`
46 if [ $runnumber -lt 20120328 ]
47 then
48 continue
49 fi
50
51 # get file numbers from DB
52 # but only for not-corrupted files
53 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND fFitsFileErrors=0 AND fRunTypeKey=1 "
54 if [ "$doupdate" = "no" ]
55 then
56 query=$query" AND ISNULL(fNum27Sec) "
57 fi
58 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query
59
60 filenumbers=( `sendquery $query` )
61 printprocesslog "INFO processing "${#filenumbers[@]}" files from date "$date
62 echo "INFO processing "${#filenumbers[@]}" files from date "$date >> $logfile 2>&1
63 # proceed only if there are files available
64 if [ ${#filenumbers} -eq 0 ]
65 then
66 printprocesslog "INFO No files found in the DB for night "$date
67 continue
68 fi
69
70 # fill
71 counter=0
72 for filenum in ${filenumbers[@]}
73 do
74 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
75 echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` >> $logfile 2>&1
76
77 cfile=$datapath"/callisto/"$date"/"$runnumber"_"`printf %03d $filenum`"_C.root"
78 if ! [ -e $cfile ]
79 then
80 printprocesslog "INFO "$cfile" does not yet exist"
81 continue
82 fi
83
84 printprocesslog "INFO filling rates from " $cfile
85 rates=( `root -q -b -l fact/processing/swtrig.C\("\"$cfile\""\) | grep "result" | grep -E -o '[0-9]+'` )
86
87 # build query to update runinfo in DB
88 query="UPDATE RunInfo SET "
89
90 if [ "${rates[0]}" == "" ]
91 then
92 query=$query"fNum27Sec=NULL, "
93 query=$query"fNumThreshold50=NULL, "
94 query=$query"fNumThreshold100=NULL, "
95 query=$query"fNumThreshold200=NULL, "
96 query=$query"fNumThreshold350=NULL, "
97 query=$query"fNumThreshold500=NULL, "
98 query=$query"fNumThreshold750=NULL, "
99 query=$query"fNumThreshold1000=NULL, "
100 query=$query"fNumThreshold1250=NULL, "
101 query=$query"fNumThreshold2500=NULL, "
102 query=$query"fNumThreshold5000=NULL, "
103 query=$query"fNumThreshold10000=NULL, "
104 query=$query"fNumThreshold20000=NULL"
105 else
106 query=$query"fNum27Sec="${rates[0]}", "
107 query=$query"fNumThreshold50="${rates[1]}", "
108 query=$query"fNumThreshold100="${rates[2]}", "
109 query=$query"fNumThreshold200="${rates[3]}", "
110 query=$query"fNumThreshold350="${rates[4]}", "
111 query=$query"fNumThreshold500="${rates[5]}", "
112 query=$query"fNumThreshold750="${rates[6]}", "
113 query=$query"fNumThreshold1000="${rates[7]}", "
114 query=$query"fNumThreshold1250="${rates[8]}", "
115 query=$query"fNumThreshold2500="${rates[9]}", "
116 query=$query"fNumThreshold5000="${rates[10]}", "
117 query=$query"fNumThreshold10000="${rates[11]}", "
118 query=$query"fNumThreshold20000="${rates[12]}
119 fi
120
121 # add where condition
122 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
123
124 # send query to DB
125 sendquery >/dev/null
126
127 counter=`echo " $counter + 1 " | bc -l`
128 done
129 #echo "processed "$counter" files."
130done
131
132finish
133
134
Note: See TracBrowser for help on using the repository browser.