4 #ifndef ALIHLTFILEPUBLISHER_H
5 #define ALIHLTFILEPUBLISHER_H
6 //* This file is property of and copyright by the ALICE HLT Project *
7 //* ALICE Experiment at CERN, All rights reserved. *
8 //* See cxx source for full Copyright notice *
10 /** @file AliHLTFilePublisher.h
11 @author Matthias Richter
13 @brief An HLT file publishing (data source) component.
14 @note The class is used in Offline (AliRoot) context
17 #include "AliHLTDataSource.h"
22 * @class AliHLTFilePublisher
23 * An HLT data source component which publishes data from one or a sequence
26 * <h2>General properties:</h2>
28 * Component ID: \b FilePublisher <br>
29 * Library: \b libAliHLTUtil.so <br>
30 * Input Data Types: none <br>
31 * Output Data Types: according to arguments <br>
33 * <h2>Mandatory arguments:</h2>
34 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
35 * \li -datafile <i> filename </i>
36 * \li -datafilelist <i> file pattern </i> <br>
38 * \li -datatype <i> datatype dataorigin </i> <br>
39 * data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt>
40 * \li -dataspec <i> specification </i> <br>
41 * data specification treated as decimal number or hex number if
44 * indicate files published by the next event
46 * <h2>Optional arguments:</h2>
47 * \li -open_files_at_start
48 * Opens all files during component initialisation rather than as needed
49 * during event processing. Note: this feature may result in the system
50 * running out of file handles if a large number of files was specified.
52 * <h2>Configuration:</h2>
53 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
54 * Configuration by component arguments.
56 * <h2>Default CDB entries:</h2>
57 * The component loads no CDB entries.
59 * <h2>Performance:</h2>
60 * The component does not process any event data.
62 * <h2>Memory consumption:</h2>
63 * The component does not process any event data.
65 * <h2>Output size:</h2>
66 * According to the available data. The component is an AliHLTDataSource
67 * and inteded to be used in the AliHLTSystem framework only. The component
68 * implements the standard AliHLTSystem adaptive buffer allocation.
70 * The component needs at least one argument \em -datafile or \em -datafilelist.
71 * Both can occur multiple times. The \em -datatype and \em -dataspec
72 * parameters are valid for all files until the next occurrence of
74 * All files er published within one event, unless the \em -nexevent specifies
75 * where to break into multiple events.
77 * @ingroup alihlt_util_components
79 class AliHLTFilePublisher : public AliHLTDataSource {
81 /** standard constructor */
82 AliHLTFilePublisher();
84 virtual ~AliHLTFilePublisher();
86 const char* GetComponentID();
87 AliHLTComponentDataType GetOutputDataType();
88 int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
89 void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
90 AliHLTComponent* Spawn();
94 * Opens all files for all events from the event list @ref fEvents and adds TFile
95 * objects to the internal list. It also calculates the maximum event size required.
96 * @param keepOpen If this flag is true then the files are kept open, otherwise
97 * this method will close the files afterwards.
99 int OpenFiles(bool keepOpen);
101 /** Get List of Events, needed in the RootFilePublisher.*/
102 TList* GetEventList() { return &fEvents;}
104 /** Set if root files instead of raw files should be read,
105 * needed in the RootFilePublisher.
106 * @param isRaw kTRUE if raw file, kFALSE for rootfile
108 void SetIsRawFile( Bool_t isRaw ) { fIsRaw = isRaw; }
114 virtual int DoInit( int argc, const char** argv );
122 * Data processing method for the component.
123 * @param evtData event data structure
124 * @param trigData trigger data structure
125 * @param outputPtr pointer to target buffer
126 * @param size <i>input</i>: size of target buffer
127 * <i>output</i>:size of produced data
128 * @param outputBlocks list to receive output block descriptors
131 int GetEvent( const AliHLTComponentEventData& evtData,
132 AliHLTComponentTriggerData& trigData,
133 AliHLTUInt8_t* outputPtr,
134 AliHLTUInt32_t& size,
135 AliHLTComponentBlockDataList& outputBlocks );
137 using AliHLTDataSource::GetEvent;
140 * Scan one argument and adjacent parameters.
141 * Can be overloaded by child classes in order to add additional arguments
142 * beyond the standard arguments of the file publisher. The method is called
143 * whenever a non-standard argument is recognized.
144 * @param argc size of the argument array
145 * @param argv agument array for component initialization
146 * @return number of processed members of the argv <br>
147 * -EINVAL unknown argument <br>
148 * -EPROTO parameter for argument missing <br>
150 virtual int ScanArgument(int argc, const char** argv);
153 * Get the data type which is set for the current file
155 //AliHLTComponentDataType GetCurrentDataType() const;
158 * Get the data specification which is set for the current file
160 //AliHLTUInt32_t GetCurrentSpecification() const;
163 /** prohibit copy constructor */
164 AliHLTFilePublisher(const AliHLTFilePublisher&);
165 /** prohibit assignment operator */
166 AliHLTFilePublisher& operator=(const AliHLTFilePublisher&);
172 class FileDesc : public TObject {
174 /** constructor not implemented */
176 /** constructor to use */
177 FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec, Bool_t isRaw=kTRUE);
183 * @return size of the file, neg. error code if failed
188 * Close the file handle.
193 * Get name of the file.
195 const char* GetName() const {return fName.Data();}
200 int SetDataType(AliHLTComponentDataType dt) {fDataType=dt; return 0;}
203 * Set data specification
205 int SetSpecification(AliHLTUInt32_t spec) {fSpecification=spec; return 0;}
207 // implicite type conversions
208 operator TFile*() const {return fpInstance;}
209 operator AliHLTComponentDataType() const {return fDataType;}
210 operator AliHLTUInt32_t() const {return fSpecification;}
213 /** prohibited copy constructor */
215 /** prohibited copy operator */
216 FileDesc& operator=(FileDesc&);
218 /** is raw (kTRUE) or root (kFALSE) file */
219 Bool_t fIsRaw; //! transient
221 TString fName; //! transient
223 TFile* fpInstance; //! transient
225 AliHLTComponentDataType fDataType; //! transient
226 /** data specification */
227 AliHLTUInt32_t fSpecification; //! transient
231 * Compound to store all files and meta information for one event.
233 class EventFiles : public TObject {
236 EventFiles() : fFiles(), fSize(0) {fFiles.SetOwner();}
241 * Add a file descriptor
243 void Add(TObject* pObj) {fFiles.Add(pObj);}
245 operator TList&() {return fFiles;}
246 operator TList*() {return &fFiles;}
249 /** list of file names for the event */
250 TList fFiles; //! transient
251 /** size of all the files in that event */
252 Int_t fSize; //! transient
256 * Insert a file descriptor into the event descriptor.
257 * If the event descriptor is NULL it is created before the file descriptor
259 * @param pCurrEvent reference of the event descriptor pointer
260 * @param pDesc file decriptor
261 * @return neg. error value if failed
263 int InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc);
267 * The event descriptor is added to the list and the reference is cleared.
268 * @param pEvent event decriptor
269 * @return neg. error value if failed
271 int InsertEvent(EventFiles* &pEvent);
273 /** the current event */
274 TObjLink *fpCurrent; //! transient
276 /** the list of events to be published */
277 TList fEvents; //! transient
279 /** the maximum buffer size i.e. size of the biggest file */
280 Int_t fMaxSize; //! transient
282 /** Flag specifying if all the files should be opened during initialisation. */
283 bool fOpenFilesAtStart; //! transient
285 /** output data types */
286 AliHLTComponentDataTypeList fOutputDataTypes; //! transient
288 /** Is raw file (kTRUE) [default] or root file (kFALSE). */
289 Bool_t fIsRaw; //! transient
291 ClassDef(AliHLTFilePublisher, 3)