]>
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 | #ifndef ROOT_TStopwatch | |
27 | #include "TStopwatch.h" | |
28 | #endif | |
29 | ||
30 | class TClass; | |
31 | class TFile; | |
32 | class TObjArray; | |
33 | class TCollection; | |
34 | class AliAnalysisTask; | |
35 | class AliAnalysisDataWrapper; | |
36 | ||
37 | class AliAnalysisDataContainer : public TNamed { | |
38 | ||
39 | public: | |
40 | enum ENotifyMessage { | |
41 | kDeleteData, | |
42 | kSaveData, | |
43 | kFileChange | |
44 | }; | |
45 | enum EAnalysisContainerFlags { | |
46 | kPostEventLoop = BIT(14), | |
47 | kSpecialOutput = BIT(15), | |
48 | kRegisterDataset = BIT(16) | |
49 | }; | |
50 | AliAnalysisDataContainer(); | |
51 | AliAnalysisDataContainer(const AliAnalysisDataContainer &cont); | |
52 | AliAnalysisDataContainer(const char *name, TClass *type); | |
53 | virtual ~AliAnalysisDataContainer(); | |
54 | ||
55 | // Assignment | |
56 | AliAnalysisDataContainer &operator=(const AliAnalysisDataContainer &cont); | |
57 | // Getters | |
58 | TObject *GetData() const {return fData;} | |
59 | const char *GetFileName() const {return fFileName.Data();} | |
60 | const char *GetFolderName() const {return fFolderName.Data();} | |
61 | TFile *GetFile() const {return fFile;} | |
62 | TClass *GetType() const; | |
63 | AliAnalysisTask *GetProducer() const {return fProducer;} | |
64 | TObjArray *GetConsumers() const {return fConsumers;} | |
65 | virtual void GetEntry(Long64_t ientry); | |
66 | // Setters | |
67 | void ResetDataReady() {fDataReady = kFALSE;} | |
68 | virtual Bool_t SetData(TObject *data, Option_t *option=""); | |
69 | void SetDataOwned(Bool_t flag) {fOwnedData = flag;} | |
70 | void SetPostEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kPostEventLoop,flag);} | |
71 | void SetSpecialOutput(Bool_t flag=kTRUE) {TObject::SetBit(kSpecialOutput,flag);} | |
72 | void SetRegisterDataset(Bool_t flag=kTRUE) {TObject::SetBit(kRegisterDataset,flag);} | |
73 | void SetFileName(const char *filename); | |
74 | void SetFile(TFile *f) {fFile = f;} | |
75 | void SetProducer(AliAnalysisTask *prod, Int_t islot); | |
76 | void AddConsumer(AliAnalysisTask *cons, Int_t islot); | |
77 | void DeleteData(); | |
78 | // Wrapping | |
79 | AliAnalysisDataWrapper *ExportData() const; | |
80 | void ImportData(AliAnalysisDataWrapper *pack); | |
81 | // Container status checking | |
82 | Bool_t IsDataReady() const {return fDataReady;} | |
83 | Bool_t IsPostEventLoop() const {return TObject::TestBit(kPostEventLoop);} | |
84 | Bool_t IsSpecialOutput() const {return TObject::TestBit(kSpecialOutput);} | |
85 | Bool_t IsRegisterDataset() const {return TObject::TestBit(kRegisterDataset);} | |
86 | Bool_t IsOwnedData() const {return fOwnedData;} | |
87 | Bool_t ClientsExecuted() const; | |
88 | Bool_t HasConsumers() const {return (fConsumers != 0);} | |
89 | Bool_t HasProducer() const {return (fProducer != 0);} | |
90 | // Container merging | |
91 | virtual Long64_t Merge(TCollection *list); | |
92 | // Send a notify signal to the container | |
93 | virtual void NotifyChange(ENotifyMessage /*type*/) {;} | |
94 | // Print connected tasks/status | |
95 | void PrintContainer(Option_t *option="all", Int_t indent=0) const; | |
96 | ||
97 | private: | |
98 | void SetType(TClass *type) {fType = type;} | |
99 | ||
100 | protected: | |
101 | Bool_t fDataReady; // Flag that data is ready | |
102 | Bool_t fOwnedData; // Flag data ownership | |
103 | TString fFileName; // File storing the data | |
104 | TString fFolderName; // Folder name in the output file | |
105 | TFile *fFile; //! Opened file | |
106 | TObject *fData; // Contained data | |
107 | TClass *fType; //! Type of contained data | |
108 | AliAnalysisTask *fProducer; // Analysis task to which the slot belongs | |
109 | TObjArray *fConsumers; // List of consumers of the data | |
110 | ||
111 | ClassDef(AliAnalysisDataContainer,2) // Class describing a data container for analysis | |
112 | }; | |
113 | ||
114 | //============================================================================== | |
115 | // AliAnalysysDataWrapper - A basic wrapper for exchanging via the network | |
116 | // the data held by AliAnalysisDataContainer between the master and the client | |
117 | // in PROOF case. | |
118 | //============================================================================== | |
119 | ||
120 | class AliAnalysisDataWrapper : public TNamed { | |
121 | ||
122 | public: | |
123 | ||
124 | enum EAnalysisWrapperFlags { | |
125 | kDeleteData = BIT(14) | |
126 | }; | |
127 | AliAnalysisDataWrapper() : TNamed(), fData(NULL) {} | |
128 | AliAnalysisDataWrapper(TObject *data); | |
129 | AliAnalysisDataWrapper(const AliAnalysisDataWrapper &other) | |
130 | : TNamed(other), fData(other.fData) {} | |
131 | virtual ~AliAnalysisDataWrapper(); | |
132 | ||
133 | // Assignment | |
134 | AliAnalysisDataWrapper &operator=(const AliAnalysisDataWrapper &other); | |
135 | ||
136 | TObject *Data() const {return fData;} | |
137 | // Merging | |
138 | virtual Long64_t Merge(TCollection *list); | |
139 | void SetDeleteData(Bool_t flag=kTRUE) {TObject::SetBit(kDeleteData,flag);} | |
140 | ||
141 | protected: | |
142 | TObject *fData; // Wrapped data | |
143 | ||
144 | ClassDef(AliAnalysisDataWrapper, 1) // Data wrapper class for exchange via the net | |
145 | }; | |
146 | ||
147 | //============================================================================== | |
148 | // AliAnalysisFileDescriptor - A simple wrapper for data related to accessing | |
149 | // an analysis input file. | |
150 | //============================================================================== | |
151 | class AliAnalysisFileDescriptor : public TObject { | |
152 | ||
153 | public: | |
154 | AliAnalysisFileDescriptor(); | |
155 | AliAnalysisFileDescriptor(const TFile *file); | |
156 | AliAnalysisFileDescriptor(const AliAnalysisFileDescriptor &other); | |
157 | virtual ~AliAnalysisFileDescriptor(); | |
158 | ||
159 | // Assignment | |
160 | AliAnalysisFileDescriptor &operator=(const AliAnalysisFileDescriptor &other); | |
161 | ||
162 | void Done(); | |
163 | ||
164 | const char *GetGUID() const {return fGUID;} | |
165 | Int_t GetImage() const {return fImage;} | |
166 | const char *GetLfn() const {return fLfn;} | |
167 | Int_t GetNreplicas() const {return fNreplicas;} | |
168 | Long64_t GetOpenAt() const {return fOpenedAt;} | |
169 | Double_t GetOpenTime() const {return fOpenTime;} | |
170 | const char *GetPfn() const {return fPfn;} | |
171 | Long64_t GetReadBytes() const {return fReadBytes;} | |
172 | Long64_t GetSize() const {return fSize;} | |
173 | const char *GetSE() const {return fSE;} | |
174 | Double_t GetThroughput() const {return fThroughput;} | |
175 | Double_t GetProcessingTime() const {return fProcessingTime;} | |
176 | const char *GetUrl() const {return fUrl;} | |
177 | Bool_t IsArchive() const {return fIsArchive;} | |
178 | virtual void Print(Option_t *option="") const; | |
179 | virtual void SavePrimitive(ostream &out, Option_t *option = ""); | |
180 | void SetOpenTime(Double_t time) {fOpenTime = time;} | |
181 | ||
182 | ||
183 | protected: | |
184 | TString fLfn; // logical file name | |
185 | TString fGUID; // GUID | |
186 | TString fUrl; // url for the opened copy | |
187 | TString fPfn; // physical file name | |
188 | TString fSE; // Storage element | |
189 | Bool_t fIsArchive; // Archive flag | |
190 | Int_t fImage; // Image number | |
191 | Int_t fNreplicas; // Number of replicas | |
192 | Long64_t fStartBytes;// Total number of read bytes at start | |
193 | Long64_t fReadBytes; // Number of bytes read | |
194 | Long64_t fSize; // Size of the file in bytes | |
195 | Long64_t fOpenedAt; // Absolute value for time when opened | |
196 | Double_t fOpenTime; // Time elapsed to open file | |
197 | Double_t fProcessingTime; // Processing | |
198 | Double_t fThroughput; // Throughput | |
199 | TStopwatch fTimer; //! Processing time | |
200 | ||
201 | ClassDef(AliAnalysisFileDescriptor,1) // Class describing a a file processed in the analysis | |
202 | }; | |
203 | ||
204 | #endif |