]>
Commit | Line | Data |
---|---|---|
807998f3 | 1 | #! /bin/bash |
2 | ||
9e160db9 | 3 | # Script to merge objects coming out of the calibration train and export of the OCDB: |
4 | # Arguments for local use: | |
5 | # 1 - directory on which to look for the files to be merged | |
6 | # 2 - runNumber | |
7 | # 3 - OCDB output path | |
8 | # [4 - input default OCDB] | |
9 | ||
10 | #ALIEN setting | |
11 | # $1 = directory where to perform the find | |
12 | # $2 = runNumber | |
13 | # $3 = OCDB path | |
14 | ||
15 | # if fourth argument given, its the default OCDB, otherwise use the default raw:// | |
16 | defaultOCDB=$4 | |
17 | [[ -z $4 ]] && defaultOCDB="raw://" | |
18 | ||
807998f3 | 19 | # init |
20 | path=$1 | |
21 | run=$2 | |
22 | ocdb=$3 | |
9e160db9 | 23 | isLocal=0 |
24 | [[ -f $path ]] && isLocal=1 | |
25 | ||
807998f3 | 26 | echo "***********************" 2>&1 | tee -a merge.log |
9e160db9 | 27 | echo mergeMakeOCDB.byComponent.sh started 2>&1 | tee -a merge.log |
807998f3 | 28 | echo path = $path 2>&1 | tee -a merge.log |
29 | echo run = $run 2>&1 | tee -a merge.log | |
30 | echo ocdb = $ocdb 2>&1 | tee -a merge.log | |
9e160db9 | 31 | echo defaultOCDB=$defaultOCDB | tee -a merge.log |
32 | echo isLocal = $isLocal 2>&1 | tee -a merge.log | |
807998f3 | 33 | echo "***********************" 2>&1 | tee -a merge.log |
34 | ||
35 | # setup components | |
9e160db9 | 36 | components="TOF MeanVertex T0 SDD TRD TPCCalib TPCAlign TPCCluster" |
807998f3 | 37 | |
9e160db9 | 38 | alienFileList="alien.list" |
39 | localFileList="local.list" | |
40 | partialLocalFileListPrefix=${localFileList}_ | |
41 | partialAlienFileListPrefix=${alienFileList}_ | |
42 | runningMergeByComponentLockFile="runningMergeByComponent.lock" | |
43 | ||
40f73007 | 44 | makeAbsolutePathsInList() |
45 | { | |
46 | #make sure the files in the list have absolute paths | |
47 | rm -f $2 | |
48 | while read file; do | |
49 | readlink -f $file >> $2 | |
50 | done < $1 | |
51 | } | |
52 | ||
9e160db9 | 53 | mergeByComponent() |
54 | { | |
55 | # process by component | |
56 | # first argument is the file list to process | |
57 | # second argument can be "doCleanup" to delete merged files | |
58 | ||
59 | #lock | |
60 | touch $runningMergeByComponentLockFile | |
61 | ||
40f73007 | 62 | # run inside a dedicated running directory |
63 | # whic means copy the file list to process and prefic each line with ../ | |
64 | # since the file names have no absolute paths! | |
65 | runningDirectory="${runningMergeByComponentLockFile}.${1}.dir" | |
66 | parentDirectory=$PWD | |
67 | fileList="$1.local" | |
68 | mkdir -p $runningDirectory | |
69 | makeAbsolutePathsInList $1 $runningDirectory/$fileList | |
70 | cd $runningDirectory | |
71 | ||
9e160db9 | 72 | previousResults=PREVIOUS_ITERATION_CalibObjects.root |
40f73007 | 73 | if [[ -f $parentDirectory/CalibObjects.root ]]; then |
74 | mv $parentDirectory/CalibObjects.root $previousResults | |
75 | echo "$previousResults" >> $fileList | |
9e160db9 | 76 | fi |
807998f3 | 77 | |
9e160db9 | 78 | echo "####DEBUG" | tee -a merge.log |
40f73007 | 79 | echo "####processed list $fileList" | tee -a merge.log |
80 | cat $fileList | tee -a merge.log | |
807998f3 | 81 | |
9e160db9 | 82 | for det in $components; do |
807998f3 | 83 | # merge |
84 | echo "***********************" 2>&1 | tee -a merge.log | |
85 | echo merging $det data 2>&1 | tee -a merge.log | |
86 | echo "***********************" 2>&1 | tee -a merge.log | |
40f73007 | 87 | echo aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C(\"$det\", \"$fileList\")" 2>&1 | tee -a merge.log |
88 | aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C(\"$det\", \"$fileList\")" 2>&1 | tee -a merge.log | |
9e160db9 | 89 | mv syswatch.log syswatch_merge_$det.log |
90 | mv CalibObjects.root CalibObjects_$det.root | |
91 | done | |
92 | ||
93 | rm -f $previousResults | |
94 | ||
95 | # global merge | |
96 | echo "***********************" 2>&1 | tee -a merge.log | |
97 | echo merging ALL data 2>&1 | tee -a merge.log | |
98 | echo "***********************" 2>&1 | tee -a merge.log | |
99 | partialCalibObjectsList="objects.list.${1}" | |
100 | ls -1 CalibObjects_*.root > $partialCalibObjectsList | |
40f73007 | 101 | aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C(\"ALL\", \"$partialCalibObjectsList\")" 2>&1 | tee -a merge.log |
9e160db9 | 102 | mv syswatch.log syswatch_ALL.log |
103 | ||
104 | #cleanup | |
105 | if [[ "$2" == "doCleanup" ]]; then | |
106 | while read filename; do | |
107 | echo rm -f $filename | tee -a merge.log | |
108 | rm -f $filename | |
40f73007 | 109 | done < $fileList |
9e160db9 | 110 | fi |
111 | rm -f CalibObjects_*.root | |
40f73007 | 112 | rm -f $fileList |
113 | ||
114 | #move stuff back to the parent dir and clean up | |
115 | #merge the syswatch logs | |
116 | for x in syswatch*log; do | |
117 | if [[ -f $parentDirectory/$x ]] | |
118 | then | |
119 | sed '1d' >> $parentDirectory/$x | |
120 | rm -f $x | |
121 | else | |
122 | mv $x $parentDirectory/$x | |
123 | fi | |
124 | done | |
125 | mv * $parentDirectory | |
126 | cd $parentDirectory | |
127 | rm -rf $runningDirectory | |
807998f3 | 128 | |
9e160db9 | 129 | #unlock |
130 | rm -f $runningMergeByComponentLockFile | |
131 | } | |
807998f3 | 132 | |
9e160db9 | 133 | waitIfLocked() |
134 | { | |
135 | while [ 1 ]; do | |
136 | [[ ! -f $1 ]] && break | |
137 | sleep 1 | |
138 | done | |
139 | } | |
807998f3 | 140 | |
9e160db9 | 141 | if [ $isLocal -eq 0 ]; then |
142 | #with alien files copy them first to local | |
143 | echo "***********************" 2>&1 | tee -a merge.log | |
144 | echo copying files for run $run 2>&1 | tee -a merge.log | |
145 | echo from $path 2>&1 | tee -a merge.log | |
146 | echo "***********************" 2>&1 | tee -a merge.log | |
40f73007 | 147 | aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C(\"MAKEALIENLIST\",\"$alienFileList\", \"$path\", \"AliESDfriends_v1.root\")" 2>&1 | tee -a merge.log |
148 | split --numeric-suffixes --suffix-length=4 --lines=20 ${alienFileList} ${partialAlienFileListPrefix} | |
9e160db9 | 149 | rm -f $runningMergeByComponentLockFile |
150 | for partialAlienFileList in ${partialAlienFileListPrefix}* | |
151 | do | |
152 | #copy the alien files to local | |
153 | partialAlienFileListPostfix=${partialAlienFileList#$partialAlienFileListPrefix} | |
154 | partialLocalFileList=${partialLocalFileListPrefix}${partialAlienFileListPostfix} | |
40f73007 | 155 | aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C(\"COPY\",\"$partialAlienFileList\",\"noPath\",\"noPattern\",10,\"$partialLocalFileList\")" 2>&1 | tee -a merge.log |
156 | ||
157 | #handle syswatch | |
158 | if [[ -f syswatch_copy.log ]] | |
159 | then | |
160 | sed '1d' syswatch.log >> syswatch_copy.log | |
161 | rm -f syswatch.log | |
162 | else | |
163 | mv syswatch.log syswatch_copy.log | |
164 | fi | |
9e160db9 | 165 | |
166 | #merge in parallel, use a simple lockfile | |
167 | waitIfLocked $runningMergeByComponentLockFile | |
168 | mergeByComponent $partialLocalFileList "doCleanup" & | |
169 | done | |
170 | else | |
171 | #locally just use the list directly | |
172 | mergeByComponent $path | |
173 | fi; | |
174 | ||
175 | #cleanup | |
176 | cat ${partialAlienFileListPrefix}* >> ${localFileList} | |
177 | rm -f ${partialAlienFileListPrefix}* | |
178 | rm -f ${partialLocalFileListPrefix}* | |
179 | ||
180 | # make OCDB | |
181 | echo "***********************" 2>&1 | tee -a ocdb.log | |
182 | echo making $det OCDB 2>&1 | tee -a ocdb.log | |
183 | echo "***********************" 2>&1 | tee -a ocdb.log | |
40f73007 | 184 | aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/makeOCDB.C($run, \"$ocdb\", \"$defaultOCDB\")" 2>&1 | tee -a ocdb.log |
9e160db9 | 185 | mv syswatch.log syswatch_makeOCDB.log |
807998f3 | 186 | |
187 | # summary | |
188 | echo "***********************" 2>&1 | tee -a ocdb.log | |
189 | echo SUMMARY 2>&1 | tee -a ocdb.log | |
190 | echo "***********************" 2>&1 | tee -a ocdb.log | |
9e160db9 | 191 | ls -altr *CalibObjects.root *done 2>&1 | tee -a ocdb.log |