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), |
47 |
|
fTreeName(Names::gkEvtTreeName), |
48 |
|
fCompLevel(2), |
49 |
|
fProof(0), |
50 |
< |
fDoNEvents(TChain::kBigNumber) |
50 |
> |
fDoNEvents(TChain::kBigNumber), |
51 |
> |
fCacheSize(134217728) |
52 |
|
{ |
53 |
|
// Default constructor. |
54 |
|
|
80 |
|
} |
81 |
|
|
82 |
|
//-------------------------------------------------------------------------------------------------- |
83 |
+ |
Bool_t Analysis::AddDataset(const Dataset *dataset) |
84 |
+ |
{ |
85 |
+ |
// Add a full dataset to the analysis. |
86 |
+ |
|
87 |
+ |
Bool_t status = true; |
88 |
+ |
|
89 |
+ |
for (UInt_t i=0; i<dataset->NFiles(); ++i) |
90 |
+ |
status = (status && AddFile(dataset->FileUrl(i))); |
91 |
+ |
|
92 |
+ |
return status; |
93 |
+ |
} |
94 |
+ |
|
95 |
+ |
//-------------------------------------------------------------------------------------------------- |
96 |
|
Bool_t Analysis::AddFile(const char *pname) |
97 |
|
{ |
98 |
|
// Add file with given name to the list of files to be processed. Using the token "|", you can |
104 |
|
} |
105 |
|
|
106 |
|
TString pnamestr(pname); |
107 |
+ |
if (pnamestr.IsNull()) |
108 |
+ |
return kFALSE; |
109 |
+ |
|
110 |
|
TString tok("|"); |
111 |
|
TObjArray *arr = pnamestr.Tokenize(tok); |
112 |
< |
TString msg; |
112 |
> |
if (!arr) |
113 |
> |
return kFALSE; |
114 |
|
|
115 |
< |
for(Int_t i=0; i<arr->GetEntries(); i++){ |
116 |
< |
|
115 |
> |
TString msg; |
116 |
> |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
117 |
> |
|
118 |
|
TObjString *dummy = dynamic_cast<TObjString*>(arr->At(i)); |
119 |
< |
if (!dummy) continue; |
119 |
> |
if (!dummy) |
120 |
> |
continue; |
121 |
|
|
122 |
|
AddFile(dummy->GetName(),i); |
123 |
< |
if (i==0) msg=dummy->GetName(); |
124 |
< |
else { |
125 |
< |
Info("AddFile", "Add file %s as friend to %s", |
126 |
< |
dummy->GetName(), msg.Data()); |
105 |
< |
} |
123 |
> |
if (i==0) |
124 |
> |
msg=dummy->GetName(); |
125 |
> |
else |
126 |
> |
Info("AddFile", "Add file %s as friend to %s", dummy->GetName(), msg.Data()); |
127 |
|
} |
128 |
|
delete arr; |
129 |
|
|
153 |
|
l = new TList; |
154 |
|
l->SetOwner(); |
155 |
|
fList->Add(l); |
156 |
< |
fNFriends++; |
156 |
> |
++fNFriends; |
157 |
|
|
158 |
|
} else if (eventlist < 0 || eventlist > fNFriends) { |
159 |
|
Error("AddFile", "Specified list %d not in [0,%d]", eventlist, fNFriends); |
219 |
|
} |
220 |
|
|
221 |
|
//-------------------------------------------------------------------------------------------------- |
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 |
– |
//-------------------------------------------------------------------------------------------------- |
222 |
|
void Analysis::AddList(TList *list, Int_t eventlist) |
223 |
|
{ |
224 |
|
// Add file name to the event list specified by eventlist. The lists are used to hold filenames of |
271 |
|
} |
272 |
|
|
273 |
|
//-------------------------------------------------------------------------------------------------- |
274 |
+ |
void Analysis::FileInputFromEnv() |
275 |
+ |
{ |
276 |
+ |
// Attempt to get list of filesets/files from environment. |
277 |
+ |
|
278 |
+ |
TString catalog(gSystem->Getenv("MIT_CATALOG")); |
279 |
+ |
TString book(gSystem->Getenv("MIT_BOOK")); |
280 |
+ |
TString dataset(gSystem->Getenv("MIT_DATASET")); |
281 |
+ |
TString filesets(gSystem->Getenv("MIT_FILESETS")); |
282 |
+ |
TString files(gSystem->Getenv("MIT_FILES")); |
283 |
+ |
|
284 |
+ |
if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) { |
285 |
+ |
Warning("FileInputFromEnv", "Called to get file info from environment, but did not get" |
286 |
+ |
" consistent set of variables:\n\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\t" |
287 |
+ |
"MIT_DATASET=%s\n\tMIT_FILESETS=%s\n\tMIT_FILES=%s\n", |
288 |
+ |
catalog.Data(), book.Data(), dataset.Data(), filesets.Data(), files.Data()); |
289 |
+ |
return; |
290 |
+ |
} |
291 |
+ |
|
292 |
+ |
if (!files.IsNull()) { // add local files |
293 |
+ |
Info("FileInputFromEnv", "Got from environment:\n" |
294 |
+ |
"\n\tMIT_FILES=%s\n", files.Data()); |
295 |
+ |
TString tok(";"); |
296 |
+ |
TObjArray *arr = files.Tokenize(tok); |
297 |
+ |
if (arr) { |
298 |
+ |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
299 |
+ |
TObjString *dummy = dynamic_cast<TObjString*>(arr->At(i)); |
300 |
+ |
if (!dummy) continue; |
301 |
+ |
AddFile(dummy->GetName(),0); |
302 |
+ |
} |
303 |
+ |
delete arr; |
304 |
+ |
} |
305 |
+ |
return; |
306 |
+ |
} |
307 |
+ |
|
308 |
+ |
Info("FileInputFromEnv", "Got from environment:\n" |
309 |
+ |
"\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\tMIT_DATASET=%s\n\tMIT_FILESETS=%s\n", |
310 |
+ |
catalog.Data(), book.Data(), dataset.Data(), filesets.Data()); |
311 |
+ |
|
312 |
+ |
Catalog cat(catalog); |
313 |
+ |
if (filesets.IsNull()) { |
314 |
+ |
Dataset *d = cat.FindDataset(book, dataset); |
315 |
+ |
if (d) { |
316 |
+ |
AddDataset(d); |
317 |
+ |
delete d; |
318 |
+ |
} |
319 |
+ |
} else { |
320 |
+ |
TString tok(";"); |
321 |
+ |
TObjArray *arr = filesets.Tokenize(tok); |
322 |
+ |
if (arr) { |
323 |
+ |
for (Int_t i=0; i<arr->GetEntries(); ++i) { |
324 |
+ |
TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i)); |
325 |
+ |
if (!fileset) continue; |
326 |
+ |
Dataset *d = cat.FindDataset(book, dataset, fileset->String()); |
327 |
+ |
if (!d) |
328 |
+ |
continue; |
329 |
+ |
AddDataset(d); |
330 |
+ |
delete d; |
331 |
+ |
} |
332 |
+ |
delete arr; |
333 |
+ |
} |
334 |
+ |
} |
335 |
+ |
} |
336 |
+ |
|
337 |
+ |
//-------------------------------------------------------------------------------------------------- |
338 |
|
Bool_t Analysis::Init() |
339 |
|
{ |
340 |
|
// Setup the TDSet and TChain to be used for the analysis with or without PROOF. If more than one |
346 |
|
return kFALSE; |
347 |
|
} |
348 |
|
|
349 |
+ |
// check if we should attempt to get filesets/filenames from environment |
350 |
+ |
if (fNFriends == 0) |
351 |
+ |
FileInputFromEnv(); |
352 |
+ |
|
353 |
|
if (fNFriends <= 0) { |
354 |
|
Error("Init", "List of friend lists is empty!"); |
355 |
|
return kFALSE; |
361 |
|
} |
362 |
|
|
363 |
|
if (fUseProof) { // first init our PROOF session |
364 |
< |
if (!InitProof()) return kFALSE; |
364 |
> |
if (!InitProof()) |
365 |
> |
return kFALSE; |
366 |
|
} |
367 |
|
|
368 |
|
// we do this here instead in Terminate() so that |
372 |
|
|
373 |
|
fChain = new TChain(fTreeName); |
374 |
|
fSet = new TDSet("TTree",fTreeName); |
375 |
+ |
|
376 |
+ |
fChain->SetCacheSize(fCacheSize); |
377 |
|
|
378 |
< |
for(Int_t i=0; i<fNFriends; i++){ |
378 |
> |
for (Int_t i=0; i<fNFriends; ++i) { |
379 |
|
|
380 |
|
TList *l = dynamic_cast<TList*>(fList->At(i)); |
381 |
|
if (!l) { |
385 |
|
|
386 |
|
if (i == 0) { |
387 |
|
TIter next(l); |
388 |
< |
while ( TObjString *obj = dynamic_cast<TObjString*>(next()) ) { |
388 |
> |
while (TObjString *obj = dynamic_cast<TObjString*>(next())) { |
389 |
|
fChain->Add(obj->GetName()); |
390 |
|
fSet->Add(obj->GetName()); |
391 |
|
} |
450 |
|
// when not running Proof, we must make a selector |
451 |
|
fSelector = new Selector; |
452 |
|
fSelector->SetDoProxy(fDoProxy); |
453 |
+ |
fSelector->SetDoObjTabClean(fDoObjTabClean); |
454 |
|
|
455 |
|
fSelector->AddInput(anamod); |
456 |
|
|
469 |
|
|
470 |
|
// pass loaders to selector |
471 |
|
TIter next(fLoaders); |
472 |
< |
while ( TAMVirtualLoader *l = dynamic_cast<TAMVirtualLoader*>(next()) ) |
472 |
> |
while (TAMVirtualLoader *l = dynamic_cast<TAMVirtualLoader*>(next())) |
473 |
|
fSelector->AddLoader(l); |
474 |
|
} |
475 |
|
|
488 |
|
delete fProof; |
489 |
|
|
490 |
|
if (fMaster.Contains("rcf.bnl.gov")) { |
491 |
< |
for(Int_t i=0;i<5;i++) { |
491 |
> |
for (Int_t i=0; i<5; ++i) { |
492 |
|
Warning("InitProof", "*** DID YOU RUN PROOF_KINIT? %d (5) ***", i); |
493 |
|
gSystem->Sleep(1000); |
494 |
|
} |
638 |
|
|
639 |
|
MitAssert("UploadPackages", packages != 0); |
640 |
|
|
641 |
< |
for (Int_t i=0; i<packages->GetEntries(); i++) { |
641 |
> |
for (Int_t i=0; i<packages->GetEntries(); ++i) { |
642 |
|
|
643 |
|
TObject* objstr = packages->At(i); |
644 |
|
if (!objstr) { |