Added support for retrieving and merging dAOD's. The producer task has to call AliAna...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisManager.h
index 771a494..32e3d05 100644 (file)
 // event for all tasks depending only on initial input data.
 //==============================================================================
 
-#ifndef ROOT_TSelector
-#include "TSelector.h"
+#ifndef ROOT_TNamed
+#include <TNamed.h>
 #endif
 
 class TClass;
+class TTree;
+class TFile;
+class AliAnalysisSelector;
 class AliAnalysisDataContainer;
 class AliAnalysisTask;
+class AliVEventHandler;
+class AliVEventPool;
+class AliAnalysisGrid;
 
-class AliAnalysisManager : public TSelector {
+
+class AliAnalysisManager : public TNamed {
 
 public:
 
 enum EAliAnalysisContType {
-   kNormalContainer  = 0,
+   kExchangeContainer  = 0,
    kInputContainer   = 1,
    kOutputContainer  = 2
 };   
-   AliAnalysisManager();
+
+enum EAliAnalysisExecMode {
+   kLocalAnalysis    = 0,
+   kProofAnalysis    = 1,
+   kGridAnalysis     = 2,
+   kMixingAnalysis   = 3
+};
+
+enum EAliAnalysisFlags {
+   kEventLoop        = BIT(14),
+   kDisableBranches  = BIT(15),
+   kUseDataSet       = BIT(16)
+};   
+
+   AliAnalysisManager(const char *name = "mgr", const char *title="");
    virtual            ~AliAnalysisManager();
+
+   AliAnalysisManager(const AliAnalysisManager& other);
+   AliAnalysisManager& operator=(const AliAnalysisManager& other);
    
-   // Selector-specific methods
-   virtual void        Init(TTree *tree);   
-   virtual void        Begin(TTree *tree);
+   // Management methods called by the framework
+   void                StartAnalysis(const char *type="local", TTree *tree=0, Long64_t nentries=1234567890, Long64_t firstentry=0);
+   void                StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0);
+
+   virtual Bool_t      Init(TTree *tree);   
+   virtual Bool_t      Notify();
    virtual void        SlaveBegin(TTree *tree);
+   virtual Bool_t      ProcessCut(Long64_t entry) {return Process(entry);}
    virtual Bool_t      Process(Long64_t entry);
-   virtual void        SlaveTerminate();
+   virtual Int_t       GetEntry(Long64_t entry, Int_t getall = 0);
+   TFile              *OpenProofFile(const char *name, const char *option);
+   void                PackOutput(TList *target);
+   void                UnpackOutput(TList *source);
    virtual void        Terminate();
 
-   // Getters
+   // Getters/Setters
+   static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;}
    TObjArray          *GetContainers() const {return fContainers;}
+   UInt_t              GetDebugLevel() const {return fDebug;}
    TObjArray          *GetInputs() const     {return fInputs;}
    TObjArray          *GetOutputs() const    {return fOutputs;}
    TObjArray          *GetTasks() const      {return fTasks;}
    TObjArray          *GetTopTasks() const   {return fTopTasks;}
+   TTree              *GetTree() const       {return fTree;}
    TObjArray          *GetZombieTasks() const {return fZombies;}
-//   AliAnalysisInfo    *GetStatus() const     {return fStatus;}  
+   Long64_t            GetCurrentEntry() const {return fCurrentEntry;}
+   EAliAnalysisExecMode 
+                       GetAnalysisType() const {return fMode;}
+   Bool_t              IsUsingDataSet() const  {return TObject::TestBit(kUseDataSet);}
+
+   void                RegisterExtraFile(const char *fname);
+   void                SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;}
+   void                SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;}
+   void                SetDebugLevel(UInt_t level) {fDebug = level;}
+   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);
+   void                SetOutputEventHandler(AliVEventHandler*  handler);
+   void                SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;}
+   void                SetGridHandler(AliAnalysisGrid *handler) {fGridHandler = handler;}
+   void                SetEventPool(AliVEventPool* epool) {fEventPool = epool;}
+   void                SetNSysInfo(Long64_t nevents) {fNSysInfo = nevents;}
+   void                SetSelector(AliAnalysisSelector *sel) {fSelector = sel;}
+   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;}
+   Bool_t              GetFileFromWrapper(const char *filename, TList *source);
+   TString             GetExtraFiles() const {return fExtraFiles;}
 
    // Container handling
    AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype, 
-                                EAliAnalysisContType type=kNormalContainer);
+                       EAliAnalysisContType type     = kExchangeContainer, 
+                       const char          *filename = NULL);
    
    // Including tasks and getting them
    void                 AddTask(AliAnalysisTask *task);
@@ -69,26 +131,41 @@ enum EAliAnalysisContType {
    // Analysis initialization and execution, status
    Bool_t               InitAnalysis();
    Bool_t               IsInitialized() const {return fInitOK;}
+   Bool_t               IsEventLoop() const {return TObject::TestBit(kEventLoop);}
    void                 ResetAnalysis();
    void                 ExecAnalysis(Option_t *option="");
    void                 FinishAnalysis();
    void                 PrintStatus(Option_t *option="all") const;
 
 protected:
-   Bool_t               fInitOK;       // Initialisation done
-   TObjArray           *fContainers;   //-> List of all containers
-   TObjArray           *fInputs;       //-> List of containers with input data
-   TObjArray           *fOutputs;      //-> List of containers with results
-   TObjArray           *fTasks;        //-> List of analysis tasks
-   TObjArray           *fTopTasks;     //-> List of top tasks
-   TObjArray           *fZombies;      //-> List of zombie tasks
-//   AliAnalysisInfo     *fStatus;       // Analysis info object
+   void                 ImportWrappers(TList *source);
+   void                 SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);}
 
 private:
-   AliAnalysisManager(const AliAnalysisManager& other);
-   AliAnalysisManager& operator=(const AliAnalysisManager& other);
-
+   TTree                  *fTree;                //! Input tree in case of TSelector model
+   AliVEventHandler       *fInputEventHandler;   //  Optional common input  event handler
+   AliVEventHandler       *fOutputEventHandler;  //  Optional common output event handler
+   AliVEventHandler       *fMCtruthEventHandler; //  Optional common MC Truth event handler
+   AliVEventPool          *fEventPool;           //  Event pool for mixing analysis
+   Long64_t                fCurrentEntry;        //! Current processed entry in the tree
+   Long64_t                fNSysInfo;            // Event frequency for collecting system information
+   EAliAnalysisExecMode    fMode;                // Execution mode
+   Bool_t                  fInitOK;              // Initialisation done
+   UInt_t                  fDebug;               // Debug level
+   TString                 fSpecialOutputLocation; // URL/path where the special outputs will be copied
+   TObjArray              *fTasks;               // List of analysis tasks
+   TObjArray              *fTopTasks;            // List of top tasks
+   TObjArray              *fZombies;             // List of zombie tasks
+   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
+   TString                 fExtraFiles;          //! List of extra files to be merged
 
-   ClassDef(AliAnalysisManager,1)  // Analysis manager class
+   static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
+   ClassDef(AliAnalysisManager,4)  // Analysis manager class
 };   
 #endif