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