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" |
35 |
|
fHierarchy(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), |
48 |
< |
fCompLevel(2), |
50 |
> |
fCompLevel(7), |
51 |
|
fProof(0), |
52 |
|
fDoNEvents(TChain::kBigNumber), |
53 |
< |
fCacheSize(134217728) |
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 |
|
} |
98 |
|
{ |
99 |
|
// Add a full dataset to the analysis. |
100 |
|
|
101 |
< |
Bool_t status = true; |
101 |
> |
Bool_t status = kTRUE; |
102 |
|
|
103 |
|
for (UInt_t i=0; i<dataset->NFiles(); ++i) |
104 |
|
status = (status && AddFile(dataset->FileUrl(i))); |
117 |
|
return kFALSE; |
118 |
|
} |
119 |
|
|
120 |
< |
TString pnamestr(pname); |
120 |
> |
//================================================================================================ |
121 |
> |
// Please do not ask me why I need to do this but I have to?! (CP - Oct02, 2010) |
122 |
> |
char fileName[4096]; |
123 |
> |
strcpy(fileName,pname); |
124 |
> |
//================================================================================================ |
125 |
> |
|
126 |
> |
TString pnamestr(fileName); |
127 |
> |
|
128 |
|
if (pnamestr.IsNull()) |
129 |
|
return kFALSE; |
130 |
|
|
181 |
|
return; |
182 |
|
} |
183 |
|
|
184 |
< |
if (!IsValidName(pname)) return; |
184 |
> |
if (! IsValidName(pname)) |
185 |
> |
return; |
186 |
|
|
187 |
< |
l->Add(new TObjString(pname)); |
187 |
> |
TString theFile(pname); |
188 |
> |
if ( theFile.BeginsWith("castor:") ) |
189 |
> |
theFile.ReplaceAll("castor:","root://castorcms/"); |
190 |
> |
if ( theFile.BeginsWith("/castor/")) |
191 |
> |
theFile.Prepend("root://castorcms/"); |
192 |
> |
printf("Adding file with path: %s\n",theFile.Data()); |
193 |
> |
l->Add(new TObjString(theFile.Data())); |
194 |
|
|
195 |
|
MDB(kAnalysis, 2) |
196 |
|
Info("AddFile", "Added %s to list of files.", pname); |
218 |
|
ifstream in; |
219 |
|
in.open(pname); |
220 |
|
if (!in) { |
221 |
< |
Error("AddFiles", "Can not open file with name %s", pname); |
221 |
> |
Error("AddFiles", "Cannot open file with name %s", pname); |
222 |
|
return kFALSE; |
223 |
|
} |
224 |
|
|
226 |
|
while (in) { |
227 |
|
TString line; |
228 |
|
line.ReadLine(in); |
201 |
– |
cout << line << endl; |
229 |
|
if (!line.EndsWith(".root")) |
230 |
|
continue; |
204 |
– |
cout << line << endl; |
231 |
|
|
232 |
|
if (!AddFile(line)) { |
233 |
|
Error("AddFiles", "Error adding file with name %s", line.Data()); |
301 |
|
{ |
302 |
|
// Attempt to get list of filesets/files from environment. |
303 |
|
|
304 |
< |
TString catalog(gSystem->Getenv("MIT_CATALOG")); |
305 |
< |
TString book(gSystem->Getenv("MIT_BOOK")); |
306 |
< |
TString dataset(gSystem->Getenv("MIT_DATASET")); |
304 |
> |
TString catalog (gSystem->Getenv("MIT_CATALOG")); |
305 |
> |
TString book (gSystem->Getenv("MIT_BOOK")); |
306 |
> |
TString dataset (gSystem->Getenv("MIT_DATASET")); |
307 |
|
TString filesets(gSystem->Getenv("MIT_FILESETS")); |
308 |
< |
TString files(gSystem->Getenv("MIT_FILES")); |
308 |
> |
TString files (gSystem->Getenv("MIT_FILES")); |
309 |
|
|
310 |
|
if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) { |
311 |
|
Warning("FileInputFromEnv", "Called to get file info from environment, but did not get" |
398 |
|
|
399 |
|
fChain = new TChain(fTreeName); |
400 |
|
fSet = new TDSet("TTree",fTreeName); |
375 |
– |
|
376 |
– |
fChain->SetCacheSize(fCacheSize); |
401 |
|
|
402 |
|
for (Int_t i=0; i<fNFriends; ++i) { |
379 |
– |
|
403 |
|
TList *l = dynamic_cast<TList*>(fList->At(i)); |
404 |
|
if (!l) { |
405 |
|
Fatal("Init", "List %d not found!", i); |
411 |
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
412 |
|
fChain->Add(obj->GetName()); |
413 |
|
fSet->Add(obj->GetName()); |
414 |
+ |
if (fCacheSize<0 && obj->GetString().Contains("/castor/")) |
415 |
+ |
fCacheSize = 64*1024*1024; |
416 |
|
} |
392 |
– |
|
417 |
|
} else { |
394 |
– |
|
418 |
|
TChain *chain = new TChain(fTreeName); |
419 |
|
TDSet *set = new TDSet("TTree",fTreeName); |
420 |
|
|
422 |
|
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
423 |
|
chain->Add(obj->GetName()); |
424 |
|
set->Add(obj->GetName()); |
425 |
+ |
if (fCacheSize<0 && obj->GetString().Contains("/castor/")) |
426 |
+ |
fCacheSize = 64*1024*1024; |
427 |
|
} |
428 |
|
|
429 |
|
TString alias("TAMTREE_"); // aliases currently not used |
435 |
|
fDeleteList->Add(chain); |
436 |
|
fDeleteList->Add(set); |
437 |
|
} |
413 |
– |
|
438 |
|
} |
439 |
|
|
440 |
+ |
if (fParallel) |
441 |
+ |
TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable); |
442 |
+ |
|
443 |
+ |
if (fCacheSize>=0) |
444 |
+ |
fChain->SetCacheSize(fCacheSize); |
445 |
+ |
|
446 |
|
// create our customized loader plugin for TAM |
447 |
|
TreeLoader *bl = new TreeLoader; |
448 |
|
fLoaders->Add(bl); |
450 |
|
|
451 |
|
// create our ana framework module |
452 |
|
AnaFwkMod *anamod = new AnaFwkMod; |
453 |
+ |
anamod->SetSkipNEvents(fSkipNEvents); |
454 |
+ |
anamod->SetPrintScale(fPrintScale); |
455 |
|
fDeleteList->Add(anamod); |
456 |
|
|
457 |
|
// create our HLT framework module |
458 |
|
HLTFwkMod *hltmod = 0; |
459 |
|
if (fUseHLT) { |
460 |
|
hltmod = new HLTFwkMod; |
461 |
+ |
hltmod->SetHLTObjsName(GetHLTObjsName()); |
462 |
+ |
hltmod->SetHLTTreeName(GetHLTTreeName()); |
463 |
|
fDeleteList->Add(hltmod); |
464 |
|
} |
465 |
|
|
482 |
|
} else { |
483 |
|
|
484 |
|
// when not running Proof, we must make a selector |
485 |
< |
fSelector = new Selector; |
486 |
< |
fSelector->SetDoProxy(fDoProxy); |
487 |
< |
fSelector->SetDoObjTabClean(fDoObjTabClean); |
488 |
< |
|
489 |
< |
fSelector->AddInput(anamod); |
485 |
> |
Selector *sel = new Selector; |
486 |
> |
sel->SetDoProxy(fDoProxy); |
487 |
> |
sel->SetDoObjTabClean(fDoObjTabClean); |
488 |
> |
sel->SetDoRunInfo(kTRUE); |
489 |
> |
sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn()); |
490 |
> |
sel->SetAllEvtTreeName(GetAllEvtTreeName()); |
491 |
> |
sel->SetEvtHdrName(GetEvtHdrName()); |
492 |
> |
sel->SetLAHdrName(GetLAHdrName()); |
493 |
> |
sel->SetLATreeName(GetLATreeName()); |
494 |
> |
sel->SetRunInfoName(GetRunInfoName()); |
495 |
> |
sel->SetRunTreeName(GetRunTreeName()); |
496 |
> |
sel->AddInput(anamod); |
497 |
> |
fSelector = sel; |
498 |
|
|
499 |
|
if (hltmod) |
500 |
|
fSelector->AddInput(hltmod); |