Fixes in the command to submit merging
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataContainer.h
CommitLineData
d3106602 1#ifndef ALIANALYSISDATACONTAINER_H
2#define ALIANALYSISDATACONTAINER_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// AliAnalysysDataContainer - Container of data of arbitrary type deriving
11// from TObject used for analysis. A container must be connected to the
12// output data slot of a single analysis task (producer) , but also as
13// input slot for possibly several other tasks (consumers). The connected
14// slots must enforce the same data type as the container (or a derived type).
15// A container becomes the owner of the contained data once this was produced.
16//==============================================================================
17
18#ifndef ROOT_TNamed
19#include "TNamed.h"
20#endif
21
c52c2132 22#ifndef ROOT_TString
23#include "TString.h"
24#endif
25
d3106602 26class TClass;
8d7d3b59 27class TFile;
d3106602 28class TObjArray;
c52c2132 29class TCollection;
d3106602 30class AliAnalysisTask;
981f2614 31class AliAnalysisDataWrapper;
d3106602 32
33class AliAnalysisDataContainer : public TNamed {
34
35public:
36enum ENotifyMessage {
37 kDeleteData,
38 kSaveData,
39 kFileChange
40};
c5a87c56 41enum EAnalysisContainerFlags {
13ef3bb0 42 kPostEventLoop = BIT(14),
90a4b3ee 43 kSpecialOutput = BIT(15),
44 kRegisterDataset = BIT(16)
c5a87c56 45};
d3106602 46 AliAnalysisDataContainer();
37a26056 47 AliAnalysisDataContainer(const AliAnalysisDataContainer &cont);
d3106602 48 AliAnalysisDataContainer(const char *name, TClass *type);
49 virtual ~AliAnalysisDataContainer();
50
37a26056 51 // Assignment
52 AliAnalysisDataContainer &operator=(const AliAnalysisDataContainer &cont);
d3106602 53 // Getters
54 TObject *GetData() const {return fData;}
c52c2132 55 const char *GetFileName() const {return fFileName.Data();}
84fcd93f 56 const char *GetFolderName() const {return fFolderName.Data();}
8d7d3b59 57 TFile *GetFile() const {return fFile;}
c52c2132 58 TClass *GetType() const;
d3106602 59 AliAnalysisTask *GetProducer() const {return fProducer;}
60 TObjArray *GetConsumers() const {return fConsumers;}
61 virtual void GetEntry(Long64_t ientry);
62 // Setters
327eaf46 63 void ResetDataReady() {fDataReady = kFALSE;}
d3106602 64 virtual Bool_t SetData(TObject *data, Option_t *option="");
65 void SetDataOwned(Bool_t flag) {fOwnedData = flag;}
b1310ef5 66 void SetPostEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kPostEventLoop,flag);}
13ef3bb0 67 void SetSpecialOutput(Bool_t flag=kTRUE) {TObject::SetBit(kSpecialOutput,flag);}
90a4b3ee 68 void SetRegisterDataset(Bool_t flag=kTRUE) {TObject::SetBit(kRegisterDataset,flag);}
84fcd93f 69 void SetFileName(const char *filename);
8d7d3b59 70 void SetFile(TFile *f) {fFile = f;}
d3106602 71 void SetProducer(AliAnalysisTask *prod, Int_t islot);
72 void AddConsumer(AliAnalysisTask *cons, Int_t islot);
73 void DeleteData();
981f2614 74 // Wrapping
75 AliAnalysisDataWrapper *ExportData() const;
76 void ImportData(AliAnalysisDataWrapper *pack);
d3106602 77 // Container status checking
78 Bool_t IsDataReady() const {return fDataReady;}
b1310ef5 79 Bool_t IsPostEventLoop() const {return TObject::TestBit(kPostEventLoop);}
13ef3bb0 80 Bool_t IsSpecialOutput() const {return TObject::TestBit(kSpecialOutput);}
90a4b3ee 81 Bool_t IsRegisterDataset() const {return TObject::TestBit(kRegisterDataset);}
d3106602 82 Bool_t IsOwnedData() const {return fOwnedData;}
83 Bool_t ClientsExecuted() const;
84 Bool_t HasConsumers() const {return (fConsumers != 0);}
85 Bool_t HasProducer() const {return (fProducer != 0);}
c52c2132 86 // Container merging
87 virtual Long64_t Merge(TCollection *list);
d3106602 88 // Send a notify signal to the container
89 virtual void NotifyChange(ENotifyMessage /*type*/) {;}
90 // Print connected tasks/status
91 void PrintContainer(Option_t *option="all", Int_t indent=0) const;
c52c2132 92
93private:
94 void SetType(TClass *type) {fType = type;}
95
d3106602 96protected:
97 Bool_t fDataReady; // Flag that data is ready
98 Bool_t fOwnedData; // Flag data ownership
c52c2132 99 TString fFileName; // File storing the data
84fcd93f 100 TString fFolderName; // Folder name in the output file
8d7d3b59 101 TFile *fFile; //! Opened file
d3106602 102 TObject *fData; // Contained data
c52c2132 103 TClass *fType; //! Type of contained data
d3106602 104 AliAnalysisTask *fProducer; // Analysis task to which the slot belongs
105 TObjArray *fConsumers; // List of consumers of the data
106
84fcd93f 107 ClassDef(AliAnalysisDataContainer,2) // Class describing a data container for analysis
d3106602 108};
981f2614 109
110//==============================================================================
111// AliAnalysysDataWrapper - A basic wrapper for exchanging via the network
112// the data held by AliAnalysisDataContainer between the master and the client
113// in PROOF case.
114//==============================================================================
115
116class AliAnalysisDataWrapper : public TNamed {
117
118public:
8167b1d0 119
120enum EAnalysisWrapperFlags {
121 kDeleteData = BIT(14)
122};
981f2614 123 AliAnalysisDataWrapper() : TNamed(), fData(NULL) {}
8167b1d0 124 AliAnalysisDataWrapper(TObject *data);
981f2614 125 AliAnalysisDataWrapper(const AliAnalysisDataWrapper &other)
126 : TNamed(other), fData(other.fData) {}
8167b1d0 127 virtual ~AliAnalysisDataWrapper();
981f2614 128
129 // Assignment
130 AliAnalysisDataWrapper &operator=(const AliAnalysisDataWrapper &other);
131
132 TObject *Data() const {return fData;}
133 // Merging
134 virtual Long64_t Merge(TCollection *list);
8167b1d0 135 void SetDeleteData(Bool_t flag=kTRUE) {TObject::SetBit(kDeleteData,flag);}
981f2614 136
137protected:
138 TObject *fData; // Wrapped data
139
140 ClassDef(AliAnalysisDataWrapper, 1) // Data wrapper class for exchange via the net
141};
142
d3106602 143#endif