19 |
|
#include "MitAna/TreeMod/interface/TreeLoader.h" |
20 |
|
#include "MitAna/TreeMod/interface/AnaFwkMod.h" |
21 |
|
#include "MitAna/TreeMod/interface/HLTFwkMod.h" |
22 |
+ |
#include "MitAna/Catalog/interface/Catalog.h" |
23 |
|
#include "MitAna/Catalog/interface/Dataset.h" |
24 |
|
|
25 |
|
ClassImp(mithep::Analysis) |
31 |
|
fUseProof(useproof), |
32 |
|
fUseHLT(kTRUE), |
33 |
|
fHierarchy(kTRUE), |
34 |
< |
fDoProxy(kTRUE), |
34 |
> |
fDoProxy(kFALSE), |
35 |
> |
fDoObjTabClean(kTRUE), |
36 |
|
fState(kPristine), |
37 |
|
fNFriends(0), |
38 |
|
fList(new TList), |
45 |
|
fSet(0), |
46 |
|
fDeleteList(new TList), |
47 |
|
fTreeName(Names::gkEvtTreeName), |
48 |
< |
fCompLevel(2), |
48 |
> |
fCompLevel(7), |
49 |
|
fProof(0), |
50 |
< |
fDoNEvents(TChain::kBigNumber) |
50 |
> |
fDoNEvents(TChain::kBigNumber), |
51 |
> |
fSkipNEvents(0), |
52 |
> |
fCacheSize(-1) |
53 |
|
{ |
54 |
|
// Default constructor. |
55 |
|
|
81 |
|
} |
82 |
|
|
83 |
|
//-------------------------------------------------------------------------------------------------- |
84 |
+ |
Bool_t Analysis::AddDataset(const Dataset *dataset) |
85 |
+ |
{ |
86 |
+ |
// Add a full dataset to the analysis. |
87 |
+ |
|
88 |
+ |
Bool_t status = true; |
89 |
+ |
|
90 |
+ |
for (UInt_t i=0; i<dataset->NFiles(); ++i) |
91 |
+ |
status = (status && AddFile(dataset->FileUrl(i))); |
92 |
+ |
|
93 |
+ |
return status; |
94 |
+ |
} |
95 |
+ |
|
96 |
+ |
//-------------------------------------------------------------------------------------------------- |
97 |
|
Bool_t Analysis::AddFile(const char *pname) |
98 |
|
{ |
99 |
|
// Add file with given name to the list of files to be processed. Using the token "|", you can |
105 |
|
} |
106 |
|
|
107 |
|
TString pnamestr(pname); |
108 |
+ |
if (pnamestr.IsNull()) |
109 |
+ |
return kFALSE; |
110 |
+ |
|
111 |
|
TString tok("|"); |
112 |
|
TObjArray *arr = pnamestr.Tokenize(tok); |
113 |
< |
TString msg; |
113 |
> |
if (!arr) |
114 |
> |
return kFALSE; |
115 |
|
|
116 |
< |
for(Int_t i=0; i<arr->GetEntries(); i++){ |
117 |
< |
|
116 |
> |
TString msg; |
117 |
> |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
118 |
> |
|
119 |
|
TObjString *dummy = dynamic_cast<TObjString*>(arr->At(i)); |
120 |
< |
if (!dummy) continue; |
120 |
> |
if (!dummy) |
121 |
> |
continue; |
122 |
|
|
123 |
|
AddFile(dummy->GetName(),i); |
124 |
< |
if (i==0) msg=dummy->GetName(); |
125 |
< |
else { |
126 |
< |
Info("AddFile", "Add file %s as friend to %s", |
127 |
< |
dummy->GetName(), msg.Data()); |
105 |
< |
} |
124 |
> |
if (i==0) |
125 |
> |
msg=dummy->GetName(); |
126 |
> |
else |
127 |
> |
Info("AddFile", "Add file %s as friend to %s", dummy->GetName(), msg.Data()); |
128 |
|
} |
129 |
|
delete arr; |
130 |
|
|
154 |
|
l = new TList; |
155 |
|
l->SetOwner(); |
156 |
|
fList->Add(l); |
157 |
< |
fNFriends++; |
157 |
> |
++fNFriends; |
158 |
|
|
159 |
|
} else if (eventlist < 0 || eventlist > fNFriends) { |
160 |
|
Error("AddFile", "Specified list %d not in [0,%d]", eventlist, fNFriends); |
220 |
|
} |
221 |
|
|
222 |
|
//-------------------------------------------------------------------------------------------------- |
201 |
– |
Bool_t Analysis::AddDataset(const Dataset *dataset) |
202 |
– |
{ |
203 |
– |
// Add a full dataset to the analysis. |
204 |
– |
|
205 |
– |
Bool_t status = true; |
206 |
– |
|
207 |
– |
for (UInt_t i=0; i<dataset->NFiles(); i++) |
208 |
– |
status = (status && AddFile(dataset->FileUrl(i))); |
209 |
– |
|
210 |
– |
return status; |
211 |
– |
} |
212 |
– |
|
213 |
– |
//-------------------------------------------------------------------------------------------------- |
223 |
|
void Analysis::AddList(TList *list, Int_t eventlist) |
224 |
|
{ |
225 |
|
// Add file name to the event list specified by eventlist. The lists are used to hold filenames of |
272 |
|
} |
273 |
|
|
274 |
|
//-------------------------------------------------------------------------------------------------- |
275 |
+ |
void Analysis::FileInputFromEnv() |
276 |
+ |
{ |
277 |
+ |
// Attempt to get list of filesets/files from environment. |
278 |
+ |
|
279 |
+ |
TString catalog(gSystem->Getenv("MIT_CATALOG")); |
280 |
+ |
TString book(gSystem->Getenv("MIT_BOOK")); |
281 |
+ |
TString dataset(gSystem->Getenv("MIT_DATASET")); |
282 |
+ |
TString filesets(gSystem->Getenv("MIT_FILESETS")); |
283 |
+ |
TString files(gSystem->Getenv("MIT_FILES")); |
284 |
+ |
|
285 |
+ |
if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) { |
286 |
+ |
Warning("FileInputFromEnv", "Called to get file info from environment, but did not get" |
287 |
+ |
" consistent set of variables:\n\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\t" |
288 |
+ |
"MIT_DATASET=%s\n\tMIT_FILESETS=%s\n\tMIT_FILES=%s\n", |
289 |
+ |
catalog.Data(), book.Data(), dataset.Data(), filesets.Data(), files.Data()); |
290 |
+ |
return; |
291 |
+ |
} |
292 |
+ |
|
293 |
+ |
if (!files.IsNull()) { // add local files |
294 |
+ |
Info("FileInputFromEnv", "Got from environment:\n" |
295 |
+ |
"\n\tMIT_FILES=%s\n", files.Data()); |
296 |
+ |
TString tok(";"); |
297 |
+ |
TObjArray *arr = files.Tokenize(tok); |
298 |
+ |
if (arr) { |
299 |
+ |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
300 |
+ |
TObjString *dummy = dynamic_cast<TObjString*>(arr->At(i)); |
301 |
+ |
if (!dummy) continue; |
302 |
+ |
AddFile(dummy->GetName(),0); |
303 |
+ |
} |
304 |
+ |
delete arr; |
305 |
+ |
} |
306 |
+ |
return; |
307 |
+ |
} |
308 |
+ |
|
309 |
+ |
Info("FileInputFromEnv", "Got from environment:\n" |
310 |
+ |
"\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\tMIT_DATASET=%s\n\tMIT_FILESETS=%s\n", |
311 |
+ |
catalog.Data(), book.Data(), dataset.Data(), filesets.Data()); |
312 |
+ |
|
313 |
+ |
Catalog cat(catalog); |
314 |
+ |
if (filesets.IsNull()) { |
315 |
+ |
Dataset *d = cat.FindDataset(book, dataset); |
316 |
+ |
if (d) { |
317 |
+ |
AddDataset(d); |
318 |
+ |
delete d; |
319 |
+ |
} |
320 |
+ |
} else { |
321 |
+ |
TString tok(";"); |
322 |
+ |
TObjArray *arr = filesets.Tokenize(tok); |
323 |
+ |
if (arr) { |
324 |
+ |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
325 |
+ |
TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i)); |
326 |
+ |
if (!fileset) continue; |
327 |
+ |
Dataset *d = cat.FindDataset(book, dataset, fileset->String()); |
328 |
+ |
if (!d) |
329 |
+ |
continue; |
330 |
+ |
AddDataset(d); |
331 |
+ |
delete d; |
332 |
+ |
} |
333 |
+ |
delete arr; |
334 |
+ |
} |
335 |
+ |
} |
336 |
+ |
} |
337 |
+ |
|
338 |
+ |
//-------------------------------------------------------------------------------------------------- |
339 |
|
Bool_t Analysis::Init() |
340 |
|
{ |
341 |
|
// Setup the TDSet and TChain to be used for the analysis with or without PROOF. If more than one |
347 |
|
return kFALSE; |
348 |
|
} |
349 |
|
|
350 |
+ |
// check if we should attempt to get filesets/filenames from environment |
351 |
+ |
if (fNFriends == 0) |
352 |
+ |
FileInputFromEnv(); |
353 |
+ |
|
354 |
|
if (fNFriends <= 0) { |
355 |
|
Error("Init", "List of friend lists is empty!"); |
356 |
|
return kFALSE; |
362 |
|
} |
363 |
|
|
364 |
|
if (fUseProof) { // first init our PROOF session |
365 |
< |
if (!InitProof()) return kFALSE; |
365 |
> |
if (!InitProof()) |
366 |
> |
return kFALSE; |
367 |
|
} |
368 |
|
|
369 |
|
// we do this here instead in Terminate() so that |
374 |
|
fChain = new TChain(fTreeName); |
375 |
|
fSet = new TDSet("TTree",fTreeName); |
376 |
|
|
377 |
< |
for(Int_t i=0; i<fNFriends; i++){ |
300 |
< |
|
377 |
> |
for (Int_t i=0; i<fNFriends; ++i) { |
378 |
|
TList *l = dynamic_cast<TList*>(fList->At(i)); |
379 |
|
if (!l) { |
380 |
|
Fatal("Init", "List %d not found!", i); |
383 |
|
|
384 |
|
if (i == 0) { |
385 |
|
TIter next(l); |
386 |
< |
while ( TObjString *obj = dynamic_cast<TObjString*>(next()) ) { |
386 |
> |
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
387 |
|
fChain->Add(obj->GetName()); |
388 |
|
fSet->Add(obj->GetName()); |
389 |
+ |
if (fCacheSize<0 && obj->GetString().BeginsWith("/castor/cern.ch")) |
390 |
+ |
fCacheSize = 64*1024*1024; |
391 |
|
} |
313 |
– |
|
392 |
|
} else { |
315 |
– |
|
393 |
|
TChain *chain = new TChain(fTreeName); |
394 |
|
TDSet *set = new TDSet("TTree",fTreeName); |
395 |
|
|
397 |
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
398 |
|
chain->Add(obj->GetName()); |
399 |
|
set->Add(obj->GetName()); |
400 |
+ |
if (fCacheSize<0 && obj->GetString().BeginsWith("/castor/cern.ch")) |
401 |
+ |
fCacheSize = 64*1024*1024; |
402 |
|
} |
403 |
|
|
404 |
|
TString alias("TAMTREE_"); // aliases currently not used |
410 |
|
fDeleteList->Add(chain); |
411 |
|
fDeleteList->Add(set); |
412 |
|
} |
334 |
– |
|
413 |
|
} |
414 |
|
|
415 |
+ |
if (fCacheSize>=0) |
416 |
+ |
fChain->SetCacheSize(fCacheSize); |
417 |
+ |
|
418 |
|
// create our customized loader plugin for TAM |
419 |
|
TreeLoader *bl = new TreeLoader; |
420 |
|
fLoaders->Add(bl); |
422 |
|
|
423 |
|
// create our ana framework module |
424 |
|
AnaFwkMod *anamod = new AnaFwkMod; |
425 |
+ |
anamod->SetSkipNEvents(fSkipNEvents); |
426 |
|
fDeleteList->Add(anamod); |
427 |
|
|
428 |
|
// create our HLT framework module |
453 |
|
// when not running Proof, we must make a selector |
454 |
|
fSelector = new Selector; |
455 |
|
fSelector->SetDoProxy(fDoProxy); |
456 |
+ |
fSelector->SetDoObjTabClean(fDoObjTabClean); |
457 |
|
|
458 |
|
fSelector->AddInput(anamod); |
459 |
|
|
472 |
|
|
473 |
|
// pass loaders to selector |
474 |
|
TIter next(fLoaders); |
475 |
< |
while ( TAMVirtualLoader *l = dynamic_cast<TAMVirtualLoader*>(next()) ) |
475 |
> |
while (TAMVirtualLoader *l = dynamic_cast<TAMVirtualLoader*>(next())) |
476 |
|
fSelector->AddLoader(l); |
477 |
|
} |
478 |
|
|
491 |
|
delete fProof; |
492 |
|
|
493 |
|
if (fMaster.Contains("rcf.bnl.gov")) { |
494 |
< |
for(Int_t i=0;i<5;i++) { |
494 |
> |
for (Int_t i=0; i<5; ++i) { |
495 |
|
Warning("InitProof", "*** DID YOU RUN PROOF_KINIT? %d (5) ***", i); |
496 |
|
gSystem->Sleep(1000); |
497 |
|
} |
641 |
|
|
642 |
|
MitAssert("UploadPackages", packages != 0); |
643 |
|
|
644 |
< |
for (Int_t i=0; i<packages->GetEntries(); i++) { |
644 |
> |
for (Int_t i=0; i<packages->GetEntries(); ++i) { |
645 |
|
|
646 |
|
TObject* objstr = packages->At(i); |
647 |
|
if (!objstr) { |