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 // see below for class documentation
19 // refer to README to build package
21 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
23 #include "AliHLTDataSource.h"
28 * @class AliHLTFilePublisher
29 * An HLT data source component which publishes data from one or a sequence
32 * Component ID: \b FilePublisher <br>
33 * Library: \b libAliHLTUtil.
35 * Mandatory arguments: <br>
36 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
37 * \li -datafile <i> filename </i>
38 * \li -datafilelist <i> file pattern </i> <br>
40 * \li -datatype <i> datatype dataorigin </i> <br>
41 * data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt>
42 * \li -dataspec <i> specification </i> <br>
43 * data specification treated as decimal number or hex number if
46 * indicate files published by the next event
48 * Optional arguments:<br>
49 * \li -open_files_at_start
50 * Opens all files during component initialisation rather than as needed
51 * during event processing. Note: this feature may result in the system
52 * running out of file handles if a large number of files was specified.
54 * The component needs at least one argument \em -datafile or \em -datafilelist.
55 * Both can occur multiple times. The \em -datatype and \em -dataspec
56 * parameters are valid for all files until the next occurrence of
58 * All files er published within one event, unless the \em -nexevent specifies
59 * where to break into multiple events.
60 * @ingroup alihlt_component
62 class AliHLTFilePublisher : public AliHLTDataSource {
64 /** standard constructor */
65 AliHLTFilePublisher();
67 virtual ~AliHLTFilePublisher();
69 const char* GetComponentID();
70 AliHLTComponentDataType GetOutputDataType();
71 int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
72 void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
73 AliHLTComponent* Spawn();
77 * Opens all files for all events from the event list @ref fEvents and adds TFile
78 * objects to the internal list. It also calculates the maximum event size required.
79 * @param keepOpen If this flag is true then the files are kept open, otherwise
80 * this method will close the files afterwards.
82 int OpenFiles(bool keepOpen);
88 int DoInit( int argc, const char** argv );
96 * Data processing method for the component.
97 * @param evtData event data structure
98 * @param trigData trigger data structure
99 * @param outputPtr pointer to target buffer
100 * @param size <i>input</i>: size of target buffer
101 * <i>output</i>:size of produced data
102 * @param outputBlocks list to receive output block descriptors
105 int GetEvent( const AliHLTComponentEventData& evtData,
106 AliHLTComponentTriggerData& trigData,
107 AliHLTUInt8_t* outputPtr,
108 AliHLTUInt32_t& size,
109 AliHLTComponentBlockDataList& outputBlocks );
111 using AliHLTDataSource::GetEvent;
114 * Scan one argument and adjacent parameters.
115 * Can be overloaded by child classes in order to add additional arguments
116 * beyond the standard arguments of the file publisher. The method is called
117 * whenever a non-standard argument is recognized.
118 * @param argc size of the argument array
119 * @param argv agument array for component initialization
120 * @return number of processed members of the argv <br>
121 * -EINVAL unknown argument <br>
122 * -EPROTO parameter for argument missing <br>
124 virtual int ScanArgument(int argc, const char** argv);
128 * Get the data type which is set for the current file
130 //AliHLTComponentDataType GetCurrentDataType() const;
133 * Get the data specification which is set for the current file
135 //AliHLTUInt32_t GetCurrentSpecification() const;
138 /** prohibit copy constructor */
139 AliHLTFilePublisher(const AliHLTFilePublisher&);
140 /** prohibit assignment operator */
141 AliHLTFilePublisher& operator=(const AliHLTFilePublisher&);
146 class FileDesc : public TObject {
148 /** constructor not implemented */
150 /** constructor to use */
151 FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec);
157 * @return size of the file, neg. error code if failed
162 * Close the file handle.
167 * Get name of the file.
169 const char* GetName() const {return fName.Data();}
174 int SetDataType(AliHLTComponentDataType dt) {fDataType=dt; return 0;}
177 * Set data specification
179 int SetSpecification(AliHLTUInt32_t spec) {fSpecification=spec; return 0;}
181 // implicite type conversions
182 operator TFile*() const {return fpInstance;}
183 operator AliHLTComponentDataType() const {return fDataType;}
184 operator AliHLTUInt32_t() const {return fSpecification;}
187 /** prohibited copy constructor */
189 /** prohibited copy operator */
190 FileDesc& operator=(FileDesc&);
193 TString fName; //! transient
195 TFile* fpInstance; //! transient
197 AliHLTComponentDataType fDataType; //! transient
198 /** data specification */
199 AliHLTUInt32_t fSpecification; //! transient
203 * Compound to store all files and meta information for one event.
205 class EventFiles : public TObject {
208 EventFiles() : fFiles(), fSize(0) {fFiles.SetOwner();}
213 * Add a file descriptor
215 void Add(TObject* pObj) {fFiles.Add(pObj);}
217 operator TList&() {return fFiles;}
220 /** list of file names for the event */
221 TList fFiles; //! transient
222 /** size of all the files in that event */
223 Int_t fSize; //! transient
227 * Insert a file descriptor into the event descriptor.
228 * If the event descriptor is NULL it is created before the file descriptor
230 * @param pCurrEvent reference of the event descriptor pointer
231 * @param pDesc file decriptor
232 * @return neg. error value if failed
234 int InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc);
238 * The event descriptor is added to the list and the reference is cleared.
239 * @param pEvent event decriptor
240 * @return neg. error value if failed
242 int InsertEvent(EventFiles* &pEvent);
244 /** the current event */
245 TObjLink *fpCurrent; //! transient
247 /** the list of events to be published */
248 TList fEvents; //! transient
250 /** the maximum buffer size i.e. size of the biggest file */
251 Int_t fMaxSize; //! transient
253 /** Flag specifying if all the files should be opened during initialisation. */
254 bool fOpenFilesAtStart; //! transient
256 /** output data types */
257 AliHLTComponentDataTypeList fOutputDataTypes; //! transient
259 ClassDef(AliHLTFilePublisher, 2)