Removing libraries that are not needed by default. Saves about 100 MBytes at start-up
[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;
d3106602 22class AliAnalysisDataContainer;
23class AliAnalysisTask;
d2f1d9ef 24class AliVEventHandler;
8c9485b2 25
d3106602 26
c52c2132 27class AliAnalysisManager : public TNamed {
d3106602 28
29public:
30
31enum EAliAnalysisContType {
c52c2132 32 kExchangeContainer = 0,
d3106602 33 kInputContainer = 1,
34 kOutputContainer = 2
35};
c52c2132 36
37enum EAliAnalysisExecMode {
38 kLocalAnalysis = 0,
39 kProofAnalysis = 1,
40 kGridAnalysis = 2
41};
42
efd53803 43enum EAliAnalysisFlags {
b1310ef5 44 kEventLoop = BIT(14),
45 kDisableBranches = BIT(15)
efd53803 46};
47
6e14aaa2 48 AliAnalysisManager(const char *name = "mgr", const char *title="");
d3106602 49 virtual ~AliAnalysisManager();
c52c2132 50
51 AliAnalysisManager(const AliAnalysisManager& other);
52 AliAnalysisManager& operator=(const AliAnalysisManager& other);
d3106602 53
c52c2132 54 void StartAnalysis(const char *type="local", TTree *tree=0);
55
d3106602 56 virtual void Init(TTree *tree);
327eaf46 57 virtual Bool_t Notify();
d3106602 58 virtual void SlaveBegin(TTree *tree);
327eaf46 59 virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);}
d3106602 60 virtual Bool_t Process(Long64_t entry);
327eaf46 61 virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0);
c52c2132 62 void PackOutput(TList *target);
63 void UnpackOutput(TList *source);
d3106602 64 virtual void Terminate();
65
c52c2132 66 // Getters/Setters
67 static AliAnalysisManager *GetAnalysisManager() {return fgAnalysisManager;}
d3106602 68 TObjArray *GetContainers() const {return fContainers;}
c52c2132 69 UInt_t GetDebugLevel() const {return fDebug;}
d3106602 70 TObjArray *GetInputs() const {return fInputs;}
71 TObjArray *GetOutputs() const {return fOutputs;}
72 TObjArray *GetTasks() const {return fTasks;}
73 TObjArray *GetTopTasks() const {return fTopTasks;}
c52c2132 74 TTree *GetTree() const {return fTree;}
d3106602 75 TObjArray *GetZombieTasks() const {return fZombies;}
c52c2132 76 Long64_t GetCurrentEntry() const {return fCurrentEntry;}
77 EAliAnalysisExecMode
78 GetAnalysisType() const {return fMode;}
79
80 void SetAnalysisType(EAliAnalysisExecMode mode) {fMode = mode;}
81 void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;}
82 void SetDebugLevel(UInt_t level) {fDebug = level;}
b1310ef5 83 void SetDisableBranches(Bool_t disable=kTRUE) {TObject::SetBit(kDisableBranches,disable);}
54cff064 84 void SetInputEventHandler(AliVEventHandler* handler) {fInputEventHandler = handler;}
d2f1d9ef 85 void SetOutputEventHandler(AliVEventHandler* handler) {fOutputEventHandler = handler;}
86 void SetMCtruthEventHandler(AliVEventHandler* handler) {fMCtruthEventHandler = handler;}
54cff064 87 AliVEventHandler* GetInputEventHandler() {return fInputEventHandler;}
d2f1d9ef 88 AliVEventHandler* GetOutputEventHandler() {return fOutputEventHandler;}
89 AliVEventHandler* GetMCtruthEventHandler() {return fMCtruthEventHandler;}
d3106602 90
91 // Container handling
92 AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype,
c52c2132 93 EAliAnalysisContType type = kExchangeContainer,
94 const char *filename = NULL);
d3106602 95
96 // Including tasks and getting them
97 void AddTask(AliAnalysisTask *task);
98 AliAnalysisTask *GetTask(const char *name) const;
99
100 // Connecting data containers to task inputs/outputs
101 Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot,
102 AliAnalysisDataContainer *cont);
103 Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot,
104 AliAnalysisDataContainer *cont);
105 // Garbage collection
106 void CleanContainers();
107
108 // Analysis initialization and execution, status
109 Bool_t InitAnalysis();
110 Bool_t IsInitialized() const {return fInitOK;}
efd53803 111 Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);}
d3106602 112 void ResetAnalysis();
113 void ExecAnalysis(Option_t *option="");
114 void FinishAnalysis();
115 void PrintStatus(Option_t *option="all") const;
116
117protected:
981f2614 118 void ImportWrappers(TList *source);
efd53803 119 void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);}
d3106602 120
5daf9fd2 121private:
6bb2b24f 122 TTree *fTree; //! Input tree in case of TSelector model
54cff064 123 AliVEventHandler *fInputEventHandler; // Optional common input event handler
d2f1d9ef 124 AliVEventHandler *fOutputEventHandler; // Optional common output event handler
125 AliVEventHandler *fMCtruthEventHandler; // Optional common MC Truth event handler
6bb2b24f 126 Long64_t fCurrentEntry; //! Current processed entry in the tree
127 EAliAnalysisExecMode fMode; // Execution mode
128 Bool_t fInitOK; // Initialisation done
129 UInt_t fDebug; // Debug level
130 TObjArray *fTasks; // List of analysis tasks
131 TObjArray *fTopTasks; // List of top tasks
132 TObjArray *fZombies; // List of zombie tasks
133 TObjArray *fContainers; // List of all containers
134 TObjArray *fInputs; // List of containers with input data
135 TObjArray *fOutputs; // List of containers with results
5daf9fd2 136
c52c2132 137 static AliAnalysisManager *fgAnalysisManager; //! static pointer to object instance
d3106602 138 ClassDef(AliAnalysisManager,1) // Analysis manager class
139};
140#endif