4 #ifndef ALIHLTOUTCOMPONENT_H
5 #define ALIHLTOUTCOMPONENT_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 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 // see class description below
18 // refer to README to build package
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTOfflineDataSink.h"
24 class AliHLTHOMERLibManager;
25 class AliHLTMonitoringWriter;
28 typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector;
31 * @class AliHLTOUTComponent
32 * The HLTOUT data sink component which models the behavior of the HLTOUT
33 * nodes of the HLT cluster.
34 * <h2>General properties:</h2>
35 * The HLTOUT component is attached at the end of a chain. It stores all input
36 * block in the HOMER format, distributed over a number of DDL link. The data
37 * is stored in a digit file or in raw ddl files.
39 * Component ID: \b HLTOUT <br>
40 * Library: \b libHLTrec.so <br>
41 * Input Data Types: @ref kAliHLTAnyDataType <br>
42 * Output Data Types: none (offline data sink) <br>
44 * <h2>Mandatory arguments:</h2>
45 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
47 * <h2>Optional arguments:</h2>
48 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
49 * \li -links <i> n </i> <br>
50 * number of output ddl links
51 * \li -digitfile <i> name </i> <br>
52 * name of the digit file to write (default HLT.Digits.root)
53 * \li -rawout[=on,off] <br>
54 * switch raw output on/off (default on)
55 * \li -digitout[=on,off] <br>
56 * switch digit output on/off (default on)
58 * <h2>Configuration:</h2>
59 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
62 * <h2>Default CDB entries:</h2>
65 * <h2>Performance:</h2>
66 * The component does not any event data processing.
68 * <h2>Memory consumption:</h2>
69 * The component does not any event data processing.
71 * <h2>Output size:</h2>
72 * The component is an offline sink component and has no output data.
74 * The component can be used to write data in the same format as
75 * the HLTOUT on the real HLT. In case of AliRoot simulation, the
76 * component is automatically added to the chain if the specified
77 * chains have output data. By that means, the HLT output is added
80 * @ingroup alihlt_aliroot_simulation
82 class AliHLTOUTComponent : public AliHLTOfflineDataSink {
84 /** standard constructor */
87 virtual ~AliHLTOUTComponent();
89 const char* GetComponentID();
90 void GetInputDataTypes( vector<AliHLTComponentDataType>& 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 /** write the raw files of the HLT links */
107 kWriteRawFiles = 0x1,
108 /** write the digit file */
116 int DoInit( int argc, const char** argv );
118 /// inherited from AliHLTComponent, component specific argument scan
119 int ScanConfigurationArgument(int argc, const char** argv);
127 * Data processing method for the component.
128 * The function can be overloaded by other file writer components.
129 * @param evtData event data structure
130 * @param blocks input data block descriptors
131 * @param trigData trigger data structure
133 int DumpEvent( const AliHLTComponentEventData& evtData,
134 const AliHLTComponentBlockData* blocks,
135 AliHLTComponentTriggerData& trigData );
137 using AliHLTDataSink::DumpEvent;
140 * Fill ESD for one event.
141 * Empty now, data written in Write() at the end of DumpEvent()
142 * @param eventNo event No. \em Note: this is an internal enumeration of the
144 * @param runLoader the AliRoot runloader
145 * @return neg. error code if failed
147 int FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd);
150 * Write the ecoded HLTOUT data to raw and digits files.
151 * Originally data was written in the FillESD function of the
152 * AliHLTOfflineInterface. Mainly for the sake of availability of the
153 * AliLoader. This concept has not turned out to be succesful and the
154 * development went a slightly different direction with the concept of
156 * 2010-04-14 change the original FillESD() to Write(), keep the body
159 * @param eventNo event No. \em Note: this is an internal enumeration of the
161 * @param runLoader the AliRoot runloader
162 * @return neg. error code if failed
164 int Write(int eventNo, AliRunLoader* runLoader);
167 /** copy constructor prohibited */
168 AliHLTOUTComponent(const AliHLTOUTComponent&);
169 /** assignment operator prohibited */
170 AliHLTOUTComponent& operator=(const AliHLTOUTComponent&);
172 int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size);
175 * Fill the output buffer and allocate if neccessary.
176 * Assemble ouput buffer with Common Data Header, HLT header and data from the
177 * writer. Works on the same buffer witch is allocated once and eventually
178 * grown in order to avoid frequent allocs/deallocs.
179 * @param eventNo number of the event
180 * @param pWriter [IN] the HOMER writer
181 * @param pBuffer [OUT] target to receive the pointer to buffer
182 * @return size of the buffer
184 int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer);
187 * Write data for a DDL link.
188 * @param hltddl Number of DDL link within the range of HLT
189 * @param pBuffer buffer to write
190 * @param bufferSize size of the buffer
192 int WriteDigitArray(int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int bufferSize);
195 * Write the digits for one DDL
196 * @param eventNo number of the event
197 * @param runLoader AliRoot run loader instance
198 * @return neg. error if failed
200 int WriteDigits(int eventNo, AliRunLoader* runLoader);
203 * Write the raw file for one DDL
204 * @param eventNo number of the event
205 * @param runLoader AliRoot run loader instance
206 * @param hltddl Number of DDL link within the range of HLT
207 * @param pBuffer buffer to write
208 * @param size size of the buffer
209 * @return neg. error if failed
211 int WriteRawFile(int eventNo, AliRunLoader* runLoader, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size);
213 /** list of HOMER writers */
214 AliHLTMonitoringWriterPVector fWriters; //!transient
216 /** number of DDLs used*/
217 int fNofDDLs; //!transient
219 /** equipment ID of first HLT DDL */
220 int fIdFirstDDL; //!transient
222 /** output buffer, allocated once in order to avoid frequent alloc/dealloc */
223 vector<AliHLTUInt8_t> fBuffer; //!transient
225 /** instance of the HOMER library manager */
226 AliHLTHOMERLibManager* fpLibManager; // !transient
228 /** global options for all instances */
229 static int fgOptions; //! transient
231 /** digit file name */
232 TString fDigitFileName; //! transient
234 /** the root file for the HLT 'digit' output */
235 TFile* fpDigitFile; //!transient
237 /** the tree for the HLT 'digit' output */
238 TTree* fpDigitTree; //!transient
240 /** array of TArrayC output buffers and branches */
241 TArrayC** fppDigitArrays; //!transient
243 /** Id of HOMER writer kept from previous event */
244 int fReservedWriter; //!transient
246 /** Data size kept in the internal buffer */
247 int fReservedData; //!transient
249 ClassDef(AliHLTOUTComponent, 4)