]>
Commit | Line | Data |
---|---|---|
0bd1f8a0 | 1 | /* $Id$ */ |
2 | ||
3 | // Helper macros can be found in this file | |
4 | // A set of them can be used to connect to proof and execute selectors. | |
5 | ||
6 | TVirtualProof* connectProof(const char* proofServer) | |
7 | { | |
8 | TVirtualProof* proof = TProof::Open(proofServer); | |
9 | ||
10 | if (!proof) | |
11 | { | |
12 | printf("ERROR: PROOF connection not established.\n"); | |
13 | return 0; | |
14 | } | |
15 | ||
16 | proof->SetParallel(20); | |
17 | ||
18 | // enable the new packetizer | |
19 | //proof->AddInput(new TNamed("PROOF_Packetizer", "TPacketizerProgressive")); | |
20 | ||
21 | proof->ClearInput(); | |
22 | ||
23 | return proof; | |
24 | } | |
25 | ||
26 | Bool_t prepareQuery(TString libraries, TString packages, Bool_t useAliRoot) | |
27 | { | |
28 | // if not proof load libraries | |
29 | if (!gProof) | |
30 | { | |
31 | TObjArray* librariesList = libraries.Tokenize(";"); | |
32 | for (Int_t i=0; i<librariesList->GetEntries(); ++i) | |
33 | { | |
34 | TObjString* str = dynamic_cast<TObjString*> (librariesList->At(i)); | |
35 | if (!str) | |
36 | continue; | |
37 | ||
38 | printf("Loading %s...", str->String().Data()); | |
39 | Int_t result = CheckLoadLibrary(str->String()); | |
40 | if (result < 0) | |
41 | { | |
42 | printf("failed\n"); | |
43 | //return kFALSE; | |
44 | } | |
45 | else | |
46 | printf("succeeded\n"); | |
47 | } | |
48 | } | |
49 | else | |
50 | { | |
51 | if (useAliRoot) | |
52 | ProofEnableAliRoot(); | |
53 | ||
54 | TObjArray* packagesList = packages.Tokenize(";"); | |
55 | for (Int_t i=0; i<packagesList->GetEntries(); ++i) | |
56 | { | |
57 | TObjString* str = dynamic_cast<TObjString*> (packagesList->At(i)); | |
58 | if (!str) | |
59 | continue; | |
60 | ||
61 | if (!EnablePackageLocal(str->String())) | |
62 | { | |
63 | printf("Loading of package %s locally failed\n", str->String().Data()); | |
64 | return kFALSE; | |
65 | } | |
66 | ||
67 | if (gProof->EnablePackage(str->String())) | |
68 | { | |
69 | printf("Loading of package %s failed\n", str->String().Data()); | |
70 | return kFALSE; | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | return kTRUE; | |
76 | } | |
77 | ||
78 | Int_t executeQuery(TChain* chain, TList* inputList, TString selectorName, const char* option = "") | |
79 | { | |
80 | if (!gProof) | |
81 | chain->GetUserInfo()->AddAll(inputList); | |
82 | else | |
83 | { | |
84 | for (Int_t i=0; i<inputList->GetEntries(); ++i) | |
85 | gProof->AddInput(inputList->At(i)); | |
86 | } | |
87 | ||
88 | TStopwatch timer; | |
89 | timer.Start(); | |
90 | ||
91 | Long64_t result = -1; | |
92 | ||
93 | if (gProof) | |
94 | result = chain->MakeTDSet()->Process(selectorName, option); | |
95 | else | |
96 | result = chain->Process(selectorName, option); | |
97 | ||
98 | if (result < 0) | |
99 | printf("ERROR: Executing process failed with %d.\n", result); | |
100 | ||
101 | timer.Stop(); | |
102 | timer.Print(); | |
103 | ||
104 | return result; | |
105 | } | |
106 | ||
107 | void ProofEnableAliRoot() | |
108 | { | |
109 | // enables a locally deployed AliRoot in a PROOF cluster | |
110 | ||
111 | /* executes the following commands on each node: | |
112 | gSystem->Setenv("ALICE_ROOT", "/home/alicecaf/ALICE/aliroot-head") | |
113 | gSystem->AddIncludePath("/home/alicecaf/ALICE/aliroot-head/include"); | |
114 | gSystem->SetDynamicPath(Form("%s:%s", gSystem->GetDynamicPath(), "/home/alicecaf/ALICE/aliroot-head/lib/tgt_linux")) | |
115 | gSystem->Load("libMinuit"); | |
116 | gROOT->Macro("$ALICE_ROOT/macros/loadlibs.C"); | |
117 | */ | |
118 | ||
119 | const char* location = "/home/alicecaf/ALICE/aliroot-head"; | |
120 | ||
121 | gProof->Exec(Form("gSystem->Setenv(\"ALICE_ROOT\", \"%s\")", location), kTRUE); | |
122 | gProof->AddIncludePath(Form("%s/include", location)); | |
123 | gProof->AddDynamicPath(Form("%s/lib/tgt_linux", location)); | |
124 | ||
125 | // load all libraries | |
126 | gProof->Exec("gSystem->Load(\"libMinuit\")"); | |
127 | gProof->Exec("gROOT->Macro(\"$ALICE_ROOT/macros/loadlibs.C\")"); | |
128 | } | |
129 | ||
130 | Bool_t EnablePackageLocal(const char* package) | |
131 | { | |
132 | printf("Enabling package %s locally...\n", package); | |
133 | ||
134 | if (!gSystem->cd(package)) | |
135 | return kFALSE; | |
136 | ||
137 | gROOT->ProcessLine(".x PROOF-INF/SETUP.C"); | |
138 | gSystem->cd(".."); | |
139 | ||
140 | return kTRUE; | |
141 | } | |
142 | ||
143 | Int_t CheckLoadLibrary(const char* library) | |
144 | { | |
145 | // checks if a library is already loaded, if not loads the library | |
146 | ||
147 | if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0) | |
148 | return 1; | |
149 | ||
150 | return gSystem->Load(library); | |
151 | } | |
152 | ||
153 | void redeployPackages(const char* proofServer, Bool_t localAliRoot = kTRUE) | |
154 | { | |
155 | // deploys PWG0base and PWG0dep (the latter only when localAliRoot is true) that are expected in $ALICE_ROOT | |
156 | // when localAliRoot is false ESD.par is also deployed | |
157 | ||
158 | TProof::Reset(proofServer); | |
159 | TVirtualProof* proof = TProof::Open(proofServer); | |
160 | proof->ClearPackages(); | |
161 | ||
162 | if (localAliRoot) | |
163 | ProofEnableAliRoot(); | |
164 | else | |
165 | { | |
166 | proof->UploadPackage("$ALICE_ROOT/ESD.par"); | |
167 | proof->EnablePackage("ESD"); | |
168 | } | |
169 | ||
170 | proof->UploadPackage("$ALICE_ROOT/PWG0base.par"); | |
171 | proof->EnablePackage("PWG0base"); | |
172 | ||
173 | proof->UploadPackage("$ALICE_ROOT/PWG0dep.par"); | |
174 | proof->EnablePackage("PWG0dep"); | |
175 | } |