]>
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 |
012e169c | 19 | #ifndef ROOT_THashTable |
20 | #include <THashTable.h> | |
21 | #endif | |
d3106602 | 22 | |
23 | class TClass; | |
c52c2132 | 24 | class TTree; |
8d7d3b59 | 25 | class TFile; |
cd11251e | 26 | class TStopwatch; |
8d7d3b59 | 27 | class AliAnalysisSelector; |
d3106602 | 28 | class AliAnalysisDataContainer; |
29 | class AliAnalysisTask; | |
d2f1d9ef | 30 | class AliVEventHandler; |
c2922515 | 31 | class AliVEventPool; |
c57f56b7 | 32 | class AliAnalysisGrid; |
8c9485b2 | 33 | |
d3106602 | 34 | |
c52c2132 | 35 | class AliAnalysisManager : public TNamed { |
d3106602 | 36 | |
37 | public: | |
38 | ||
39 | enum EAliAnalysisContType { | |
6cd44ee0 | 40 | kExchangeContainer = 0, // use to exchange data between tasks |
41 | kInputContainer = 1, // use for the task private input data | |
42 | kOutputContainer = 2, // use for the task private output data | |
43 | kParamContainer = 3 // use for storing task private parameters/cuts per analysis session | |
d3106602 | 44 | }; |
c52c2132 | 45 | |
46 | enum EAliAnalysisExecMode { | |
47 | kLocalAnalysis = 0, | |
48 | kProofAnalysis = 1, | |
aee5ee44 | 49 | kGridAnalysis = 2, |
50 | kMixingAnalysis = 3 | |
c52c2132 | 51 | }; |
52 | ||
efd53803 | 53 | enum EAliAnalysisFlags { |
b1310ef5 | 54 | kEventLoop = BIT(14), |
d86ed856 | 55 | kDisableBranches = BIT(15), |
a0e2e8b1 | 56 | kUseDataSet = BIT(16), |
06a59280 | 57 | kSaveCanvases = BIT(17), |
90a4b3ee | 58 | kExternalLoop = BIT(18), |
ff0d33e8 | 59 | kSkipTerminate = BIT(19), |
60 | kUseProgressBar = BIT(20) | |
efd53803 | 61 | }; |
62 | ||
6e14aaa2 | 63 | AliAnalysisManager(const char *name = "mgr", const char *title=""); |
d3106602 | 64 | virtual ~AliAnalysisManager(); |
c52c2132 | 65 | |
66 | AliAnalysisManager(const AliAnalysisManager& other); | |
67 | AliAnalysisManager& operator=(const AliAnalysisManager& other); | |
d3106602 | 68 | |
06a59280 | 69 | // Event loop control |
70 | virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0); | |
2d626244 | 71 | virtual Bool_t Init(TTree *tree); |
327eaf46 | 72 | virtual Bool_t Notify(); |
327eaf46 | 73 | virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);} |
d3106602 | 74 | virtual Bool_t Process(Long64_t entry); |
039e671e | 75 | TFile *OpenProofFile(AliAnalysisDataContainer *cont, const char *option, const char *extaod=""); |
84fcd93f | 76 | static TFile *OpenFile(AliAnalysisDataContainer *cont, const char *option, Bool_t ignoreProof=kFALSE); |
c52c2132 | 77 | void PackOutput(TList *target); |
06a59280 | 78 | void RegisterExtraFile(const char *fname); |
27734f0e | 79 | Long64_t StartAnalysis(const char *type, TTree * const tree, Long64_t nentries=1234567890, Long64_t firstentry=0); |
1f87e9fb | 80 | Long64_t StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0); |
27734f0e | 81 | Long64_t StartAnalysis(const char *type, Long64_t nentries=1234567890, Long64_t firstentry=0); |
06a59280 | 82 | virtual void SlaveBegin(TTree *tree); |
d3106602 | 83 | virtual void Terminate(); |
06a59280 | 84 | void UnpackOutput(TList *source); |
d3106602 | 85 | |
c52c2132 | 86 | // Getters/Setters |
87 | static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;} | |
c52c2132 | 88 | EAliAnalysisExecMode |
06a59280 | 89 | GetAnalysisType() const {return fMode;} |
d29168d6 | 90 | void GetAnalysisTypeString(TString &type) const; |
012e169c | 91 | Bool_t GetAutoBranchLoading() const {return fAutoBranchHandling;} |
06a59280 | 92 | static const char *GetCommonFileName() {return fgCommonFileName.Data();} |
93 | AliAnalysisDataContainer * | |
61505f8b | 94 | GetCommonInputContainer() const {return fCommonInput;} |
06a59280 | 95 | AliAnalysisDataContainer * |
61505f8b | 96 | GetCommonOutputContainer() const {return fCommonOutput;} |
06a59280 | 97 | TObjArray *GetContainers() const {return fContainers;} |
98 | Long64_t GetCurrentEntry() const {return fCurrentEntry;} | |
99 | UInt_t GetDebugLevel() const {return fDebug;} | |
100 | TString GetExtraFiles() const {return fExtraFiles;} | |
61505f8b | 101 | AliVEventPool* GetEventPool() const {return fEventPool;} |
102 | Bool_t GetFileFromWrapper(const char *filename, const TList *source); | |
242accb2 | 103 | static Int_t GetRunFromAlienPath(const char *path); |
06a59280 | 104 | AliAnalysisGrid* GetGridHandler() {return fGridHandler;} |
105 | TObjArray *GetInputs() const {return fInputs;} | |
61505f8b | 106 | AliVEventHandler* GetInputEventHandler() const {return fInputEventHandler;} |
107 | AliVEventHandler* GetMCtruthEventHandler() const {return fMCtruthEventHandler;} | |
108 | AliVEventHandler* GetOutputEventHandler() const {return fOutputEventHandler;} | |
06a59280 | 109 | TObjArray *GetOutputs() const {return fOutputs;} |
ff07ec61 | 110 | TObjArray *GetParamOutputs() const {return fParamCont;} |
242accb2 | 111 | Int_t GetRunFromPath() const {return fRunFromPath;} |
7acc5b9d | 112 | const char *GetRequestedBranches() const {return fRequestedBranches.Data();} |
06a59280 | 113 | TObjArray *GetTasks() const {return fTasks;} |
114 | TObjArray *GetTopTasks() const {return fTopTasks;} | |
115 | TTree *GetTree() const {return fTree;} | |
116 | TObjArray *GetZombieTasks() const {return fZombies;} | |
d791fad6 | 117 | Bool_t IsProofMode() const {return (fMode==kProofAnalysis)?kTRUE:kFALSE;} |
8e1f0465 | 118 | Bool_t IsRemote() const {return fIsRemote;} |
06a59280 | 119 | Bool_t IsUsingDataSet() const {return TObject::TestBit(kUseDataSet);} |
012e169c | 120 | void LoadBranch(const char *n) { if(fAutoBranchHandling) return; DoLoadBranch(n); } |
c52c2132 | 121 | void SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;} |
012e169c | 122 | void SetAutoBranchLoading(Bool_t b) { fAutoBranchHandling = b; } |
06a59280 | 123 | void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;} |
124 | void SetCollectSysInfoEach(Int_t nevents=0) {fNSysInfo = nevents;} | |
125 | static void SetCommonFileName(const char *name) {fgCommonFileName = name;} | |
126 | void SetDebugLevel(UInt_t level) {fDebug = level;} | |
127 | void SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);} | |
128 | void SetExternalLoop(Bool_t flag) {TObject::SetBit(kExternalLoop,flag);} | |
61505f8b | 129 | void SetEventPool(AliVEventPool* const epool) {fEventPool = epool;} |
130 | void SetGridHandler(AliAnalysisGrid * const handler) {fGridHandler = handler;} | |
131 | void SetInputEventHandler(AliVEventHandler* const handler); | |
132 | void SetMCtruthEventHandler(AliVEventHandler* const handler) {fMCtruthEventHandler = handler;} | |
06a59280 | 133 | void SetNSysInfo(Long64_t nevents) {fNSysInfo = nevents;} |
61505f8b | 134 | void SetOutputEventHandler(AliVEventHandler* const handler); |
242accb2 | 135 | void SetRunFromPath(Int_t run) {fRunFromPath = run;} |
61505f8b | 136 | void SetSelector(AliAnalysisSelector * const sel) {fSelector = sel;} |
06a59280 | 137 | void SetSaveCanvases(Bool_t flag=kTRUE) {TObject::SetBit(kSaveCanvases,flag);} |
90a4b3ee | 138 | void SetSkipTerminate(Bool_t flag) {TObject::SetBit(kSkipTerminate,flag);} |
ff0d33e8 | 139 | void SetUseProgressBar(Bool_t flag) {TObject::SetBit(kUseProgressBar,flag);} |
06a59280 | 140 | void SetSpecialOutputLocation(const char *loc) {fSpecialOutputLocation = loc;} |
d3106602 | 141 | |
142 | // Container handling | |
143 | AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype, | |
c52c2132 | 144 | EAliAnalysisContType type = kExchangeContainer, |
145 | const char *filename = NULL); | |
d3106602 | 146 | |
147 | // Including tasks and getting them | |
148 | void AddTask(AliAnalysisTask *task); | |
149 | AliAnalysisTask *GetTask(const char *name) const; | |
150 | ||
151 | // Connecting data containers to task inputs/outputs | |
152 | Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot, | |
153 | AliAnalysisDataContainer *cont); | |
154 | Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot, | |
155 | AliAnalysisDataContainer *cont); | |
156 | // Garbage collection | |
157 | void CleanContainers(); | |
158 | ||
159 | // Analysis initialization and execution, status | |
7acc5b9d | 160 | void AddBranches(const char *branches); |
161 | void CheckBranches(Bool_t load=kFALSE); | |
d3106602 | 162 | Bool_t InitAnalysis(); |
163 | Bool_t IsInitialized() const {return fInitOK;} | |
90a4b3ee | 164 | Bool_t IsExternalLoop() const {return TObject::TestBit(kExternalLoop);} |
efd53803 | 165 | Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);} |
90a4b3ee | 166 | Bool_t IsSkipTerminate() const {return TObject::TestBit(kSkipTerminate);} |
d3106602 | 167 | void ResetAnalysis(); |
168 | void ExecAnalysis(Option_t *option=""); | |
d3106602 | 169 | void PrintStatus(Option_t *option="all") const; |
096b5a2e | 170 | void ProfileTask(const char *name, const char *option="VM") const; |
171 | void ProfileTask(Int_t itop, const char *option="VM") const; | |
61505f8b | 172 | static void ProgressBar(const char *opname, Long64_t current, Long64_t size, TStopwatch * const watch=0, Bool_t last=kFALSE, Bool_t refresh=kFALSE); |
e9247450 | 173 | void AddStatisticsMsg(const char *line); |
174 | const char *GetStatisticsMsg() const {return fStatisticsMsg.Data();} | |
175 | void WriteStatisticsMsg(Int_t nevents); | |
176 | Int_t GetNcalls() const {return fNcalls;} | |
923e2ca5 | 177 | Bool_t ValidateOutputFiles() const; |
d3106602 | 178 | |
179 | protected: | |
981f2614 | 180 | void ImportWrappers(TList *source); |
efd53803 | 181 | void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);} |
012e169c | 182 | void DoLoadBranch(const char *name); |
d3106602 | 183 | |
5daf9fd2 | 184 | private: |
6bb2b24f | 185 | TTree *fTree; //! Input tree in case of TSelector model |
54cff064 | 186 | AliVEventHandler *fInputEventHandler; // Optional common input event handler |
d2f1d9ef | 187 | AliVEventHandler *fOutputEventHandler; // Optional common output event handler |
188 | AliVEventHandler *fMCtruthEventHandler; // Optional common MC Truth event handler | |
c2922515 | 189 | AliVEventPool *fEventPool; // Event pool for mixing analysis |
6bb2b24f | 190 | Long64_t fCurrentEntry; //! Current processed entry in the tree |
8c0ab8e8 | 191 | Long64_t fNSysInfo; // Event frequency for collecting system information |
6bb2b24f | 192 | EAliAnalysisExecMode fMode; // Execution mode |
193 | Bool_t fInitOK; // Initialisation done | |
8e1f0465 | 194 | Bool_t fIsRemote; //! Flag is set for remote analysis |
6bb2b24f | 195 | UInt_t fDebug; // Debug level |
13ef3bb0 | 196 | TString fSpecialOutputLocation; // URL/path where the special outputs will be copied |
6bb2b24f | 197 | TObjArray *fTasks; // List of analysis tasks |
198 | TObjArray *fTopTasks; // List of top tasks | |
199 | TObjArray *fZombies; // List of zombie tasks | |
200 | TObjArray *fContainers; // List of all containers | |
201 | TObjArray *fInputs; // List of containers with input data | |
202 | TObjArray *fOutputs; // List of containers with results | |
ff07ec61 | 203 | TObjArray *fParamCont; // List of containers with results |
60a04972 | 204 | AliAnalysisDataContainer *fCommonInput; // Common input container |
205 | AliAnalysisDataContainer *fCommonOutput; // Common output container | |
8d7d3b59 | 206 | AliAnalysisSelector *fSelector; //! Current selector |
c57f56b7 | 207 | AliAnalysisGrid *fGridHandler; //! Grid handler plugin |
c9e39043 | 208 | TString fExtraFiles; // List of extra files to be merged |
012e169c | 209 | Bool_t fAutoBranchHandling; // def=kTRUE, turn off if you use LoadBranch |
210 | THashTable fTable; // keep branch ptrs in case of manual branch loading | |
242accb2 | 211 | Int_t fRunFromPath; // Run number retrieved from path to input data |
e9247450 | 212 | Int_t fNcalls; // Total number of calls (events) of ExecAnalysis |
213 | TString fStatisticsMsg; // Statistics user message | |
7acc5b9d | 214 | TString fRequestedBranches; // Requested branch names |
84fcd93f | 215 | static TString fgCommonFileName; //! Common output file name (not streamed) |
c52c2132 | 216 | static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance |
7acc5b9d | 217 | ClassDef(AliAnalysisManager,11) // Analysis manager class |
d3106602 | 218 | }; |
219 | #endif |