]>
Commit | Line | Data |
---|---|---|
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 | ||
23 | class TClass; | |
24 | class AliAnalysisDataSlot; | |
25 | class AliAnalysisDataContainer; | |
26 | ||
27 | class AliAnalysisTask : public TTask { | |
28 | public: | |
29 | enum EAnalysisTaskFlags { | |
30 | kTaskUsed = BIT(14), | |
31 | kTaskZombie = BIT(15), | |
32 | kTaskChecked = BIT(16) | |
33 | }; | |
34 | protected: | |
d3106602 | 35 | // Define the input/output slots (called by user in the ctor of the derived class) |
36 | //=== CALL IN THE CONSTRUCTOR OF DERIVED CLASS TO DEFINE INPUTS/OUTPUTS === | |
37 | void DefineInput(Int_t islot, TClass *type); | |
38 | void DefineOutput(Int_t islot, TClass *type); | |
39 | //===================================================================== | |
40 | ||
41 | // Post output data (called by Exec() when data is ready) | |
42 | //=== CALL IN EXEC() FOR EACH OUTPUT WHEN READY === | |
43 | Bool_t PostData(Int_t iout, TObject *data, Option_t *option=""); | |
44 | //===================================================================== | |
45 | ||
46 | public: | |
47 | AliAnalysisTask(); | |
48 | AliAnalysisTask(const char *name, const char *title); | |
49 | AliAnalysisTask(const AliAnalysisTask &task); | |
50 | virtual ~AliAnalysisTask(); | |
51 | ||
37a26056 | 52 | // Assignment |
53 | AliAnalysisTask& operator=(const AliAnalysisTask &task); | |
d3106602 | 54 | // Conect inputs/outputs to data containers (by AliAnalysisModule) |
55 | Bool_t ConnectInput(Int_t islot, AliAnalysisDataContainer *cont); | |
56 | Bool_t ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont); | |
57 | // Check connectivity | |
58 | Bool_t AreSlotsConnected(); | |
59 | // Check if data for all inputs is ready | |
60 | void CheckNotify(); | |
61 | // Check if there are illegal circular dependencies | |
62 | Bool_t CheckCircularDeps(); | |
63 | // Getters | |
64 | Int_t GetNinputs() const {return fNinputs;} | |
65 | Int_t GetNoutputs() const {return fNoutputs;} | |
66 | TObject *GetPublishedData() const {return fPublishedData;} | |
67 | AliAnalysisDataSlot *GetInputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fInputs->At(islot);} | |
68 | AliAnalysisDataSlot *GetOutputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fOutputs->At(islot);} | |
69 | TClass *GetInputType(Int_t islot) const; | |
70 | TClass *GetOutputType(Int_t islot) const; | |
71 | // === USE THIS TO RETREIVE INPUT DATA AND STATICALLY CAST IT TO THE DECLARED TYPE | |
72 | TObject *GetInputData(Int_t islot) const; | |
73 | //===================================================================== | |
74 | Bool_t IsOutputReady(Int_t islot) const {return fOutputReady[islot];} | |
75 | Bool_t IsChecked() const {return TObject::TestBit(kTaskChecked);} | |
76 | Bool_t IsReady() const {return fReady;} | |
77 | Bool_t IsUsed() const {return TObject::TestBit(kTaskUsed);} | |
78 | Bool_t IsZombie() const {return TObject::TestBit(kTaskZombie);} | |
79 | void PrintTask(Option_t *option="all", Int_t indent=0) const; | |
80 | void PrintContainers(Option_t *option="all", Int_t indent=0) const; | |
81 | void SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);} | |
82 | void SetUsed(Bool_t flag=kTRUE); | |
83 | void SetZombie(Bool_t flag=kTRUE) {TObject::SetBit(kTaskZombie,flag);} | |
84 | // Main task execution | |
85 | //=== IMPLEMENT THIS !!! ============================================== | |
86 | virtual void Exec(Option_t *option) = 0; | |
87 | //===================================================================== | |
88 | Bool_t HasExecuted() const {return fHasExecuted;} | |
89 | ||
90 | protected: | |
91 | Bool_t fReady; // Flag if the task is ready | |
92 | Int_t fNinputs; // Number of inputs | |
93 | Int_t fNoutputs; // Number of outputs | |
94 | Bool_t *fOutputReady; //[fNoutputs] Flags for output readyness | |
95 | TObject *fPublishedData; // !published data | |
96 | TObjArray *fInputs; // Array of input slots | |
97 | TObjArray *fOutputs; // Array of output slots | |
98 | ||
99 | ClassDef(AliAnalysisTask,1) // Class describing an analysis task | |
100 | }; | |
101 | #endif |