- Common input and output data containers are now created automatically when attachin...
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Feb 2009 13:53:19 +0000 (13:53 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Feb 2009 13:53:19 +0000 (13:53 +0000)
   mgr->ConnectInput(myTask, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(myTask, iout, mgr->GetCommonOutputContainer());
 (M. Gheata)
- Protection added in AliAnalysisTaskSE for user tasks that are not connected to an output AOD container.
- Protection added in AliAnalysisManager::ConnectInput/Output() when the task pointer is NULL

ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisManager.h
ANALYSIS/AliAnalysisTaskSE.cxx

index 51ca9df..5f5c70f 100644 (file)
@@ -70,6 +70,8 @@ AliAnalysisManager::AliAnalysisManager(const char *name, const char *title)
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
+                    fCommonInput(NULL),
+                    fCommonOutput(NULL),
                     fSelector(NULL),
                     fGridHandler(NULL)
 {
@@ -104,6 +106,8 @@ AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other)
                     fContainers(NULL),
                     fInputs(NULL),
                     fOutputs(NULL),
+                    fCommonInput(NULL),
+                    fCommonOutput(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);
+      fCommonInput = NULL;
+      fCommonOutput = NULL;
       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.
+   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());
@@ -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.
+   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());
@@ -1280,3 +1294,19 @@ void AliAnalysisManager::FinishAnalysis()
 {
 // 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");
+}
index 3c95aa4..e7c92f5 100644 (file)
@@ -93,8 +93,8 @@ enum EAliAnalysisFlags {
    void                SetSpecialOutputLocation(const char *location) {fSpecialOutputLocation = location;}
    void                SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);}
    void                SetCollectSysInfoEach(Int_t nevents=0) {fNSysInfo = nevents;}
-   void                SetInputEventHandler(AliVEventHandler*  handler)  {fInputEventHandler   = handler;}
-   void                SetOutputEventHandler(AliVEventHandler*  handler) {fOutputEventHandler  = handler;}
+   void                SetInputEventHandler(AliVEventHandler*  handler);
+   void                SetOutputEventHandler(AliVEventHandler*  handler);
    void                SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;}
    void                SetGridHandler(AliAnalysisGrid *handler) {fGridHandler = handler;}
    void                SetEventPool(AliVEventPool* epool) {fEventPool = epool;}
@@ -103,6 +103,8 @@ enum EAliAnalysisFlags {
    AliVEventHandler*   GetInputEventHandler()   {return fInputEventHandler;}
    AliVEventHandler*   GetOutputEventHandler()  {return fOutputEventHandler;}
    AliVEventHandler*   GetMCtruthEventHandler() {return fMCtruthEventHandler;}
+   AliAnalysisDataContainer *GetCommonInputContainer() {return fCommonInput;}
+   AliAnalysisDataContainer *GetCommonOutputContainer() {return fCommonOutput;}
    AliAnalysisGrid*    GetGridHandler()         {return fGridHandler;}
    AliVEventPool*      GetEventPool()           {return fEventPool;}
 
@@ -154,10 +156,12 @@ private:
    TObjArray              *fContainers;          // List of all containers
    TObjArray              *fInputs;              // List of containers with input data
    TObjArray              *fOutputs;             // List of containers with results
+   AliAnalysisDataContainer *fCommonInput;       // Common input container
+   AliAnalysisDataContainer *fCommonOutput;      // Common output container
    AliAnalysisSelector    *fSelector;            //! Current selector
    AliAnalysisGrid        *fGridHandler;         //! Grid handler plugin
 
    static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
-   ClassDef(AliAnalysisManager,3)  // Analysis manager class
+   ClassDef(AliAnalysisManager,4)  // Analysis manager class
 };   
 #endif
index 96bf8e1..a458069 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AliAnalysisTaskSE.h"
 #include "AliAnalysisManager.h"
+#include "AliAnalysisDataSlot.h"
 #include "AliESDEvent.h"
 #include "AliESD.h"
 #include "AliAODEvent.h"
@@ -299,8 +300,9 @@ void AliAnalysisTaskSE::Exec(Option_t* option)
 
 // Call the user analysis    
     UserExec(option);
-    PostData(0, fTreeA);
-    
+    // Added protection in case the derived task is not an AOD producer.
+    AliAnalysisDataSlot *out0 = GetOutputSlot(0);
+    if (out0 && out0->IsConnected()) PostData(0, fTreeA);    
 }
 
 const char* AliAnalysisTaskSE::CurrentFileName()