15 |
|
#include "MitAna/DataTree/interface/Names.h" |
16 |
|
#include "MitAna/TAM/interface/TAMVirtualLoader.h" |
17 |
|
#include "MitAna/TAM/interface/TAModule.h" |
18 |
< |
#include "MitAna/TAM/interface/TAMSelector.h" |
18 |
> |
#include "MitAna/TreeMod/interface/Selector.h" |
19 |
> |
#include "MitAna/TreeMod/interface/TreeLoader.h" |
20 |
> |
#include "MitAna/TreeMod/interface/HLTFwkMod.h" |
21 |
> |
#include "MitAna/Catalog/interface/Dataset.h" |
22 |
|
|
23 |
|
ClassImp(mithep::Analysis) |
24 |
|
|
25 |
|
using namespace mithep; |
26 |
|
|
27 |
< |
//__________________________________________________________________________________________________ |
27 |
> |
//-------------------------------------------------------------------------------------------------- |
28 |
|
Analysis::Analysis(Bool_t useproof) : |
29 |
|
fUseProof(useproof), |
30 |
< |
fHierachy(kTRUE), |
30 |
> |
fUseHLT(kTRUE), |
31 |
> |
fHierarchy(kTRUE), |
32 |
> |
fDoProxy(kTRUE), |
33 |
|
fState(kPristine), |
34 |
|
fNFriends(0), |
35 |
|
fList(new TList), |
41 |
|
fChain(0), |
42 |
|
fSet(0), |
43 |
|
fDeleteList(new TList), |
44 |
< |
fTreeName(Names::gkMitTreeName), |
44 |
> |
fTreeName(Names::gkEvtTreeName), |
45 |
|
fCompLevel(2), |
46 |
|
fProof(0), |
47 |
< |
fDoNEvents(-1) |
47 |
> |
fDoNEvents(TChain::kBigNumber) |
48 |
|
{ |
49 |
|
// Default constructor. |
50 |
|
|
56 |
|
// nothing to be done since we do not use par files (yet?) |
57 |
|
} |
58 |
|
|
59 |
< |
//__________________________________________________________________________________________________ |
59 |
> |
//-------------------------------------------------------------------------------------------------- |
60 |
|
Analysis::~Analysis() |
61 |
|
{ |
62 |
|
// Destructor. |
65 |
|
Terminate(); |
66 |
|
|
67 |
|
delete fList; |
68 |
< |
delete fDeleteList; |
68 |
> |
delete fPackages; |
69 |
|
delete fLoaders; |
70 |
+ |
delete fDeleteList; |
71 |
|
delete fSelector; |
66 |
– |
delete fPackages; |
72 |
|
fOutput = 0; // owned by TAM |
73 |
|
fSuperMod = 0; // owned by user |
74 |
|
|
75 |
|
delete fProof; |
76 |
|
} |
77 |
|
|
78 |
< |
//__________________________________________________________________________________________________ |
78 |
> |
//-------------------------------------------------------------------------------------------------- |
79 |
|
Bool_t Analysis::AddFile(const char *pname) |
80 |
|
{ |
81 |
< |
// Add file with given name to the list of files to be processed. |
82 |
< |
// Using the token "|", you can specify an arbritray number |
78 |
< |
// of paths to tree files that will be concatenated as friend |
79 |
< |
// trees. |
81 |
> |
// Add file with given name to the list of files to be processed. Using the token "|", you can |
82 |
> |
// specify an arbritray number of paths to tree files that will be concatenated as friend trees. |
83 |
|
|
84 |
|
if (fState != kPristine) { |
85 |
|
Error("AddFile", "Analysis already initialized"); |
108 |
|
return kTRUE; |
109 |
|
} |
110 |
|
|
111 |
< |
//________________________________________________________________________ |
111 |
> |
//-------------------------------------------------------------------------------------------------- |
112 |
|
void Analysis::AddFile(const char *pname, Int_t eventlist) |
113 |
|
{ |
114 |
< |
// Add file name to the event list specified by eventlist. The lists |
115 |
< |
// are used to hold filenames of different types of events. In case |
116 |
< |
// you dont want friend trees, just give no eventlist argument (default 0). |
114 |
> |
// Add file name to the event list specified by eventlist. The lists are used to hold filenames of |
115 |
> |
// different types of events. In case you dont want friend trees, just give no eventlist argument |
116 |
> |
// (default 0). |
117 |
|
|
118 |
|
MitAssert("AddFile", pname != 0); |
119 |
|
|
146 |
|
Info("AddFile", "Added %s to list of files.", pname); |
147 |
|
} |
148 |
|
|
149 |
< |
//__________________________________________________________________________________________________ |
149 |
> |
//-------------------------------------------------------------------------------------------------- |
150 |
|
void Analysis::AddFile(const TObject *oname, Int_t eventlist) |
151 |
|
{ |
152 |
< |
// Add file name to the event list specified by eventlist. The lists |
153 |
< |
// are used to hold filenames of different types of events. In case |
154 |
< |
// you dont want mixing, just give no eventlist argument (default 0). |
152 |
> |
// Add file name to the event list specified by eventlist. The lists are used to hold filenames of |
153 |
> |
// different types of events. In case you dont want mixing, just give no eventlist argument |
154 |
> |
// (default 0). |
155 |
|
|
156 |
|
MitAssert("AddFile", oname != 0); |
157 |
|
|
161 |
|
//________________________________________________________________________ |
162 |
|
Bool_t Analysis::AddFiles(const char *pname, Int_t nmax) |
163 |
|
{ |
164 |
< |
// Add files from text file with given name. If nmax>0, |
162 |
< |
// maximum nmax files will be added. |
164 |
> |
// Add files from text file with given name. If nmax>0, maximum nmax files will be added. |
165 |
|
|
166 |
|
MitAssert("AddFiles", pname != 0); |
167 |
|
|
196 |
|
return kTRUE; |
197 |
|
} |
198 |
|
|
199 |
< |
//__________________________________________________________________________________________________ |
199 |
> |
//-------------------------------------------------------------------------------------------------- |
200 |
> |
Bool_t Analysis::AddDataset(const Dataset *dataset) |
201 |
> |
{ |
202 |
> |
// Add a full dataset to the analysis. |
203 |
> |
|
204 |
> |
Bool_t status = true; |
205 |
> |
|
206 |
> |
for (UInt_t i=0; i<dataset->NFiles(); i++) |
207 |
> |
status = (status && AddFile(dataset->FileUrl(i))); |
208 |
> |
|
209 |
> |
return status; |
210 |
> |
} |
211 |
> |
|
212 |
> |
//-------------------------------------------------------------------------------------------------- |
213 |
|
void Analysis::AddList(TList *list, Int_t eventlist) |
214 |
|
{ |
215 |
< |
// Add file name to the event list specified by eventlist. The lists |
216 |
< |
// are used to hold filenames of different types of events. In case |
217 |
< |
// you dont want mixing, just give no eventlist argument (default 0). |
215 |
> |
// Add file name to the event list specified by eventlist. The lists are used to hold filenames of |
216 |
> |
// different types of events. In case you dont want mixing, just give no eventlist argument |
217 |
> |
// (default 0). |
218 |
|
|
219 |
|
MitAssert("AddList", list != 0); |
220 |
|
|
223 |
|
AddFile(obj->GetName(), eventlist); |
224 |
|
} |
225 |
|
|
226 |
< |
//__________________________________________________________________________________________________ |
226 |
> |
//-------------------------------------------------------------------------------------------------- |
227 |
|
void Analysis::AddLoader(TAMVirtualLoader *l) |
228 |
|
{ |
229 |
|
// Add loader to the list of loaders. |
231 |
|
fLoaders->Add(l); |
232 |
|
} |
233 |
|
|
234 |
< |
//__________________________________________________________________________________________________ |
234 |
> |
//-------------------------------------------------------------------------------------------------- |
235 |
|
void Analysis::AddPackage(const char* name) |
236 |
|
{ |
237 |
|
// Add package to the list of uploaded packages. |
240 |
|
fPackages->Add(new TObjString(name)); |
241 |
|
} |
242 |
|
|
243 |
< |
//__________________________________________________________________________________________________ |
243 |
> |
//-------------------------------------------------------------------------------------------------- |
244 |
|
void Analysis::AddPackages(TList *list) |
245 |
|
{ |
246 |
|
// Add list of packages to the list of uploaded packages. |
253 |
|
} |
254 |
|
} |
255 |
|
|
256 |
< |
//__________________________________________________________________________________________________ |
256 |
> |
//-------------------------------------------------------------------------------------------------- |
257 |
|
Bool_t Analysis::Init() |
258 |
|
{ |
259 |
< |
// Setup the TDSet and TChain to be used for the analysis |
260 |
< |
// with or without PROOF. If more than one list of |
246 |
< |
// file names was given, friend trees are supported. |
259 |
> |
// Setup the TDSet and TChain to be used for the analysis with or without PROOF. If more than one |
260 |
> |
// list of file names was given, friend trees are supported. |
261 |
|
|
262 |
|
if (fState == kRun || fState == kInit) { |
263 |
|
Error("Init", "Init in state %d is not possible! Call Terminate() first.", |
325 |
|
|
326 |
|
} |
327 |
|
|
328 |
< |
// if we had our default TAM plugin we would create it here |
329 |
< |
// TreeLoader *bl = new TreeLoader; |
330 |
< |
// fLoaders->Add(bl); |
331 |
< |
// fDeleteList->Add(bl); |
328 |
> |
// create our customized loader plugin for TAM |
329 |
> |
TreeLoader *bl = new TreeLoader; |
330 |
> |
fLoaders->Add(bl); |
331 |
> |
fDeleteList->Add(bl); |
332 |
> |
|
333 |
> |
// create our HLT framework module |
334 |
> |
HLTFwkMod *hltmod = 0; |
335 |
> |
if (fUseHLT) { |
336 |
> |
hltmod = new HLTFwkMod; |
337 |
> |
fDeleteList->Add(hltmod); |
338 |
> |
} |
339 |
|
|
340 |
|
if (fUseProof) { |
341 |
|
|
342 |
+ |
if (hltmod) |
343 |
+ |
fProof->AddInput(hltmod); |
344 |
+ |
|
345 |
|
fProof->AddInput(fSuperMod); |
346 |
|
fLoaders->SetName("TAM_LOADERS"); |
347 |
|
fProof->AddInput(fLoaders); |
349 |
|
} else { |
350 |
|
|
351 |
|
// when not running Proof, we must make a selector |
352 |
< |
fSelector = new TAMSelector; |
352 |
> |
fSelector = new Selector; |
353 |
> |
fSelector->SetDoProxy(fDoProxy); |
354 |
> |
if (hltmod) |
355 |
> |
fSelector->AddInput(hltmod); |
356 |
|
fSelector->AddInput(fSuperMod); |
357 |
|
MDB(kAnalysis, 2) |
358 |
|
fSelector->SetVerbosity(1); |
367 |
|
return kTRUE; |
368 |
|
} |
369 |
|
|
370 |
< |
//__________________________________________________________________________________________________ |
370 |
> |
//-------------------------------------------------------------------------------------------------- |
371 |
|
Bool_t Analysis::InitProof() |
372 |
|
{ |
373 |
|
// Initialize PROOF connection. |
408 |
|
return ret; |
409 |
|
} |
410 |
|
|
411 |
< |
//__________________________________________________________________________________________________ |
411 |
> |
//-------------------------------------------------------------------------------------------------- |
412 |
|
void Analysis::Run() |
413 |
|
{ |
414 |
|
// Run the analysis on the created file set. |
423 |
|
MDB(kAnalysis, 1) |
424 |
|
Info("Run", "Start processing with PROOF..."); |
425 |
|
|
426 |
< |
fSet->Process("TAMSelector","",fDoNEvents); |
426 |
> |
fSet->Process("Selector","",fDoNEvents); |
427 |
|
|
428 |
|
} else { |
429 |
|
|
439 |
|
fState = kRun; |
440 |
|
} |
441 |
|
|
442 |
< |
//__________________________________________________________________________________________________ |
442 |
> |
//-------------------------------------------------------------------------------------------------- |
443 |
|
Bool_t Analysis::Run(Bool_t browse) |
444 |
|
{ |
445 |
|
// Execute analysis and open TBrowser if requested. |
447 |
|
if (Init()) { |
448 |
|
Run(); |
449 |
|
Terminate(); |
450 |
< |
if(browse) { |
450 |
> |
if (browse) { |
451 |
|
new TBrowser; |
452 |
|
} |
453 |
|
return kTRUE; |
457 |
|
return kFALSE; |
458 |
|
} |
459 |
|
|
460 |
< |
//__________________________________________________________________________________________________ |
460 |
> |
//-------------------------------------------------------------------------------------------------- |
461 |
|
void Analysis::Terminate() |
462 |
|
{ |
463 |
|
// Terminate current analysis run. |
496 |
|
MDB(kAnalysis, 1) |
497 |
|
Info("Terminate", "Saving output to %s!", fAnaOutput.Data()); |
498 |
|
|
499 |
< |
if (fHierachy) |
499 |
> |
if (fHierarchy) |
500 |
|
fOutput->Write(fOutput->GetName(),TObject::kSingleKey); |
501 |
|
else |
502 |
|
fOutput->Write(); |
503 |
|
|
504 |
|
} |
505 |
|
} |
506 |
+ |
// set state to terminate |
507 |
+ |
fState = kTerminate; |
508 |
|
} |
509 |
|
|
510 |
|
delete fChain; |
511 |
|
delete fSet; |
512 |
|
fDeleteList->Delete(); |
484 |
– |
|
485 |
– |
fState = kTerminate; |
513 |
|
} |
514 |
|
|
515 |
< |
//__________________________________________________________________________________________________ |
515 |
> |
//-------------------------------------------------------------------------------------------------- |
516 |
|
Bool_t Analysis::UploadPackages(TList *packages) |
517 |
|
{ |
518 |
|
// Upload list of par files to the server. |
519 |
|
|
520 |
|
MitAssert("UploadPackages", packages != 0); |
521 |
|
|
522 |
< |
for(Int_t i=0; i < packages->GetEntries(); i++) { |
522 |
> |
for (Int_t i=0; i<packages->GetEntries(); i++) { |
523 |
|
|
524 |
|
TObject* objstr = packages->At(i); |
525 |
< |
if (!objstr){ |
525 |
> |
if (!objstr) { |
526 |
|
Error("InitProof", "Problem at package number %d!", i); |
527 |
|
return kFALSE; |
528 |
|
} |
529 |
|
|
530 |
|
TString packname = objstr->GetName(); |
531 |
< |
Int_t en = 0; |
531 |
> |
Int_t en = 0; |
532 |
|
if (packname.EndsWith("+")) { |
533 |
|
en=1; |
534 |
|
packname.Resize(packname.Length()-1); |
535 |
|
} |
536 |
|
|
537 |
|
ifstream ftest(gSystem->ExpandPathName(packname.Data()),ios_base::binary); |
538 |
< |
if (!ftest.good()){ |
538 |
> |
if (!ftest.good()) { |
539 |
|
Error("InitProof", "Could not open %s for upload!", packname.Data()); |
540 |
|
return kFALSE; |
541 |
|
} |
542 |
|
|
543 |
< |
if(fProof->UploadPackage(packname)<0) { |
543 |
> |
if (fProof->UploadPackage(packname)<0) { |
544 |
|
Error("UploadPackage", "Upload for %s failed!", packname.Data()); |
545 |
|
return kFALSE; |
546 |
|
} |
547 |
|
|
548 |
|
if (en == 1) { |
549 |
|
Int_t pos=packname.Last('/')+1; |
550 |
< |
if (pos) packname.Remove(0,pos); |
551 |
< |
if(fProof->EnablePackage(packname)<0) { |
550 |
> |
if (pos) |
551 |
> |
packname.Remove(0,pos); |
552 |
> |
if (fProof->EnablePackage(packname)<0) { |
553 |
|
Error("UploadPackage", "Enabling for %s failed!", packname.Data()); |
554 |
|
return kFALSE; |
555 |
|
} |