X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ANALYSIS%2FAliAnalysisTask.cxx;h=09c922c0c79463fba43096efd569e1ec996c4276;hb=ada6b882ca8069d28a8b4bb7be23007ad3ff615d;hp=2ea368db23ade12bed603478af38bd1048e711d2;hpb=13ef3bb0ae3d813ba9d1b701c4961bc8db4d0a80;p=u%2Fmrichter%2FAliRoot.git diff --git a/ANALYSIS/AliAnalysisTask.cxx b/ANALYSIS/AliAnalysisTask.cxx index 2ea368db23a..09c922c0c79 100644 --- a/ANALYSIS/AliAnalysisTask.cxx +++ b/ANALYSIS/AliAnalysisTask.cxx @@ -100,7 +100,9 @@ #include #include #include +#include #include +#include #include "AliAnalysisTask.h" #include "AliAnalysisDataSlot.h" @@ -118,7 +120,8 @@ AliAnalysisTask::AliAnalysisTask() fOutputReady(NULL), fPublishedData(NULL), fInputs(NULL), - fOutputs(NULL) + fOutputs(NULL), + fBranchNames() { // Default constructor. } @@ -133,7 +136,8 @@ AliAnalysisTask::AliAnalysisTask(const char *name, const char *title) fOutputReady(NULL), fPublishedData(NULL), fInputs(NULL), - fOutputs(NULL) + fOutputs(NULL), + fBranchNames() { // Constructor. fInputs = new TObjArray(2); @@ -150,7 +154,8 @@ AliAnalysisTask::AliAnalysisTask(const AliAnalysisTask &task) fOutputReady(NULL), fPublishedData(NULL), fInputs(NULL), - fOutputs(NULL) + fOutputs(NULL), + fBranchNames(task.fBranchNames) { // Copy ctor. fInputs = new TObjArray((fNinputs)?fNinputs:2); @@ -194,6 +199,7 @@ AliAnalysisTask& AliAnalysisTask::operator=(const AliAnalysisTask& task) fOutputReady[i] = IsOutputReady(i); fOutputs->AddAt(new AliAnalysisDataSlot(*task.GetOutputSlot(i)),i); } + fBranchNames = task.fBranchNames; return *this; } @@ -249,6 +255,47 @@ void AliAnalysisTask::CheckNotify(Bool_t init) fInitialized = kTRUE; } +//______________________________________________________________________________ +Bool_t AliAnalysisTask::CheckPostData() const +{ +// Checks if data was posted to all outputs defined by the task. If task does +// not have output slots this returns always kTRUE. + Bool_t dataPosted = kTRUE; + AliAnalysisDataContainer *coutput; + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + for (Int_t islot=0; islotGetContainer(); + if (!mgr->GetOutputs()->FindObject(coutput) || coutput==mgr->GetCommonOutputContainer()) continue; + if (!coutput->GetData()) { + Error("CheckPostData", "Data not posted for slot #%d of task %s (%s)", + islot, GetName(), ClassName()); + dataPosted = kFALSE; + } + } + CheckOwnership(); + return dataPosted; +} + +//______________________________________________________________________________ +Bool_t AliAnalysisTask::CheckOwnership() const +{ +// Check ownership of containers posted on output slots (1 level only) + TObject *outdata; + for (Int_t islot=0; islotInheritsFrom(TCollection::Class())) { + TCollection *coll = (TCollection*)outdata; + if (!coll->IsOwner()) { + Error("CheckOwnership","####### IMPORTANT! ####### \n\n\n\ + Task %s (%s) posts a container that is not owner at output #%d. This may apply for other embedded containers. \n\n\ + ####### FIX YOUR CODE, THIS WILL PRODUCE A FATAL ERROR IN FUTURE! ##########", GetName(), ClassName(), islot); + return kFALSE; + } + } + } + return kTRUE; +} + //______________________________________________________________________________ Bool_t AliAnalysisTask::ConnectInput(Int_t islot, AliAnalysisDataContainer *cont) { @@ -401,6 +448,16 @@ void AliAnalysisTask::EnableBranch(Int_t islot, const char *bname) const } AliAnalysisDataSlot::EnableBranch(bname, tree); } + +//______________________________________________________________________________ +void AliAnalysisTask::FinishTaskOutput() +{ +// Optional method that is called in SlaveTerminate phase. +// Used for calling aditional methods just after the last event was processed ON +// THE WORKING NODE. The call is made also in local case. +// Do NOT delete output objects here since they will have to be sent for +// merging in PROOF mode - use class destructor for cleanup. +} //______________________________________________________________________________ void AliAnalysisTask::ConnectInputData(Option_t *) @@ -452,14 +509,9 @@ TFile *AliAnalysisTask::OpenFile(Int_t iout, Option_t *option) const Error("OpenFile", "No output slot for task %s with index %d", GetName(), iout); return NULL; } - // We allow file opening also on the slaves (AG) -// AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); -// if (!mgr || mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return; + // Method delegated to the analysis manager (A.G. 02/11/09) AliAnalysisDataContainer *cont = GetOutputSlot(iout)->GetContainer(); - TFile *f = NULL; - if (strlen(cont->GetFileName())) f = new TFile(cont->GetFileName(), option); - if (f && !f->IsZombie()) return f; - return NULL; + return AliAnalysisManager::OpenFile(cont, option); } //______________________________________________________________________________ @@ -469,6 +521,13 @@ Bool_t AliAnalysisTask::Notify() return kTRUE; } +//______________________________________________________________________________ +Bool_t AliAnalysisTask::NotifyBinChange() +{ +// Overload this IF you need to treat bin change in event mixing. + return kTRUE; +} + //______________________________________________________________________________ void AliAnalysisTask::Terminate(Option_t *) { @@ -537,7 +596,6 @@ Bool_t AliAnalysisTask::CheckCircularDeps() void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const { // Print task info. - AliAnalysisTask *thistask = (AliAnalysisTask*)this; TString opt(option); opt.ToLower(); Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE; @@ -546,8 +604,9 @@ void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const AliAnalysisDataContainer *cont; for (Int_t i=0; iSetChecked(kFALSE); + if (dep) const_cast(this)->SetChecked(kFALSE); else { for (islot=0; islotGetName())); @@ -564,6 +623,7 @@ void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const } } PrintContainers(option, indent+3); + if (!fBranchNames.IsNull()) printf("Requested branches: %s\n", fBranchNames.Data()); } //______________________________________________________________________________ @@ -594,3 +654,18 @@ void AliAnalysisTask::SetPostEventLoop(Bool_t flag) } } +//______________________________________________________________________________ +void AliAnalysisTask::GetBranches(const char *type, TString &result) const +{ +// Get the list of branches for a given type (ESD, AOD). The list of branches +// requested by a task has to ve declared in the form: +// SetBranches("ESD:branch1,branch2,...,branchN AOD:branch1,branch2,...,branchM") + result = ""; + if (fBranchNames.IsNull()) return; + Int_t index1 = fBranchNames.Index(type); + if (index1<0) return; + index1 += 1+strlen(type); + Int_t index2 = fBranchNames.Index(" ", index1); + if (index2<0) index2 = fBranchNames.Length(); + result = fBranchNames(index1, index2-index1); +}