]>
Commit | Line | Data |
---|---|---|
a8aea857 | 1 | // -*- Mode: C++ -*- |
2 | // @(#) $Id$ | |
3 | ||
4 | #ifndef ALIHLTFILEPUBLISHER_H | |
5 | #define ALIHLTFILEPUBLISHER_H | |
b6800be0 | 6 | /* This file is property of and copyright by the ALICE HLT Project * |
7 | * ALICE Experiment at CERN, All rights reserved. * | |
a8aea857 | 8 | * See cxx source for full Copyright notice */ |
9 | ||
10 | /** @file AliHLTFilePublisher.h | |
11 | @author Matthias Richter | |
12 | @date | |
13 | @brief An HLT file publishing (data source) component. | |
14 | @note The class is used in Offline (AliRoot) context | |
15 | */ | |
16 | ||
17 | #include "AliHLTDataSource.h" | |
d397a3b2 | 18 | #include <TFile.h> |
a8aea857 | 19 | #include <TList.h> |
20 | ||
21 | /** | |
22 | * @class AliHLTFilePublisher | |
23 | * An HLT data source component which publishes data from one or a sequence | |
24 | * of files.<br> | |
25 | * | |
26 | * Component ID: \b FilePublisher <br> | |
90ebac25 | 27 | * Library: \b libAliHLTUtil. |
a8aea857 | 28 | * |
29 | * Mandatory arguments: <br> | |
30 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating --> | |
31 | * \li -datafile <i> filename </i> | |
32 | * \li -datafilelist <i> file pattern </i> <br> | |
33 | * not yet implemented | |
34 | * \li -datatype <i> datatype dataorigin </i> <br> | |
d397a3b2 | 35 | * data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt> |
a8aea857 | 36 | * \li -dataspec <i> specification </i> <br> |
37 | * data specification treated as decimal number or hex number if | |
38 | * prepended by '0x' | |
d397a3b2 | 39 | * \li -nextevent |
40 | * indicate files published by the next event | |
a8aea857 | 41 | * |
42 | * Optional arguments:<br> | |
43 | * | |
44 | * The component needs at least one argument \em -datafile or \em -datafilelist. | |
45 | * Both can occur multiple times. The \em -datatype and \em -dataspec | |
46 | * parameters are valid for all files until the next occurrence of | |
d397a3b2 | 47 | * \em -datatype/spec. |
48 | * All files er published within one event, unless the \em -nexevent specifies | |
49 | * where to break into multiple events. | |
a8aea857 | 50 | * @ingroup alihlt_component |
51 | */ | |
52 | class AliHLTFilePublisher : public AliHLTDataSource { | |
53 | public: | |
54 | /** standard constructor */ | |
55 | AliHLTFilePublisher(); | |
a8aea857 | 56 | /** destructor */ |
57 | virtual ~AliHLTFilePublisher(); | |
58 | ||
59 | const char* GetComponentID(); | |
60 | AliHLTComponentDataType GetOutputDataType(); | |
61 | void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); | |
62 | AliHLTComponent* Spawn(); | |
63 | ||
64 | /** | |
65 | * Open all files. | |
d397a3b2 | 66 | * Opens all files for all events from the event list @ref fEvents and adds TFile |
67 | * opjects to the internal list. | |
a8aea857 | 68 | */ |
69 | int OpenFiles(); | |
70 | ||
71 | protected: | |
72 | /** | |
73 | * Init method. | |
74 | */ | |
75 | int DoInit( int argc, const char** argv ); | |
76 | ||
77 | /** | |
78 | * Deinit method. | |
79 | */ | |
80 | int DoDeinit(); | |
81 | ||
82 | /** | |
83 | * Data processing method for the component. | |
84 | * @param evtData event data structure | |
85 | * @param trigData trigger data structure | |
86 | * @param outputPtr pointer to target buffer | |
87 | * @param size <i>input</i>: size of target buffer | |
88 | * <i>output</i>:size of produced data | |
89 | * @param outputBlocks list to receive output block descriptors | |
90 | * @return | |
91 | */ | |
92 | int GetEvent( const AliHLTComponentEventData& evtData, | |
93 | AliHLTComponentTriggerData& trigData, | |
94 | AliHLTUInt8_t* outputPtr, | |
95 | AliHLTUInt32_t& size, | |
96 | vector<AliHLTComponentBlockData>& outputBlocks ); | |
97 | ||
98 | /** | |
99 | * Scan one argument and adjacent parameters. | |
100 | * Can be overloaded by child classes in order to add additional arguments | |
101 | * beyond the standard arguments of the file publisher. The method is called | |
102 | * whenever a non-standard argument is recognized. | |
103 | * @param argc size of the argument array | |
104 | * @param argv agument array for component initialization | |
105 | * @return number of processed members of the argv <br> | |
106 | * -EINVAL unknown argument <br> | |
107 | * -EPROTO parameter for argument missing <br> | |
108 | */ | |
109 | virtual int ScanArgument(int argc, const char** argv); | |
110 | ||
111 | protected: | |
112 | /** | |
113 | * Get the data type which is set for the current file | |
114 | */ | |
d397a3b2 | 115 | //AliHLTComponentDataType GetCurrentDataType() const; |
a8aea857 | 116 | |
117 | /** | |
118 | * Get the data specification which is set for the current file | |
119 | */ | |
d397a3b2 | 120 | //AliHLTUInt32_t GetCurrentSpecification() const; |
a8aea857 | 121 | |
122 | private: | |
d397a3b2 | 123 | /** prohibit copy constructor */ |
124 | AliHLTFilePublisher(const AliHLTFilePublisher&); | |
125 | /** prohibit assignment operator */ | |
126 | AliHLTFilePublisher& operator=(const AliHLTFilePublisher&); | |
127 | ||
128 | /** | |
129 | * File descriptor. | |
130 | */ | |
131 | class FileDesc : public TObject { | |
132 | public: | |
133 | /** constructor not implemented */ | |
134 | FileDesc(); | |
135 | /** constructor to use */ | |
136 | FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec); | |
137 | /** destructor */ | |
138 | ~FileDesc(); | |
139 | ||
140 | /** | |
141 | * Open the file. | |
142 | * @return size of the file, neg. error code if failed | |
143 | */ | |
144 | int OpenFile(); | |
145 | ||
146 | /** | |
147 | * Get name of the file. | |
148 | */ | |
149 | const char* GetName() {return fName.Data();} | |
150 | ||
151 | // implicite type conversions | |
152 | operator TFile*() const {return fpInstance;} | |
153 | operator AliHLTComponentDataType() {return fDataType;} | |
154 | operator AliHLTUInt32_t() {return fSpecification;} | |
155 | ||
156 | private: | |
157 | /** prohibited copy constructor */ | |
158 | FileDesc(FileDesc&); | |
159 | /** prohibited copy operator */ | |
160 | FileDesc& operator=(FileDesc&); | |
161 | ||
162 | /** file name */ | |
163 | TString fName; //! transient | |
164 | /** file instance */ | |
165 | TFile* fpInstance; //! transient | |
166 | /** data type */ | |
167 | AliHLTComponentDataType fDataType; //! transient | |
168 | /** data specification */ | |
169 | AliHLTUInt32_t fSpecification; //! transient | |
170 | }; | |
171 | ||
172 | /** | |
173 | * Compound to store all files and meta information for one event. | |
174 | */ | |
175 | class EventFiles : public TObject { | |
176 | public: | |
177 | /** constructor */ | |
178 | EventFiles() : fFiles(), fSize(0) {fFiles.SetOwner();} | |
179 | /** destructor */ | |
180 | ~EventFiles() {} | |
181 | ||
182 | /** | |
183 | * Add a file descriptor | |
184 | */ | |
185 | void Add(TObject* pObj) {fFiles.Add(pObj);} | |
186 | ||
187 | operator TList&() {return fFiles;} | |
188 | ||
189 | private: | |
190 | /** list of file names for the event */ | |
191 | TList fFiles; //! transient | |
192 | /** size of all the files in that event */ | |
193 | Int_t fSize; //! transient | |
194 | }; | |
195 | ||
196 | /** | |
197 | * Insert a file descriptor into the event descriptor. | |
198 | * If the event descriptor is NULL it is created before the file descriptor | |
199 | * is inserted. | |
200 | * @param pCurrEvent reference of the event descriptor pointer | |
201 | * @param pDesc file decriptor | |
202 | * @return neg. error value if failed | |
203 | */ | |
204 | int InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc); | |
205 | ||
206 | /** | |
207 | * Insert an event. | |
208 | * The event descriptor is added to the list and the reference is cleared. | |
209 | * @param pEvent event decriptor | |
210 | * @return neg. error value if failed | |
211 | */ | |
212 | int InsertEvent(EventFiles* &pEvent); | |
213 | ||
214 | /** the current event */ | |
215 | TObjLink *fpCurrent; //! transient | |
216 | ||
217 | /** the list of events to be published */ | |
218 | TList fEvents; //! transient | |
219 | ||
a8aea857 | 220 | /** the maximum buffer size i.e. size of the biggest file */ |
d397a3b2 | 221 | Int_t fMaxSize; //! transient |
a8aea857 | 222 | |
d397a3b2 | 223 | ClassDef(AliHLTFilePublisher, 1) |
a8aea857 | 224 | }; |
225 | #endif |