]>
Commit | Line | Data |
---|---|---|
e2640fbd | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
c4228ec4 | 3 | |
4 | #ifndef ALIHLTOUTCOMPONENT_H | |
5 | #define ALIHLTOUTCOMPONENT_H | |
3c29512c | 6 | //* This file is property of and copyright by the * |
c5123824 | 7 | //* ALICE Experiment at CERN, All rights reserved. * |
8 | //* See cxx source for full Copyright notice * | |
c4228ec4 | 9 | |
4aa34abc | 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. | |
c4228ec4 | 15 | |
3c29512c | 16 | #include "AliHLTDataSink.h" |
c4228ec4 | 17 | |
64defa03 | 18 | class AliHLTHOMERLibManager; |
a183f221 | 19 | class AliHLTMonitoringWriter; |
c5123824 | 20 | class TFile; |
21 | class TTree; | |
a183f221 | 22 | typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector; |
4b113031 | 23 | |
c4228ec4 | 24 | /** |
25 | * @class AliHLTOUTComponent | |
26 | * The HLTOUT data sink component which models the behavior of the HLTOUT | |
27 | * nodes of the HLT cluster. | |
a8420176 | 28 | * <h2>General properties:</h2> |
e2640fbd | 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. | |
a8420176 | 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> | |
1ac82ce6 | 39 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> |
a8420176 | 40 | * |
41 | * <h2>Optional arguments:</h2> | |
1ac82ce6 | 42 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> |
a8420176 | 43 | * \li -links <i> n </i> <br> |
44 | * number of output ddl links | |
e2640fbd | 45 | * \li -digitfile <i> name </i> <br> |
3d24abe7 | 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) | |
a8420176 | 51 | * |
52 | * <h2>Configuration:</h2> | |
1ac82ce6 | 53 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> |
a8420176 | 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 | * | |
fb345ed7 | 74 | * @ingroup alihlt_aliroot_simulation |
c4228ec4 | 75 | */ |
3c29512c | 76 | class AliHLTOUTComponent : public AliHLTDataSink { |
c4228ec4 | 77 | public: |
6a904136 | 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); | |
c4228ec4 | 86 | /** destructor */ |
87 | virtual ~AliHLTOUTComponent(); | |
88 | ||
89 | const char* GetComponentID(); | |
3c29512c | 90 | void GetInputDataTypes( AliHLTComponentDataTypeList& list); |
c4228ec4 | 91 | AliHLTComponent* Spawn(); |
92 | ||
2c0e5942 | 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 | ||
6a904136 | 105 | /** |
106 | * Test one of the global options | |
107 | */ | |
108 | static bool TestGlobalOption(unsigned int option); | |
109 | ||
2c0e5942 | 110 | enum { |
111 | /** write the raw files of the HLT links */ | |
112 | kWriteRawFiles = 0x1, | |
113 | /** write the digit file */ | |
114 | kWriteDigits = 0x2 | |
115 | }; | |
116 | ||
c4228ec4 | 117 | protected: |
118 | /** | |
119 | * Init method. | |
120 | */ | |
121 | int DoInit( int argc, const char** argv ); | |
122 | ||
e2640fbd | 123 | /// inherited from AliHLTComponent, component specific argument scan |
124 | int ScanConfigurationArgument(int argc, const char** argv); | |
125 | ||
c4228ec4 | 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 | ||
d76bc02a | 142 | using AliHLTDataSink::DumpEvent; |
143 | ||
3d24abe7 | 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 | */ | |
3c29512c | 159 | int Write(int eventNo); |
3d24abe7 | 160 | |
c4228ec4 | 161 | private: |
162 | /** copy constructor prohibited */ | |
163 | AliHLTOUTComponent(const AliHLTOUTComponent&); | |
164 | /** assignment operator prohibited */ | |
165 | AliHLTOUTComponent& operator=(const AliHLTOUTComponent&); | |
166 | ||
a183f221 | 167 | int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size); |
4b113031 | 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 | */ | |
a183f221 | 179 | int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer); |
4b113031 | 180 | |
c5123824 | 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 | ||
4b113031 | 189 | /** |
190 | * Write the digits for one DDL | |
191 | * @param eventNo number of the event | |
4b113031 | 192 | * @return neg. error if failed |
193 | */ | |
3c29512c | 194 | int WriteDigits(int eventNo); |
4b113031 | 195 | |
196 | /** | |
197 | * Write the raw file for one DDL | |
198 | * @param eventNo number of the event | |
4b113031 | 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 | */ | |
3c29512c | 204 | int WriteRawFile(int eventNo, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size); |
4b113031 | 205 | |
206 | /** list of HOMER writers */ | |
a183f221 | 207 | AliHLTMonitoringWriterPVector fWriters; //!transient |
4b113031 | 208 | |
209 | /** number of DDLs used*/ | |
210 | int fNofDDLs; //!transient | |
211 | ||
212 | /** equipment ID of first HLT DDL */ | |
213 | int fIdFirstDDL; //!transient | |
214 | ||
4b113031 | 215 | /** output buffer, allocated once in order to avoid frequent alloc/dealloc */ |
216 | vector<AliHLTUInt8_t> fBuffer; //!transient | |
217 | ||
a183f221 | 218 | /** instance of the HOMER library manager */ |
219 | AliHLTHOMERLibManager* fpLibManager; // !transient | |
220 | ||
2c0e5942 | 221 | /** global options for all instances */ |
222 | static int fgOptions; //! transient | |
223 | ||
6a904136 | 224 | /// component options set from component type or global options at DoInit |
225 | int fOptions; //! transient | |
226 | ||
e2640fbd | 227 | /** digit file name */ |
228 | TString fDigitFileName; //! transient | |
229 | ||
c5123824 | 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 | ||
6478b06b | 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 | ||
6a904136 | 245 | /// type of the component |
246 | EType fType; //! type of the component | |
247 | ||
4aa34abc | 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) | |
c4228ec4 | 252 | }; |
253 | #endif |