]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/macros/AliRsnLoad.C
Modifications in the balance function code + addition of the very first version of...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / macros / AliRsnLoad.C
1 //=============================================================================
2 // Compilation of all PAR archives for resonance analysis.
3 // Returns an integer error message if some compilation fails.
4 //
5 // Allowed options:
6 // - "UNTAR"   --> explodes the .par files in the working directory
7 // - "CLEAR"   --> removes the PAR archive directory and automatically
8 //                 recreates it by exploding again the .par file
9 //=============================================================================
10
11 Int_t SetupPar(const char* parName, Bool_t untar = kTRUE)
12 {
13 //
14 // Operations to set up the PAR archive
15 //
16
17     if (!parName) {
18         Error("SetupPar", "NULL argument passed - Abort!");
19         return -1;
20     }
21
22     // if the directory does not exist, the package is
23     // un-tarred anyway
24     if (!gSystem->OpenDirectory(parName)) untar = kTRUE;
25
26     // unzip + untar (optional)
27     if (untar) {
28         Char_t processLine[1024];
29         sprintf(processLine, ".! tar xvzf ./%s.par", parName);
30         gROOT->ProcessLine(processLine);
31     }
32
33     // change from working directory to sub-dir containing PAR archive
34     const char* ocwd = gSystem->WorkingDirectory();
35     gSystem->ChangeDirectory(parName);
36
37     // check for existence of appropriate 'BUILD.sh' script (in PROOF-INF.<parName>)
38     // and execute it (non-zero return values mean that errors occurred)
39     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
40         cout << "*** Building PAR archive \"" << parName << "\"" << endl;
41         if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
42             Error("SetupPar", "Cannot Build the PAR Archive - Abort!");
43             return -1;
44         }
45     }
46
47     // check for existence of appropriate 'SETUP.C' macro (in PROOF-INF.<parName>)
48     // and execute it
49     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
50         cout << "*** Setting up PAR archive \"" << parName << "\"" << endl;
51         gROOT->Macro("PROOF-INF/SETUP.C");
52     }
53
54     // return to working directory
55     gSystem->ChangeDirectory("../");
56
57     // return 1 if everything is OK
58     return 1;
59 }
60
61 Int_t AliRsnLoad(Option_t *option = "BUILD+UNTAR")
62 {
63 //
64 // Main function of this macro
65 // Sets up all the packages useful for resonance analysis.
66 // Depending on the support (PROOF / others), the functions are different.
67 //
68
69     TString opt(option);
70     opt.ToUpper();
71
72     // check for the UNTAR option
73     Bool_t untar = opt.Contains("UNTAR");
74
75     // check for the CLEAR option
76     // if this is found automatically is required the UNTAR
77     if (opt.Contains("CLEAR")) {
78         gSystem->Exec("rm -rf STEERBase ESD AOD ANALYSIS ANALYSISalice PWG2resonances");
79         untar = kTRUE;
80     }
81
82     // build all libraries with the defined options
83     SetupPar("STEERBase", untar);
84     SetupPar("ESD", untar);
85     SetupPar("AOD", untar);
86     SetupPar("ANALYSIS", untar);
87     SetupPar("ANALYSISalice", untar);
88     SetupPar("PWG2resonances", untar);
89 }