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