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

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