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