]>
Commit | Line | Data |
---|---|---|
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 | 26 | class TClass; |
d3106602 | 27 | class TObjArray; |
c52c2132 | 28 | class TCollection; |
d3106602 | 29 | class AliAnalysisTask; |
981f2614 | 30 | class AliAnalysisDataWrapper; |
d3106602 | 31 | class AliESD; |
32 | ||
33 | class AliAnalysisDataContainer : public TNamed { | |
34 | ||
35 | public: | |
36 | enum ENotifyMessage { | |
37 | kDeleteData, | |
38 | kSaveData, | |
39 | kFileChange | |
40 | }; | |
c5a87c56 | 41 | enum EAnalysisContainerFlags { |
13ef3bb0 | 42 | kPostEventLoop = BIT(14), |
43 | kSpecialOutput = BIT(15) | |
c5a87c56 | 44 | }; |
d3106602 | 45 | AliAnalysisDataContainer(); |
37a26056 | 46 | AliAnalysisDataContainer(const AliAnalysisDataContainer &cont); |
d3106602 | 47 | AliAnalysisDataContainer(const char *name, TClass *type); |
48 | virtual ~AliAnalysisDataContainer(); | |
49 | ||
37a26056 | 50 | // Assignment |
51 | AliAnalysisDataContainer &operator=(const AliAnalysisDataContainer &cont); | |
d3106602 | 52 | // Getters |
53 | TObject *GetData() const {return fData;} | |
c52c2132 | 54 | const char *GetFileName() const {return fFileName.Data();} |
55 | TClass *GetType() const; | |
d3106602 | 56 | AliAnalysisTask *GetProducer() const {return fProducer;} |
57 | TObjArray *GetConsumers() const {return fConsumers;} | |
58 | virtual void GetEntry(Long64_t ientry); | |
59 | // Setters | |
327eaf46 | 60 | void ResetDataReady() {fDataReady = kFALSE;} |
d3106602 | 61 | virtual Bool_t SetData(TObject *data, Option_t *option=""); |
62 | void SetDataOwned(Bool_t flag) {fOwnedData = flag;} | |
b1310ef5 | 63 | void SetPostEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kPostEventLoop,flag);} |
13ef3bb0 | 64 | void SetSpecialOutput(Bool_t flag=kTRUE) {TObject::SetBit(kSpecialOutput,flag);} |
c52c2132 | 65 | void SetFileName(const char *filename) {fFileName = filename;} |
d3106602 | 66 | void SetProducer(AliAnalysisTask *prod, Int_t islot); |
67 | void AddConsumer(AliAnalysisTask *cons, Int_t islot); | |
68 | void DeleteData(); | |
981f2614 | 69 | // Wrapping |
70 | AliAnalysisDataWrapper *ExportData() const; | |
71 | void ImportData(AliAnalysisDataWrapper *pack); | |
d3106602 | 72 | // Container status checking |
73 | Bool_t IsDataReady() const {return fDataReady;} | |
b1310ef5 | 74 | Bool_t IsPostEventLoop() const {return TObject::TestBit(kPostEventLoop);} |
13ef3bb0 | 75 | Bool_t IsSpecialOutput() const {return TObject::TestBit(kSpecialOutput);} |
d3106602 | 76 | Bool_t IsOwnedData() const {return fOwnedData;} |
77 | Bool_t ClientsExecuted() const; | |
78 | Bool_t HasConsumers() const {return (fConsumers != 0);} | |
79 | Bool_t HasProducer() const {return (fProducer != 0);} | |
c52c2132 | 80 | // Container merging |
81 | virtual Long64_t Merge(TCollection *list); | |
d3106602 | 82 | // Send a notify signal to the container |
83 | virtual void NotifyChange(ENotifyMessage /*type*/) {;} | |
84 | // Print connected tasks/status | |
85 | void PrintContainer(Option_t *option="all", Int_t indent=0) const; | |
c52c2132 | 86 | |
87 | private: | |
88 | void SetType(TClass *type) {fType = type;} | |
89 | ||
d3106602 | 90 | protected: |
91 | Bool_t fDataReady; // Flag that data is ready | |
92 | Bool_t fOwnedData; // Flag data ownership | |
c52c2132 | 93 | TString fFileName; // File storing the data |
d3106602 | 94 | TObject *fData; // Contained data |
c52c2132 | 95 | TClass *fType; //! Type of contained data |
d3106602 | 96 | AliAnalysisTask *fProducer; // Analysis task to which the slot belongs |
97 | TObjArray *fConsumers; // List of consumers of the data | |
98 | ||
99 | ClassDef(AliAnalysisDataContainer,1) // Class describing a data container for analysis | |
100 | }; | |
981f2614 | 101 | |
102 | //============================================================================== | |
103 | // AliAnalysysDataWrapper - A basic wrapper for exchanging via the network | |
104 | // the data held by AliAnalysisDataContainer between the master and the client | |
105 | // in PROOF case. | |
106 | //============================================================================== | |
107 | ||
108 | class AliAnalysisDataWrapper : public TNamed { | |
109 | ||
110 | public: | |
8167b1d0 | 111 | |
112 | enum EAnalysisWrapperFlags { | |
113 | kDeleteData = BIT(14) | |
114 | }; | |
981f2614 | 115 | AliAnalysisDataWrapper() : TNamed(), fData(NULL) {} |
8167b1d0 | 116 | AliAnalysisDataWrapper(TObject *data); |
981f2614 | 117 | AliAnalysisDataWrapper(const AliAnalysisDataWrapper &other) |
118 | : TNamed(other), fData(other.fData) {} | |
8167b1d0 | 119 | virtual ~AliAnalysisDataWrapper(); |
981f2614 | 120 | |
121 | // Assignment | |
122 | AliAnalysisDataWrapper &operator=(const AliAnalysisDataWrapper &other); | |
123 | ||
124 | TObject *Data() const {return fData;} | |
125 | // Merging | |
126 | virtual Long64_t Merge(TCollection *list); | |
8167b1d0 | 127 | void SetDeleteData(Bool_t flag=kTRUE) {TObject::SetBit(kDeleteData,flag);} |
981f2614 | 128 | |
129 | protected: | |
130 | TObject *fData; // Wrapped data | |
131 | ||
132 | ClassDef(AliAnalysisDataWrapper, 1) // Data wrapper class for exchange via the net | |
133 | }; | |
134 | ||
d3106602 | 135 | #endif |