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