]>
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; |
8d7d3b59 | 22 | class TFile; |
23 | class AliAnalysisSelector; | |
d3106602 | 24 | class AliAnalysisDataContainer; |
25 | class AliAnalysisTask; | |
d2f1d9ef | 26 | class AliVEventHandler; |
c2922515 | 27 | class AliVEventPool; |
c57f56b7 | 28 | class AliAnalysisGrid; |
8c9485b2 | 29 | |
d3106602 | 30 | |
c52c2132 | 31 | class AliAnalysisManager : public TNamed { |
d3106602 | 32 | |
33 | public: | |
34 | ||
35 | enum EAliAnalysisContType { | |
c52c2132 | 36 | kExchangeContainer = 0, |
d3106602 | 37 | kInputContainer = 1, |
38 | kOutputContainer = 2 | |
39 | }; | |
c52c2132 | 40 | |
41 | enum EAliAnalysisExecMode { | |
42 | kLocalAnalysis = 0, | |
43 | kProofAnalysis = 1, | |
aee5ee44 | 44 | kGridAnalysis = 2, |
45 | kMixingAnalysis = 3 | |
c52c2132 | 46 | }; |
47 | ||
efd53803 | 48 | enum EAliAnalysisFlags { |
b1310ef5 | 49 | kEventLoop = BIT(14), |
d86ed856 | 50 | kDisableBranches = BIT(15), |
a0e2e8b1 | 51 | kUseDataSet = BIT(16), |
06a59280 | 52 | kSaveCanvases = BIT(17), |
90a4b3ee | 53 | kExternalLoop = BIT(18), |
54 | kSkipTerminate = BIT(19) | |
efd53803 | 55 | }; |
56 | ||
6e14aaa2 | 57 | AliAnalysisManager(const char *name = "mgr", const char *title=""); |
d3106602 | 58 | virtual ~AliAnalysisManager(); |
c52c2132 | 59 | |
60 | AliAnalysisManager(const AliAnalysisManager& other); | |
61 | AliAnalysisManager& operator=(const AliAnalysisManager& other); | |
d3106602 | 62 | |
06a59280 | 63 | // Event loop control |
64 | virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0); | |
2d626244 | 65 | virtual Bool_t Init(TTree *tree); |
327eaf46 | 66 | virtual Bool_t Notify(); |
327eaf46 | 67 | virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);} |
d3106602 | 68 | virtual Bool_t Process(Long64_t entry); |
84fcd93f | 69 | TFile *OpenProofFile(AliAnalysisDataContainer *cont, const char *option); |
70 | static TFile *OpenFile(AliAnalysisDataContainer *cont, const char *option, Bool_t ignoreProof=kFALSE); | |
c52c2132 | 71 | void PackOutput(TList *target); |
06a59280 | 72 | void RegisterExtraFile(const char *fname); |
73 | void StartAnalysis(const char *type="local", TTree *tree=0, Long64_t nentries=1234567890, Long64_t firstentry=0); | |
74 | void StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0); | |
75 | virtual void SlaveBegin(TTree *tree); | |
d3106602 | 76 | virtual void Terminate(); |
06a59280 | 77 | void UnpackOutput(TList *source); |
d3106602 | 78 | |
c52c2132 | 79 | // Getters/Setters |
80 | static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;} | |
c52c2132 | 81 | EAliAnalysisExecMode |
06a59280 | 82 | GetAnalysisType() const {return fMode;} |
d29168d6 | 83 | void GetAnalysisTypeString(TString &type) const; |
06a59280 | 84 | static const char *GetCommonFileName() {return fgCommonFileName.Data();} |
85 | AliAnalysisDataContainer * | |
86 | GetCommonInputContainer() {return fCommonInput;} | |
87 | AliAnalysisDataContainer * | |
88 | GetCommonOutputContainer() {return fCommonOutput;} | |
89 | TObjArray *GetContainers() const {return fContainers;} | |
90 | Long64_t GetCurrentEntry() const {return fCurrentEntry;} | |
91 | UInt_t GetDebugLevel() const {return fDebug;} | |
92 | TString GetExtraFiles() const {return fExtraFiles;} | |
93 | AliVEventPool* GetEventPool() {return fEventPool;} | |
94 | Bool_t GetFileFromWrapper(const char *filename, TList *source); | |
95 | AliAnalysisGrid* GetGridHandler() {return fGridHandler;} | |
96 | TObjArray *GetInputs() const {return fInputs;} | |
97 | AliVEventHandler* GetInputEventHandler() {return fInputEventHandler;} | |
98 | AliVEventHandler* GetMCtruthEventHandler() {return fMCtruthEventHandler;} | |
99 | AliVEventHandler* GetOutputEventHandler() {return fOutputEventHandler;} | |
100 | TObjArray *GetOutputs() const {return fOutputs;} | |
101 | TObjArray *GetTasks() const {return fTasks;} | |
102 | TObjArray *GetTopTasks() const {return fTopTasks;} | |
103 | TTree *GetTree() const {return fTree;} | |
104 | TObjArray *GetZombieTasks() const {return fZombies;} | |
06a59280 | 105 | Bool_t IsUsingDataSet() const {return TObject::TestBit(kUseDataSet);} |
c52c2132 | 106 | void SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;} |
06a59280 | 107 | void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;} |
108 | void SetCollectSysInfoEach(Int_t nevents=0) {fNSysInfo = nevents;} | |
109 | static void SetCommonFileName(const char *name) {fgCommonFileName = name;} | |
110 | void SetDebugLevel(UInt_t level) {fDebug = level;} | |
111 | void SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);} | |
112 | void SetExternalLoop(Bool_t flag) {TObject::SetBit(kExternalLoop,flag);} | |
113 | void SetEventPool(AliVEventPool* epool) {fEventPool = epool;} | |
114 | void SetGridHandler(AliAnalysisGrid *handler) {fGridHandler = handler;} | |
60a04972 | 115 | void SetInputEventHandler(AliVEventHandler* handler); |
d2f1d9ef | 116 | void SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;} |
06a59280 | 117 | void SetNSysInfo(Long64_t nevents) {fNSysInfo = nevents;} |
118 | void SetOutputEventHandler(AliVEventHandler* handler); | |
119 | void SetSelector(AliAnalysisSelector *sel) {fSelector = sel;} | |
120 | void SetSaveCanvases(Bool_t flag=kTRUE) {TObject::SetBit(kSaveCanvases,flag);} | |
90a4b3ee | 121 | void SetSkipTerminate(Bool_t flag) {TObject::SetBit(kSkipTerminate,flag);} |
06a59280 | 122 | void SetSpecialOutputLocation(const char *loc) {fSpecialOutputLocation = loc;} |
d3106602 | 123 | |
124 | // Container handling | |
125 | AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype, | |
c52c2132 | 126 | EAliAnalysisContType type = kExchangeContainer, |
127 | const char *filename = NULL); | |
d3106602 | 128 | |
129 | // Including tasks and getting them | |
130 | void AddTask(AliAnalysisTask *task); | |
131 | AliAnalysisTask *GetTask(const char *name) const; | |
132 | ||
133 | // Connecting data containers to task inputs/outputs | |
134 | Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot, | |
135 | AliAnalysisDataContainer *cont); | |
136 | Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot, | |
137 | AliAnalysisDataContainer *cont); | |
138 | // Garbage collection | |
139 | void CleanContainers(); | |
140 | ||
141 | // Analysis initialization and execution, status | |
142 | Bool_t InitAnalysis(); | |
143 | Bool_t IsInitialized() const {return fInitOK;} | |
90a4b3ee | 144 | Bool_t IsExternalLoop() const {return TObject::TestBit(kExternalLoop);} |
efd53803 | 145 | Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);} |
90a4b3ee | 146 | Bool_t IsSkipTerminate() const {return TObject::TestBit(kSkipTerminate);} |
d3106602 | 147 | void ResetAnalysis(); |
148 | void ExecAnalysis(Option_t *option=""); | |
149 | void FinishAnalysis(); | |
150 | void PrintStatus(Option_t *option="all") const; | |
923e2ca5 | 151 | Bool_t ValidateOutputFiles() const; |
d3106602 | 152 | |
153 | protected: | |
981f2614 | 154 | void ImportWrappers(TList *source); |
efd53803 | 155 | void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);} |
d3106602 | 156 | |
5daf9fd2 | 157 | private: |
6bb2b24f | 158 | TTree *fTree; //! Input tree in case of TSelector model |
54cff064 | 159 | AliVEventHandler *fInputEventHandler; // Optional common input event handler |
d2f1d9ef | 160 | AliVEventHandler *fOutputEventHandler; // Optional common output event handler |
161 | AliVEventHandler *fMCtruthEventHandler; // Optional common MC Truth event handler | |
c2922515 | 162 | AliVEventPool *fEventPool; // Event pool for mixing analysis |
6bb2b24f | 163 | Long64_t fCurrentEntry; //! Current processed entry in the tree |
8c0ab8e8 | 164 | Long64_t fNSysInfo; // Event frequency for collecting system information |
6bb2b24f | 165 | EAliAnalysisExecMode fMode; // Execution mode |
166 | Bool_t fInitOK; // Initialisation done | |
167 | UInt_t fDebug; // Debug level | |
13ef3bb0 | 168 | TString fSpecialOutputLocation; // URL/path where the special outputs will be copied |
6bb2b24f | 169 | TObjArray *fTasks; // List of analysis tasks |
170 | TObjArray *fTopTasks; // List of top tasks | |
171 | TObjArray *fZombies; // List of zombie tasks | |
172 | TObjArray *fContainers; // List of all containers | |
173 | TObjArray *fInputs; // List of containers with input data | |
174 | TObjArray *fOutputs; // List of containers with results | |
60a04972 | 175 | AliAnalysisDataContainer *fCommonInput; // Common input container |
176 | AliAnalysisDataContainer *fCommonOutput; // Common output container | |
8d7d3b59 | 177 | AliAnalysisSelector *fSelector; //! Current selector |
c57f56b7 | 178 | AliAnalysisGrid *fGridHandler; //! Grid handler plugin |
c9e39043 | 179 | TString fExtraFiles; // List of extra files to be merged |
5daf9fd2 | 180 | |
84fcd93f | 181 | static TString fgCommonFileName; //! Common output file name (not streamed) |
c52c2132 | 182 | static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance |
c9e39043 | 183 | ClassDef(AliAnalysisManager,5) // Analysis manager class |
d3106602 | 184 | }; |
185 | #endif |