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