]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliAnalysisTask.h
- Implementation of post-event loop tasks (Mihaela Gheata)
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTask.h
index 35bfd1b63f118b0a6a880e537920320fbee30365..37f93c65bf0571100cb6a06b1e176525f0d9c12b 100644 (file)
@@ -29,18 +29,19 @@ class AliAnalysisTask : public TTask {
   enum EAnalysisTaskFlags {
     kTaskUsed    = BIT(14),
     kTaskZombie  = BIT(15),
-    kTaskChecked = BIT(16)
-  };   
+    kTaskChecked = BIT(16),
+    kTaskPostEventLoop = BIT(17)
+  };
 
  protected:
-  Bool_t                    fReady;      // Flag if the task is ready
-  Bool_t                    fInitialized; // True if Init() was called
-  Int_t                     fNinputs;    // Number of inputs
-  Int_t                     fNoutputs;   // Number of outputs
-  Bool_t                   *fOutputReady; //[fNoutputs] Flags for output readyness
-  TObject                  *fPublishedData; // !published data
-  TObjArray                *fInputs;     // Array of input slots
-  TObjArray                *fOutputs;    // Array of output slots
+  Bool_t                    fReady;         // Flag if the task is ready
+  Bool_t                    fInitialized;   // True if Init() was called
+  Int_t                     fNinputs;       // Number of inputs
+  Int_t                     fNoutputs;      // Number of outputs
+  Bool_t                   *fOutputReady;   //[fNoutputs] Flags for output readyness
+  TObject                  *fPublishedData; //published data
+  TObjArray                *fInputs;        // Array of input slots
+  TObjArray                *fOutputs;       // Array of output slots
 
   // Define the input/output slots (called by user in the ctor of the derived class)
   //=== CALL IN THE CONSTRUCTOR OF DERIVED CLASS TO DEFINE INPUTS/OUTPUTS ===
@@ -59,14 +60,18 @@ class AliAnalysisTask : public TTask {
   Bool_t                    PostData(Int_t iout, TObject *data, Option_t *option="");
   //=====================================================================
   
-  // === USE THIS FIRST IN YOUR Init() TO CHECH IF A BRANCH IS ALREADY CONNECTED
+  // === USE THIS FIRST IN YOUR ConnectInputData() TO CHECH IF A BRANCH IS ALREADY CONNECTED
   // TO SOME ADDRESS.
   char                     *GetBranchAddress(Int_t islot, const char *branch) const;
-  // === CALL THIS AFTERWARDS IN Init() IF THE BRANCH ADDRESS IS NOT YET SET
+  // === CALL THIS AFTERWARDS IN ConnectInputData() IF THE BRANCH ADDRESS IS NOT YET SET
   Bool_t                    SetBranchAddress(Int_t islot, const char *branch, void *address) const;
   //=====================================================================
-  // === CALL THIS IN CreateOutputObjects IF THE OUTPUT IS TO BE WRITTEN AT OUTPUT IOUT
-//  void                      OpenFile(Int_t iout, const char *name, Option_t *option) const;
+  //=== CALL IN ConnectInputData() TO ENABLE ONLY EXPLICIT BRANCHES NEEDED FOR THIS TASK EXECUTION
+  void                      EnableBranch(Int_t islot, const char *bname) const;
+  //=====================================================================
+  // === CALL THIS IN CreateOutputObjects BEFORE CREATING THE OBJECT FOR EACH 
+  // OUTPUT IOUT THAT HAS TO BE WRITTEN TO A FILE
+  void                      OpenFile(Int_t iout, Option_t *option="RECREATE") const;
   
 public:  
   AliAnalysisTask();
@@ -79,6 +84,10 @@ public:
   //=====================================================================
   // === OVERLOAD THIS AND CREATE YOUR OUTPUT OBJECTS (HISTOGRAMS,DATA) HERE
   virtual void              CreateOutputObjects();
+  // === OVERLOAD THIS IF YOU NEED TO INITIALIZE YOUR CLASS ON THE CLIENT
+  virtual void              LocalInit();
+  // === OVERLOAD THIS IF YOU NEED TO TREAT INPUT FILE CHANGE
+  virtual Bool_t            Notify();
   // Conect inputs/outputs to data containers (by AliAnalysisModule)
   Bool_t                    ConnectInput(Int_t islot, AliAnalysisDataContainer *cont);
   Bool_t                    ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont);
@@ -101,6 +110,7 @@ public:
   TObject                  *GetOutputData(Int_t islot) const;  
   Bool_t                    IsOutputReady(Int_t islot) const {return fOutputReady[islot];}
   Bool_t                    IsChecked() const  {return TObject::TestBit(kTaskChecked);}
+  Bool_t                    IsPostEventLoop() const {return TObject::TestBit(kTaskPostEventLoop);}
   Bool_t                    IsInitialized() const  {return fInitialized;}
   Bool_t                    IsReady() const  {return fReady;}
   Bool_t                    IsUsed() const   {return TObject::TestBit(kTaskUsed);}
@@ -108,6 +118,7 @@ public:
   void                      PrintTask(Option_t *option="all", Int_t indent=0) const;
   void                      PrintContainers(Option_t *option="all", Int_t indent=0) const;
   void                      SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);}
+  void                      SetPostEventLoop(Bool_t flag=kTRUE);
   void                      SetUsed(Bool_t flag=kTRUE);
   void                      SetZombie(Bool_t flag=kTRUE) {TObject::SetBit(kTaskZombie,flag);}
   // Main task execution