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