Temporary: do not link AliHLTMUON.so
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTask.h
CommitLineData
d3106602 1#ifndef ALIANALYSISTASK_H
2#define ALIANALYSISTASK_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7// Author: Andrei Gheata, 31/05/2006
8
9//==============================================================================
10// AliAnalysysTask - Class representing a basic analysis task. Any
11// user-defined task should derive from it and implement the Exec() virtual
12// method.
13//==============================================================================
14
15#ifndef ROOT_TTask
16#include "TTask.h"
17#endif
18
19#ifndef ROOT_TObjArray
20#include "TObjArray.h"
21#endif
22
23class TClass;
24class AliAnalysisDataSlot;
25class AliAnalysisDataContainer;
26
27class AliAnalysisTask : public TTask {
327eaf46 28 public:
29 enum EAnalysisTaskFlags {
30 kTaskUsed = BIT(14),
31 kTaskZombie = BIT(15),
c5a87c56 32 kTaskChecked = BIT(16),
b1310ef5 33 kTaskPostEventLoop = BIT(17)
c5a87c56 34 };
c52c2132 35
36 protected:
37153431 37 Bool_t fReady; // Flag if the task is ready
38 Bool_t fInitialized; // True if Init() was called
39 Int_t fNinputs; // Number of inputs
40 Int_t fNoutputs; // Number of outputs
41 Bool_t *fOutputReady; //[fNoutputs] Flags for output readyness
42 TObject *fPublishedData; //! published data
43 TObjArray *fInputs; // Array of input slots
44 TObjArray *fOutputs; // Array of output slots
c52c2132 45
46 // Define the input/output slots (called by user in the ctor of the derived class)
47 //=== CALL IN THE CONSTRUCTOR OF DERIVED CLASS TO DEFINE INPUTS/OUTPUTS ===
48 void DefineInput(Int_t islot, TClass *type);
49 void DefineOutput(Int_t islot, TClass *type);
50 //=====================================================================
51
52 //=====================================================================
53 // === OVERLOAD THIS TO CONNECT TREE BRANCHES AT INPUT SLOTS. YOU
54 // SHOULD DEFINE HERE ALSO THE OBJECTS TO BE CONNECTED TO YOUR OUTPUTS
55 virtual void ConnectInputData(Option_t *option="");
56 //=====================================================================
57
58 // Post output data (called by Exec() when data is ready)
59 //=== CALL IN EXEC() FOR EACH OUTPUT WHEN READY ===
60 Bool_t PostData(Int_t iout, TObject *data, Option_t *option="");
61 //=====================================================================
327eaf46 62
b1310ef5 63 // === USE THIS FIRST IN YOUR ConnectInputData() TO CHECH IF A BRANCH IS ALREADY CONNECTED
c52c2132 64 // TO SOME ADDRESS.
65 char *GetBranchAddress(Int_t islot, const char *branch) const;
b1310ef5 66 // === CALL THIS AFTERWARDS IN ConnectInputData() IF THE BRANCH ADDRESS IS NOT YET SET
c52c2132 67 Bool_t SetBranchAddress(Int_t islot, const char *branch, void *address) const;
68 //=====================================================================
b1310ef5 69 //=== CALL IN ConnectInputData() TO ENABLE ONLY EXPLICIT BRANCHES NEEDED FOR THIS TASK EXECUTION
70 void EnableBranch(Int_t islot, const char *bname) const;
71 //=====================================================================
c5a87c56 72 // === CALL THIS IN CreateOutputObjects BEFORE CREATING THE OBJECT FOR EACH
73 // OUTPUT IOUT THAT HAS TO BE WRITTEN TO A FILE
521adffd 74 void OpenFile(Int_t iout, Option_t *option="RECREATE") const;
c52c2132 75
76public:
327eaf46 77 AliAnalysisTask();
78 AliAnalysisTask(const char *name, const char *title);
79 AliAnalysisTask(const AliAnalysisTask &task);
80 virtual ~AliAnalysisTask();
81
82 // Assignment
83 AliAnalysisTask& operator=(const AliAnalysisTask &task);
c52c2132 84 //=====================================================================
85 // === OVERLOAD THIS AND CREATE YOUR OUTPUT OBJECTS (HISTOGRAMS,DATA) HERE
86 virtual void CreateOutputObjects();
9b33830a 87 // === OVERLOAD THIS IF YOU NEED TO INITIALIZE YOUR CLASS ON THE CLIENT
88 virtual void LocalInit();
981f2614 89 // === OVERLOAD THIS IF YOU NEED TO TREAT INPUT FILE CHANGE
90 virtual Bool_t Notify();
327eaf46 91 // Conect inputs/outputs to data containers (by AliAnalysisModule)
92 Bool_t ConnectInput(Int_t islot, AliAnalysisDataContainer *cont);
93 Bool_t ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont);
94 // Check connectivity
95 Bool_t AreSlotsConnected();
96 // Check if data for all inputs is ready
97 void CheckNotify(Bool_t init=kFALSE);
98 // Check if there are illegal circular dependencies
99 Bool_t CheckCircularDeps();
100 // Getters
101 Int_t GetNinputs() const {return fNinputs;}
102 Int_t GetNoutputs() const {return fNoutputs;}
103 TObject *GetPublishedData() const {return fPublishedData;}
104 AliAnalysisDataSlot *GetInputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fInputs->At(islot);}
105 AliAnalysisDataSlot *GetOutputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fOutputs->At(islot);}
106 TClass *GetInputType(Int_t islot) const;
107 TClass *GetOutputType(Int_t islot) const;
108 // === USE THIS TO RETREIVE INPUT DATA AND STATICALLY CAST IT TO THE DECLARED TYPE
109 TObject *GetInputData(Int_t islot) const;
c52c2132 110 TObject *GetOutputData(Int_t islot) const;
327eaf46 111 Bool_t IsOutputReady(Int_t islot) const {return fOutputReady[islot];}
112 Bool_t IsChecked() const {return TObject::TestBit(kTaskChecked);}
b1310ef5 113 Bool_t IsPostEventLoop() const {return TObject::TestBit(kTaskPostEventLoop);}
327eaf46 114 Bool_t IsInitialized() const {return fInitialized;}
115 Bool_t IsReady() const {return fReady;}
116 Bool_t IsUsed() const {return TObject::TestBit(kTaskUsed);}
117 Bool_t IsZombie() const {return TObject::TestBit(kTaskZombie);}
118 void PrintTask(Option_t *option="all", Int_t indent=0) const;
119 void PrintContainers(Option_t *option="all", Int_t indent=0) const;
120 void SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);}
b1310ef5 121 void SetPostEventLoop(Bool_t flag=kTRUE);
327eaf46 122 void SetUsed(Bool_t flag=kTRUE);
123 void SetZombie(Bool_t flag=kTRUE) {TObject::SetBit(kTaskZombie,flag);}
124 // Main task execution
125 //=== IMPLEMENT THIS !!! ==============================================
126 virtual void Exec(Option_t *option) = 0;
127 //=====================================================================
128 Bool_t HasExecuted() const {return fHasExecuted;}
129 //=====================================================================
130 // === OVERLOAD THIS IF YOU WANT TO DO SOMETHING WITH THE OUTPUT
131 virtual void Terminate(Option_t *option="");
132 //=====================================================================
c52c2132 133
134 ClassDef(AliAnalysisTask,1) // Class describing an analysis task
d3106602 135};
136#endif