]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/electrons/README
New analysis for electron identification
[u/mrichter/AliRoot.git] / PWG4 / macros / electrons / README
1 29 May 2009
2
3 This is a grand unified example of the ALICE Analysis Framework for
4 EMCal analysis on Local, Local CAF, PROOF, GRID interactive, GRID
5 batch, and AliEn PLUGIN.
6
7 Notice: Everything is working today. Really!
8
9
10 ---------------------------------------------------------------------
11
12 PAR files
13
14 You can skip this PAR section for your first use of the example if you
15 just want to see how things work. The PAR files in the example were
16 built with ROOT v5-23-04 and AliRoot v4-16-Rev-11. See VM20090529.pdf
17 file with updated build instructions for ROOT v5-23-04 and AliROOT
18 v4-16-Rev-11. If you have write access to $ALICE_ROOT, you can install
19 AliAnalysisTaskElectron.cxx and make a new PAR file as follows:
20
21 edit $ALICE_ROOT/PWG4/PWG4PartCorrLinkDef.h to include AliAnalysisTaskElectron
22 edit $ALICE_ROOT/PWG4/libPWG4PartCorr.pkg to include AliAnalysisTaskElectron
23 edit $ALICE_ROOT/PWG4/CMake_libPWG4PartCorr.txt to include AliAnalysisTaskElectron
24 cp <yourlocalarea>/AliAnalysisTaskElectron.cxx $ALICE_ROOT/PWG4/PartCorr
25 cp <yourlocalarea>/AliAnalysisTaskElectron.h   $ALICE_ROOT/PWG4/PartCorr
26
27 cd $ALICE_ROOT
28 make
29 make PWG4PartCorr.par
30 mv PWG4PartCorr.par <your workarea>
31
32
33 ---------------------------------------------------------------------
34
35 local usage (your laptop, workstation, PDSF account, etc.):
36
37 For PDSF:
38 ssh -X <username>@pdsf.nersc.gov
39 cp ~kread/.chos $HOME/.chos (to invoke SciLinux 4.4)
40 logout and log back in
41 source /project/projectdirs/alice/alisetup.csh
42
43 All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
44 copied to your local workarea (except for README and PDF files).
45
46 If not at PDSF, need a valid local matching ROOT and AliROOT installation. 
47 (See /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf)
48
49 cd <yourworkarea>
50
51 Change this line in anaElectron.C to point to your local AliESDs.root
52 data files:
53 char * kInDir = "/afs/cern.ch/user/k/kread/PWG4/data/"
54
55 root -b
56 .L anaElectron.C
57 anaElectron(0,"ConfigAnalysisElectron")
58 .q
59
60
61 ---------------------------------------------------------------------
62
63 CAF local usage (including for files on GRID):
64
65 All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
66 copied to your local workarea.
67
68 Your valid public and private keys need to be properly located in
69 /afs/cern.ch/user/<username>/.globus.
70
71 ssh -X <username>@lxplus.cern.sh
72 cd <yourworkarea>
73 bash
74 source /afs/cern.ch/alice/caf/caf-lxplus.sh -alien v4-16-Release 
75 enter GRID password
76
77 Edit ESDlist.txt to point to the location of your AliESDs.root files
78 (including those on the GRID).
79
80 root -b
81 .L anaElectron.C
82 anaElectron(1,"ConfigAnalysisElectron")
83 .q
84
85
86 ---------------------------------------------------------------------
87
88 PROOF usage within CERN:
89
90 All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to be
91 copied to your local workarea.
92
93 The lines in anaElectron.C to need to look like this (which is the default):
94     char* myproofname = "alicecaf";
95     //char* myproofname = "kread@localhost";
96
97
98 Your valid public and private keys need to be properly located in
99 $HOME/.globus.
100
101 ssh -X <username>@lxplus.cern.sh (or other computer at CERN)
102 cd <yourworkarea>
103 bash
104
105 You need a valid matching local ROOT and AliROOT installation with ROOT
106 v5-23-04 or higher.  (See
107 /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf if necessary.)
108 For instance:
109 source /afs/cern.ch/alice/caf/caf-lxplus.sh -alien v4-16-Release
110 enter GRID password
111
112 Edit this line in anaElectron.C to point to the appropriate CAF
113 dataset:
114 char * kmydataset = "/COMMON/COMMON/LHC09a4_run8101X"
115
116 To access files in AliEN, first type
117 root -b
118 gEnv->SetValue("XSec.GSI.DelegProxy","2")
119
120 root -b
121 .L anaElectron.C
122 anaElectron(2,"ConfigAnalysisElectron")
123 .q
124
125 For instructions concerning how to stage data files to CAF and how
126 to inspect what data is already staged, see:
127 http://aliceinfo.cern.ch/Offline/Activities/Analysis/CAF/index.html
128
129 If you do not use the provided PAR files, then you will need to add
130 the following lines at the beginning of
131 AliAnalysisTaskElectron::Terminate in AliAnalysisTaskElectron.cxx,
132
133   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
134   if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
135
136 These lines work for all modes of anaElectron.cxx. So, you can install
137 a revised version of AliAnalysisTaskElectron.cxx at $ALICE_ROOT/PWG4/PartCorr .
138
139 ---------------------------------------------------------------------
140
141 remote PROOF usage (not at CERN):
142
143 This is a GREAT feature, but you will need a local installation with
144 ROOT v5-23-04 built with --globus, AliROOT v4-16-Rev-nn, and probably
145 write-access to $ALICE_ROOT. 
146 (See /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf. Remote
147 PROOF access is not possible without at least ROOT v5-23-02b.)  This
148 requires some understanding of PAR file manipulation.  If you have
149 already been using the example, first type this and be sure not to do it
150 in the $ALICE_ROOT area:
151
152 cd <your workarea>
153 /bin/rm -rf ANALYSIS ANALYSISalice AOD ESD STEERBase PWG4PartCorr
154
155 All of the files at /afs/cern.ch/user/k/kread/public/all/v416 need to
156 be copied to your local workarea.  You should only have the (provided)
157 PAR file versions (not untarred versions) of the AliRoot
158 subdirectories present in your workarea.
159
160 Modify these lines in anaElectron.C to look like this, replacing
161 "kread" with your lxplus.cern.ch username:
162     //char* myproofname = "alicecaf";
163     char* myproofname = "kread@localhost";
164
165 Your valid public and private keys need to be properly located in
166 $HOME/.globus.
167
168 ssh -L 1093:alicecaf.cern.ch:1093 -fN <username>@lxplus.cern.ch
169 bash
170 alien-token-init
171
172 enter GRID password
173 source /tmp/gclient_env_$UID
174 export alien_CLOSE_SE="ALICE::CNAF::SE"
175 export XrdSecGSISRVNAMES="lxfsrd0506.cern.ch"
176
177 Edit this line in anaElectron.C to point to the appropriate CAF
178 dataset:
179 char * kmydataset = "/COMMON/COMMON/LHC09a4_run8101X"
180
181 root -b
182 .L anaElectron.C
183 anaElectron(2,"ConfigAnalysisElectron")
184 .q
185
186 For instructions concerning how to stage data files to CAF and how
187 to inspect what data is already staged, see:
188 http://aliceinfo.cern.ch/Offline/Activities/Analysis/CAF/index.html .
189
190 The macro will create PAR files in $HOME/.proof/packages.  If you have
191 trouble you can look at what is there and also uncomment appropriate
192 lines in anaElectron.C to ClearPackages.
193
194 You can see PROOF slave log files by creating a file GetProofLogs.C with these
195 lines:
196 {
197  gEnv->SetValue("XSec.GSI.DelegProxy","2");
198  logs=TProof::Mgr("kread@localhost")->GetSessionLogs(0);
199  logs->Display();
200  //logs->Grep("segmentation violation");
201  logs->Save("*","logs.txt");
202 }
203
204 and then relaunching root and typing:
205
206 root -b
207 .x GetProofLogs.C
208
209
210 If you do not use the provided PAR files, then you will need to add
211 the following lines at the beginning of
212 AliAnalysisTaskElectron::Terminate in AliAnalysisTaskElectron.cxx,
213
214   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
215   if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
216
217 These lines work for all modes of anaElectron.cxx. So, you can install
218 a revised version of AliAnalysisTaskElectron.cxx at $ALICE_ROOT/PWG4/PartCorr .
219
220 ---------------------------------------------------------------------
221
222 GRID usage:
223
224 Copy all of the files at /afs/cern.ch/user/k/kread/public/all/v416 to your
225 local workarea.
226
227 Change all instances of username "kread" and to your username in
228 anaElectron.jdl and mergeElectron.jdl.  Change email address in
229 mergeElectron.jdl.  There is no need to change the jobid number inside
230 mergeElectron.jdl.
231
232 Need a valid local ROOT installation built with --enable-globus.
233 Need a valid local alien grid shell installed.
234 (If running locally and not at PDSF or lxplus, see
235 /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
236
237 Your valid public and private keys need to be properly located in
238 $HOME/.globus.
239
240 bash
241 alien-token-init
242 enter GRID password
243 source /tmp/gclient_env_$UID
244 export alien_CLOSE_SE="ALICE::CNAF::SE"
245
246 cd <local workarea>
247 aliensh (to get to GRID home directory)
248
249 Make the following directories (if not done already):
250 cd $HOME
251 mkdir bin
252 mkdir work3
253 mkdir work3/output
254 mkdir work3/output/merge
255
256 Need to upload files (including par and jdl files) to GRID.
257
258 Can use:
259 cp file:yourlocalfile.ext gridfile.ext (being sure to spell out the GRID
260 file name.)
261 Do not try:
262 cp file:yourlocalfile.ext .
263
264 Or, exit from aliensh and type locally:
265 alien_cp localfile.ext alien://alice/cern.ch/user/<first-initial>/<username>/work3/gridfile.ext
266
267 Do not try to skip the complete GRID file name like this:
268 alien_cp localfile.ext alien://alice/cern.ch/user/<first-initial>/<username>/work3/
269
270 anaElectron.sh needs to be uploaded to the GRID to $HOME/bin.
271 anaElectron.sh sets the mode to GRID.
272
273 To launch job:
274 aliensh
275 cd $HOME/work3
276 submit anaElectron.jdl
277
278 To change input data.
279 aliensh
280 cd $HOME/work3
281 rm mycollect.xml (need to remove before uploading new version)
282 Use the desired run number and pattern in the find command, perhaps using the -l switch:
283 find -x mycollect /alice/sim/PDC_08b/LHC08d8/30009/0* AliESDs.root > mycollect.xml
284 or
285 find -x mycollect -l 200 /alice/sim/PDC_08b/LHC08d9/40010/* AliESDs.root > mycollect.xml
286 exit
287 alien_cp mycollect.xml alien://alice/cern.ch/user/<first-initial>/<username>/work3/mycollect.xml
288
289 Then, relaunch.
290
291 To monitor grid job:
292 aliensh
293 ps
294 ps -trace <jobid>
295 spy <jobid> stdout
296 spy <jobid> stderr
297 spy <jobid> anaElectron.log
298
299 If job fails with status E or EV, then to obtain stdout and other output type:
300 registerOutput <jobid>
301
302 Available GRID productions monitored via MonaLisa are listed here:
303 http://pcalimonitor.cern.ch/job_details.jsp
304
305 The choice of $alien_CLOSE_SE is very important.  You can see the status of ALICE grid
306 storage elements here:
307
308 http://pcalimonitor.cern.ch/stats?page=SE/table
309
310
311 ---------------------------------------------------------------------
312
313 Plugin usage:
314
315 Copy all of the files at /afs/cern.ch/user/k/kread/public/all/v416 to your
316 local workarea.
317
318 Change all instances of username "kread" to your username in
319 anaElectron.jdl and mergeElectron.jdl.  Change email address in
320 mergeElectron.jdl.  There is no need to change the jobid number inside
321 mergeElectron.jdl.
322
323 Need a valid local ROOT installation built with --enable-globus.
324 Need a valid local alien grid shell installed.
325 (If running locally and not at PDSF or lxplus, see
326 /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
327
328 Your valid public and private keys need to be properly located in
329 $HOME/.globus.
330
331 bash
332 alien-token-init
333 enter GRID password
334 source /tmp/gclient_env_$UID
335 export alien_CLOSE_SE="ALICE::CNAF::SE"
336
337 Copy new xml file manually to AliEn (after deleting any existing copy in $HOME/work3) by typing
338 alien_cp mycollect.xml alien://alice/cern.ch/user/<first-initial>/<username>/work3/mycollect.xml
339
340
341 cd <local workarea>
342 root -b
343 .L anaElectron.C
344 anaElectron(4,"ConfigAnalysisElectron")
345 .q
346
347 Ignore warning messages from plugin about missing myAnalysis.C and
348 analysis.root which are not needed here.
349
350 Files should be automatically uploaded to grid and job launched.
351 aliensh is launched in order to monitor job.  Exiting aliensh after
352 jobs are done will automatically invoke merge and copy merged output
353 histograms to local workarea.
354
355 Note that above we interactively submit the plugin job using mode=4.
356 However, do not change the mode to 4 inside the file anaElectron.sh
357 which is executed on each GRID compute node.  That needs to remain
358 mode=3 (GRID).
359
360 See GRID usage section above for more about copying to/from GRID and
361 monitoring jobs.
362 Make directories on the GRID (if not done already) as follows:
363
364 aliensh
365 cd $HOME
366 mkdir bin
367 mkdir work3
368 mkdir work3/output
369 mkdir work3/output/merge
370 exit
371
372
373 ---------------------------------------------------------------------
374
375 GRID via AliEn plugin for simpler macro
376
377 An earlier, simpler, separate stand-alone example of EMCal analysis
378 with the AliEn plugin is presently available at
379 /afs/cern.ch/user/k/kread/public/plugin.
380
381 Copy the tar file to your local workarea.
382 Untar the file.
383 tar -xvf plugin-example.tar
384
385 Need a valid local ROOT installation built with --enable-globus.
386 Need a valid local alien grid shell installed.
387 (If running locally and not at PDSF or lxplus, see
388 /afs/cern.ch/user/k/kread/public/all/v416/VM20090529.pdf.)
389
390 Your valid public and private keys need to be properly located in
391 $HOME/.globus.
392
393 bash
394 alien-token-init
395 enter GRID password
396 source /tmp/gclient_env_$UID
397 export alien_CLOSE_SE="ALICE::CNAF::SE"
398
399 cd <local workarea>
400 root -b
401 .x runGrid.C
402 .q
403
404 Edit CreateAlienHandler.C to select different input data available on GRID.
405 See GRID section above for more about copying to/from GRID and monitoring jobs.
406 1 June 2009
407
408 These are the instructions for the anaElctron helper macro when used
409 with AliRoot v4-17. All of the v416 files and instructions (located at
410 /afs/cern.ch/user/k/kread/public/all/v416) are appropriate for use
411 with AliRoot v4-17 except for the following which are different:
412
413 anaElectron.C, anaElectron.jdl, and all of the *.par files.
414
415 The PAR files in this subdirectory were built using ROOT v5-23-04 and
416 AliRoot v4-17-03.
417
418 The warnings about input and output containers being automatically created are
419 normal.
420
421 For remote PROOF, follow the usual instructions but set up two tunnels:
422 ssh -L 1093:alicecaf.cern.ch:1093 -fN <username>@lxplus.cern.ch
423 ssh -L 11094:alicecaf.cern.ch:11094 -fN <username>@lxplus.cern.ch
424
425 As usual, for PROOF, if you don't use these PAR files, then you will need
426 to add these lines at the beginning of AliAnalysisTaskElectron::Terminate in
427 AliAnalysisTaskElectron.cxx:
428
429   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
430   if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
431
432 To build PWG4PartCorrDep.par:
433
434 copy AliAnalysisTaskElectron.cxx and AliAnalysisTaskElectron.h to $ALICE_ROOT/PWG4/PartCorrDep
435 edit $ALICE_ROOT/PWG4/PWG4PartCorrDepLinkDef.h to include AliAnalysisTaskElectron
436 edit $ALICE_ROOT/PWG4/libPWG4PartCorrDep.pkg to include AliAnalysisTaskElectron
437 edit $ALICE_ROOT/PWG4/CMake_libPWG4PartCorrDep.txt to include AliAnalysisTaskElectron
438
439 For PLUGIN mode, we have to work around a new small bug in the AliEn
440 plugin for v4-17-03.  Please, ignore the fact that an irrelevant xml
441 file (30010.xml) is generated for PLUGIN mode and uploaded to the
442 grid.  This satisfies some (uneccesary) requirements in the plugin for
443 this release and will be fixed in the future.
444 June 2009
445
446 mylauncher.C is a robust file upload and grid submit helper.  Just
447 edit the first few lines (after, of course, defining alien_CLOSE_SE
448 and doing alien-token-init).  Adjust it as needed and you may
449 prefer it to the plugin.  Even for manual grid submitters, it
450 can really simplify uploading and make it more robust.
451
452 The environment variable alien_CLOSE_SE needs to be defined locally,
453 and be defined BEFORE you do alien-token-init.  (I will change the
454 other READMEs to reflect this.) Then, and only then, you will find
455 that it is listed in /tmp/gclient_env_$UID.  It needs to be there in
456 order to be defined later within aliensh.  Within aliensh you can see if
457 things are OK by typing echo $alien_CLOSE_SE.  And, of course, outside
458 of aliensh, you can type echo $alien_CLOSE_SE.
459
460 My recommendation to enforce this is either to put 
461 export alien_CLOSE_SE="ALICE::CNAF::SE"
462
463 in your login profile or initial setup script or to make the following local alias:
464
465 alias myaliti='export alien_CLOSE_SE="ALICE::CNAF::SE";alien-token-init'
466
467 For tcsh/csh, that would of course be
468
469 alias myaliti 'setenv alien_CLOSE_SE "ALICE::CNAF::SE";alien-token-init'
470
471 Then, by just typing "myaliti" (which means my alien token init),
472 everything will be OK concerning alien_CLOSE_SE and you will never forget
473 to set it.
474
475 Next, people who use bash will continue to type "source
476 /tmp/glient_env_$uid" after typing myaliti.
477
478 However, they can to this in their login files 
479
480 alias myalige='source /tmp/gclient_env_$UID'
481
482 (That stands for my alien globus environment.)
483
484 Then, they just always type
485
486 myaliti
487 myalige
488
489 Tcsh/csh users never even need to type "bash" (since they can't source
490 that bash file in the /tmp area) if they do the following.
491
492 1. Prepare a new file in your util subdirectory and call it
493 $HOME/util/gclient_env.csh.  It should be just like
494 /tmp/gclient_env_$uid, except remove all the equal signs and change
495 the word export to setenv everywhere. You only need to do that once.
496 And you need to make two changes in the new file:
497
498 a. Comment out one line and let the myaliti alias do it:
499 #setenv alien_CLOSE_SE "ALICE::CNAF::SE"
500
501 b. Replace the corresponding line about the volatile GBBOX_ENVFILE with this sed magic:
502
503 setenv GBBOX_ENVFILE `grep ENVFILE /tmp/gclient_env_$uid | sed s/"export GBBOX_ENVFILE="/""/`
504
505
506 2. Then, define:
507
508 alias myalige 'source $HOME/util/gclient_env.csh'
509
510 So, these users never need to type "bash", but also just always type
511
512 myaliti 
513 myalige
514
515
516 The symmetry of myaliti, myalige is why I didn't put alien_CLOSE_SE
517 in my login script.  By defining myaliti1, myaliti2, ... myaliti5
518 with different, favored SE's in advance, then based on varying storage
519 element health you can type
520
521 myaliti3  (or 4 or 5 or whatever is best, and avoid mis-typing)
522 myalige
523
524 I like that.
525
526 Next, note that interactive copying to your alien space does not allow
527 graceful overwriting.  You need to delete any existing copy of a
528 desired file before you copy a new one to the grid with that name.
529 (mylauncher.C detects this and does it automatically.)
530
531
532
533 --------------------------------------------------
534
535 Note that mylauncher.C opens the way to arbitrary file upload,
536 download, and copy, and multiple simultaneous, coordinated submits.
537 That could be useful for systematic analyses involving scores or
538 hundreds of jobs.