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