+//______________________________________________________________________________
+TObject *AliAnalysisTask::GetOutputData(Int_t islot) const
+{
+// Retreive output data for a slot. Normally called in UserTask::Terminate to
+// get a valid pointer to data even in case of Proof.
+ AliAnalysisDataSlot *output = GetOutputSlot(islot);
+ if (!output) {
+ Error("GetOutputData","Input slot %d not defined for analysis task %s", islot, GetName());
+ return NULL;
+ }
+ return (output->GetData());
+}
+
+//______________________________________________________________________________
+char *AliAnalysisTask::GetBranchAddress(Int_t islot, const char *branch) const
+{
+// Check if a branch with a given name from the specified input is connected
+// to some address. Call this in Init() before trying to call SetBranchAddress()
+// since the adress may be set by other task.
+ return (char *)GetInputSlot(islot)->GetBranchAddress(branch);
+}
+
+//______________________________________________________________________________
+Bool_t AliAnalysisTask::SetBranchAddress(Int_t islot, const char *branch, void *address) const
+{
+// Connect an object address to a branch of the specified input.
+ return GetInputSlot(islot)->SetBranchAddress(branch, address);
+}
+
+//______________________________________________________________________________
+void AliAnalysisTask::EnableBranch(Int_t islot, const char *bname) const
+{
+// Call this in ConnectInputData() to enable only the branches needed by this
+// task. "*" will enable everything.
+ AliAnalysisDataSlot *input = GetInputSlot(islot);
+ if (!input || !input->GetType()->InheritsFrom(TTree::Class())) {
+ Error("EnableBranch", "Wrong slot type #%d for task %s: not TTree-derived type", islot, GetName());
+ return;
+ }
+ TTree *tree = (TTree*)input->GetData();
+ if (!strcmp(bname, "*")) {
+ tree->SetBranchStatus("*",1);
+ return;
+ }
+ 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 *)
+{
+// Overload and connect your branches here.
+}
+
+//______________________________________________________________________________
+void AliAnalysisTask::LocalInit()
+{
+// The method LocalInit() may be implemented to call locally (on the client)
+// all initialization methods of the class. It is not mandatory and was created
+// in order to minimize the complexity and readability of the analysis macro.
+// DO NOT create in this method the histigrams or task output objects that will
+// go in the task output containers. Use CreateOutputObjects for that.
+}
+
+//______________________________________________________________________________
+void AliAnalysisTask::CreateOutputObjects()
+{
+// Called once per task either in PROOF or local mode. Overload to put some
+// task initialization and/or create your output objects here.
+}
+
+//______________________________________________________________________________
+TFile *AliAnalysisTask::OpenFile(Int_t iout, Option_t *option) const
+{
+// This method has to be called INSIDE the user redefined CreateOutputObjects
+// method, before creating each object corresponding to the output containers
+// that are to be written to a file. This need to be done in general for the big output
+// objects that may not fit memory during processing.
+// - 'option' is the file opening option.
+//=========================================================================
+// NOTE !: The method call will be ignored in PROOF mode, in which case the
+// results have to be streamed back to the client and written just before Terminate()
+//=========================================================================
+//
+// Example:
+// void MyAnaTask::CreateOutputObjects() {
+// OpenFile(0); // Will open the file for the object to be written at output #0
+// fAOD = new TTree("AOD for D0toKPi");
+// OpenFile(1);
+// now some histos that should go in the file of the second output container
+// fHist1 = new TH1F("my quality check hist1",...);
+// fHist2 = new TH2F("my quality check hist2",...);
+// }
+
+ if (iout<0 || iout>=fNoutputs) {
+ 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();
+ AliAnalysisDataContainer *cont = GetOutputSlot(iout)->GetContainer();
+ TFile *f = NULL;
+ if (!strlen(cont->GetFileName())) {
+ Error("OpenFile", "No file name specified for container %s", cont->GetName());
+ return f;
+ }
+ if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis && cont->IsSpecialOutput())
+ f = mgr->OpenProofFile(cont->GetFileName(),option);
+ else {
+ // Check first if the file is already opened
+ f = (TFile*)gROOT->GetListOfFiles()->FindObject(cont->GetFileName());
+ if (!f) f = new TFile(cont->GetFileName(), option);
+ }
+ if (f && !f->IsZombie()) {
+ cont->SetFile(f);
+ return f;
+ }
+ cont->SetFile(NULL);
+ return NULL;
+}
+
+//______________________________________________________________________________
+Bool_t AliAnalysisTask::Notify()
+{
+// Overload this IF you need to treat input file change.
+ 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 *)
+{
+// Method called by the framework at the end of data processing.
+}
+