4 #ifndef ALIHLTOUTCOMPONENT_H
5 #define ALIHLTOUTCOMPONENT_H
6 //* This file is property of and copyright by the *
7 //* ALICE Experiment at CERN, All rights reserved. *
8 //* See cxx source for full Copyright notice *
10 /// @file AliHLTOUTComponent.h
11 /// @author Matthias Richter
13 /// @brief The HLTOUT data sink component similar to HLTOUT nodes.
14 /// @note Used in the AliRoot environment only.
16 #include "AliHLTDataSink.h"
18 class AliHLTHOMERLibManager;
19 class AliHLTMonitoringWriter;
22 typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector;
25 * @class AliHLTOUTComponent
26 * The HLTOUT data sink component which models the behavior of the HLTOUT
27 * nodes of the HLT cluster.
28 * <h2>General properties:</h2>
29 * The HLTOUT component is attached at the end of a chain. It stores all input
30 * block in the HOMER format, distributed over a number of DDL link. The data
31 * is stored in a digit file or in raw ddl files.
33 * Component ID: \b HLTOUT <br>
34 * Library: \b libHLTrec.so <br>
35 * Input Data Types: @ref kAliHLTAnyDataType <br>
36 * Output Data Types: none (offline data sink) <br>
38 * <h2>Mandatory arguments:</h2>
39 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
41 * <h2>Optional arguments:</h2>
42 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
43 * \li -links <i> n </i> <br>
44 * number of output ddl links
45 * \li -digitfile <i> name </i> <br>
46 * name of the digit file to write (default HLT.Digits.root)
47 * \li -rawout[=on,off] <br>
48 * switch raw output on/off (default on)
49 * \li -digitout[=on,off] <br>
50 * switch digit output on/off (default on)
52 * <h2>Configuration:</h2>
53 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
56 * <h2>Default CDB entries:</h2>
59 * <h2>Performance:</h2>
60 * The component does not any event data processing.
62 * <h2>Memory consumption:</h2>
63 * The component does not any event data processing.
65 * <h2>Output size:</h2>
66 * The component is an offline sink component and has no output data.
68 * The component can be used to write data in the same format as
69 * the HLTOUT on the real HLT. In case of AliRoot simulation, the
70 * component is automatically added to the chain if the specified
71 * chains have output data. By that means, the HLT output is added
74 * @ingroup alihlt_aliroot_simulation
76 class AliHLTOUTComponent : public AliHLTDataSink {
78 /// type of the HLTOUT component
80 kGlobal = 0, // generate according to global flags
81 kDigits = 1, // generate only digits: ID HLTOUTdigits
82 kRaw = 2 // generate only raw: ID HLTOUTraw
84 /// constructor for different component types
85 AliHLTOUTComponent(EType type=kGlobal);
87 virtual ~AliHLTOUTComponent();
89 const char* GetComponentID();
90 void GetInputDataTypes( AliHLTComponentDataTypeList& list);
91 AliHLTComponent* Spawn();
94 * Enable global options valid for all instances of the component
95 * @param options bit field
97 static void SetGlobalOption(unsigned int options);
100 * Disable global options valid for all instances of the component
101 * @param options bit field
103 static void ClearGlobalOption(unsigned int options);
106 * Test one of the global options
108 static bool TestGlobalOption(unsigned int option);
111 /** write the raw files of the HLT links */
112 kWriteRawFiles = 0x1,
113 /** write the digit file */
121 int DoInit( int argc, const char** argv );
123 /// inherited from AliHLTComponent, component specific argument scan
124 int ScanConfigurationArgument(int argc, const char** argv);
132 * Data processing method for the component.
133 * The function can be overloaded by other file writer components.
134 * @param evtData event data structure
135 * @param blocks input data block descriptors
136 * @param trigData trigger data structure
138 int DumpEvent( const AliHLTComponentEventData& evtData,
139 const AliHLTComponentBlockData* blocks,
140 AliHLTComponentTriggerData& trigData );
142 using AliHLTDataSink::DumpEvent;
145 * Write the ecoded HLTOUT data to raw and digits files.
146 * Originally data was written in the FillESD function of the
147 * AliHLTOfflineInterface. Mainly for the sake of availability of the
148 * AliLoader. This concept has not turned out to be succesful and the
149 * development went a slightly different direction with the concept of
151 * 2010-04-14 change the original FillESD() to Write(), keep the body
154 * @param eventNo event No. \em Note: this is an internal enumeration of the
156 * @param runLoader the AliRoot runloader
157 * @return neg. error code if failed
159 int Write(int eventNo);
162 /** copy constructor prohibited */
163 AliHLTOUTComponent(const AliHLTOUTComponent&);
164 /** assignment operator prohibited */
165 AliHLTOUTComponent& operator=(const AliHLTOUTComponent&);
167 int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size);
170 * Fill the output buffer and allocate if neccessary.
171 * Assemble ouput buffer with Common Data Header, HLT header and data from the
172 * writer. Works on the same buffer witch is allocated once and eventually
173 * grown in order to avoid frequent allocs/deallocs.
174 * @param eventNo number of the event
175 * @param pWriter [IN] the HOMER writer
176 * @param pBuffer [OUT] target to receive the pointer to buffer
177 * @return size of the buffer
179 int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer);
182 * Write data for a DDL link.
183 * @param hltddl Number of DDL link within the range of HLT
184 * @param pBuffer buffer to write
185 * @param bufferSize size of the buffer
187 int WriteDigitArray(int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int bufferSize);
190 * Write the digits for one DDL
191 * @param eventNo number of the event
192 * @return neg. error if failed
194 int WriteDigits(int eventNo);
197 * Write the raw file for one DDL
198 * @param eventNo number of the event
199 * @param hltddl Number of DDL link within the range of HLT
200 * @param pBuffer buffer to write
201 * @param size size of the buffer
202 * @return neg. error if failed
204 int WriteRawFile(int eventNo, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size);
206 /** list of HOMER writers */
207 AliHLTMonitoringWriterPVector fWriters; //!transient
209 /** number of DDLs used*/
210 int fNofDDLs; //!transient
212 /** equipment ID of first HLT DDL */
213 int fIdFirstDDL; //!transient
215 /** output buffer, allocated once in order to avoid frequent alloc/dealloc */
216 vector<AliHLTUInt8_t> fBuffer; //!transient
218 /** instance of the HOMER library manager */
219 AliHLTHOMERLibManager* fpLibManager; // !transient
221 /** global options for all instances */
222 static int fgOptions; //! transient
224 /// component options set from component type or global options at DoInit
225 int fOptions; //! transient
227 /** digit file name */
228 TString fDigitFileName; //! transient
230 /** the root file for the HLT 'digit' output */
231 TFile* fpDigitFile; //!transient
233 /** the tree for the HLT 'digit' output */
234 TTree* fpDigitTree; //!transient
236 /** array of TArrayC output buffers and branches */
237 TArrayC** fppDigitArrays; //!transient
239 /** Id of HOMER writer kept from previous event */
240 int fReservedWriter; //!transient
242 /** Data size kept in the internal buffer */
243 int fReservedData; //!transient
245 /// type of the component
246 EType fType; //! type of the component
248 /// counter for round robin usage of HLTOUT links
249 int fRoundRobinCounter; //! counter for round robin usage of HLTOUT links
251 ClassDef(AliHLTOUTComponent, 0)