#include <Riostream.h>
#include <TFile.h>
#include <TClass.h>
+#include <TTree.h>
+#include <TROOT.h>
#include "AliAnalysisTask.h"
#include "AliAnalysisDataSlot.h"
fOutputs(NULL)
{
// Default constructor.
- TObject::SetBit(kTaskEvtByEvt, kTRUE);
}
//______________________________________________________________________________
fOutputs(NULL)
{
// Constructor.
- TObject::SetBit(kTaskEvtByEvt, kTRUE);
fInputs = new TObjArray(2);
fOutputs = new TObjArray(2);
}
// accordingly. This method is called automatically for all tasks connected
// to a container where the data was published.
if (init) fInitialized = kFALSE;
- Bool_t execperevent = IsExecPerEvent();
+ Bool_t single_shot = IsPostEventLoop();
AliAnalysisDataContainer *cinput;
for (Int_t islot=0; islot<fNinputs; islot++) {
cinput = GetInputSlot(islot)->GetContainer();
- if (!cinput) return;
- if (!cinput->GetData() || execperevent!=cinput->IsEventByEvent()) {
+ if (!cinput->GetData() || (single_shot && !cinput->IsPostEventLoop())) {
SetActive(kFALSE);
return;
}
}
// Connect the slot to the container as output
if (!output->ConnectContainer(cont)) return kFALSE;
+ // Set event loop type the same as for the task
+ cont->SetPostEventLoop(IsPostEventLoop());
// Declare this as the data producer
cont->SetProducer(this, islot);
AreSlotsConnected();
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 *)
{
}
//______________________________________________________________________________
-void AliAnalysisTask::OpenFile(Int_t iout, Option_t *option) const
+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
// fHist2 = new TH2F("my quality check hist2",...);
// }
- if (iout<0 || iout>=fNoutputs) return;
- AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
- if (!mgr || mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis) return;
+ if (iout<0 || iout>=fNoutputs) {
+ Error("OpenFile", "No output slot for task %s with index %d", GetName(), iout);
+ return NULL;
+ }
+ // Method delegated to the analysis manager (A.G. 02/11/09)
AliAnalysisDataContainer *cont = GetOutputSlot(iout)->GetContainer();
- if (strlen(cont->GetFileName())) new TFile(cont->GetFileName(), option);
+ return AliAnalysisManager::OpenFile(cont, option);
}
//______________________________________________________________________________
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 *)
{
AliAnalysisDataContainer *cont;
for (Int_t i=0; i<indent; i++) ind += " ";
if (!dep || (dep && IsChecked())) {
- printf("%s\n", Form("%stask: %s ACTIVE=%i", ind.Data(), GetName(),IsActive()));
+ printf("%s\n", Form("%stask: %s ACTIVE=%i POST_LOOP=%i", ind.Data(), GetName(),IsActive(),IsPostEventLoop()));
if (dep) thistask->SetChecked(kFALSE);
else {
for (islot=0; islot<fNinputs; islot++) {
}
//______________________________________________________________________________
-void AliAnalysisTask::SetExecPerEvent(Bool_t flag)
+void AliAnalysisTask::SetPostEventLoop(Bool_t flag)
{
-// Set the task execution mode - run in a event loop or single shot. All output
+// Set the task execution mode - run after event loop or not. All output
// containers of this task will get the same type.
- TObject::SetBit(kTaskEvtByEvt,flag);
+ TObject::SetBit(kTaskPostEventLoop,flag);
AliAnalysisDataContainer *cont;
Int_t islot;
for (islot=0; islot<fNoutputs; islot++) {
cont = GetOutputSlot(islot)->GetContainer();
- if (cont) cont->SetEventByEvent(flag);
+ if (cont) cont->SetPostEventLoop(flag);
}
}