]>
Commit | Line | Data |
---|---|---|
adf1619a | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
3 | ||
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 * | |
9 | ||
10 | /// @file AliHLTOUTComponent.h | |
11 | /// @author Matthias Richter | |
12 | /// @date | |
13 | /// @brief The HLTOUT data sink component similar to HLTOUT nodes. | |
14 | /// @note Used in the AliRoot environment only. | |
15 | ||
16 | #include "AliHLTDataSink.h" | |
17 | ||
18 | class AliHLTHOMERLibManager; | |
19 | class AliHLTMonitoringWriter; | |
20 | class TFile; | |
21 | class TTree; | |
22 | typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector; | |
23 | ||
24 | /** | |
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. | |
32 | * | |
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> | |
37 | * | |
38 | * <h2>Mandatory arguments:</h2> | |
39 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> | |
40 | * | |
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) | |
51 | * | |
52 | * <h2>Configuration:</h2> | |
53 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> | |
54 | * none | |
55 | * | |
56 | * <h2>Default CDB entries:</h2> | |
57 | * none | |
58 | * | |
59 | * <h2>Performance:</h2> | |
60 | * The component does not any event data processing. | |
61 | * | |
62 | * <h2>Memory consumption:</h2> | |
63 | * The component does not any event data processing. | |
64 | * | |
65 | * <h2>Output size:</h2> | |
66 | * The component is an offline sink component and has no output data. | |
67 | * | |
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 | |
72 | * to the simulation. | |
73 | * | |
74 | * @ingroup alihlt_aliroot_simulation | |
75 | */ | |
76 | class AliHLTOUTComponent : public AliHLTDataSink { | |
77 | public: | |
78 | /// type of the HLTOUT component | |
79 | enum EType { | |
80 | kGlobal = 0, // generate according to global flags | |
81 | kDigits = 1, // generate only digits: ID HLTOUTdigits | |
82 | kRaw = 2 // generate only raw: ID HLTOUTraw | |
83 | }; | |
84 | /// constructor for different component types | |
85 | AliHLTOUTComponent(EType type=kGlobal); | |
86 | /** destructor */ | |
87 | virtual ~AliHLTOUTComponent(); | |
88 | ||
89 | const char* GetComponentID(); | |
90 | void GetInputDataTypes( AliHLTComponentDataTypeList& list); | |
91 | AliHLTComponent* Spawn(); | |
92 | ||
93 | /** | |
94 | * Enable global options valid for all instances of the component | |
95 | * @param options bit field | |
96 | */ | |
97 | static void SetGlobalOption(unsigned int options); | |
98 | ||
99 | /** | |
100 | * Disable global options valid for all instances of the component | |
101 | * @param options bit field | |
102 | */ | |
103 | static void ClearGlobalOption(unsigned int options); | |
104 | ||
105 | /** | |
106 | * Test one of the global options | |
107 | */ | |
108 | static bool TestGlobalOption(unsigned int option); | |
109 | ||
110 | enum { | |
111 | /** write the raw files of the HLT links */ | |
112 | kWriteRawFiles = 0x1, | |
113 | /** write the digit file */ | |
114 | kWriteDigits = 0x2 | |
115 | }; | |
116 | ||
117 | protected: | |
118 | /** | |
119 | * Init method. | |
120 | */ | |
121 | int DoInit( int argc, const char** argv ); | |
122 | ||
123 | /// inherited from AliHLTComponent, component specific argument scan | |
124 | int ScanConfigurationArgument(int argc, const char** argv); | |
125 | ||
126 | /** | |
127 | * Deinit method. | |
128 | */ | |
129 | int DoDeinit(); | |
130 | ||
131 | /** | |
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 | |
137 | */ | |
138 | int DumpEvent( const AliHLTComponentEventData& evtData, | |
139 | const AliHLTComponentBlockData* blocks, | |
140 | AliHLTComponentTriggerData& trigData ); | |
141 | ||
142 | using AliHLTDataSink::DumpEvent; | |
143 | ||
144 | /** | |
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 | |
150 | * HLTOUT handlers. | |
151 | * 2010-04-14 change the original FillESD() to Write(), keep the body | |
152 | * of the function | |
153 | * | |
154 | * @param eventNo event No. \em Note: this is an internal enumeration of the | |
155 | * processed events. | |
156 | * @param runLoader the AliRoot runloader | |
157 | * @return neg. error code if failed | |
158 | */ | |
159 | int Write(int eventNo); | |
160 | ||
161 | private: | |
162 | /** copy constructor prohibited */ | |
163 | AliHLTOUTComponent(const AliHLTOUTComponent&); | |
164 | /** assignment operator prohibited */ | |
165 | AliHLTOUTComponent& operator=(const AliHLTOUTComponent&); | |
166 | ||
167 | int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size); | |
168 | ||
169 | /** | |
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 | |
178 | */ | |
179 | int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer); | |
180 | ||
181 | /** | |
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 | |
186 | */ | |
187 | int WriteDigitArray(int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int bufferSize); | |
188 | ||
189 | /** | |
190 | * Write the digits for one DDL | |
191 | * @param eventNo number of the event | |
192 | * @return neg. error if failed | |
193 | */ | |
194 | int WriteDigits(int eventNo); | |
195 | ||
196 | /** | |
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 | |
203 | */ | |
204 | int WriteRawFile(int eventNo, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size); | |
205 | ||
206 | /** list of HOMER writers */ | |
207 | AliHLTMonitoringWriterPVector fWriters; //!transient | |
208 | ||
209 | /** number of DDLs used*/ | |
210 | int fNofDDLs; //!transient | |
211 | ||
212 | /** equipment ID of first HLT DDL */ | |
213 | int fIdFirstDDL; //!transient | |
214 | ||
215 | /** output buffer, allocated once in order to avoid frequent alloc/dealloc */ | |
216 | vector<AliHLTUInt8_t> fBuffer; //!transient | |
217 | ||
218 | /** instance of the HOMER library manager */ | |
219 | AliHLTHOMERLibManager* fpLibManager; // !transient | |
220 | ||
221 | /** global options for all instances */ | |
222 | static int fgOptions; //! transient | |
223 | ||
224 | /// component options set from component type or global options at DoInit | |
225 | int fOptions; //! transient | |
226 | ||
227 | /** digit file name */ | |
228 | TString fDigitFileName; //! transient | |
229 | ||
230 | /** the root file for the HLT 'digit' output */ | |
231 | TFile* fpDigitFile; //!transient | |
232 | ||
233 | /** the tree for the HLT 'digit' output */ | |
234 | TTree* fpDigitTree; //!transient | |
235 | ||
236 | /** array of TArrayC output buffers and branches */ | |
237 | TArrayC** fppDigitArrays; //!transient | |
238 | ||
239 | /** Id of HOMER writer kept from previous event */ | |
240 | int fReservedWriter; //!transient | |
241 | ||
242 | /** Data size kept in the internal buffer */ | |
243 | int fReservedData; //!transient | |
244 | ||
245 | /// type of the component | |
246 | EType fType; //! type of the component | |
247 | ||
248 | /// counter for round robin usage of HLTOUT links | |
249 | int fRoundRobinCounter; //! counter for round robin usage of HLTOUT links | |
250 | ||
251 | ClassDef(AliHLTOUTComponent, 0) | |
252 | }; | |
253 | #endif |