X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ANALYSIS%2FAliAnalysisManager.cxx;h=cfafd4002b65c8a1abf41e56f61bda8e319ea30a;hb=0ca57c2f019e3764c982f29478c26c1a10b5b0f7;hp=09666beb84dc3c909283d1e6d3c6399ee06ace9b;hpb=a07b6be8666c9c7f85584d6a4ed8048beed14910;p=u%2Fmrichter%2FAliRoot.git diff --git a/ANALYSIS/AliAnalysisManager.cxx b/ANALYSIS/AliAnalysisManager.cxx index 09666beb84d..cfafd4002b6 100644 --- a/ANALYSIS/AliAnalysisManager.cxx +++ b/ANALYSIS/AliAnalysisManager.cxx @@ -81,6 +81,7 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title) fMustClean(kFALSE), fIsRemote(kFALSE), fLocked(kFALSE), + fMCLoop(kFALSE), fDebug(0), fSpecialOutputLocation(""), fTasks(0), @@ -90,6 +91,7 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title) fInputs(0), fOutputs(0), fParamCont(0), + fExchangeCont(0), fDebugOptions(0), fFileDescriptors(new TObjArray()), fCurrentDescriptor(0), @@ -128,6 +130,7 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title) fInputs = new TObjArray(); fOutputs = new TObjArray(); fParamCont = new TObjArray(); + fExchangeCont = new TObjArray(); fGlobals = new TMap(); } fIOTimer = new TStopwatch(); @@ -151,6 +154,7 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other) fMustClean(other.fMustClean), fIsRemote(other.fIsRemote), fLocked(other.fLocked), + fMCLoop(other.fMCLoop), fDebug(other.fDebug), fSpecialOutputLocation(""), fTasks(NULL), @@ -160,6 +164,7 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other) fInputs(NULL), fOutputs(NULL), fParamCont(NULL), + fExchangeCont(NULL), fDebugOptions(NULL), fFileDescriptors(new TObjArray()), fCurrentDescriptor(0), @@ -195,6 +200,7 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other) fInputs = new TObjArray(*other.fInputs); fOutputs = new TObjArray(*other.fOutputs); fParamCont = new TObjArray(*other.fParamCont); + fExchangeCont = new TObjArray(*other.fExchangeCont); fgCommonFileName = "AnalysisResults.root"; fgAnalysisManager = this; } @@ -216,6 +222,7 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe fInitOK = other.fInitOK; fIsRemote = other.fIsRemote; fLocked = other.fLocked; + fMCLoop = other.fMCLoop; fDebug = other.fDebug; fTasks = new TObjArray(*other.fTasks); fTopTasks = new TObjArray(*other.fTopTasks); @@ -224,6 +231,7 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe fInputs = new TObjArray(*other.fInputs); fOutputs = new TObjArray(*other.fOutputs); fParamCont = new TObjArray(*other.fParamCont); + fExchangeCont = new TObjArray(*other.fExchangeCont); fDebugOptions = NULL; fFileDescriptors = new TObjArray(); fCurrentDescriptor = 0; @@ -261,18 +269,19 @@ AliAnalysisManager::~AliAnalysisManager() { // Destructor. if (fTasks) {fTasks->Delete(); delete fTasks;} - if (fTopTasks) delete fTopTasks; - if (fZombies) delete fZombies; + delete fTopTasks; + delete fZombies; if (fContainers) {fContainers->Delete(); delete fContainers;} - if (fInputs) delete fInputs; - if (fOutputs) delete fOutputs; - if (fParamCont) delete fParamCont; - if (fDebugOptions) delete fDebugOptions; - if (fGridHandler) delete fGridHandler; - if (fInputEventHandler) delete fInputEventHandler; - if (fOutputEventHandler) delete fOutputEventHandler; - if (fMCtruthEventHandler) delete fMCtruthEventHandler; - if (fEventPool) delete fEventPool; + delete fInputs; + delete fOutputs; + delete fParamCont; + delete fExchangeCont; + delete fDebugOptions; + delete fGridHandler; + delete fInputEventHandler; + delete fOutputEventHandler; + delete fMCtruthEventHandler; + delete fEventPool; if (fgAnalysisManager==this) fgAnalysisManager = NULL; if (fGlobals) {fGlobals->DeleteAll(); delete fGlobals;} if (fFileDescriptors) {fFileDescriptors->Delete(); delete fFileDescriptors;} @@ -298,12 +307,47 @@ void AliAnalysisManager::CreateReadCache() if (fAsyncReading) gEnv->SetValue("TFile.AsyncReading",1); fTree->SetCacheSize(fCacheSize); TTreeCache::SetLearnEntries(1); //<<< we can take the decision after 1 entry - fTree->AddBranchToCache("*",kTRUE); //<<< add all branches to the cache + if (!fAutoBranchHandling && !fRequestedBranches.IsNull()) { + TObjArray *arr = fRequestedBranches.Tokenize(","); + TIter next(arr); + TObject *obj; + while ((obj=next())) + fTree->AddBranchToCache(obj->GetName(),kTRUE); //<<< add requested branches to cache + delete arr; + } else { + fTree->AddBranchToCache("*", kTRUE); //<<< add all branches to cache + } if (fDebug) { Info("CreateReadCache","Read cache enabled %lld bytes with async reading=%d",fCacheSize, (Int_t)fAsyncReading); } return; } + +//______________________________________________________________________________ +Bool_t AliAnalysisManager::EventLoop(Long64_t nevents) +{ +// Initialize an event loop where the data producer is the input handler +// The handler must implement MakeTree creating the tree of events (likely +// memory resident) and generate the current event in the method BeginEvent. +// If the tree is memory resident, the handler should never call TTree::Fill +// method. + cout << "===== RUNNING IN EVENT LOOP MODE: " << GetName() << endl; + if (!fInputEventHandler) { + Error("EventLoop", "No input handler: exiting"); + return kFALSE; + } + TTree *tree = new TTree("DummyTree", "Dummy tree for AliAnalysisManager::EventLoop"); + SetExternalLoop(kTRUE); + if (!Init(tree)) return kFALSE; + SlaveBegin(tree); + for (Long64_t iev=0; ievAt(0); if (!top) { @@ -426,6 +473,7 @@ Bool_t AliAnalysisManager::Init(TTree *tree) } top->SetData(tree); CheckBranches(kFALSE); + fTable.Rehash(100); if (fDebug > 1) { printf("<-AliAnalysisManager::Init(%s)\n", tree->GetName()); } @@ -551,7 +599,7 @@ Bool_t AliAnalysisManager::Notify() if (fCurrentDescriptor) fCurrentDescriptor->Done(); fCurrentDescriptor = new AliAnalysisFileDescriptor(curfile); fFileDescriptors->Add(fCurrentDescriptor); - } + } if (fDebug > 1) printf("->AliAnalysisManager::Notify() file: %s\n", curfile->GetName()); Int_t run = AliAnalysisManager::GetRunFromAlienPath(curfile->GetName()); @@ -1399,6 +1447,9 @@ AliAnalysisDataContainer *AliAnalysisManager::CreateContainer(const char *name, } break; case kExchangeContainer: + cont->SetExchange(kTRUE); + fExchangeCont->Add(cont); + cont->SetDataOwned(kFALSE); // data owned by the publisher break; } return cont; @@ -1610,8 +1661,8 @@ void AliAnalysisManager::CheckBranches(Bool_t load) Error("CheckBranches", "Could not find branch %s",obj->GetName()); continue; } + fTable.Add(br); } - fTable.Add(br); if (load && br->GetReadEntry()!=GetCurrentEntry()) { br->GetEntry(GetCurrentEntry()); } @@ -1654,10 +1705,17 @@ void AliAnalysisManager::PrintStatus(Option_t *option) const Bool_t getsysInfo = ((fNSysInfo>0) && (fMode==kLocalAnalysis))?kTRUE:kFALSE; if (getsysInfo) Info("PrintStatus", "System information will be collected each %lld events", fNSysInfo); - TIter next(fTopTasks); + AliAnalysisDataContainer *cont = fCommonInput; + if (!cont) cont = (AliAnalysisDataContainer*)fInputs->At(0); + printf("=== TOP CONTAINER:\n"); + cont->PrintContainer(option,0); + // Reset "touched" flag + TIter next(fContainers); + while ((cont = (AliAnalysisDataContainer*)next())) cont->SetTouched(kFALSE); + TIter nextt(fTasks); AliAnalysisTask *task; - while ((task=(AliAnalysisTask*)next())) - task->PrintTask(option); + while ((task=(AliAnalysisTask*)nextt())) + task->SetActive(kFALSE); if (!fAutoBranchHandling && !fRequestedBranches.IsNull()) printf("Requested input branches:\n%s\n", fRequestedBranches.Data()); @@ -1680,7 +1738,13 @@ void AliAnalysisManager::PrintStatus(Option_t *option) const void AliAnalysisManager::ResetAnalysis() { // Reset all execution flags and clean containers. - CleanContainers(); + TIter nextTask(fTasks); + AliAnalysisTask *task; + while ((task=(AliAnalysisTask*)nextTask())) { + // Clean all tasks + task->Reset(); + } +// CleanContainers(); } //______________________________________________________________________________ @@ -2208,13 +2272,15 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option) } fNcalls++; AliAnalysisTask *task; + // Reset the analysis + ResetAnalysis(); // Check if the top tree is active. if (fTree) { if (getsysInfo && ((fNcalls%fNSysInfo)==0)) AliSysInfo::AddStamp("Handlers_BeginEventGroup",fNcalls, 1002, 0); TIter next(fTasks); - // De-activate all tasks - while ((task=(AliAnalysisTask*)next())) task->SetActive(kFALSE); + // De-activate all tasks (not needed anymore after ResetAnalysis +// while ((task=(AliAnalysisTask*)next())) task->SetActive(kFALSE); AliAnalysisDataContainer *cont = fCommonInput; if (!cont) cont = (AliAnalysisDataContainer*)fInputs->At(0); if (!cont) { @@ -2222,7 +2288,7 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option) if (cdir) cdir->cd(); return; } - cont->SetData(fTree); // This will notify all consumers + cont->SetData(fTree); // This set activity for all tasks reading only from the top container Long64_t entry = fTree->GetTree()->GetReadEntry(); // // Call BeginEvent() for optional input/output and MC services @@ -2241,6 +2307,7 @@ void AliAnalysisManager::ExecAnalysis(Option_t *option) TIter next1(fTopTasks); Int_t itask = 0; while ((task=(AliAnalysisTask*)next1())) { + task->SetActive(kTRUE); if (fDebug >1) { cout << " Executing task " << task->GetName() << endl; } @@ -2817,7 +2884,7 @@ void AliAnalysisManager::ApplyDebugOptions() } //______________________________________________________________________________ -Bool_t AliAnalysisManager::IsMacroLoaded(const char filename) +Bool_t AliAnalysisManager::IsMacroLoaded(const char * filename) { // Check if a macro was loaded. return fgMacroNames.Contains(filename);