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