]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALIANALYSISMANAGER_H | |
2 | #define ALIANALYSISMANAGER_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 | // AliAnalysysManager - Manager analysis class. Allows creation of several | |
11 | // analysis tasks and data containers storing their input/output. Allows | |
12 | // connecting/chaining tasks via shared data containers. Serializes the current | |
13 | // event for all tasks depending only on initial input data. | |
14 | //============================================================================== | |
15 | ||
16 | #ifndef ROOT_TNamed | |
17 | #include <TNamed.h> | |
18 | #endif | |
19 | ||
20 | class TClass; | |
21 | class TTree; | |
22 | class AliAnalysisDataContainer; | |
23 | class AliAnalysisTask; | |
24 | class AliVEventHandler; | |
25 | ||
26 | ||
27 | class AliAnalysisManager : public TNamed { | |
28 | ||
29 | public: | |
30 | ||
31 | enum EAliAnalysisContType { | |
32 | kExchangeContainer = 0, | |
33 | kInputContainer = 1, | |
34 | kOutputContainer = 2 | |
35 | }; | |
36 | ||
37 | enum EAliAnalysisExecMode { | |
38 | kLocalAnalysis = 0, | |
39 | kProofAnalysis = 1, | |
40 | kGridAnalysis = 2 | |
41 | }; | |
42 | ||
43 | enum EAliAnalysisFlags { | |
44 | kEventLoop = BIT(14), | |
45 | kDisableBranches = BIT(15) | |
46 | }; | |
47 | ||
48 | AliAnalysisManager(); | |
49 | AliAnalysisManager(const char *name, const char *title=""); | |
50 | virtual ~AliAnalysisManager(); | |
51 | ||
52 | AliAnalysisManager(const AliAnalysisManager& other); | |
53 | AliAnalysisManager& operator=(const AliAnalysisManager& other); | |
54 | ||
55 | void StartAnalysis(const char *type="local", TTree *tree=0); | |
56 | ||
57 | virtual void Init(TTree *tree); | |
58 | virtual void Begin(TTree *tree); | |
59 | virtual Bool_t Notify(); | |
60 | virtual void SlaveBegin(TTree *tree); | |
61 | virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);} | |
62 | virtual Bool_t Process(Long64_t entry); | |
63 | virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0); | |
64 | void PackOutput(TList *target); | |
65 | void UnpackOutput(TList *source); | |
66 | virtual void Terminate(); | |
67 | ||
68 | // Getters/Setters | |
69 | static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;} | |
70 | TObjArray *GetContainers() const {return fContainers;} | |
71 | UInt_t GetDebugLevel() const {return fDebug;} | |
72 | TObjArray *GetInputs() const {return fInputs;} | |
73 | TObjArray *GetOutputs() const {return fOutputs;} | |
74 | TObjArray *GetTasks() const {return fTasks;} | |
75 | TObjArray *GetTopTasks() const {return fTopTasks;} | |
76 | TTree *GetTree() const {return fTree;} | |
77 | TObjArray *GetZombieTasks() const {return fZombies;} | |
78 | Long64_t GetCurrentEntry() const {return fCurrentEntry;} | |
79 | EAliAnalysisExecMode | |
80 | GetAnalysisType() const {return fMode;} | |
81 | ||
82 | void SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;} | |
83 | void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;} | |
84 | void SetDebugLevel(UInt_t level) {fDebug = level;} | |
85 | void SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);} | |
86 | void SetInputEventHandler(AliVEventHandler* handler) {fInputEventHandler = handler;} | |
87 | void SetOutputEventHandler(AliVEventHandler* handler) {fOutputEventHandler = handler;} | |
88 | void SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;} | |
89 | AliVEventHandler* GetInputEventHandler() {return fInputEventHandler;} | |
90 | AliVEventHandler* GetOutputEventHandler() {return fOutputEventHandler;} | |
91 | AliVEventHandler* GetMCtruthEventHandler() {return fMCtruthEventHandler;} | |
92 | ||
93 | // Container handling | |
94 | AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype, | |
95 | EAliAnalysisContType type = kExchangeContainer, | |
96 | const char *filename = NULL); | |
97 | ||
98 | // Including tasks and getting them | |
99 | void AddTask(AliAnalysisTask *task); | |
100 | AliAnalysisTask *GetTask(const char *name) const; | |
101 | ||
102 | // Connecting data containers to task inputs/outputs | |
103 | Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot, | |
104 | AliAnalysisDataContainer *cont); | |
105 | Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot, | |
106 | AliAnalysisDataContainer *cont); | |
107 | // Garbage collection | |
108 | void CleanContainers(); | |
109 | ||
110 | // Analysis initialization and execution, status | |
111 | Bool_t InitAnalysis(); | |
112 | Bool_t IsInitialized() const {return fInitOK;} | |
113 | Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);} | |
114 | void ResetAnalysis(); | |
115 | void ExecAnalysis(Option_t *option=""); | |
116 | void FinishAnalysis(); | |
117 | void PrintStatus(Option_t *option="all") const; | |
118 | ||
119 | protected: | |
120 | void ImportWrappers(TList *source); | |
121 | void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);} | |
122 | ||
123 | private: | |
124 | TTree *fTree; //! Input tree in case of TSelector model | |
125 | AliVEventHandler *fInputEventHandler; // Optional common input event handler | |
126 | AliVEventHandler *fOutputEventHandler; // Optional common output event handler | |
127 | AliVEventHandler *fMCtruthEventHandler; // Optional common MC Truth event handler | |
128 | Long64_t fCurrentEntry; //! Current processed entry in the tree | |
129 | EAliAnalysisExecMode fMode; // Execution mode | |
130 | Bool_t fInitOK; // Initialisation done | |
131 | UInt_t fDebug; // Debug level | |
132 | TObjArray *fTasks; // List of analysis tasks | |
133 | TObjArray *fTopTasks; // List of top tasks | |
134 | TObjArray *fZombies; // List of zombie tasks | |
135 | TObjArray *fContainers; // List of all containers | |
136 | TObjArray *fInputs; // List of containers with input data | |
137 | TObjArray *fOutputs; // List of containers with results | |
138 | ||
139 | static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance | |
140 | ClassDef(AliAnalysisManager,1) // Analysis manager class | |
141 | }; | |
142 | #endif |