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