]>
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 { | |
327eaf46 | 28 | public: |
29 | enum EAnalysisTaskFlags { | |
30 | kTaskUsed = BIT(14), | |
31 | kTaskZombie = BIT(15), | |
32 | kTaskChecked = BIT(16) | |
33 | }; | |
34 | ||
35 | AliAnalysisTask(); | |
36 | AliAnalysisTask(const char *name, const char *title); | |
37 | AliAnalysisTask(const AliAnalysisTask &task); | |
38 | virtual ~AliAnalysisTask(); | |
39 | ||
40 | // Assignment | |
41 | AliAnalysisTask& operator=(const AliAnalysisTask &task); | |
42 | // Conect inputs/outputs to data containers (by AliAnalysisModule) | |
43 | Bool_t ConnectInput(Int_t islot, AliAnalysisDataContainer *cont); | |
44 | Bool_t ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont); | |
45 | // Check connectivity | |
46 | Bool_t AreSlotsConnected(); | |
47 | // Check if data for all inputs is ready | |
48 | void CheckNotify(Bool_t init=kFALSE); | |
49 | // Check if there are illegal circular dependencies | |
50 | Bool_t CheckCircularDeps(); | |
51 | // Getters | |
52 | Int_t GetNinputs() const {return fNinputs;} | |
53 | Int_t GetNoutputs() const {return fNoutputs;} | |
54 | TObject *GetPublishedData() const {return fPublishedData;} | |
55 | AliAnalysisDataSlot *GetInputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fInputs->At(islot);} | |
56 | AliAnalysisDataSlot *GetOutputSlot(Int_t islot) const {return (AliAnalysisDataSlot*)fOutputs->At(islot);} | |
57 | TClass *GetInputType(Int_t islot) const; | |
58 | TClass *GetOutputType(Int_t islot) const; | |
59 | // === USE THIS TO RETREIVE INPUT DATA AND STATICALLY CAST IT TO THE DECLARED TYPE | |
60 | TObject *GetInputData(Int_t islot) const; | |
61 | Bool_t IsOutputReady(Int_t islot) const {return fOutputReady[islot];} | |
62 | Bool_t IsChecked() const {return TObject::TestBit(kTaskChecked);} | |
63 | Bool_t IsInitialized() const {return fInitialized;} | |
64 | Bool_t IsReady() const {return fReady;} | |
65 | Bool_t IsUsed() const {return TObject::TestBit(kTaskUsed);} | |
66 | Bool_t IsZombie() const {return TObject::TestBit(kTaskZombie);} | |
67 | void PrintTask(Option_t *option="all", Int_t indent=0) const; | |
68 | void PrintContainers(Option_t *option="all", Int_t indent=0) const; | |
69 | void SetChecked(Bool_t flag=kTRUE) {TObject::SetBit(kTaskChecked,flag);} | |
70 | void SetUsed(Bool_t flag=kTRUE); | |
71 | void SetZombie(Bool_t flag=kTRUE) {TObject::SetBit(kTaskZombie,flag);} | |
72 | // Main task execution | |
73 | //=== IMPLEMENT THIS !!! ============================================== | |
74 | virtual void Exec(Option_t *option) = 0; | |
75 | //===================================================================== | |
76 | Bool_t HasExecuted() const {return fHasExecuted;} | |
77 | //===================================================================== | |
78 | // === OVERLOAD THIS IF YOU WANT TO DO SOMETHING WITH THE OUTPUT | |
79 | virtual void Terminate(Option_t *option=""); | |
80 | //===================================================================== | |
81 | ||
82 | protected: | |
83 | // Define the input/output slots (called by user in the ctor of the derived class) | |
84 | //=== CALL IN THE CONSTRUCTOR OF DERIVED CLASS TO DEFINE INPUTS/OUTPUTS === | |
85 | void DefineInput(Int_t islot, TClass *type); | |
86 | void DefineOutput(Int_t islot, TClass *type); | |
87 | //===================================================================== | |
88 | ||
89 | //===================================================================== | |
90 | // === OVERLOAD THIS TO CONNECT TREE BRANCHES AT INPUT SLOTS. YOU | |
91 | // SHOULD DEFINE HERE ALSO THE OBJECTS TO BE CONNECTED TO YOUR OUTPUTS | |
92 | virtual void Init(Option_t *option=""); | |
93 | //===================================================================== | |
94 | ||
95 | // Post output data (called by Exec() when data is ready) | |
96 | //=== CALL IN EXEC() FOR EACH OUTPUT WHEN READY === | |
97 | Bool_t PostData(Int_t iout, TObject *data, Option_t *option=""); | |
98 | //===================================================================== | |
99 | ||
100 | // === USE THIS FIRST IN YOUR Init() TO CHECH IF A BRANCH IS ALREADY CONNECTED | |
101 | // TO SOME ADDRESS. | |
102 | char *GetBranchAddress(Int_t islot, const char *branch) const; | |
103 | // === CALL THIS AFTERWARDS IN Init() IF THE BRANCH ADDRESS IS NOT YET SET | |
104 | Bool_t SetBranchAddress(Int_t islot, const char *branch, void *address) const; | |
105 | //===================================================================== | |
106 | // === CALL THIS IN INIT IF THE OUTPUT IS TO BE WRITTEN AT OUTPUT IOUT | |
107 | void OpenFile(Int_t iout, const char *name, Option_t *option) const; | |
108 | ||
109 | Bool_t fReady; // Flag if the task is ready | |
110 | Bool_t fInitialized; // True if Init() was called | |
111 | Int_t fNinputs; // Number of inputs | |
112 | Int_t fNoutputs; // Number of outputs | |
113 | Bool_t *fOutputReady; //[fNoutputs] Flags for output readyness | |
114 | TObject *fPublishedData; // !published data | |
115 | TObjArray *fInputs; // Array of input slots | |
116 | TObjArray *fOutputs; // Array of output slots | |
117 | ||
118 | ClassDef(AliAnalysisTask,2) // Class describing an analysis task | |
d3106602 | 119 | }; |
120 | #endif |