]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/CalibMacros/CPass1/runCPass1.sh
Updating scripts, to have the same in master as those in alien
[u/mrichter/AliRoot.git] / PWGPP / CalibMacros / CPass1 / runCPass1.sh
CommitLineData
a45764d9 1#!/bin/bash
2
3# Script to run:
4# 1. reconstruction
1169eaef 5# 2. calibration
a45764d9 6#
7# Files assumed to be in working directory:
054d9070 8# recCPass1.C - reconstruction macro
a45764d9 9# runCalibTrain.C - calibration/filtering macro
10# Arguments (run locally):
11# 1 - raw data file name
12# 2 - number of events to be processed
13# 3 - run number
e6844064 14
a45764d9 15# example:
e6844064 16# runCPass1.sh raw.root 50 104892
a45764d9 17
18#ALIEN setting
19# $1 = raw input filename
25e2b4b3 20runNum=`echo $1 | cut -d "/" -f 6 | sed 's/^0*//'`
e6844064 21
22if [ $# -eq 1 ]; then
23 # alien Setup
24 nEvents=99999999
25 ocdbPath="raw://"
1169eaef 26 # use the value passed by LPM, or by default use the kCalibBarrel alias
27 triggerOptions=${ALIEN_JDL_TRIGGERALIAS-?Trigger=kCalibBarrel}
28 #triggerOptions="?Trigger=kPhysicsAll"
e6844064 29fi
30
31if [ $# -ge 4 ]; then
32 # local setup
33 nEvents=$2
34 runNum=$3
35 ocdbPath=$4
36 triggerOptions="?Trigger=kCalibBarrel"
a6168b42 37fi
e6844064 38
39if [ $# -eq 5 ]; then
40 # local setup in case we specify the trigger mask
41 triggerOptions=$5
5cebce24 42fi
43
44CHUNKNAME="$1"
45
46if [ "${CHUNKNAME:0:1}" = "/" ]; then
47 FILENAME=${CHUNKNAME##*/}
48
49 if [ -f "$FILENAME" ]; then
50 # locally downloaded chunk
51 CHUNKNAME="`pwd`/$FILENAME"
52 else
53 # one chunk from alien (nodownload option to the collection)
54 CHUNKNAME="alien://$CHUNKNAME"
55 fi
56fi
a6168b42 57
5cebce24 58if [ -f "wn.xml" ]; then
59 # several chunks accessed remotely
60 CHUNKNAME="collection://wn.xml"
a45764d9 61fi
62
5cebce24 63echo "* ************************"
64echo "* runCPass1.sh $*"
65echo "* Chunk name: $CHUNKNAME"
66echo "* Run number: $runNum"
e6844064 67echo "* nEvents: $nEvents"
68echo "* runNum: $runNum"
69echo "* ocdbPath: $ocdbPath"
70echo "* triggerOptions: $triggerOptions"
5cebce24 71echo "* ************************"
a45764d9 72
e6844064 73mkdir Barrel OuterDet
74
a45764d9 75if [ -f Run0_999999999_v3_s0.root ]; then
5cebce24 76 echo "* TPC correction file found"
77
a45764d9 78 mkdir -p TPC/Calib/Correction
79 mv Run0_999999999_v3_s0.root TPC/Calib/Correction/
5cebce24 80
e6844064 81 for DIR in Barrel OuterDet; do
82 mkdir -p $DIR/TPC/Calib/Correction
83 ln -s ../../../../TPC/Calib/Correction/Run0_999999999_v3_s0.root $DIR/TPC/Calib/Correction/Run0_999999999_v3_s0.root
84 done
a45764d9 85fi
86
5cebce24 87echo "* PATH: $PATH"
88echo "* LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
89echo
a45764d9 90
5cebce24 91if [ "$2" == "OCDB" ]; then
92 export OCDB_SNAPSHOT_CREATE="kTRUE"
93 export OCDB_SNAPSHOT_FILENAME="OCDB.root"
1169eaef 94 touch OCDB.generating.job
a45764d9 95
5cebce24 96 echo "* Running AliRoot to generate the OCDB based on $CHUNKNAME"
a45764d9 97
5cebce24 98 echo "OCDB/recCPass1.C" >&2
1169eaef 99 time aliroot -l -b -q -x recCPass1.C\(\"$CHUNKNAME\"\) &> rec.log
5cebce24 100 exitcode=$?
101 echo "Exit code: $exitcode"
1169eaef 102
103 if [ $exitcode -ne 0 ]; then
104 echo "recCPass1.C for OCDB snapshot exited with code $exitcode" > validation_error.message
105 exit 10
106 fi
5cebce24 107
108 echo "* Reconstruction ran in fake mode to create OCDB.root, exiting quickly now"
a45764d9 109
5cebce24 110 if [ -f OCDB.root ]; then
111 echo "* OCDB.root was indeed produced"
112 else
113 echo "* Error: OCDB.root was NOT generated !!!"
1169eaef 114 echo "OCDB.root was not generated" > validation_error.message
5cebce24 115 exit 1
116 fi
a45764d9 117
1169eaef 118 exit 0
5cebce24 119fi
120
1169eaef 121for COMMON_FILE in wn.xml localOCDBaccessConfig.C AddTaskTPCCalib.C AddTaskTRDCalib.C OCDB.root QAtrain_duo.C; do
e6844064 122 if [ -f $COMMON_FILE ]; then
123 ln -s ../$COMMON_FILE Barrel/$COMMON_FILE
124 ln -s ../$COMMON_FILE OuterDet/$COMMON_FILE
125 fi
126done
5cebce24 127
e6844064 128for BARREL_FILE in recCPass1.C runCalibTrain.C; do
129 ln -s ../$BARREL_FILE Barrel/$BARREL_FILE
130done
5cebce24 131
e6844064 132for OUTER_FILE in recCPass1_OuterDet.C; do
133 ln -s ../$OUTER_FILE OuterDet/$OUTER_FILE
134done
5cebce24 135
136#################################### Barrel #######################################
137
383fa54e 138cd Barrel
a45764d9 139
5cebce24 140echo "* Running AliRoot to reconstruct barrel of $CHUNKNAME"
d74ff87e 141
1169eaef 142echo executing aliroot -l -b -q -x "recCPass1.C(\"$CHUNKNAME\", $nEvents, \"$ocdbPath\", \"$triggerOptions\")"
143time aliroot -l -b -q -x "recCPass1.C(\"$CHUNKNAME\", $nEvents, \"$ocdbPath\", \"$triggerOptions\")" &> ../rec.log
5cebce24 144exitcode=$?
145echo "Exit code: $exitcode"
383fa54e 146
5cebce24 147if [ $exitcode -ne 0 ]; then
1169eaef 148 echo "recCPass1.C exited with code $exitcode" > ../validation_error.message
149 exit 10
5cebce24 150fi
383fa54e 151
5cebce24 152mv syswatch.log ../syswatch_rec_Barrel.log
153
154echo "* Running AliRoot to make calibration..."
155
1169eaef 156echo executing aliroot -l -b -q -x "runCalibTrain.C($runNum,\"AliESDs.root\",\"$ocdbPath\")"
157time aliroot -l -b -q -x "runCalibTrain.C($runNum,\"AliESDs.root\",\"$ocdbPath\")" &> ../calib.log
5cebce24 158exitcode=$?
159echo "Exit code: $exitcode"
160
161if [ $exitcode -ne 0 ]; then
1169eaef 162 echo "runCalibTrain.C exited with code $exitcode" > ../validation_error.message
163 exit 40
383fa54e 164fi
d74ff87e 165
5cebce24 166mv syswatch.log ../syswatch_calib.log
167
168if [ -f QAtrain_duo.C ]; then
169 echo "* Running the QA train (barrel) ..."
170
1169eaef 171# echo executing aliroot -b -q "QAtrain_duo.C(\"_barrel\",$runNum,\"$ocdbPath\")"
172# time aliroot -b -q "QAtrain_duo.C(\"_barrel\",$runNum,\"$ocdbPath\")" &> ../qa_barrel.log
173
174 echo executing aliroot -b -q -x "QAtrain_duo.C(\"_barrel\",$runNum)"
175 time aliroot -b -q -x "QAtrain_duo.C(\"_barrel\",$runNum)" &> ../qa_barrel.log
e6844064 176
5cebce24 177 exitcode=$?
178 echo "Exit code: $exitcode"
d74ff87e 179
5cebce24 180 if [ $exitcode -ne 0 ]; then
1169eaef 181 echo "QAtrain_duo.C / barrel exited with code $exitcode" > ../validation_error.message
182 exit 100
5cebce24 183 fi
66c736ae 184
5cebce24 185 for file in *.stat; do
186 mv $file ../$file.qa_barrel
187 done
188fi
189
fcb0741e 190mv AliESDs.root ../AliESDs_Barrel.root
191mv AliESDfriends.root ../AliESDfriends_Barrel.root
192
1169eaef 193for file in AliESDfriends_v1.root QAresults_barrel.root EventStat_temp_barrel.root AODtpITS.root Run*.Event*_*.ESD.tag.root; do
5cebce24 194 if [ -f "$file" ]; then
195 mv "$file" ../
196 fi
66c736ae 197done
d74ff87e 198
5cebce24 199#################################### Outer #######################################
200
201cd ../OuterDet
202
203echo "* Running AliRoot to reconstruct outer of $CHUNKNAME"
204
1169eaef 205echo executing aliroot -l -b -q -x "recCPass1_OuterDet.C(\"$CHUNKNAME\", $nEvents, \"$ocdbPath\")"
206time aliroot -l -b -q -x "recCPass1_OuterDet.C(\"$CHUNKNAME\", $nEvents, \"$ocdbPath\")" &> ../rec_Outer.log
5cebce24 207exitcode=$?
208echo "Exit code: $exitcode"
209
210if [ $exitcode -ne 0 ]; then
1169eaef 211 echo "recCPass1_OuterDet.C exited with code $exitcode" > ../validation_error.message
212 exit 11
5cebce24 213fi
214
215mv syswatch.log ../syswatch_rec_Outer.log
216
217if [ -f QAtrain_duo.C ]; then
218 echo "* Running the QA train (outer) ..."
219
1169eaef 220# echo executing aliroot -b -q "QAtrain_duo.C(\"_outer\",$runNum,\"$ocdbPath\")"
221# time aliroot -b -q "QAtrain_duo.C(\"_outer\",$runNum,\"$ocdbPath\")" &> ../qa_outer.log
222
223 echo executing aliroot -b -q -x "QAtrain_duo.C(\"_outer\",$runNum)"
224 time aliroot -b -q -x "QAtrain_duo.C(\"_outer\",$runNum)" &> ../qa_outer.log
e6844064 225
5cebce24 226 exitcode=$?
227 echo "Exit code: $exitcode"
228
229 if [ $exitcode -ne 0 ]; then
1169eaef 230 echo "QAtrain_duo.C / outer exited with code $exitcode" > ../validation_error.message
231 exit 101
5cebce24 232 fi
233
234 for file in *.stat ; do
235 mv $file ../$file.qa_outer
236 done
237fi
238
383fa54e 239mv AliESDs.root ../AliESDs_Outer.root
5cebce24 240mv AliESDfriends.root ../AliESDfriends_Outer.root
9e160db9 241
5cebce24 242for file in QAresults_outer.root EventStat_temp_outer.root; do
243 if [ -f "$file" ]; then
244 mv "$file" ../
245 fi
246done
9e160db9 247
1169eaef 248exit 0