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