#include "AliVEventPool.h"
#include "AliSysInfo.h"
#include "AliAnalysisStatistics.h"
+#include "AliVEvent.h"
+#include "AliHLTTestInputHandler.h"
using std::ofstream;
using std::ios;
fMustClean(kFALSE),
fIsRemote(kFALSE),
fLocked(kFALSE),
+ fMCLoop(kFALSE),
fDebug(0),
fSpecialOutputLocation(""),
fTasks(0),
fInputs(0),
fOutputs(0),
fParamCont(0),
+ fExchangeCont(0),
fDebugOptions(0),
fFileDescriptors(new TObjArray()),
fCurrentDescriptor(0),
fInputs = new TObjArray();
fOutputs = new TObjArray();
fParamCont = new TObjArray();
+ fExchangeCont = new TObjArray();
fGlobals = new TMap();
}
fIOTimer = new TStopwatch();
fMustClean(other.fMustClean),
fIsRemote(other.fIsRemote),
fLocked(other.fLocked),
+ fMCLoop(other.fMCLoop),
fDebug(other.fDebug),
fSpecialOutputLocation(""),
fTasks(NULL),
fInputs(NULL),
fOutputs(NULL),
fParamCont(NULL),
+ fExchangeCont(NULL),
fDebugOptions(NULL),
fFileDescriptors(new TObjArray()),
fCurrentDescriptor(0),
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;
}
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);
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;
{
// 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;}
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);
}
Error("EventLoop", "No input handler: exiting");
return kFALSE;
}
- TTree *tree = fInputEventHandler->MakeTree();
- if (!tree) {
- Error("EventLoop", "The input handler must provide MakeTree()");
- return kFALSE;
- }
- SetExternalLoop(kTRUE);
- if (!Init(tree)) return kFALSE;
- for (Long64_t iev=0; iev<nevents; iev++) {
- fInputEventHandler->BeginEvent(iev);
- ExecAnalysis();
- fInputEventHandler->FinishEvent();
- }
- return kTRUE;
+ TTree *tree = new TTree("DummyTree", "Dummy tree for AliAnalysisManager::EventLoop");
+ SetExternalLoop(kTRUE);
+ if (!Init(tree)) return kFALSE;
+ SlaveBegin(tree);
+ for (Long64_t iev=0; iev<nevents; iev++)
+ ExecAnalysis();
+ TList dummyList;
+ PackOutput(&dummyList);
+ fIsRemote = kTRUE;
+ Terminate();
+ return kTRUE;
}
//______________________________________________________________________________
if (!fInitOK) return kFALSE;
fTree = tree;
if (fMode != kProofAnalysis) CreateReadCache();
- fTable.Rehash(100);
+ else {
+ // cholm - here we should re-add to the table or branches
+ fTable.Clear();
+ }
AliAnalysisDataContainer *top = fCommonInput;
if (!top) top = (AliAnalysisDataContainer*)fInputs->At(0);
if (!top) {
}
top->SetData(tree);
CheckBranches(kFALSE);
+ fTable.Rehash(100);
if (fDebug > 1) {
printf("<-AliAnalysisManager::Init(%s)\n", tree->GetName());
}
}
break;
case kExchangeContainer:
+ cont->SetExchange(kTRUE);
+ fExchangeCont->Add(cont);
+ cont->SetDataOwned(kFALSE); // data owned by the publisher
break;
}
return cont;
Error("CheckBranches", "Could not find branch %s",obj->GetName());
continue;
}
+ fTable.Add(br);
}
- fTable.Add(br);
if (load && br->GetReadEntry()!=GetCurrentEntry()) {
br->GetEntry(GetCurrentEntry());
}
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());
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();
}
//______________________________________________________________________________
}
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) {
if (cdir) cdir->cd();
return;
}
- cont->SetData(fTree); // This will notify all consumers
- Long64_t entry = fTree->GetTree()->GetReadEntry();
+ 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
if (fInputEventHandler) fInputEventHandler ->BeginEvent(entry);
TIter next1(fTopTasks);
Int_t itask = 0;
while ((task=(AliAnalysisTask*)next1())) {
- if (fDebug >1) {
+ task->SetActive(kTRUE);
+ if (fDebug >1) {
cout << " Executing task " << task->GetName() << endl;
}
if (fStatistics) fStatistics->StartTimer(GetTaskIndex(task), task->GetName(), task->ClassName());
}
//______________________________________________________________________________
-Bool_t AliAnalysisManager::IsMacroLoaded(const char filename)
+Bool_t AliAnalysisManager::IsMacroLoaded(const char * filename)
{
// Check if a macro was loaded.
return fgMacroNames.Contains(filename);
// in case the lock was set.
if (fLocked) Fatal("Changed","Critical setter called in locked mode");
}
+
+//______________________________________________________________________________
+void AliAnalysisManager::InitInputData(AliVEvent* esdEvent, AliESDfriend* esdFriend)
+{
+
+// Method to propagte to all the connected tasks the HLT event.
+// This method expects that the input hanlder is of type HLT, should
+// not be used otherwise
+
+ if (fInputEventHandler) {
+ TString classInputHandler = fInputEventHandler->ClassName();
+ if (classInputHandler.Contains("HLT")){
+ TObjArray* arrTasks = GetTasks();
+ fInputEventHandler->InitTaskInputData(esdEvent, esdFriend, arrTasks);
+ }
+ else {
+ Fatal("PropagateHLTEvent", "Input Handler not of type HLT, we cannot use this method!");
+ }
+ }
+ else {
+ Fatal("PropagateHLTEvent", "Input Handler not found, we cannot use this method!");
+ }
+}