1 |
loizides |
1.4 |
// $Id: Analysis.cc,v 1.3 2008/06/05 07:54:21 loizides Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitAna/TreeMod/interface/Analysis.h"
|
4 |
|
|
#include <Riostream.h>
|
5 |
|
|
#include <TFile.h>
|
6 |
|
|
#include <TList.h>
|
7 |
|
|
#include <TDSet.h>
|
8 |
|
|
#include <TChain.h>
|
9 |
|
|
#include <TObjString.h>
|
10 |
|
|
#include <TSystem.h>
|
11 |
|
|
#include <TProof.h>
|
12 |
|
|
#include <TROOT.h>
|
13 |
loizides |
1.4 |
#include <TBrowser.h>
|
14 |
loizides |
1.1 |
#include "MitAna/DataUtil/interface/Debug.h"
|
15 |
loizides |
1.2 |
#include "MitAna/DataTree/interface/Names.h"
|
16 |
loizides |
1.1 |
#include "MitAna/TAM/interface/TAMVirtualLoader.h"
|
17 |
|
|
#include "MitAna/TAM/interface/TAModule.h"
|
18 |
|
|
#include "MitAna/TAM/interface/TAMSelector.h"
|
19 |
|
|
|
20 |
|
|
ClassImp(mithep::Analysis)
|
21 |
|
|
|
22 |
|
|
using namespace mithep;
|
23 |
|
|
|
24 |
|
|
//__________________________________________________________________________________________________
|
25 |
loizides |
1.4 |
Analysis::Analysis(Bool_t useproof)
|
26 |
|
|
: fUseProof(useproof),
|
27 |
|
|
fHierachy(kTRUE),
|
28 |
|
|
fState(kPristine),
|
29 |
|
|
fNFriends(0),
|
30 |
|
|
fList(new TList),
|
31 |
|
|
fOutput(0),
|
32 |
|
|
fPackages(new TList),
|
33 |
|
|
fLoaders(new TList),
|
34 |
|
|
fSuperMod(0),
|
35 |
|
|
fSelector(0),
|
36 |
|
|
fChain(0),
|
37 |
|
|
fSet(0),
|
38 |
|
|
fDeleteList(new TList),
|
39 |
|
|
fTreeName(Names::gkMitTreeName),
|
40 |
|
|
fCompLevel(2),
|
41 |
|
|
fProof(0)
|
42 |
|
|
{
|
43 |
|
|
// Default constructor.
|
44 |
|
|
|
45 |
|
|
fList->SetOwner();
|
46 |
|
|
fDeleteList->SetOwner();
|
47 |
|
|
|
48 |
|
|
/* default packages for PROOF upload */
|
49 |
|
|
fPackages->SetOwner();
|
50 |
|
|
// nothing to be done since we do not use par files (yet?)
|
51 |
loizides |
1.1 |
}
|
52 |
|
|
|
53 |
|
|
//__________________________________________________________________________________________________
|
54 |
|
|
Analysis::~Analysis()
|
55 |
|
|
{
|
56 |
loizides |
1.4 |
// Destructor.
|
57 |
loizides |
1.1 |
|
58 |
loizides |
1.4 |
if (fState == kInit || fState == kRun)
|
59 |
|
|
Terminate();
|
60 |
loizides |
1.1 |
|
61 |
loizides |
1.4 |
delete fList;
|
62 |
|
|
delete fDeleteList;
|
63 |
|
|
delete fLoaders;
|
64 |
|
|
delete fSelector;
|
65 |
|
|
delete fPackages;
|
66 |
|
|
fOutput = 0; // owned by TAM
|
67 |
|
|
fSuperMod = 0; // owned by user
|
68 |
loizides |
1.1 |
|
69 |
loizides |
1.4 |
delete fProof;
|
70 |
loizides |
1.1 |
}
|
71 |
|
|
|
72 |
|
|
//__________________________________________________________________________________________________
|
73 |
|
|
Bool_t Analysis::AddFile(const char *pname)
|
74 |
|
|
{
|
75 |
loizides |
1.4 |
// Add file with given name to the list of files to be processed.
|
76 |
|
|
// Using the token "|", you can specify an arbritray number
|
77 |
|
|
// of paths to tree files that will be concatenated as friend
|
78 |
|
|
// trees.
|
79 |
|
|
|
80 |
|
|
if (fState != kPristine) {
|
81 |
|
|
Error("AddFile", "Analysis already initialized");
|
82 |
|
|
return kFALSE;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
TString pnamestr(pname);
|
86 |
|
|
TString tok("|");
|
87 |
|
|
TObjArray *arr = pnamestr.Tokenize(tok);
|
88 |
|
|
TString msg;
|
89 |
loizides |
1.1 |
|
90 |
loizides |
1.4 |
for(Int_t i=0; i<arr->GetEntries(); i++){
|
91 |
loizides |
1.1 |
|
92 |
loizides |
1.4 |
TObjString *dummy = dynamic_cast<TObjString*>(arr->At(i));
|
93 |
|
|
if(!dummy) continue;
|
94 |
loizides |
1.1 |
|
95 |
loizides |
1.4 |
AddFile(dummy->GetName(),i);
|
96 |
|
|
if(i==0) msg=dummy->GetName();
|
97 |
|
|
else {
|
98 |
|
|
Info("AddFile", "Add file %s as friend to %s",
|
99 |
|
|
dummy->GetName(), msg.Data());
|
100 |
|
|
}
|
101 |
|
|
}
|
102 |
|
|
delete arr;
|
103 |
loizides |
1.1 |
|
104 |
loizides |
1.4 |
return kTRUE;
|
105 |
loizides |
1.1 |
}
|
106 |
|
|
|
107 |
|
|
//________________________________________________________________________
|
108 |
|
|
void Analysis::AddFile(const char *pname, Int_t eventlist)
|
109 |
|
|
{
|
110 |
loizides |
1.4 |
// Add file name to the event list specified by eventlist. The lists
|
111 |
|
|
// are used to hold filenames of different types of events. In case
|
112 |
|
|
// you dont want friend trees, just give no eventlist argument (default 0).
|
113 |
loizides |
1.1 |
|
114 |
loizides |
1.4 |
MitAssert("AddFile", pname != 0);
|
115 |
loizides |
1.1 |
|
116 |
loizides |
1.4 |
TList *l = 0;
|
117 |
|
|
if (eventlist >= 0 && eventlist < fNFriends) {
|
118 |
loizides |
1.1 |
|
119 |
loizides |
1.4 |
l = dynamic_cast<TList*>(fList->At(eventlist));
|
120 |
|
|
if (!l) {
|
121 |
|
|
Fatal("AddFile", "Requested list %d not found!", eventlist);
|
122 |
|
|
return;
|
123 |
|
|
}
|
124 |
loizides |
1.1 |
|
125 |
loizides |
1.4 |
} else if (eventlist == fNFriends) {
|
126 |
loizides |
1.1 |
|
127 |
loizides |
1.4 |
l = new TList;
|
128 |
|
|
l->SetOwner();
|
129 |
|
|
fList->Add(l);
|
130 |
|
|
fNFriends++;
|
131 |
|
|
|
132 |
|
|
} else if (eventlist < 0 || eventlist > fNFriends) {
|
133 |
|
|
Error("AddFile", "Specified list %d not in [0,%d]", eventlist, fNFriends);
|
134 |
|
|
return;
|
135 |
|
|
}
|
136 |
loizides |
1.1 |
|
137 |
loizides |
1.4 |
if(!IsValidName(pname)) return;
|
138 |
loizides |
1.1 |
|
139 |
loizides |
1.4 |
l->Add(new TObjString(pname));
|
140 |
loizides |
1.1 |
|
141 |
loizides |
1.4 |
MDB(kAnalysis, 2)
|
142 |
|
|
Info("AddFile", "Added %s to list of files.", pname);
|
143 |
loizides |
1.1 |
}
|
144 |
|
|
|
145 |
|
|
//__________________________________________________________________________________________________
|
146 |
|
|
void Analysis::AddFile(const TObject *oname, Int_t eventlist)
|
147 |
|
|
{
|
148 |
loizides |
1.4 |
// Add file name to the event list specified by eventlist. The lists
|
149 |
|
|
// are used to hold filenames of different types of events. In case
|
150 |
|
|
// you dont want mixing, just give no eventlist argument (default 0).
|
151 |
loizides |
1.1 |
|
152 |
loizides |
1.4 |
MitAssert("AddFile", oname != 0);
|
153 |
loizides |
1.1 |
|
154 |
loizides |
1.4 |
return AddFile(oname->GetName(), eventlist);
|
155 |
loizides |
1.1 |
}
|
156 |
|
|
|
157 |
|
|
//__________________________________________________________________________________________________
|
158 |
|
|
void Analysis::AddList(TList *list, Int_t eventlist)
|
159 |
|
|
{
|
160 |
loizides |
1.4 |
// Add file name to the event list specified by eventlist. The lists
|
161 |
|
|
// are used to hold filenames of different types of events. In case
|
162 |
|
|
// you dont want mixing, just give no eventlist argument (default 0).
|
163 |
|
|
|
164 |
|
|
MitAssert("AddList", list != 0);
|
165 |
|
|
|
166 |
|
|
TIter next(list);
|
167 |
|
|
while (TObject *obj = next())
|
168 |
|
|
AddFile(obj->GetName(), eventlist);
|
169 |
loizides |
1.1 |
}
|
170 |
|
|
|
171 |
|
|
//__________________________________________________________________________________________________
|
172 |
|
|
void Analysis::AddLoader(TAMVirtualLoader *l)
|
173 |
|
|
{
|
174 |
loizides |
1.4 |
// Add loader to the list of loaders.
|
175 |
loizides |
1.1 |
|
176 |
loizides |
1.4 |
fLoaders->Add(l);
|
177 |
loizides |
1.1 |
}
|
178 |
|
|
|
179 |
|
|
//__________________________________________________________________________________________________
|
180 |
|
|
void Analysis::AddPackage(const char* name)
|
181 |
|
|
{
|
182 |
loizides |
1.4 |
// Add package to the list of uploaded packages.
|
183 |
loizides |
1.1 |
|
184 |
loizides |
1.4 |
MitAssert("AddPackage", name != 0);
|
185 |
|
|
fPackages->Add(new TObjString(name));
|
186 |
loizides |
1.1 |
}
|
187 |
|
|
|
188 |
|
|
//__________________________________________________________________________________________________
|
189 |
|
|
void Analysis::AddPackages(TList *list)
|
190 |
|
|
{
|
191 |
loizides |
1.4 |
// Add list of packages to the list of uploaded packages.
|
192 |
loizides |
1.1 |
|
193 |
loizides |
1.4 |
MitAssert("AddPackage", list != 0);
|
194 |
loizides |
1.1 |
|
195 |
loizides |
1.4 |
TIter next(list);
|
196 |
|
|
while (TObject *obj = next()) {
|
197 |
|
|
fPackages->Add(new TObjString(obj->GetName()));
|
198 |
|
|
}
|
199 |
loizides |
1.1 |
}
|
200 |
|
|
|
201 |
|
|
//__________________________________________________________________________________________________
|
202 |
|
|
Bool_t Analysis::Init()
|
203 |
|
|
{
|
204 |
loizides |
1.4 |
// Setup the TDSet and TChain to be used for the analysis
|
205 |
|
|
// with or without PROOF. If more than one list of
|
206 |
|
|
// file names was given, friend trees are supported.
|
207 |
|
|
|
208 |
|
|
if (fState == kRun || fState == kInit) {
|
209 |
|
|
Error("Init", "Init in state %d is not possible! Call Terminate() first.",
|
210 |
|
|
Int_t(fState));
|
211 |
|
|
return kFALSE;
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
if (fNFriends <= 0) {
|
215 |
|
|
Error("Init", "List of friend lists is empty!");
|
216 |
|
|
return kFALSE;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
if (!fSuperMod) {
|
220 |
|
|
Error("Init", "Top-level TAM module is NULL!");
|
221 |
|
|
return kFALSE;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
if (fUseProof) { // first init our PROOF session
|
225 |
|
|
if (!InitProof()) return kFALSE;
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
// we do this here instead in Terminate() so that
|
229 |
|
|
// we can browse the output even after Terminate()
|
230 |
|
|
delete fSelector;
|
231 |
|
|
fSelector = 0;
|
232 |
|
|
|
233 |
|
|
fChain = new TChain(fTreeName);
|
234 |
|
|
fSet = new TDSet("TTree",fTreeName);
|
235 |
|
|
|
236 |
|
|
for(Int_t i=0; i<fNFriends; i++){
|
237 |
|
|
|
238 |
|
|
TList *l = dynamic_cast<TList*>(fList->At(i));
|
239 |
|
|
if (!l) {
|
240 |
|
|
Fatal("Init", "List %d not found!", i);
|
241 |
loizides |
1.1 |
return kFALSE;
|
242 |
loizides |
1.4 |
}
|
243 |
|
|
|
244 |
|
|
if (i == 0) {
|
245 |
|
|
TIter next(l);
|
246 |
|
|
while ( TObjString *obj = dynamic_cast<TObjString*>(next()) ) {
|
247 |
|
|
fChain->Add(obj->GetName());
|
248 |
|
|
fSet->Add(obj->GetName());
|
249 |
|
|
}
|
250 |
loizides |
1.1 |
|
251 |
loizides |
1.4 |
} else {
|
252 |
loizides |
1.1 |
|
253 |
loizides |
1.4 |
TChain *chain = new TChain(fTreeName);
|
254 |
|
|
TDSet *set = new TDSet("TTree",fTreeName);
|
255 |
loizides |
1.1 |
|
256 |
loizides |
1.4 |
TIter next(l);
|
257 |
|
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
|
258 |
|
|
chain->Add(obj->GetName());
|
259 |
|
|
set->Add(obj->GetName());
|
260 |
loizides |
1.1 |
}
|
261 |
|
|
|
262 |
loizides |
1.4 |
TString alias("TAMTREE_"); // aliases currently not used
|
263 |
|
|
alias+=i;
|
264 |
loizides |
1.1 |
|
265 |
loizides |
1.4 |
fChain->AddFriend(chain,alias.Data());
|
266 |
|
|
fSet->AddFriend(set,alias.Data());
|
267 |
loizides |
1.1 |
|
268 |
loizides |
1.4 |
fDeleteList->Add(chain);
|
269 |
|
|
fDeleteList->Add(set);
|
270 |
|
|
}
|
271 |
loizides |
1.1 |
|
272 |
loizides |
1.4 |
}
|
273 |
loizides |
1.1 |
|
274 |
loizides |
1.4 |
// if we had our default TAM plugin we would create it here
|
275 |
|
|
// TreeLoader *bl = new TreeLoader;
|
276 |
|
|
// fLoaders->Add(bl);
|
277 |
|
|
// fDeleteList->Add(bl);
|
278 |
loizides |
1.1 |
|
279 |
loizides |
1.4 |
if (fUseProof) {
|
280 |
loizides |
1.1 |
|
281 |
loizides |
1.4 |
fProof->AddInput(fSuperMod);
|
282 |
|
|
fLoaders->SetName("TAM_LOADERS");
|
283 |
|
|
fProof->AddInput(fLoaders);
|
284 |
loizides |
1.1 |
|
285 |
loizides |
1.4 |
} else {
|
286 |
loizides |
1.1 |
|
287 |
loizides |
1.4 |
// when not running Proof, we must make a selector
|
288 |
|
|
fSelector = new TAMSelector;
|
289 |
|
|
fSelector->AddInput(fSuperMod);
|
290 |
|
|
MDB(kAnalysis, 2)
|
291 |
|
|
fSelector->SetVerbosity(1);
|
292 |
loizides |
1.1 |
|
293 |
loizides |
1.4 |
// pass loaders to selector
|
294 |
|
|
TIter next(fLoaders);
|
295 |
|
|
while ( TAMVirtualLoader *l = dynamic_cast<TAMVirtualLoader*>(next()) )
|
296 |
|
|
fSelector->AddLoader(l);
|
297 |
|
|
}
|
298 |
loizides |
1.1 |
|
299 |
loizides |
1.4 |
fState = kInit;
|
300 |
|
|
return kTRUE;
|
301 |
loizides |
1.1 |
}
|
302 |
|
|
|
303 |
|
|
//__________________________________________________________________________________________________
|
304 |
|
|
Bool_t Analysis::InitProof()
|
305 |
|
|
{
|
306 |
loizides |
1.4 |
// Initialize PROOF connection.
|
307 |
loizides |
1.1 |
|
308 |
loizides |
1.4 |
if(fProof && fProof->IsValid())
|
309 |
|
|
return kTRUE;
|
310 |
loizides |
1.1 |
|
311 |
loizides |
1.4 |
delete fProof;
|
312 |
loizides |
1.1 |
|
313 |
loizides |
1.4 |
if (fMaster.Contains("rcf.bnl.gov")) {
|
314 |
|
|
for(Int_t i=0;i<5;i++) {
|
315 |
|
|
Warning("InitProof", "*** DID YOU RUN PROOF_KINIT? %d (5) ***", i);
|
316 |
|
|
gSystem->Sleep(1000);
|
317 |
|
|
}
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
MDB(kAnalysis, 1)
|
321 |
|
|
Info("InitProof", "Starting PROOF on master %s with config %s",
|
322 |
|
|
fMaster.Data(), fConfig.Data());
|
323 |
|
|
|
324 |
|
|
fProof = dynamic_cast<TProof*>(TProof::Open(fMaster, fConfig));
|
325 |
|
|
if (!fProof) {
|
326 |
|
|
Error("InitProof", "Could not start PROOF!");
|
327 |
|
|
return kFALSE;
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
MDB(kAnalysis, 3)
|
331 |
|
|
gROOT->Print();
|
332 |
|
|
|
333 |
|
|
//fProof->AddInput(new TNamed("PROOF_NewPacketizer",""));
|
334 |
|
|
|
335 |
|
|
Bool_t ret=kTRUE;
|
336 |
|
|
if (fPackages) {
|
337 |
|
|
// tell Proof what additional libraries we will need on each worker computer
|
338 |
|
|
ret = UploadPackages(fPackages);
|
339 |
|
|
}
|
340 |
loizides |
1.1 |
|
341 |
loizides |
1.4 |
return ret;
|
342 |
loizides |
1.1 |
}
|
343 |
|
|
|
344 |
|
|
//__________________________________________________________________________________________________
|
345 |
|
|
void Analysis::Run()
|
346 |
|
|
{
|
347 |
loizides |
1.4 |
// Run the analysis on the created file set.
|
348 |
loizides |
1.1 |
|
349 |
loizides |
1.4 |
if (fState == kPristine || fState == kRun) {
|
350 |
|
|
Error("Run", "Run in state %d is not possible! Call Init() first.",
|
351 |
|
|
Int_t(fState));
|
352 |
|
|
}
|
353 |
loizides |
1.1 |
|
354 |
loizides |
1.4 |
if (fUseProof) {
|
355 |
loizides |
1.1 |
|
356 |
loizides |
1.4 |
MDB(kAnalysis, 1)
|
357 |
|
|
Info("Run", "Start processing with PROOF...");
|
358 |
loizides |
1.1 |
|
359 |
loizides |
1.4 |
fSet->Process("TAMSelector");
|
360 |
loizides |
1.1 |
|
361 |
loizides |
1.4 |
} else {
|
362 |
loizides |
1.1 |
|
363 |
loizides |
1.4 |
MDB(kAnalysis, 1)
|
364 |
|
|
Info("Run", "Start processing (no PROOF)...");
|
365 |
loizides |
1.1 |
|
366 |
loizides |
1.4 |
fChain->Process(fSelector);
|
367 |
|
|
}
|
368 |
loizides |
1.1 |
|
369 |
loizides |
1.4 |
MDB(kAnalysis, 1)
|
370 |
|
|
Info("Run", "Processing complete!");
|
371 |
loizides |
1.1 |
|
372 |
loizides |
1.4 |
fState = kRun;
|
373 |
loizides |
1.1 |
}
|
374 |
|
|
|
375 |
|
|
//__________________________________________________________________________________________________
|
376 |
loizides |
1.4 |
Bool_t Analysis::Run(Bool_t browse)
|
377 |
loizides |
1.1 |
{
|
378 |
loizides |
1.4 |
// Execute analysis and open TBrowser if requested.
|
379 |
loizides |
1.1 |
|
380 |
loizides |
1.4 |
if (Init()) {
|
381 |
|
|
Run();
|
382 |
|
|
Terminate();
|
383 |
|
|
if(browse) {
|
384 |
|
|
new TBrowser;
|
385 |
|
|
}
|
386 |
|
|
return kTRUE;
|
387 |
|
|
}
|
388 |
loizides |
1.1 |
|
389 |
loizides |
1.4 |
Error("Execute", "Could not initialize analysis.");
|
390 |
|
|
return kFALSE;
|
391 |
|
|
}
|
392 |
loizides |
1.1 |
|
393 |
loizides |
1.4 |
//__________________________________________________________________________________________________
|
394 |
|
|
void Analysis::Terminate()
|
395 |
|
|
{
|
396 |
|
|
// Terminate current analysis run.
|
397 |
loizides |
1.1 |
|
398 |
loizides |
1.4 |
if (fState == kPristine || fState == kTerminate) {
|
399 |
|
|
Error("Terminate", "Terminate in state %d is not possible! Call Init() first.",
|
400 |
|
|
Int_t(fState));
|
401 |
|
|
return;
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
if (fState == kRun) {
|
405 |
|
|
|
406 |
|
|
if (fUseProof) {
|
407 |
|
|
// the output list from Proof can (in principal) contain other objects
|
408 |
|
|
// besides the module output hierarchy.
|
409 |
|
|
TList* outputlist = fProof->GetOutputList();
|
410 |
|
|
TIter nextOut(outputlist);
|
411 |
|
|
while (TObject *obj = nextOut()) {
|
412 |
|
|
if (obj->InheritsFrom(TAMOutput::Class())) {
|
413 |
|
|
fOutput = dynamic_cast<TList*>(obj);
|
414 |
|
|
break;
|
415 |
|
|
}
|
416 |
|
|
}
|
417 |
|
|
|
418 |
|
|
} else {
|
419 |
|
|
fOutput = fSelector->GetModOutput();
|
420 |
|
|
}
|
421 |
|
|
|
422 |
|
|
if (fOutput && !fAnaOutput.IsNull()) {
|
423 |
|
|
TDirectory::TContext context(0); // automatically restore gDirectory
|
424 |
|
|
|
425 |
|
|
std::auto_ptr<TFile> outf(TFile::Open(fAnaOutput,"recreate","", fCompLevel));
|
426 |
|
|
if (outf.get() == 0) {
|
427 |
|
|
Error("Terminate", "Could not open file %s for output!", fAnaOutput.Data());
|
428 |
loizides |
1.1 |
} else {
|
429 |
loizides |
1.4 |
MDB(kAnalysis, 1)
|
430 |
|
|
Info("Terminate", "Saving output to %s!", fAnaOutput.Data());
|
431 |
loizides |
1.1 |
|
432 |
loizides |
1.4 |
if (fHierachy)
|
433 |
|
|
fOutput->Write(fOutput->GetName(),TObject::kSingleKey);
|
434 |
|
|
else
|
435 |
|
|
fOutput->Write();
|
436 |
loizides |
1.1 |
|
437 |
|
|
}
|
438 |
loizides |
1.4 |
}
|
439 |
|
|
}
|
440 |
loizides |
1.1 |
|
441 |
loizides |
1.4 |
delete fChain;
|
442 |
|
|
delete fSet;
|
443 |
|
|
fDeleteList->Delete();
|
444 |
loizides |
1.1 |
|
445 |
loizides |
1.4 |
fState = kTerminate;
|
446 |
loizides |
1.1 |
}
|
447 |
|
|
|
448 |
|
|
//__________________________________________________________________________________________________
|
449 |
|
|
Bool_t Analysis::UploadPackages(TList *packages)
|
450 |
|
|
{
|
451 |
loizides |
1.4 |
// Upload list of par files to the server.
|
452 |
loizides |
1.1 |
|
453 |
loizides |
1.4 |
MitAssert("UploadPackages", packages != 0);
|
454 |
loizides |
1.1 |
|
455 |
loizides |
1.4 |
for(Int_t i=0; i < packages->GetEntries(); i++) {
|
456 |
loizides |
1.1 |
|
457 |
loizides |
1.4 |
TObject* objstr = packages->At(i);
|
458 |
|
|
if (!objstr){
|
459 |
|
|
Error("InitProof", "Problem at package number %d!", i);
|
460 |
|
|
return kFALSE;
|
461 |
|
|
}
|
462 |
loizides |
1.1 |
|
463 |
loizides |
1.4 |
TString packname = objstr->GetName();
|
464 |
|
|
Int_t en = 0;
|
465 |
|
|
if (packname.EndsWith("+")) {
|
466 |
|
|
en=1;
|
467 |
|
|
packname.Resize(packname.Length()-1);
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
ifstream ftest(gSystem->ExpandPathName(packname.Data()),ios_base::binary);
|
471 |
|
|
if (!ftest.good()){
|
472 |
|
|
Error("InitProof", "Could not open %s for upload!", packname.Data());
|
473 |
|
|
return kFALSE;
|
474 |
|
|
}
|
475 |
loizides |
1.1 |
|
476 |
loizides |
1.4 |
if(fProof->UploadPackage(packname)<0) {
|
477 |
|
|
Error("UploadPackage", "Upload for %s failed!", packname.Data());
|
478 |
|
|
return kFALSE;
|
479 |
|
|
}
|
480 |
loizides |
1.1 |
|
481 |
loizides |
1.4 |
if (en == 1) {
|
482 |
|
|
Int_t pos=packname.Last('/')+1;
|
483 |
|
|
if (pos) packname.Remove(0,pos);
|
484 |
|
|
if(fProof->EnablePackage(packname)<0) {
|
485 |
|
|
Error("UploadPackage", "Enabling for %s failed!", packname.Data());
|
486 |
|
|
return kFALSE;
|
487 |
loizides |
1.1 |
}
|
488 |
loizides |
1.4 |
}
|
489 |
|
|
}
|
490 |
loizides |
1.1 |
|
491 |
loizides |
1.4 |
return kTRUE;
|
492 |
loizides |
1.1 |
}
|