source: trunk/DataCheck/QuickLook/Step2b.sh@ 15311

Last change on this file since 15311 was 15310, checked in by Daniela Dorner, 12 years ago
adapted names of scripts for automatic analysis
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/bash
2#
3source `dirname $0`/../Sourcefile.sh
4printprocesslog "INFO starting $0"
5
6#root=/opt/root_svn/bin/thisroot.sh
7#source $root
8#factpath=/home/fact/FACT++.in-run-fad-loss
9
10#anapath=/loc_data/analysis
11
12sources=( 1 2 5 7 )
13numganymeds=0
14
15for source in ${sources[@]}
16do
17 # getting all nights
18 printprocesslog "INFO get all nights for source "$source
19 dirs=( `find $anapath/$source/datasets005min -maxdepth 3 -mindepth 3 -type d 2>/dev/null | sort` )
20 nights=1
21 # write data set file
22 dspath=$anapath/$source/datasets`printf %04d $nights`nights
23 makedir $dspath
24 for (( i=1 ; i<=${#dirs[@]} ; i++ ))
25 do
26 numdsfiles=`find ${dirs[$i-1]} -type f | wc -l`
27 imgpath=`echo ${dirs[$i-1]} | sed -e 's/datasets005min/star/'`
28 numimgfiles=`find $imgpath -type f -name '*_I.root' | wc -l`
29 echo ${dirs[$i-1]}" "$numdsfiles" "$numimgfiles
30 dsfile=$dspath/dataset$i.txt
31 printprocesslog "INFO writing dataset file "$dsfile
32 echo "INFO writing dataset file "$dsfile
33 #cat ${dirs[$i-1]}/dataset*.txt
34 cat ${dirs[$i-1]}/dataset*.txt > $dsfile
35 # process only if ganymedlogfiles is not yet there
36 logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
37 if [ $numdsfiles -ne $numimgfiles ]
38 then
39 printprocesslog "INFO remove $logfiles (new files added to dataset) "
40 rm $logfile
41 fi
42 if ! ls $logfile >/dev/null 2>&1
43 then
44 `dirname $0`/RunGanymed.sh $source $dsfile
45 numganymeds=`echo " $numganymeds + 1 " | bc -l`
46 fi
47 done
48
49 # get list of dataset files for 1 night as starting point
50 printprocesslog "INFO get list of dataset files for "$nights" nights"
51 files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
52 nightsold=1
53 # loop over data set files
54 # copy always 2 in one new file for double observation time
55 while [ ${#files[@]} -gt 1 ]
56 do
57 # get double observation time and path for datasets
58 nights=`echo " $nightsold + $nightsold " | bc -l `
59 dspathold=$dspath
60 dspath=$anapath"/"$source"/datasets"`printf %04d $nights`"nights"
61 makedir $dspath
62 # loop over already existing data set files
63 for (( i=0 ; i<=${#files[@]} ; i++ ))
64 do
65 # number of 1st and 2nd old dataset file
66 num1=`echo " $i + $i + 1" | bc -l `
67 num2=`echo " $i + $i + 2 " | bc -l `
68 # number of new dataset file
69 dsnum=`echo " $i + 1 " | bc -l `
70 # continue only if 2 dataset files are left
71 if ! [ ${files[$num1]} ]
72 then
73 break
74 fi
75 ds1=$dspathold"/dataset"$num1".txt"
76 ds2=$dspathold"/dataset"$num2".txt"
77 dsfile=$dspath"/dataset"$dsnum".txt"
78 # copy two old into one new dataset file
79 printprocesslog "INFO writing dataset "$dsfile
80 echo "INFO writing dataset "$dsfile
81 cat $ds1 > $dsfile
82 cat $ds2 >> $dsfile
83 # process only if ganymedlogfiles is not yet there
84 logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
85 if ! ls $logfile >/dev/null 2>&1
86 then
87 `dirname $0`/RunGanymed.sh $source $dsfile
88 numganymeds=`echo " $numganymeds + 1 " | bc -l`
89 fi
90 done
91 # get list of new dataset files
92 printprocesslog "INFO get list of dataset files for "$nights" nights"
93 files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
94 nightsold=$nights
95 done
96 if [ $numganymeds -gt 0 ]
97 then
98 if ! ps aux | grep Step3 | grep -v grep >/dev/null 2>&1
99 then
100 `dirname $0`/Step3.sh nights &
101 fi
102 numganymeds=0
103 fi
104
105done
106
107finish
Note: See TracBrowser for help on using the repository browser.