3 #ifndef ALIHLTFILEWRITER_H
4 #define ALIHLTFILEWRITER_H
5 /* This file is property of and copyright by the ALICE HLT Project *
6 * ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
9 /** @file AliHLTFileWriter.h
10 @author Matthias Richter
12 @brief An HLT file dump (data sink) component.
15 #include "AliHLTDataSink.h"
20 * @class AliHLTFileWriter
21 * An HLT data sink component which writes data to file(s).
23 * Component ID: \b FileWriter <br>
24 * Library: \b libHLTBase (in order to use the component from the external
25 * interface, it might be necessary to specify a dummy library with the
26 * \em -componentlibrary argument).
28 * Mandatory arguments: <br>
29 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
31 * Optional arguments: <br>
32 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
33 * \li -datafile <i> filename </i> <br>
35 * \li -directory <i> directory </i> <br>
38 * don't use the event number but an event counter beginning from 0
39 * \li -concatenate-blocks <br>
40 * concatenate all blocks of one event into one file, this skips
41 * the block no, and the block data type in the file name
42 * \li -concatenate-events <br>
43 * concatenate all events into one file, this skips the event no,
44 * the block no, and the block data type in the file name. Currently,
45 * this implies the -concatenate-blocks option.
47 * The file name is built from the basename, the event number, the block
48 * number and the data type in the format:
50 * basename_eventno_blockno_dt
52 * If the basename was not given, \em 'event' ist used instead. A file
53 * extension after the last dot is separated from the basename and appended
56 * The class can be used as a base class for file writers. Additional
57 * argument scan can be implemented in @ref ScanArgument which is called
58 * for each unknown argument.
59 * @ingroup alihlt_component
61 class AliHLTFileWriter : public AliHLTDataSink {
63 /** standard constructor */
65 /** not a valid copy constructor, defined according to effective C++ style */
66 AliHLTFileWriter(const AliHLTFileWriter&);
67 /** not a valid assignment op, but defined according to effective C++ style */
68 AliHLTFileWriter& operator=(const AliHLTFileWriter&);
70 virtual ~AliHLTFileWriter();
72 virtual const char* GetComponentID();
73 virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
74 virtual AliHLTComponent* Spawn();
80 int DoInit( int argc, const char** argv );
89 * The DoInit function is not available for child classes. InitWriter is the
90 * corresponding function for classes derived from AliHLTFileWriter.
92 virtual int InitWriter();
96 * The DoDeinit function is not available for child classes. CloseWriter is the
97 * corresponding function for classes derived from AliHLTFileWriter.
99 virtual int CloseWriter();
102 * Data processing method for the component.
103 * The function can be overloaded by other file writer components.
104 * @param evtData event data structure
105 * @param blocks input data block descriptors
106 * @param trigData trigger data structure
108 virtual int DumpEvent( const AliHLTComponentEventData& evtData,
109 const AliHLTComponentBlockData* blocks,
110 AliHLTComponentTriggerData& trigData );
113 * Scan one argument and adjacent parameters.
114 * Can be overloaded by child classes in order to add additional arguments
115 * beyond the standard arguments of the file publisher. The method is called
116 * whenever a non-standard argument is recognized. Make sure to return
117 * <tt> -EPROTO </tt> if the argument is not recognized be the child.
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);
127 * Build file name from eventID data type and the specified directory and basename.
128 * @param eventID [in] the ID of the event
129 * @param blockID [in] the ID of the current block
130 * no block string appended if -1
131 * @param dataType [in] the data type of the data block
132 * no type string appanded if @ref kAliHLTVoidDataType
133 * @param filename [out] string to receive the file name
135 int BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename);
139 * @return current mode flags
141 int SetMode(Short_t mode);
145 * @return current mode flags
147 int ClearMode(Short_t mode);
151 * @return 1 if flag is set, 0 if not
153 int CheckMode(Short_t mode) const;
156 * Working modes of the writer
161 * flag to indicate whether to write each incoming block to separate files
162 * or all blocks of one event to one file. set = concatenate (one file).
164 kConcatenateBlocks = 0x1,
167 * flag to indicate whether to concatenate incoming blocks of the same type
168 * for all events to one file. If also @ref kConcatenateBlocks is set,
169 * or all blocks of all events are written to the same file.
171 kConcatenateEvents = 0x2,
173 /** event enumeration flag */
178 /** the basename of the output file */
179 TString fBaseName; // see above
180 /** the extension of the output file */
181 TString fExtension; // see above
182 /** target directory */
183 TString fDirectory; // see above
184 /** enumeration format string */
185 TString fCurrentFileName; // see above
187 /** mode specifier, see @ref TWriterMode */
188 Short_t fMode; // see above
190 ClassDef(AliHLTFileWriter, 1)