]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/CalibMacros/CPass0/runCPass0.sh
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / CalibMacros / CPass0 / runCPass0.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 # recCPass0.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 # runCPass0.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 [ $# -lt 3 ]; then
23     # alien Setup
24     nEvents=99999999
25     ocdbPath="raw://"
26     
27     # use the value passed by LPM, or by default use the kCalibBarrel alias
28     triggerAlias=${ALIEN_JDL_TRIGGERALIAS-?Trigger=kCalibBarrel}
29     #triggerAlias="?Trigger=kPhysicsAll"
30 fi
31
32 if [ $# -ge 4 ]; then
33   # local setup
34   nEvents=$2
35   runNum=$3
36   ocdbPath=$4
37   triggerAlias="?Trigger=kCalibBarrel"
38 fi
39
40 if [ $# -eq 5 ]; then
41     # local setup in case we provide the trigger mask
42     # the trigger mask is first stripped of quotation characters
43     triggerAlias=${5//\"/}
44 fi
45
46 if [ -f Run0_999999999_v3_s0.root ]; then
47     mkdir -p TPC/Calib/Correction
48     mv Run0_999999999_v3_s0.root TPC/Calib/Correction/
49 fi
50
51 echo "File to be  processed $1"
52 echo "Number of events to be processed $nEvents"
53
54 echo "* PATH: $PATH"
55 echo "* LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
56 echo
57
58 if [ "$2" == "OCDB" ]; then
59     echo "Generating OCDB.root only"
60     export OCDB_SNAPSHOT_CREATE="kTRUE"
61     export OCDB_SNAPSHOT_FILENAME="OCDB.root"
62     touch OCDB.generating.job
63 fi
64
65 CHUNKNAME="$1"
66
67 if [ "${CHUNKNAME:0:1}" = "/" ]; then
68     FILENAME=${CHUNKNAME##*/}
69
70     if [ -f "$FILENAME" ]; then
71         # locally downloaded chunk
72         CHUNKNAME="`pwd`/$FILENAME"
73     else
74         # one chunk from alien (nodownload option to the collection)
75         CHUNKNAME="alien://$CHUNKNAME"
76     fi
77 fi
78
79 if [ -f "wn.xml" ]; then
80     CHUNKNAME="collection://wn.xml"
81 fi
82
83 echo "* Running AliRoot to reconstruct $*"
84 echo "* Chunk name: $CHUNKNAME"
85 echo "* Run number: $runNum"
86 echo "* nEvents: $nEvents"
87 echo "* ocdbPath: $ocdbPath"
88 echo "* triggerAlias: $triggerAlias"
89 echo ""
90
91 echo executing aliroot -l -b -q -x "recCPass0.C(\"$CHUNKNAME\",$nEvents,\"$ocdbPath\",\"$triggerAlias\")"
92 time aliroot -l -b -q -x "recCPass0.C(\"$CHUNKNAME\",$nEvents,\"$ocdbPath\",\"$triggerAlias\")" &> rec.log
93
94 exitcode=$?
95
96 echo "*! Exit code of recCPass0.C: $exitcode"
97
98 if [ $exitcode -ne 0 ]; then
99     exit $exitcode
100 fi 
101
102 mv syswatch.log syswatch_rec.log
103
104 if [ "$2" == "OCDB" ]; then
105     echo "*! Reconstruction ran in fake mode to create OCDB.root, exiting quickly now"
106
107     if [ -f OCDB.root ]; then
108         echo "* OCDB.root was indeed produced"
109     else
110         echo "! Error: OCDB.root was NOT generated !!!"
111         echo "OCDB.root was not generated" > validation_error.message
112         exit 1
113     fi
114     
115     exit 0
116 fi
117
118 echo "* Running AliRoot to make calibration..."
119 echo executing aliroot -l -b -q -x "runCalibTrain.C($runNum,\"AliESDs.root\",\"$ocdbPath\")"
120 time aliroot -l -b -q -x "runCalibTrain.C($runNum,\"AliESDs.root\",\"$ocdbPath\")" &> calib.log
121 exitcode=$?
122
123 echo "*! Exit code of runCalibTrain.C: $exitcode"
124
125 if [ $exitcode -ne 0 ]; then
126     echo "runCalibTrain.C exited with code $exitcode" > validation_error.message
127     exit 40
128 fi
129
130 exit 0