]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/testdEdx/submitSimJobs.sh
modified: rec.C == changed name for the RecoParam OCDB Specific storage
[u/mrichter/AliRoot.git] / test / testdEdx / submitSimJobs.sh
1 #!/bin/sh
2
3 ###############################################################################
4 #
5 # Aim is to submit simulation/reconstruction jobs for multiplicity dependence check
6 # For local running one can use the instructions in runSim() function.
7 #    submitMultiplicityScan() --> main function to submit jobs for each event with a given multiplicity
8 #    runSim()                 --> runs the macros for simulation and reconstruction
9 # To see how to run these functions look below
10 #
11 ###############################################################################
12
13 # global variables to be set
14 DATE=`date +%Y_%m_%d_%H`
15 nEvents=1               #fixed to 1 to make an event by event job submission
16
17 ###############################################################################
18 submitIonTailXTalkScan()
19 {
20
21   #
22   # cals the submitMultiplicityScan fuction for 
23   #  --> IonTail ON/OFF, XTALK ON/OFF, in reconstruction  and MC
24   ###############################################################################
25   ## example  --> for 5 multiplicity bins, each most central event having 15000 track multiplicity. 
26   ##              For each multiplicity bin total statistic is 75000   
27   if [ 1 -eq 0 ]; then
28     cd $ALICE_ROOT/test/testdEdx
29     source submitSimJobs.sh 
30     submitIonTailXTalkScan 8 1000000 50 /hera/alice/marsland/software/bin/set_private_TPCdev.sh > out.log 2>&1 &
31   fi
32   ###############################################################################
33
34   # inputs
35   nMultBins=$1
36   maxNTracks=$2
37   nEventsCentral=$3
38   alirootSourceFile=$4
39
40   if [ $# -ne 4 ]; then 
41     echo "4 parameters needed --> multiplicity bins, maximum number of tracks, maximum number of central events, source file for root"
42     return 1
43   fi
44
45   baseDir=$(pwd)
46   testDir=$baseDir/test_$nMultBins\_$maxNTracks\_$nEventsCentral\_$DATE
47   DirCheckCreate $testDir
48   cd $testDir
49
50   for ((iontail=0; iontail<2 ; iontail=iontail+1))
51   do
52     for ((xtalk=0; xtalk<2 ; xtalk=xtalk+1))
53     do
54
55       MultiplicityScan $nMultBins $maxNTracks $nEventsCentral $alirootSourceFile $iontail $xtalk
56
57     done  
58   done
59
60 }
61 ###############################################################################
62 runSim(){
63
64   #
65   # Function which runs rec.C and sim.C for given multiplicity and event number. 
66   # (if submitMultiplicityScan function is called, this parameter is always fixed to 1, i.e event by event)
67   # Input parameters are
68   # 1) total track multiplicity 
69   # 2) number of events to be processed for given total track multiplicity (if submitMultiplicityScan() is called, it is 1)
70   # 3) script to source a specific aliroot
71   #
72   ###############################################################################
73   ## example --> 2 events with total multiplicity of 1000 tracks
74   if [ 1 -eq 0 ]; then
75     cd $ALICE_ROOT/test/testdEdx
76     source submitSimJobs.sh
77     runSim 100 1  0 0 /hera/alice/marsland/software/bin/set_private_TPCdev.sh > out.log 2>&1 &
78   fi
79   ###############################################################################
80
81   export TestdEdxNTracks=$1
82   nevents=$2
83   ionTail=$3
84   xTalk=$4
85   alirootSourceFile=$5
86
87   if [ $# -ne 4 ]; then
88     echo "5 parameters needed --> multiplicity, number of events, source file for aliroot, iontail switch (0 or 1), xTalk switch (0 or 1)"
89     return 1
90   fi
91
92   echo " Running dEdx digitzer test job" 
93   echo " NEvents = $nevents" 
94   echo " NTracks per event  $TestdEdxNTracks"
95
96
97   ## main body of the simulation part
98   rm -rf *.root *.dat *.log fort* hlt hough raw* recraw/*.root recraw/*.log GRP* 
99   printf   "\n ======================================================================\n\n"
100   echo Running: aliroot -b -q sim.C\($nevents,$ionTail,$xTalk\)     
101   aliroot -b -q sim.C\($nevents,$ionTail,$xTalk\)            2>&1 | tee sim.log
102   mv syswatch.log simwatch.log
103   printf   "\n ======================================================================\n\n"
104   echo Running: aliroot -b -q rec.C\($ionTail\,$xTalk\) 
105   aliroot -b -q rec.C\($ionTail\,$xTalk\)    2>&1 | tee rec.log    
106   mv syswatch.log recwatch.log
107   ## OCDB entries to be dumped in human readable format
108   source $ALICE_ROOT/PWGPP/CalibMacros/AliOCDBtoolkit.sh
109   printf   "\n ======================================================================\n\n"
110   echo Running: ocdbMakeTable AliESDs.root "ESD" OCDBrec.list
111   ocdbMakeTable AliESDs.root "ESD" OCDBrec.list
112   printf   "\n ======================================================================\n\n"
113   echo Running: ocdbMakeTable galice.root MC OCDBsim.list
114   ocdbMakeTable galice.root MC OCDBsim.list
115   ocdbFileName=$(cat OCDBrec.list | grep "TPC/Calib/RecoParam" | gawk '{print $2"/"$3}' )
116   printf   "\n ======================================================================\n\n"
117   echo Running: dumpObject $ocdbFileName  "object" "XML" RecoParam
118   dumpObject $ocdbFileName  "object" "XML" RecoParam
119
120   return 1;
121
122 }
123 ###############################################################################
124 MultiplicityScan(){
125   #
126   # Here we submit the jobs for the simulation//reconstruction for one setting of IonTail and XTalk configuration
127   # Parameters:
128   #   1. multiplicity bins to be investigated  (default 5)
129   #   2. max multiplicity for whole processing (default 75000 tracks --> 5 central PbPb event )
130   #   3. number of central events to be used   (default 5)
131   #   4. file to source aliroot
132   # (2)/(3) should be a reasonable multiplicity estimate (e.g. 15000 tracks which is 1 central PbPb event)
133   # Jobs will be submitted per event     
134   #
135   # For each setting new directory will be created - indicating muiltiplicity
136   # dir<ntracks>/dir<eventNr>  
137   #
138   ###############################################################################
139   ## example  --> for 5 multiplicity bins, each most central event having 15000 track multiplicity. 
140   ##              For each multiplicity bin total statistic is 75000   
141   if [ 1 -eq 0 ]; then
142     cd $ALICE_ROOT/test/testdEdx
143     source submitSimJobs.sh 
144     MultiplicityScan 8 1000000 50 /hera/alice/marsland/software/bin/set_private_TPCdev.sh 0 1 > out.log 2>&1 &
145   fi
146   ###############################################################################
147
148   # inputs
149   nMultBins=$1
150   maxNTracks=$2
151   nEventsCentral=$3
152   alirootSourceFile=$4
153   ionTail=$5
154   xTalk=$6
155
156   if [ $# -ne 6 ]; then 
157     echo "6 parameters needed --> multiplicity bins, maximum number of tracks, maximum number of central events, source file for root, iontail switch (0 or 1), xTalk switch (0 or 1)"
158     return 1
159   fi
160
161   baseDir=$(pwd)
162   testDir=$baseDir/IonTail_XTalk_$ionTail\_$xTalk
163   DirCheckCreate $testDir
164   cd $testDir
165
166   # create multiplicity bins 
167   multPerCentralEvent=$(echo $maxNTracks/$nEventsCentral | bc)
168   echo "multiplicity per most central event is $multPerCentralEvent"
169   for ((i=0; i<$nMultBins ; i=i+1))
170   do
171
172     multSteps=$(echo $multPerCentralEvent/$nMultBins | bc)
173     multBin=$(echo $multPerCentralEvent - $multSteps*$i | bc)
174     multBinDir=$testDir/mult_$multBin
175     DirCheckCreate $multBinDir
176     cd $multBinDir
177     echo $multBinDir
178
179     nEventsPerMultBin=$(echo $maxNTracks/$multBin | bc)
180     echo $nEventsPerMultBin
181     for ((j=1; j<$(echo $nEventsPerMultBin+1 | bc) ; j=j+1))
182     do
183
184       eventDir=$multBinDir/event_$j
185       DirCheckCreate $eventDir
186       cd $eventDir
187       cp -r $ALICE_ROOT/test/testdEdx/GRP $ALICE_ROOT/test/testdEdx/OCDB* $ALICE_ROOT/test/testdEdx/*.* .   
188       #cp $ALICE_ROOT/test/testdEdx/*.* .      
189
190       qsub -V -cwd -l h_rt=24:0:0,h_rss=6G -P alice -b y -r y -o outSim.log -e errSim.log $baseDir/submitSimJobs.sh runSim $multBin $nEvents $4 $5 $6
191  
192     done  
193   done
194
195   cd $baseDir 
196 }
197 ###############################################################################
198 DirCheckCreate()
199 {
200
201   #
202   # check if the directory exist. If so, delete it
203   #
204
205   dirName=$1
206   if [ -d "$dirName" ]; then
207     echo " $dirName already exist delete it and create a new one  "
208     rm -rf $dirName 
209   fi
210   mkdir $dirName
211
212 }
213 ###############################################################################
214 main()
215 {
216   eval "$@"
217 }
218
219 main $@
220