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
8 # [4 - input default OCDB]
11 # $1 = directory where to perform the find
15 # if fourth argument given, its the default OCDB, otherwise use the default raw://
17 [[ -z $4 ]] && defaultOCDB="raw://"
24 [[ -f $path ]] && isLocal=1
26 echo "***********************" 2>&1 | tee -a merge.log
27 echo mergeMakeOCDB.byComponent.sh started 2>&1 | tee -a merge.log
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
31 echo defaultOCDB=$defaultOCDB | tee -a merge.log
32 echo isLocal = $isLocal 2>&1 | tee -a merge.log
33 echo "***********************" 2>&1 | tee -a merge.log
36 components="TOF MeanVertex T0 SDD TRD TPCCalib TPCAlign TPCCluster"
38 alienFileList="alien.list"
39 localFileList="local.list"
40 partialLocalFileListPrefix=${localFileList}_
41 partialAlienFileListPrefix=${alienFileList}_
42 runningMergeByComponentLockFile="runningMergeByComponent.lock"
46 # process by component
47 # first argument is the file list to process
48 # second argument can be "doCleanup" to delete merged files
51 touch $runningMergeByComponentLockFile
53 previousResults=PREVIOUS_ITERATION_CalibObjects.root
54 if [[ -f CalibObjects.root ]]; then
55 mv CalibObjects.root $previousResults
56 echo "$previousResults" >> $1
59 echo "####DEBUG" | tee -a merge.log
60 echo "####processed list $1" | tee -a merge.log
63 for det in $components; do
65 echo "***********************" 2>&1 | tee -a merge.log
66 echo merging $det data 2>&1 | tee -a merge.log
67 echo "***********************" 2>&1 | tee -a merge.log
68 echo aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C(\"$det\", \"$1\")" 2>&1 | tee -a merge.log
69 aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C(\"$det\", \"$1\")" 2>&1 | tee -a merge.log
70 mv syswatch.log syswatch_merge_$det.log
71 mv CalibObjects.root CalibObjects_$det.root
74 rm -f $previousResults
77 echo "***********************" 2>&1 | tee -a merge.log
78 echo merging ALL data 2>&1 | tee -a merge.log
79 echo "***********************" 2>&1 | tee -a merge.log
80 partialCalibObjectsList="objects.list.${1}"
81 ls -1 CalibObjects_*.root > $partialCalibObjectsList
82 aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C(\"ALL\", \"$partialCalibObjectsList\")" 2>&1 | tee -a merge.log
83 mv syswatch.log syswatch_ALL.log
86 if [[ "$2" == "doCleanup" ]]; then
87 while read filename; do
88 echo rm -f $filename | tee -a merge.log
92 rm -f CalibObjects_*.root
95 rm -f $runningMergeByComponentLockFile
101 [[ ! -f $1 ]] && break
106 if [ $isLocal -eq 0 ]; then
107 #with alien files copy them first to local
108 echo "***********************" 2>&1 | tee -a merge.log
109 echo copying files for run $run 2>&1 | tee -a merge.log
110 echo from $path 2>&1 | tee -a merge.log
111 echo "***********************" 2>&1 | tee -a merge.log
112 aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C(\"MAKEALIENLIST\",\"$alienFileList\", \"$path\", \"AliESDfriends_v1.root\")" 2>&1 | tee -a merge.log
113 split --numeric-suffixes --suffix-length=4 --lines=100 ${alienFileList} ${partialAlienFileListPrefix}
115 rm -f $runningMergeByComponentLockFile
116 for partialAlienFileList in ${partialAlienFileListPrefix}*
118 #copy the alien files to local
119 partialAlienFileListPostfix=${partialAlienFileList#$partialAlienFileListPrefix}
120 partialLocalFileList=${partialLocalFileListPrefix}${partialAlienFileListPostfix}
121 aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C(\"COPY\",\"$partialAlienFileList\",\"noPath\",\"noPattern\",10,\"$partialLocalFileList\")" 2>&1 | tee -a merge.log
122 [[ $counter -ne 0 ]] && sed -i '1d' syswatch.log && $(( $counter++ ))
123 cat syswatch.log >> syswatch_copy.log
126 #merge in parallel, use a simple lockfile
127 waitIfLocked $runningMergeByComponentLockFile
128 mergeByComponent $partialLocalFileList "doCleanup" &
131 #locally just use the list directly
132 mergeByComponent $path
136 cat ${partialAlienFileListPrefix}* >> ${localFileList}
137 rm -f ${partialAlienFileListPrefix}*
138 rm -f ${partialLocalFileListPrefix}*
141 echo "***********************" 2>&1 | tee -a ocdb.log
142 echo making $det OCDB 2>&1 | tee -a ocdb.log
143 echo "***********************" 2>&1 | tee -a ocdb.log
144 aliroot -b -q "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/makeOCDB.C($run, \"$ocdb\", \"$defaultOCDB\")" 2>&1 | tee -a ocdb.log
145 mv syswatch.log syswatch_makeOCDB.log
148 echo "***********************" 2>&1 | tee -a ocdb.log
149 echo SUMMARY 2>&1 | tee -a ocdb.log
150 echo "***********************" 2>&1 | tee -a ocdb.log
151 ls -altr *CalibObjects.root *done 2>&1 | tee -a ocdb.log