3 #ifndef ALIHLTFILEWRITER_H
4 #define ALIHLTFILEWRITER_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
8 /** @file AliHLTFileWriter.h
9 @author Matthias Richter
11 @brief An HLT file dump (data sink) component.
14 #include "AliHLTDataSink.h"
19 * @class AliHLTFileWriter
20 * An HLT data sink component which writes data to file(s).
22 * Component ID: \b FileWriter <br>
23 * Library: \b libHLTBase (in order to use the component from the external
24 * interface, it might be necessary to specify a dummy library with the
25 * \em -componentlibrary argument).
27 * Mandatory arguments: <br>
28 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
30 * Optional arguments: <br>
31 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
32 * \li -datafile <i> filename </i> <br>
34 * \li -directory <i> directory </i> <br>
37 * don't use the event number but an event counter beginning from 0
38 * \li -concatenate-blocks <br>
39 * concatenate all blocks of one event into one file, this skips
40 * the block no, and the block data type in the file name
41 * \li -concatenate-events <br>
42 * concatenate all events into one file, this skips the event no,
43 * the block no, and the block data type in the file name. Currently,
44 * this implies the -concatenate-blocks option.
46 * The file name is built from the basename, the event number, the block
47 * number and the data type in the format:
49 * basename_eventno_blockno_dt
51 * If the basename was not given, \em 'event' ist used instead. A file
52 * extension after the last dot is separated from the basename and appended
55 * The class can be used as a base class for file writers. Additional
56 * argument scan can be implemented in @ref ScanArgument which is called
57 * for each unknown argument.
58 * @ingroup alihlt_component
60 class AliHLTFileWriter : public AliHLTDataSink {
62 /** standard constructor */
64 /** not a valid copy constructor, defined according to effective C++ style */
65 AliHLTFileWriter(const AliHLTFileWriter&);
66 /** not a valid assignment op, but defined according to effective C++ style */
67 AliHLTFileWriter& operator=(const AliHLTFileWriter&);
69 virtual ~AliHLTFileWriter();
71 virtual const char* GetComponentID();
72 virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
73 virtual AliHLTComponent* Spawn();
79 int DoInit( int argc, const char** argv );
88 * The DoInit function is not available for child classes. InitWriter is the
89 * corresponding function for classes derived from AliHLTFileWriter.
91 virtual int InitWriter();
95 * The DoDeinit function is not available for child classes. CloseWriter is the
96 * corresponding function for classes derived from AliHLTFileWriter.
98 virtual int CloseWriter();
101 * Data processing method for the component.
102 * The function can be overloaded by other file writer components.
103 * @param evtData event data structure
104 * @param blocks input data block descriptors
105 * @param trigData trigger data structure
107 virtual int DumpEvent( const AliHLTComponentEventData& evtData,
108 const AliHLTComponentBlockData* blocks,
109 AliHLTComponentTriggerData& trigData );
112 * Scan one argument and adjacent parameters.
113 * Can be overloaded by child classes in order to add additional arguments
114 * beyond the standard arguments of the file publisher. The method is called
115 * whenever a non-standard argument is recognized. Make sure to return
116 * <tt> -EPROTO </tt> if the argument is not recognized be the child.
117 * @param argc size of the argument array
118 * @param argv agument array for component initialization
119 * @return number of processed members of the argv <br>
120 * -EINVAL unknown argument <br>
121 * -EPROTO parameter for argument missing <br>
123 virtual int ScanArgument(int argc, const char** argv);
126 * Build file name from eventID data type and the specified directory and basename.
127 * @param eventID [in] the ID of the event
128 * @param blockID [in] the ID of the current block
129 * no block string appended if -1
130 * @param dataType [in] the data type of the data block
131 * no type string appanded if @ref kAliHLTVoidDataType
132 * @param filename [out] string to receive the file name
134 int BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename);
138 * @return current mode flags
140 int SetMode(Short_t mode);
144 * @return current mode flags
146 int ClearMode(Short_t mode);
150 * @return 1 if flag is set, 0 if not
152 int CheckMode(Short_t mode) const;
155 * Working modes of the writer
160 * flag to indicate whether to write each incoming block to separate files
161 * or all blocks of one event to one file. set = concatenate (one file).
163 kConcatenateBlocks = 0x1,
166 * flag to indicate whether to concatenate incoming blocks of the same type
167 * for all events to one file. If also @ref kConcatenateBlocks is set,
168 * or all blocks of all events are written to the same file.
170 kConcatenateEvents = 0x2,
172 /** event enumeration flag */
177 /** the basename of the output file */
178 TString fBaseName; // see above
179 /** the extension of the output file */
180 TString fExtension; // see above
181 /** target directory */
182 TString fDirectory; // see above
183 /** enumeration format string */
184 TString fCurrentFileName; // see above
186 /** mode specifier, see @ref TWriterMode */
187 Short_t fMode; // see above
189 ClassDef(AliHLTFileWriter, 1)