1 |
|
// $Id$ |
2 |
|
|
3 |
|
#include "MitAna/TreeMod/interface/Analysis.h" |
4 |
+ |
#include <memory> |
5 |
|
#include <Riostream.h> |
6 |
|
#include <TFile.h> |
7 |
|
#include <TList.h> |
12 |
|
#include <TProof.h> |
13 |
|
#include <TROOT.h> |
14 |
|
#include <TBrowser.h> |
15 |
+ |
#include <TTreeCacheUnzip.h> |
16 |
|
#include "MitAna/DataUtil/interface/Debug.h" |
17 |
|
#include "MitAna/DataTree/interface/Names.h" |
18 |
|
#include "MitAna/TAM/interface/TAMVirtualLoader.h" |
33 |
|
fUseProof(useproof), |
34 |
|
fUseHLT(kTRUE), |
35 |
|
fHierarchy(kTRUE), |
36 |
< |
fDoProxy(kTRUE), |
36 |
> |
fDoProxy(kFALSE), |
37 |
> |
fDoObjTabClean(kTRUE), |
38 |
> |
fParallel(kFALSE), |
39 |
|
fState(kPristine), |
40 |
|
fNFriends(0), |
41 |
|
fList(new TList), |
47 |
|
fChain(0), |
48 |
|
fSet(0), |
49 |
|
fDeleteList(new TList), |
50 |
< |
fTreeName(Names::gkEvtTreeName), |
47 |
< |
fCompLevel(2), |
50 |
> |
fCompLevel(7), |
51 |
|
fProof(0), |
52 |
< |
fDoNEvents(TChain::kBigNumber) |
52 |
> |
fDoNEvents(TChain::kBigNumber), |
53 |
> |
fSkipNEvents(0), |
54 |
> |
fPrintScale(1), |
55 |
> |
fCacheSize(-1), |
56 |
> |
fTreeName(Names::gkEvtTreeName), |
57 |
> |
fEvtHdrName(Names::gkEvtHeaderBrn), |
58 |
> |
fRunTreeName(Names::gkRunTreeName), |
59 |
> |
fRunInfoName(Names::gkRunInfoBrn), |
60 |
> |
fAllEvtHdrBrn(Names::gkAllEvtHeaderBrn), |
61 |
> |
fLATreeName(Names::gkLATreeName), |
62 |
> |
fLAHdrName(Names::gkLAHeaderBrn), |
63 |
> |
fHLTTreeName(Names::gkHltTreeName), |
64 |
> |
fAllEvtTreeName(Names::gkAllEvtTreeName), |
65 |
> |
fHLTObjsName(Names::gkHltObjBrn) |
66 |
|
{ |
67 |
|
// Default constructor. |
68 |
|
|
88 |
|
delete fDeleteList; |
89 |
|
delete fSelector; |
90 |
|
delete fSuperMods; |
91 |
< |
fOutput = 0; // owned by TAM |
91 |
> |
fOutput = 0; // owned by TAM |
92 |
|
|
93 |
|
delete fProof; |
94 |
|
} |
176 |
|
|
177 |
|
if (!IsValidName(pname)) return; |
178 |
|
|
179 |
< |
l->Add(new TObjString(pname)); |
179 |
> |
TString theFile(pname); |
180 |
> |
if ( theFile.BeginsWith("castor:") ) |
181 |
> |
theFile.ReplaceAll("castor:","root://castorcms/"); |
182 |
> |
if ( theFile.BeginsWith("/castor/")) |
183 |
> |
theFile.Prepend("root://castorcms/"); |
184 |
> |
printf("Adding file with path: %s\n",theFile.Data()); |
185 |
> |
l->Add(new TObjString(theFile)); |
186 |
|
|
187 |
|
MDB(kAnalysis, 2) |
188 |
|
Info("AddFile", "Added %s to list of files.", pname); |
210 |
|
ifstream in; |
211 |
|
in.open(pname); |
212 |
|
if (!in) { |
213 |
< |
Error("AddFiles", "Can not open file with name %s", pname); |
213 |
> |
Error("AddFiles", "Cannot open file with name %s", pname); |
214 |
|
return kFALSE; |
215 |
|
} |
216 |
|
|
218 |
|
while (in) { |
219 |
|
TString line; |
220 |
|
line.ReadLine(in); |
199 |
– |
cout << line << endl; |
221 |
|
if (!line.EndsWith(".root")) |
222 |
|
continue; |
202 |
– |
cout << line << endl; |
223 |
|
|
224 |
|
if (!AddFile(line)) { |
225 |
|
Error("AddFiles", "Error adding file with name %s", line.Data()); |
307 |
|
return; |
308 |
|
} |
309 |
|
|
290 |
– |
|
310 |
|
if (!files.IsNull()) { // add local files |
311 |
|
Info("FileInputFromEnv", "Got from environment:\n" |
312 |
|
"\n\tMIT_FILES=%s\n", files.Data()); |
328 |
|
catalog.Data(), book.Data(), dataset.Data(), filesets.Data()); |
329 |
|
|
330 |
|
Catalog cat(catalog); |
331 |
< |
TString tok(";"); |
332 |
< |
TObjArray *arr = filesets.Tokenize(tok); |
333 |
< |
if (arr) { |
315 |
< |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
316 |
< |
TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i)); |
317 |
< |
if (!fileset) continue; |
318 |
< |
Dataset *d = cat.FindDataset(book, dataset, fileset->String()); |
319 |
< |
if (!d) |
320 |
< |
continue; |
331 |
> |
if (filesets.IsNull()) { |
332 |
> |
Dataset *d = cat.FindDataset(book, dataset); |
333 |
> |
if (d) { |
334 |
|
AddDataset(d); |
335 |
|
delete d; |
336 |
|
} |
337 |
< |
delete arr; |
337 |
> |
} else { |
338 |
> |
TString tok(";"); |
339 |
> |
TObjArray *arr = filesets.Tokenize(tok); |
340 |
> |
if (arr) { |
341 |
> |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
342 |
> |
TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i)); |
343 |
> |
if (!fileset) continue; |
344 |
> |
Dataset *d = cat.FindDataset(book, dataset, fileset->String()); |
345 |
> |
if (!d) |
346 |
> |
continue; |
347 |
> |
AddDataset(d); |
348 |
> |
delete d; |
349 |
> |
} |
350 |
> |
delete arr; |
351 |
> |
} |
352 |
|
} |
353 |
|
} |
354 |
|
|
392 |
|
fSet = new TDSet("TTree",fTreeName); |
393 |
|
|
394 |
|
for (Int_t i=0; i<fNFriends; ++i) { |
368 |
– |
|
395 |
|
TList *l = dynamic_cast<TList*>(fList->At(i)); |
396 |
|
if (!l) { |
397 |
|
Fatal("Init", "List %d not found!", i); |
403 |
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
404 |
|
fChain->Add(obj->GetName()); |
405 |
|
fSet->Add(obj->GetName()); |
406 |
+ |
if (fCacheSize<0 && obj->GetString().Contains("/castor/")) |
407 |
+ |
fCacheSize = 64*1024*1024; |
408 |
|
} |
381 |
– |
|
409 |
|
} else { |
383 |
– |
|
410 |
|
TChain *chain = new TChain(fTreeName); |
411 |
|
TDSet *set = new TDSet("TTree",fTreeName); |
412 |
|
|
414 |
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
415 |
|
chain->Add(obj->GetName()); |
416 |
|
set->Add(obj->GetName()); |
417 |
+ |
if (fCacheSize<0 && obj->GetString().Contains("/castor/")) |
418 |
+ |
fCacheSize = 64*1024*1024; |
419 |
|
} |
420 |
|
|
421 |
|
TString alias("TAMTREE_"); // aliases currently not used |
427 |
|
fDeleteList->Add(chain); |
428 |
|
fDeleteList->Add(set); |
429 |
|
} |
402 |
– |
|
430 |
|
} |
431 |
|
|
432 |
+ |
if (fParallel) |
433 |
+ |
TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable); |
434 |
+ |
|
435 |
+ |
if (fCacheSize>=0) |
436 |
+ |
fChain->SetCacheSize(fCacheSize); |
437 |
+ |
|
438 |
|
// create our customized loader plugin for TAM |
439 |
|
TreeLoader *bl = new TreeLoader; |
440 |
|
fLoaders->Add(bl); |
442 |
|
|
443 |
|
// create our ana framework module |
444 |
|
AnaFwkMod *anamod = new AnaFwkMod; |
445 |
+ |
anamod->SetSkipNEvents(fSkipNEvents); |
446 |
+ |
anamod->SetPrintScale(fPrintScale); |
447 |
|
fDeleteList->Add(anamod); |
448 |
|
|
449 |
|
// create our HLT framework module |
450 |
|
HLTFwkMod *hltmod = 0; |
451 |
|
if (fUseHLT) { |
452 |
|
hltmod = new HLTFwkMod; |
453 |
+ |
hltmod->SetHLTObjsName(GetHLTObjsName()); |
454 |
+ |
hltmod->SetHLTTreeName(GetHLTTreeName()); |
455 |
|
fDeleteList->Add(hltmod); |
456 |
|
} |
457 |
|
|
474 |
|
} else { |
475 |
|
|
476 |
|
// when not running Proof, we must make a selector |
477 |
< |
fSelector = new Selector; |
478 |
< |
fSelector->SetDoProxy(fDoProxy); |
479 |
< |
|
480 |
< |
fSelector->AddInput(anamod); |
477 |
> |
Selector *sel = new Selector; |
478 |
> |
sel->SetDoProxy(fDoProxy); |
479 |
> |
sel->SetDoObjTabClean(fDoObjTabClean); |
480 |
> |
sel->SetDoRunInfo(kTRUE); |
481 |
> |
sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn()); |
482 |
> |
sel->SetAllEvtTreeName(GetAllEvtTreeName()); |
483 |
> |
sel->SetEvtHdrName(GetEvtHdrName()); |
484 |
> |
sel->SetLAHdrName(GetLAHdrName()); |
485 |
> |
sel->SetLATreeName(GetLATreeName()); |
486 |
> |
sel->SetRunInfoName(GetRunInfoName()); |
487 |
> |
sel->SetRunTreeName(GetRunTreeName()); |
488 |
> |
sel->AddInput(anamod); |
489 |
> |
fSelector = sel; |
490 |
|
|
491 |
|
if (hltmod) |
492 |
|
fSelector->AddInput(hltmod); |