AliRoot Core  3dc7879 (3dc7879)
Go to the documentation of this file.
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
15 #ifndef ROOT_TNamed
16 #include <TNamed.h>
17 #endif
18 #ifndef ROOT_THashTable
19 #include <THashTable.h>
20 #endif
22 class TClass;
23 class TTree;
24 class TFile;
25 class TFileCollection;
26 class TStopwatch;
27 class TMap;
31 class AliAnalysisTask;
32 class AliVEventHandler;
33 class AliVEventPool;
34 class AliAnalysisGrid;
36 class AliVfriendEvent;
37 class AliVEvent;
39 class AliAnalysisManager : public TNamed {
41 public:
44  kExchangeContainer = 0, // use to exchange data between tasks
45  kInputContainer = 1, // use for the task private input data
46  kOutputContainer = 2, // use for the task private output data
47  kParamContainer = 3 // use for storing task private parameters/cuts per analysis session
48 };
55 };
58  kEventLoop = BIT(14),
59  kDisableBranches = BIT(15),
60  kUseDataSet = BIT(16),
61  kSaveCanvases = BIT(17),
62  kExternalLoop = BIT(18),
63  kSkipTerminate = BIT(19),
64  kUseProgressBar = BIT(20),
65  kTrueNotify = BIT(21),
66  kTasksInitialized = BIT(22),
68 };
70  AliAnalysisManager(const char *name = "mgr", const char *title="");
71  virtual ~AliAnalysisManager();
76  // Event loop control
77  Bool_t EventLoop(Long64_t nevents);
78  virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0);
79  virtual Bool_t Init(TTree *tree);
80  virtual Bool_t Notify();
81  virtual Bool_t ProcessCut(Long64_t entry) {return Process(entry);}
82  virtual Bool_t Process(Long64_t entry);
83  TFile *OpenProofFile(AliAnalysisDataContainer *cont, const char *option, const char *extaod="");
84  static TFile *OpenFile(AliAnalysisDataContainer *cont, const char *option, Bool_t ignoreProof=kFALSE);
85  void PackOutput(TList *target);
86  void RegisterExtraFile(const char *fname);
87  Long64_t StartAnalysis(const char *type, TTree * const tree, Long64_t nentries=1234567890, Long64_t firstentry=0);
88  Long64_t StartAnalysis(const char *type, const char *dataset, Long64_t nentries=1234567890, Long64_t firstentry=0);
89  Long64_t StartAnalysis(const char *type, TFileCollection* dataset, Long64_t nentries=1234567890, Long64_t firstentry=0);
90  Long64_t StartAnalysis(const char *type, Long64_t nentries=1234567890, Long64_t firstentry=0);
91  virtual void SlaveBegin(TTree *tree);
92  virtual void Terminate();
93  void UnpackOutput(TList *source);
95  // Getters/Setters
97  static Int_t LoadMacro(const char *filename, Int_t *error = 0, Bool_t check = kFALSE);
99  GetAnalysisType() const {return fMode;}
100  void GetAnalysisTypeString(TString &type) const;
101  Bool_t GetAutoBranchLoading() const {return fAutoBranchHandling;}
102  Long64_t GetCacheSize() const {return fCacheSize;}
103  static const char *GetCommonFileName() {return fgCommonFileName.Data();}
109  Long64_t GetCurrentEntry() const {return fCurrentEntry;}
110  UInt_t GetDebugLevel() const {return fDebug;}
111  Bool_t GetAsyncReading() const {return fAsyncReading;}
112  TString GetExtraFiles() const {return fExtraFiles;}
114  Bool_t GetFileFromWrapper(const char *filename, const TList *source);
115  const char *GetFileInfoLog() const {return fFileInfoLog.Data();}
116  static Int_t GetRunFromAlienPath(const char *path);
118  TObjArray *GetInputs() const {return fInputs;}
121  Int_t GetNsysInfo() const {return fNSysInfo;}
123  TObjArray *GetOutputs() const {return fOutputs;}
126  Int_t GetRunFromPath() const {return fRunFromPath;}
127  const char *GetRequestedBranches() const {return fRequestedBranches.Data();}
128  TObjArray *GetTasks() const {return fTasks;}
129  TObjArray *GetTopTasks() const {return fTopTasks;}
130  TTree *GetTree() const {return fTree;}
131  TObjArray *GetZombieTasks() const {return fZombies;}
132  static const char *GetGlobalStr(const char *key, Bool_t &valid);
133  static Int_t GetGlobalInt(const char *key, Bool_t &valid);
134  static Double_t GetGlobalDbl(const char *key, Bool_t &valid);
135  TMap *GetGlobals() {return fGlobals;}
136  static Bool_t IsMacroLoaded(const char * filename);
137  Bool_t IsMCLoop() const {return fMCLoop;}
138  static Bool_t IsPipe(std::ostream &out);
139  Bool_t IsProofMode() const {return (fMode==kProofAnalysis)?kTRUE:kFALSE;}
140  Bool_t IsRemote() const {return fIsRemote;}
141  Bool_t IsCollectThroughput() {return TObject::TestBit(kCollectThroughput);}
142  Bool_t IsUsingDataSet() const {return TObject::TestBit(kUseDataSet);}
143  void LoadBranch(const char *n) { if(fAutoBranchHandling) return; DoLoadBranch(n); }
144  void RunLocalInit();
147  void SetCurrentEntry(Long64_t entry) {fCurrentEntry = entry;}
148  void SetCacheSize(Long64_t size) {fCacheSize = size;}
149  void SetCollectSysInfoEach(Int_t nevents=0) {fNSysInfo = nevents;}
150  void SetCollectThroughput(Bool_t flag) {Changed(); TObject::SetBit(kCollectThroughput,flag);}
151  static void SetCommonFileName(const char *name) {fgCommonFileName = name;}
152  void SetDebugLevel(UInt_t level);
153  void SetDisableBranches(Bool_t disable=kTRUE) {Changed(); TObject::SetBit(kDisableBranches,disable);}
154  void SetAsyncReading(Bool_t flag=kTRUE) {fAsyncReading = flag;}
155  void SetExternalLoop(Bool_t flag) {Changed(); TObject::SetBit(kExternalLoop,flag);}
156  void SetMCLoop(Bool_t flag=kTRUE) {fMCLoop = flag;}
157  void SetEventPool(AliVEventPool* const epool) {Changed(); fEventPool = epool;}
158  void SetFileInfoLog(const char *name) {TObject::SetBit(kCollectThroughput,kTRUE); fFileInfoLog = name;}
159  void SetGridHandler(AliAnalysisGrid * const handler) {Changed(); fGridHandler = handler;}
160  void SetInputEventHandler(AliVEventHandler* const handler);
162  void SetNSysInfo(Long64_t nevents) {fNSysInfo = nevents;}
163  void SetOutputEventHandler(AliVEventHandler* const handler);
164  void SetRunFromPath(Int_t run) {fRunFromPath = run;}
165  void SetSelector(AliAnalysisSelector * const sel) {fSelector = sel;}
166  void SetSaveCanvases(Bool_t flag=kTRUE) {TObject::SetBit(kSaveCanvases,flag);}
167  void SetSkipTerminate(Bool_t flag) {TObject::SetBit(kSkipTerminate,flag);}
168  void SetUseProgressBar(Bool_t flag, Int_t freq=1);
169  void SetSpecialOutputLocation(const char *loc) {fSpecialOutputLocation = loc;}
170  static void SetGlobalStr(const char *key, const char *value);
171  static void SetGlobalInt(const char *key, Int_t value);
172  static void SetGlobalDbl(const char *key, Double_t value);
175  // Container handling
176  AliAnalysisDataContainer *CreateContainer(const char *name, TClass *datatype,
178  const char *filename = NULL);
180  // Including tasks and getting them
181  void AddTask(AliAnalysisTask *task);
182  AliAnalysisTask *GetTask(const char *name) const;
183  Int_t GetTaskIndex(const AliAnalysisTask *task) const;
185  // Connecting data containers to task inputs/outputs
186  Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot,
188  Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot,
190  // Garbage collection
191  void CleanContainers();
193  // Analysis initialization and execution, status
194  void AddBranches(const char *branches);
195  void AddStatisticsTask(UInt_t offlineMask=0);
196  void CheckBranches(Bool_t load=kFALSE);
197  Bool_t CheckTasks() const;
198  void CountEvent(Int_t ninput, Int_t nprocessed, Int_t nfailed, Int_t naccepted);
199  Bool_t InitAnalysis();
200  Bool_t IsInitialized() const {return fInitOK;}
201  Bool_t IsTrainInitialized() const {return TObject::TestBit(kTasksInitialized);}
202  Bool_t IsExternalLoop() const {return TObject::TestBit(kExternalLoop);}
203  Bool_t IsEventLoop() const {return TObject::TestBit(kEventLoop);}
204  Bool_t IsSkipTerminate() const {return TObject::TestBit(kSkipTerminate);}
205  Bool_t MustClean() const {return fMustClean;}
206  void SetMustClean(Bool_t flag=kTRUE) {fMustClean = flag;}
207  void ResetAnalysis();
208  void ExecAnalysis(Option_t *option="");
209  void PrintStatus(Option_t *option="all") const;
210  void ProfileTask(const char *name, const char *option="VM") const;
211  void ProfileTask(Int_t itop, const char *option="VM") const;
212  static void ProgressBar(const char *opname, Long64_t current, Long64_t size, TStopwatch * const watch=0, Bool_t last=kFALSE, Bool_t refresh=kFALSE);
213  void AddStatisticsMsg(const char *line);
214  const char *GetStatisticsMsg() const {return fStatisticsMsg.Data();}
217  void WriteStatisticsMsg(Int_t nevents);
218  Int_t GetNcalls() const {return fNcalls;}
219  Bool_t ValidateOutputFiles() const;
221  static const char* GetOADBPath();
223  void ApplyDebugOptions();
224  void AddClassDebug(const char *className, Int_t debugLevel);
226  // Security
227  Bool_t IsLocked() const {return fLocked;}
228  void Lock();
229  void UnLock();
230  void Changed();
231  void InitInputData(AliVEvent* esdEvent, AliVfriendEvent* esdFriend);
232 protected:
233  void CreateReadCache();
234  void ImportWrappers(TList *source);
235  void InputFileFromTree(TTree * const tree, TString &fname);
236  void SetEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kEventLoop,flag);}
237  void DoLoadBranch(const char *name);
239 private:
240  TTree *fTree;
245  Long64_t fCurrentEntry;
246  Long64_t fNSysInfo;
248  Bool_t fInitOK;
249  Bool_t fMustClean;
250  Bool_t fIsRemote;
251  Bool_t fLocked;
252  Bool_t fMCLoop;
253  UInt_t fDebug;
270  TString fExtraFiles;
271  TString fFileInfoLog;
273  Bool_t fAsyncReading;
274  THashTable fTable;
275  Int_t fRunFromPath;
276  Int_t fNcalls;
277  Long64_t fMaxEntries;
278  Long64_t fCacheSize;
279  static Int_t fPBUpdateFreq;
280  TString fStatisticsMsg;
283  TMap *fGlobals;
284  TStopwatch *fIOTimer;
285  TStopwatch *fCPUTimer;
286  TStopwatch *fInitTimer;
287  Double_t fIOTime;
288  Double_t fCPUTime;
289  Double_t fInitTime;
290  static TString fgCommonFileName;
291  static TString fgMacroNames;
293  ClassDef(AliAnalysisManager, 21) // Analysis manager class
294 };
295 #endif
Bool_t ConnectOutput(AliAnalysisTask *task, Int_t islot, AliAnalysisDataContainer *cont)
AliAnalysysTask - Class representing a basic analysis task. Any user-defined task should derive from...
Bool_t GetFileFromWrapper(const char *filename, const TList *source)
void SetSpecialOutputLocation(const char *loc)
TBrowser b
Definition: RunAnaESD.C:12
void SetGridHandler(AliAnalysisGrid *const handler)
TObjArray * fContainers
List of all containers.
AliAnalysisFileDescriptor * fCurrentDescriptor
! Current file descriptor
void InputFileFromTree(TTree *const tree, TString &fname)
AliAnalysisDataContainer * GetCommonOutputContainer() const
TObjArray * GetTopTasks() const
TFile * OpenProofFile(AliAnalysisDataContainer *cont, const char *option, const char *extaod="")
void SetMustClean(Bool_t flag=kTRUE)
void SetDisableBranches(Bool_t disable=kTRUE)
virtual Bool_t Process(Long64_t entry)
static void SetCommonFileName(const char *name)
static Int_t GetRunFromAlienPath(const char *path)
void SetEventLoop(Bool_t flag=kTRUE)
void PrintStatus(Option_t *option="all") const
void WriteStatisticsMsg(Int_t nevents)
AliAnalysisTask * GetTask(const char *name) const
static Int_t LoadMacro(const char *filename, Int_t *error=0, Bool_t check=kFALSE)
Bool_t IsProofMode() const
void SetSelector(AliAnalysisSelector *const sel)
static TFile * OpenFile(AliAnalysisDataContainer *cont, const char *option, Bool_t ignoreProof=kFALSE)
static TString fgMacroNames
! Loaded macro names
#define TObjArray
Bool_t fIsRemote
! Flag is set for remote analysis
void AddStatisticsTask(UInt_t offlineMask=0)
TObjArray * GetInputs() const
void GetAnalysisTypeString(TString &type) const
void SetSkipTerminate(Bool_t flag)
const AliAnalysisStatistics * GetStatistics() const
Int_t fNcalls
Total number of calls (events) of ExecAnalysis.
static AliAnalysisManager * GetAnalysisManager()
EAliAnalysisExecMode fMode
Execution mode.
Long64_t GetCacheSize() const
AliAnalysysManager Manager analysis class. Allows creation of several analysis tasks and data contain...
const char * path
TString fStatisticsMsg
Statistics user message.
void DoLoadBranch(const char *name)
const char * GetStatisticsMsg() const
void SetAsyncReading(Bool_t flag=kTRUE)
void SetRunFromPath(Int_t run)
void SetEventPool(AliVEventPool *const epool)
AliVEventHandler * fInputEventHandler
Optional common input event handler.
THashTable fTable
keep branch ptrs in case of manual branch loading
virtual Bool_t Init(TTree *tree)
static void SetGlobalDbl(const char *key, Double_t value)
void SetMCtruthEventHandler(AliVEventHandler *const handler)
static const char * GetGlobalStr(const char *key, Bool_t &valid)
TObjArray * fTasks
List of analysis tasks.
void UnpackOutput(TList *source)
TObjArray * GetParamOutputs() const
AliAnalysisGrid * GetGridHandler()
UInt_t fDebug
Debug level.
AliAnalysysDataContainer AliAnalysysDataContainer - Container of data of arbitrary type deriving from...
static const char * GetCommonFileName()
TTree * GetTree() const
UInt_t GetDebugLevel() const
TMap * fGlobals
Map with global variables.
TString GetExtraFiles() const
TStopwatch * fCPUTimer
! Timer for useful processing
TString fRequestedBranches
Requested branch names.
EAliAnalysisExecMode GetAnalysisType() const
TStatToolkit stat
Definition: AnalyzeLaser.C:5
TObjArray * GetZombieTasks() const
static TString fgCommonFileName
! Common output file name (not streamed)
TObjArray * GetTasks() const
AliAnalysisDataContainer * fCommonOutput
Common output container.
AliAnalysisDataContainer * GetCommonInputContainer() const
void SetCollectSysInfoEach(Int_t nevents=0)
AliVEventPool * fEventPool
Event pool for mixing analysis.
Long64_t StartAnalysis(const char *type, TTree *const tree, Long64_t nentries=1234567890, Long64_t firstentry=0)
void RegisterExtraFile(const char *fname)
AliVEventPool * GetEventPool() const
Bool_t IsMCLoop() const
AliVEventHandler * GetInputEventHandler() const
void SetDebugLevel(UInt_t level)
Int_t GetTaskIndex(const AliAnalysisTask *task) const
void SetStatistics(AliAnalysisStatistics *stat)
AliAnalysisSelector * fSelector
! Current selector
AliAnalysisStatistics basic class for storing statistics for the processed events. The object is mergeable and can be used for general purpose. In case a AliAnalysisTaskStat is used, this will set the global statistics object to the analysis manager and will update it for the accepted events.
Double_t fInitTime
! Cumulated time in initialization
TTree * fTree
! Input tree in case of TSelector model
TTree * tree
void AddBranches(const char *branches)
void SetFileInfoLog(const char *name)
Int_t GetRunFromPath() const
AliAnalysisManager & operator=(const AliAnalysisManager &other)
AliAnalysisManager(const char *name="mgr", const char *title="")
virtual void SlaveBegin(TTree *tree)
AliAnalysisGrid Base grid utility class. Provides interface for creating a personalized JDL...
void SetSaveCanvases(Bool_t flag=kTRUE)
static void SetGlobalStr(const char *key, const char *value)
Bool_t ValidateOutputFiles() const
Bool_t GetAsyncReading() const
TStopwatch * fInitTimer
! Timer for initialization
Bool_t IsExternalLoop() const
void SetOutputEventHandler(AliVEventHandler *const handler)
AliVEventHandler * GetMCtruthEventHandler() const
void PackOutput(TList *target)
void SetUseProgressBar(Bool_t flag, Int_t freq=1)
TObjArray * fZombies
List of zombie tasks.
TObjArray * fOutputs
List of containers with results.
TObjArray * GetOutputs() const
virtual Bool_t Notify()
AliAnalysisSelector Transparent selector class instantiated by an analysis manager object...
void SetInputEventHandler(AliVEventHandler *const handler)
void ExecAnalysis(Option_t *option="")
Long64_t fNSysInfo
Event frequency for collecting system information.
Double_t fIOTime
! Cumulated time in IO
Bool_t fInitOK
Initialisation done.
void SetAutoBranchLoading(Bool_t b)
Int_t GetNsysInfo() const
static Bool_t IsMacroLoaded(const char *filename)
TObjArray * GetExchangeContainers() const
static AliAnalysisManager * fgAnalysisManager
! static pointer to object instance
AliVEventHandler * GetOutputEventHandler() const
static Int_t fPBUpdateFreq
Progress bar update freq.
static void SetGlobalInt(const char *key, Int_t value)
TString fSpecialOutputLocation
URL/path where the special outputs will be copied.
void SetAnalysisType(EAliAnalysisExecMode mode)
TObjArray * fTopTasks
List of top tasks.
TStopwatch * fIOTimer
! Timer for I/O + deserialization
AliVEventHandler * fMCtruthEventHandler
Optional common MC Truth event handler.
AliAnalysisStatistics * fStatistics
Statistics info about input events.
void AddClassDebug(const char *className, Int_t debugLevel)
void ProfileTask(const char *name, const char *option="VM") const
AliAnalysisDataContainer * fCommonInput
Common input container.
Bool_t fLocked
! Lock for the manager and handlers
static const char * GetOADBPath()
Bool_t ConnectInput(AliAnalysisTask *task, Int_t islot, AliAnalysisDataContainer *cont)
static Double_t GetGlobalDbl(const char *key, Bool_t &valid)
AliAnalysisGrid * fGridHandler
! Grid handler plugin
Bool_t IsSkipTerminate() const
TObjArray * fFileDescriptors
! List of file descriptors
void AddTask(AliAnalysisTask *task)
TString fExtraFiles
List of extra files to be merged.
void AddStatisticsMsg(const char *line)
Int_t GetNcalls() const
Bool_t fAsyncReading
Enable async reading.
void SetCollectThroughput(Bool_t flag)
TObjArray * fExchangeCont
List of exchange containers.
void SetCacheSize(Long64_t size)
TObjArray * fParamCont
List of containers with parameters.
void ImportWrappers(TList *source)
Bool_t IsEventLoop() const
Bool_t fAutoBranchHandling
def=kTRUE, turn off if you use LoadBranch
void LoadBranch(const char *n)
Long64_t GetCurrentEntry() const
Bool_t IsInitialized() const
static void ProgressBar(const char *opname, Long64_t current, Long64_t size, TStopwatch *const watch=0, Bool_t last=kFALSE, Bool_t refresh=kFALSE)
void SetExternalLoop(Bool_t flag)
Bool_t fMustClean
Flag to let ROOT do cleanup.
TObjArray * fDebugOptions
List of debug options.
Bool_t GetAutoBranchLoading() const
Long64_t fMaxEntries
Maximum number of entries.
Int_t debugLevel
AliVEventHandler * fOutputEventHandler
Optional common output event handler.
Bool_t IsTrainInitialized() const
virtual Bool_t ProcessCut(Long64_t entry)
void SetMCLoop(Bool_t flag=kTRUE)
Bool_t MustClean() const
TObjArray * fInputs
List of containers with input data.
void SetCurrentEntry(Long64_t entry)
Long64_t fCacheSize
Cache size in bytes.
void SetNSysInfo(Long64_t nevents)
Double_t fCPUTime
! Cumulated time in Exec
TString fFileInfoLog
File name for fileinfo logs.
Bool_t IsRemote() const
const char * GetRequestedBranches() const
char * fname
Bool_t EventLoop(Long64_t nevents)
Long64_t fCurrentEntry
! Current processed entry in the tree
Bool_t IsUsingDataSet() const
void InitInputData(AliVEvent *esdEvent, AliVfriendEvent *esdFriend)
TObjArray * GetContainers() const
Bool_t fMCLoop
External MC generator loop.
static Bool_t IsPipe(std::ostream &out)
Int_t fRunFromPath
Run number retrieved from path to input data.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
static Int_t GetGlobalInt(const char *key, Bool_t &valid)
Bool_t CheckTasks() const
AliAnalysisDataContainer * CreateContainer(const char *name, TClass *datatype, EAliAnalysisContType type=kExchangeContainer, const char *filename=NULL)
void CheckBranches(Bool_t load=kFALSE)
void CountEvent(Int_t ninput, Int_t nprocessed, Int_t nfailed, Int_t naccepted)
const char * GetFileInfoLog() const
Bool_t IsLocked() const