fix mem leak and compiler warning
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisManager.h
CommitLineData
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
20class TClass;
c52c2132 21class TTree;
8d7d3b59 22class TFile;
23class AliAnalysisSelector;
d3106602 24class AliAnalysisDataContainer;
25class AliAnalysisTask;
d2f1d9ef 26class AliVEventHandler;
c2922515 27class AliVEventPool;
8c9485b2 28
d3106602 29
c52c2132 30class AliAnalysisManager : public TNamed {
d3106602 31
32public:
33
34enum EAliAnalysisContType {
c52c2132 35 kExchangeContainer = 0,
d3106602 36 kInputContainer = 1,
37 kOutputContainer = 2
38};
c52c2132 39
40enum EAliAnalysisExecMode {
41 kLocalAnalysis = 0,
42 kProofAnalysis = 1,
aee5ee44 43 kGridAnalysis = 2,
44 kMixingAnalysis = 3
c52c2132 45};
46
efd53803 47enum EAliAnalysisFlags {
b1310ef5 48 kEventLoop = BIT(14),
d86ed856 49 kDisableBranches = BIT(15),
50 kUseDataSet = BIT(16)
efd53803 51};
52
6e14aaa2 53 AliAnalysisManager(const char *name = "mgr", const char *title="");
d3106602 54 virtual ~AliAnalysisManager();
c52c2132 55
56 AliAnalysisManager(const AliAnalysisManager& other);
57 AliAnalysisManager& operator=(const AliAnalysisManager& other);
d3106602 58
8c0ab8e8 59 // Management
60 void StartAnalysis(const char *type="local", TTree *tree=0, Long64_t nentries=1234567890, Long64_t firstentry=0);
d86ed856 61 void StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0);
c52c2132 62
d3106602 63 virtual void Init(TTree *tree);
327eaf46 64 virtual Bool_t Notify();
d3106602 65 virtual void SlaveBegin(TTree *tree);
327eaf46 66 virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);}
d3106602 67 virtual Bool_t Process(Long64_t entry);
327eaf46 68 virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0);
8d7d3b59 69 TFile *OpenProofFile(const char *name, const char *option);
c52c2132 70 void PackOutput(TList *target);
71 void UnpackOutput(TList *source);
d3106602 72 virtual void Terminate();
73
c52c2132 74 // Getters/Setters
75 static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;}
d3106602 76 TObjArray *GetContainers() const {return fContainers;}
c52c2132 77 UInt_t GetDebugLevel() const {return fDebug;}
d3106602 78 TObjArray *GetInputs() const {return fInputs;}
79 TObjArray *GetOutputs() const {return fOutputs;}
80 TObjArray *GetTasks() const {return fTasks;}
81 TObjArray *GetTopTasks() const {return fTopTasks;}
c52c2132 82 TTree *GetTree() const {return fTree;}
d3106602 83 TObjArray *GetZombieTasks() const {return fZombies;}
c52c2132 84 Long64_t GetCurrentEntry() const {return fCurrentEntry;}
85 EAliAnalysisExecMode
86 GetAnalysisType() const {return fMode;}
d86ed856 87 Bool_t IsUsingDataSet() const {return TObject::TestBit(kUseDataSet);}
c52c2132 88
89 void SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;}
90 void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;}
91 void SetDebugLevel(UInt_t level) {fDebug = level;}
13ef3bb0 92 void SetSpecialOutputLocation(const char *location) {fSpecialOutputLocation = location;}
b1310ef5 93 void SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);}
8c0ab8e8 94 void SetCollectSysInfoEach(Int_t nevents=0) {fNSysInfo = nevents;}
54cff064 95 void SetInputEventHandler(AliVEventHandler* handler) {fInputEventHandler = handler;}
d2f1d9ef 96 void SetOutputEventHandler(AliVEventHandler* handler) {fOutputEventHandler = handler;}
97 void SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;}
c2922515 98 void SetEventPool(AliVEventPool* epool) {fEventPool = epool;}
8c0ab8e8 99 void SetNSysInfo(Long64_t nevents) {fNSysInfo = nevents;}
8d7d3b59 100 void SetSelector(AliAnalysisSelector *sel) {fSelector = sel;}
54cff064 101 AliVEventHandler* GetInputEventHandler() {return fInputEventHandler;}
d2f1d9ef 102 AliVEventHandler* GetOutputEventHandler() {return fOutputEventHandler;}
103 AliVEventHandler* GetMCtruthEventHandler() {return fMCtruthEventHandler;}
c2922515 104 AliVEventPool* GetEventPool() {return fEventPool;}
d3106602 105
106 // Container handling
107 AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype,
c52c2132 108 EAliAnalysisContType type = kExchangeContainer,
109 const char *filename = NULL);
d3106602 110
111 // Including tasks and getting them
112 void AddTask(AliAnalysisTask *task);
113 AliAnalysisTask *GetTask(const char *name) const;
114
115 // Connecting data containers to task inputs/outputs
116 Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot,
117 AliAnalysisDataContainer *cont);
118 Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot,
119 AliAnalysisDataContainer *cont);
120 // Garbage collection
121 void CleanContainers();
122
123 // Analysis initialization and execution, status
124 Bool_t InitAnalysis();
125 Bool_t IsInitialized() const {return fInitOK;}
efd53803 126 Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);}
d3106602 127 void ResetAnalysis();
128 void ExecAnalysis(Option_t *option="");
129 void FinishAnalysis();
130 void PrintStatus(Option_t *option="all") const;
131
132protected:
981f2614 133 void ImportWrappers(TList *source);
efd53803 134 void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);}
d3106602 135
5daf9fd2 136private:
6bb2b24f 137 TTree *fTree; //! Input tree in case of TSelector model
54cff064 138 AliVEventHandler *fInputEventHandler; // Optional common input event handler
d2f1d9ef 139 AliVEventHandler *fOutputEventHandler; // Optional common output event handler
140 AliVEventHandler *fMCtruthEventHandler; // Optional common MC Truth event handler
c2922515 141 AliVEventPool *fEventPool; // Event pool for mixing analysis
6bb2b24f 142 Long64_t fCurrentEntry; //! Current processed entry in the tree
8c0ab8e8 143 Long64_t fNSysInfo; // Event frequency for collecting system information
6bb2b24f 144 EAliAnalysisExecMode fMode; // Execution mode
145 Bool_t fInitOK; // Initialisation done
146 UInt_t fDebug; // Debug level
13ef3bb0 147 TString fSpecialOutputLocation; // URL/path where the special outputs will be copied
6bb2b24f 148 TObjArray *fTasks; // List of analysis tasks
149 TObjArray *fTopTasks; // List of top tasks
150 TObjArray *fZombies; // List of zombie tasks
151 TObjArray *fContainers; // List of all containers
152 TObjArray *fInputs; // List of containers with input data
153 TObjArray *fOutputs; // List of containers with results
8d7d3b59 154 AliAnalysisSelector *fSelector; //! Current selector
5daf9fd2 155
c52c2132 156 static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
13ef3bb0 157 ClassDef(AliAnalysisManager,3) // Analysis manager class
d3106602 158};
159#endif