Fixed includes and scope of a string
[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
9c19e756 26#ifndef ROOT_TStopwatch
27#include "TStopwatch.h"
28#endif
29
d3106602 30class TClass;
8d7d3b59 31class TFile;
d3106602 32class TObjArray;
c52c2132 33class TCollection;
d3106602 34class AliAnalysisTask;
981f2614 35class AliAnalysisDataWrapper;
d3106602 36
e61afb80 37using std::ostream;
38
d3106602 39class AliAnalysisDataContainer : public TNamed {
40
41public:
42enum ENotifyMessage {
43 kDeleteData,
44 kSaveData,
45 kFileChange
46};
c5a87c56 47enum EAnalysisContainerFlags {
13ef3bb0 48 kPostEventLoop = BIT(14),
90a4b3ee 49 kSpecialOutput = BIT(15),
50 kRegisterDataset = BIT(16)
c5a87c56 51};
d3106602 52 AliAnalysisDataContainer();
37a26056 53 AliAnalysisDataContainer(const AliAnalysisDataContainer &cont);
d3106602 54 AliAnalysisDataContainer(const char *name, TClass *type);
55 virtual ~AliAnalysisDataContainer();
56
37a26056 57 // Assignment
58 AliAnalysisDataContainer &operator=(const AliAnalysisDataContainer &cont);
d3106602 59 // Getters
60 TObject *GetData() const {return fData;}
c52c2132 61 const char *GetFileName() const {return fFileName.Data();}
84fcd93f 62 const char *GetFolderName() const {return fFolderName.Data();}
8d7d3b59 63 TFile *GetFile() const {return fFile;}
c52c2132 64 TClass *GetType() const;
d3106602 65 AliAnalysisTask *GetProducer() const {return fProducer;}
66 TObjArray *GetConsumers() const {return fConsumers;}
67 virtual void GetEntry(Long64_t ientry);
68 // Setters
327eaf46 69 void ResetDataReady() {fDataReady = kFALSE;}
d3106602 70 virtual Bool_t SetData(TObject *data, Option_t *option="");
71 void SetDataOwned(Bool_t flag) {fOwnedData = flag;}
b1310ef5 72 void SetPostEventLoop(Bool_t flag=kTRUE) {TObject::SetBit(kPostEventLoop,flag);}
13ef3bb0 73 void SetSpecialOutput(Bool_t flag=kTRUE) {TObject::SetBit(kSpecialOutput,flag);}
90a4b3ee 74 void SetRegisterDataset(Bool_t flag=kTRUE) {TObject::SetBit(kRegisterDataset,flag);}
84fcd93f 75 void SetFileName(const char *filename);
8d7d3b59 76 void SetFile(TFile *f) {fFile = f;}
d3106602 77 void SetProducer(AliAnalysisTask *prod, Int_t islot);
78 void AddConsumer(AliAnalysisTask *cons, Int_t islot);
79 void DeleteData();
981f2614 80 // Wrapping
81 AliAnalysisDataWrapper *ExportData() const;
82 void ImportData(AliAnalysisDataWrapper *pack);
d3106602 83 // Container status checking
84 Bool_t IsDataReady() const {return fDataReady;}
b1310ef5 85 Bool_t IsPostEventLoop() const {return TObject::TestBit(kPostEventLoop);}
13ef3bb0 86 Bool_t IsSpecialOutput() const {return TObject::TestBit(kSpecialOutput);}
90a4b3ee 87 Bool_t IsRegisterDataset() const {return TObject::TestBit(kRegisterDataset);}
d3106602 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);}
c52c2132 92 // Container merging
93 virtual Long64_t Merge(TCollection *list);
d3106602 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;
c52c2132 98
99private:
100 void SetType(TClass *type) {fType = type;}
101
d3106602 102protected:
103 Bool_t fDataReady; // Flag that data is ready
104 Bool_t fOwnedData; // Flag data ownership
c52c2132 105 TString fFileName; // File storing the data
84fcd93f 106 TString fFolderName; // Folder name in the output file
8d7d3b59 107 TFile *fFile; //! Opened file
d3106602 108 TObject *fData; // Contained data
c52c2132 109 TClass *fType; //! Type of contained data
d3106602 110 AliAnalysisTask *fProducer; // Analysis task to which the slot belongs
111 TObjArray *fConsumers; // List of consumers of the data
112
84fcd93f 113 ClassDef(AliAnalysisDataContainer,2) // Class describing a data container for analysis
d3106602 114};
981f2614 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
122class AliAnalysisDataWrapper : public TNamed {
123
124public:
8167b1d0 125
126enum EAnalysisWrapperFlags {
127 kDeleteData = BIT(14)
128};
981f2614 129 AliAnalysisDataWrapper() : TNamed(), fData(NULL) {}
8167b1d0 130 AliAnalysisDataWrapper(TObject *data);
981f2614 131 AliAnalysisDataWrapper(const AliAnalysisDataWrapper &other)
132 : TNamed(other), fData(other.fData) {}
8167b1d0 133 virtual ~AliAnalysisDataWrapper();
981f2614 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);
8167b1d0 141 void SetDeleteData(Bool_t flag=kTRUE) {TObject::SetBit(kDeleteData,flag);}
981f2614 142
143protected:
144 TObject *fData; // Wrapped data
145
146 ClassDef(AliAnalysisDataWrapper, 1) // Data wrapper class for exchange via the net
147};
148
9162405c 149//==============================================================================
150// AliAnalysisFileDescriptor - A simple wrapper for data related to accessing
151// an analysis input file.
152//==============================================================================
9162405c 153class AliAnalysisFileDescriptor : public TObject {
154
155public:
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;
2ad98fc5 181 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
9162405c 182 void SetOpenTime(Double_t time) {fOpenTime = time;}
183
184
185protected:
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
9c19e756 201 TStopwatch fTimer; //! Processing time
9162405c 202
203 ClassDef(AliAnalysisFileDescriptor,1) // Class describing a a file processed in the analysis
204};
205
d3106602 206#endif