- Common input and output data containers are now created automatically when attachin...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisManager.cxx
index 51ca9dfe3978cec59abaec86866661426330930a..5f5c70fa76ab559c404f5aa463a6fb3e71f0bfef 100644 (file)
@@ -70,6 +70,8 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title)
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
+                    fCommonInput(NULL),
+                    fCommonOutput(NULL),
                     fSelector(NULL),
                     fGridHandler(NULL)
 {
                     fSelector(NULL),
                     fGridHandler(NULL)
 {
@@ -104,6 +106,8 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other)
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
+                    fCommonInput(NULL),
+                    fCommonOutput(NULL),
                     fSelector(NULL),
                     fGridHandler(NULL)
 {
                     fSelector(NULL),
                     fGridHandler(NULL)
 {
@@ -139,6 +143,8 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe
       fContainers = new TObjArray(*other.fContainers);
       fInputs     = new TObjArray(*other.fInputs);
       fOutputs    = new TObjArray(*other.fOutputs);
       fContainers = new TObjArray(*other.fContainers);
       fInputs     = new TObjArray(*other.fInputs);
       fOutputs    = new TObjArray(*other.fOutputs);
+      fCommonInput = NULL;
+      fCommonOutput = NULL;
       fSelector   = NULL;
       fGridHandler = NULL;
       fgAnalysisManager = this;
       fSelector   = NULL;
       fGridHandler = NULL;
       fgAnalysisManager = this;
@@ -841,6 +847,10 @@ Bool_t AliAnalysisManager::ConnectInput(AliAnalysisTask *task, Int_t islot,
                                         AliAnalysisDataContainer *cont)
 {
 // Connect input of an existing task to a data container.
                                         AliAnalysisDataContainer *cont)
 {
 // Connect input of an existing task to a data container.
+   if (!task) {
+      Error("ConnectInput", "Task pointer is NULL");
+      return kFALSE;
+   }   
    if (!fTasks->FindObject(task)) {
       AddTask(task);
       Info("ConnectInput", "Task %s was not registered. Now owned by analysis manager", task->GetName());
    if (!fTasks->FindObject(task)) {
       AddTask(task);
       Info("ConnectInput", "Task %s was not registered. Now owned by analysis manager", task->GetName());
@@ -854,6 +864,10 @@ Bool_t AliAnalysisManager::ConnectOutput(AliAnalysisTask *task, Int_t islot,
                                         AliAnalysisDataContainer *cont)
 {
 // Connect output of an existing task to a data container.
                                         AliAnalysisDataContainer *cont)
 {
 // Connect output of an existing task to a data container.
+   if (!task) {
+      Error("ConnectOutput", "Task pointer is NULL");
+      return kFALSE;
+   }   
    if (!fTasks->FindObject(task)) {
       AddTask(task);
       Warning("ConnectOutput", "Task %s not registered. Now owned by analysis manager", task->GetName());
    if (!fTasks->FindObject(task)) {
       AddTask(task);
       Warning("ConnectOutput", "Task %s not registered. Now owned by analysis manager", task->GetName());
@@ -1280,3 +1294,19 @@ void AliAnalysisManager::FinishAnalysis()
 {
 // Finish analysis.
 }
 {
 // Finish analysis.
 }
+
+//______________________________________________________________________________
+void AliAnalysisManager::SetInputEventHandler(AliVEventHandler*  handler)
+{
+// Set the input event handler and create a container for it.
+   fInputEventHandler   = handler;
+   fCommonInput = CreateContainer("cinput", TChain::Class(), AliAnalysisManager::kInputContainer);
+}
+
+//______________________________________________________________________________
+void AliAnalysisManager::SetOutputEventHandler(AliVEventHandler*  handler)
+{
+// Set the input event handler and create a container for it.
+   fOutputEventHandler   = handler;
+   fCommonOutput = CreateContainer("coutput", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");
+}