source: trunk/Mars/fact/analysis/gain/runanalysis.sh@ 20112

Last change on this file since 20112 was 17327, checked in by tbretz, 11 years ago
Updated query to account for new sql version
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/bin/bash
2
3threshold=5
4maxdist=14
5macro=$PWD/extract_singles.C
6outpath=$PWD/files
7
8mkdir -p $outpath
9cp ${macro} ${outpath}
10
11where="(((fNumPedestalTrigger=3000 OR fNumPedestalTrigger=5000) AND fRunTypeKey=2) OR (fNumPedestalTrigger=10000 AND fRunTypeKey=3) OR fRunTypeKey=17)"
12wheredrs="(drs.fROI=single.fROI AND fDrsStep=2)"
13
14query="SELECT Concat(fNight, '_', fRunID, '_', (SELECT fRunID FROM RunInfo \`drs\` WHERE drs.fNight=single.fNight AND "$wheredrs" AND single.fRunID<30+drs.fRunID ORDER BY ABS(CAST(single.fRunID AS SIGNED) - CAST(drs.fRunID AS SIGNED)) ASC LIMIT 0,1)) AS num "
15query=$query" FROM RunInfo \`single\` WHERE "$where
16
17runpairs=( `mysql -u factread --password=r3adfac! --host=lp-fact factdata -s -e "$query"` )
18
19for runpair in ${runpairs[@]}
20do
21 if [ $runpair = 'NULL' ]
22 then
23 continue
24 fi
25
26 year=`echo $runpair | cut -c1-4`
27 month=`echo $runpair | cut -c5-6`
28 day=`echo $runpair | cut -c7-8`
29 night=`echo $runpair | cut -d_ -f1`
30 run=`echo $runpair | cut -d_ -f2`
31 drs=`echo $runpair | cut -d_ -f3`
32 name=`echo $night | cut -c3-`
33
34 runnum=`printf %03d $run`
35 drsnum=`printf %03d $drs`
36
37 #runpath="/archive/fact/fails/raw/"$year"/"$month"/"$day
38 #drspath="/fact/raw/"$year"/"$month"/"$day
39
40 runpath="/fact/raw/"$year"/"$month"/"$day
41 drspath="/fact/raw/"$year"/"$month"/"$day
42
43 runfile=$runpath"/"$night"_"
44 drsfile=$drspath"/"$night"_"$drsnum.drs.fits.gz
45 log=$outpath"/"$night"_"$runnum
46
47 outfile=$outpath/`basename $runfile`${runnum}_${runnum}.root
48
49 if [ -e $outfile ]
50 then
51 continue
52 fi
53
54# echo "Submitting "${night}"_"${runnum}"["${drsnum}"]"
55
56 cd ~/Mars
57
58 cmd="ROOT_HIST=0 ${ROOTSYS}/bin/root -q -b -l ${macro}+\($maxdist,$threshold,\\\"$runfile\\\",$run,$run,\\\"$drsfile\\\",\\\"${outpath}\\\"\)"
59
60 echo "echo '${cmd}'; date; ${cmd}" | qsub -N e${name}${runnum} -q test -cwd -e ${log}".err" -o ${log}".log"
61
62 cd - > /dev/null
63done
64
65
Note: See TracBrowser for help on using the repository browser.