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