]>
Commit | Line | Data |
---|---|---|
dba14d7d | 1 | #ifndef ALIHLTMUONDATACHECKERCOMPONENT_H |
2 | #define ALIHLTMUONDATACHECKERCOMPONENT_H | |
3 | /* This file is property of and copyright by the ALICE HLT Project * | |
4 | * ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
887a669c | 7 | /* $Id: AliHLTMUONDataCheckerComponent.h 26179 2008-05-29 22:27:27Z aszostak $ */ |
dba14d7d | 8 | |
9 | /// | |
10 | /// @file AliHLTMUONDataCheckerComponent.h | |
11 | /// @author Artur Szostak <artursz@iafrica.com> | |
887a669c | 12 | /// @date 27 May 2008 |
dba14d7d | 13 | /// @brief Declaration of a component to check and validate the integrity of dHLT data. |
14 | /// | |
15 | ||
16 | #include "AliHLTMUONProcessor.h" | |
17 | ||
18 | #if __GNUC__ && __GNUC__ < 3 | |
19 | #define std | |
20 | #endif | |
21 | ||
22 | class AliMpDDLStore; | |
23 | extern "C" struct AliHLTMUONRecHitStruct; | |
24 | ||
25 | /** | |
26 | * @class AliHLTMUONDataCheckerComponent | |
27 | * This component is used to check and validate the integrity of dHLT internal | |
28 | * raw data blocks. If there are any problems then an appropriate error message | |
29 | * is logged. | |
30 | * The component should be rather used only for debugging and testing since the | |
31 | * validation procedure can be slow.<br> | |
32 | * | |
33 | * Component ID: \b MUONDataChecker <br> | |
34 | * Library: \b libAliHLTMUON.so <br> | |
35 | * | |
36 | * Optional arguments:<br> | |
37 | * \li -ignoretype <br> | |
38 | * Indicates if the data type of the raw data blocks as given by the HLT | |
39 | * framework in the DoEvent method should be ignored. | |
40 | * (default behaviour is not to ignore the type)<br> | |
41 | * \li -ignorespec <br> | |
42 | * Indicates if the data specification of the raw data blocks as given by | |
43 | * the HLT framework in the DoEvent method should be ignored. | |
44 | * (default behaviour is not to ignore the specification)<br> | |
45 | * \li -dontforward <br> | |
46 | * If set given then the data blocks are not forwarded as output from this | |
47 | * component. | |
48 | * (default behaviour is not to forward all data blocks)<br> | |
49 | * \li -filter <br> | |
50 | * If specified then all the data blocks for which a problem was found are | |
51 | * forwarded to the output and everything else is suppressed. | |
52 | * (default behaviour is not to filter for bad data blocks)<br> | |
53 | * \li -no_global_check <br> | |
54 | * If specified then no global checks between the data blocks are performed, | |
55 | * but rather only the per data block checks. | |
56 | * (default behaviour is to perform all per block and global checks)<br> | |
57 | * \li -warn_on_unexpected_block <br> | |
58 | * Indicates if a warning message should be generated when this component | |
59 | * receives an unknown data block type. | |
60 | * (default behaviour is not to just log a debugging message)<br> | |
887a669c | 61 | * \li -return_error <br> |
62 | * Indicates if error codes should be returned from the DoEvent method which | |
63 | * would tell the framework that processing of the event failed. Otherwise | |
64 | * errors are just logged but the data is considered to be processed successfully. | |
65 | * (default behaviour is not to return errors)<br> | |
dba14d7d | 66 | * |
67 | * @ingroup alihlt_dimuon_component | |
68 | */ | |
69 | class AliHLTMUONDataCheckerComponent : public AliHLTMUONProcessor | |
70 | { | |
71 | public: | |
72 | AliHLTMUONDataCheckerComponent(); | |
73 | virtual ~AliHLTMUONDataCheckerComponent(); | |
74 | ||
75 | // Public functions to implement AliHLTComponent's interface. | |
76 | // These functions are required for the component registration process. | |
77 | ||
78 | virtual const char* GetComponentID(); | |
79 | virtual void GetInputDataTypes(std::vector<AliHLTComponentDataType>& list); | |
80 | virtual AliHLTComponentDataType GetOutputDataType(); | |
81 | virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); | |
82 | virtual AliHLTComponent* Spawn(); | |
83 | ||
84 | protected: | |
85 | ||
86 | // Protected functions to implement AliHLTComponent's interface. | |
87 | // These functions provide initialization as well as the actual processing | |
88 | // capabilities of the component. | |
89 | ||
90 | virtual int DoInit(int argc, const char** argv); | |
91 | virtual int DoDeinit(); | |
92 | virtual int DoEvent( | |
93 | const AliHLTComponentEventData& evtData, | |
94 | const AliHLTComponentBlockData* blocks, | |
95 | AliHLTComponentTriggerData& trigData, | |
96 | AliHLTUInt8_t* outputPtr, | |
97 | AliHLTUInt32_t& size, | |
98 | std::vector<AliHLTComponentBlockData>& outputBlocks | |
99 | ); | |
100 | ||
101 | using AliHLTProcessor::DoEvent; | |
102 | ||
103 | private: | |
104 | ||
105 | // Do not allow copying of this class. | |
106 | AliHLTMUONDataCheckerComponent(const AliHLTMUONDataCheckerComponent& /*obj*/); | |
107 | AliHLTMUONDataCheckerComponent& operator = (const AliHLTMUONDataCheckerComponent& /*obj*/); | |
108 | ||
109 | bool IsSpecificationValid( | |
110 | const AliHLTComponentBlockData& block, | |
111 | AliHLTUInt32_t blockNumber, | |
112 | const char* name | |
113 | ) const; | |
114 | ||
115 | bool IsFromTrackerOnly( | |
116 | const AliHLTComponentBlockData& block, | |
117 | AliHLTUInt32_t blockNumber, | |
118 | const char* name | |
119 | ) const; | |
120 | ||
121 | bool IsFromTriggerOnly( | |
122 | const AliHLTComponentBlockData& block, | |
123 | AliHLTUInt32_t blockNumber, | |
124 | const char* name | |
125 | ) const; | |
126 | ||
127 | bool IsMomentumVectorOk( | |
128 | const AliHLTComponentBlockData& block, | |
129 | AliHLTUInt32_t blockNumber, | |
130 | const char* name, | |
131 | AliHLTUInt32_t entryNumber, | |
132 | AliHLTFloat32_t px, | |
133 | AliHLTFloat32_t py, | |
134 | AliHLTFloat32_t pz | |
135 | ) const; | |
136 | ||
137 | bool AreMomentumCalcParamsOk( | |
138 | const AliHLTComponentBlockData& block, | |
139 | AliHLTUInt32_t blockNumber, | |
140 | const char* name, | |
141 | AliHLTUInt32_t entryNumber, | |
142 | AliHLTFloat32_t zmiddle, | |
143 | AliHLTFloat32_t bl | |
144 | ) const; | |
145 | ||
146 | bool IsHitCoordinateOk( | |
147 | const AliHLTComponentBlockData& block, | |
148 | AliHLTUInt32_t blockNumber, | |
149 | const char* name, | |
150 | AliHLTUInt32_t entryNumber, | |
151 | const AliHLTMUONRecHitStruct& hit, | |
152 | AliHLTInt32_t minChamber, | |
153 | AliHLTInt32_t maxChamber, | |
154 | AliHLTInt32_t expectedChamber, | |
155 | bool ddl[22] | |
156 | ) const; | |
157 | ||
158 | bool IsMansoTrackOk( | |
159 | const AliHLTComponentBlockData& block, | |
160 | AliHLTUInt32_t blockNumber, | |
161 | const char* name, | |
162 | AliHLTUInt32_t entryNumber, | |
163 | const AliHLTMUONMansoTrackStruct& track, | |
164 | bool ddl[22] | |
165 | ) const; | |
166 | ||
167 | bool CheckRawDataBlock( | |
168 | const AliHLTComponentBlockData& block, | |
169 | AliHLTUInt32_t blockNumber | |
170 | ) const; | |
171 | ||
172 | bool CheckTriggerRecordsBlock( | |
173 | const AliHLTComponentBlockData& block, | |
174 | AliHLTUInt32_t blockNumber | |
175 | ) const; | |
176 | ||
177 | bool CheckTrigRecsDebugBlock( | |
178 | const AliHLTComponentBlockData& block, | |
179 | AliHLTUInt32_t blockNumber | |
180 | ) const; | |
181 | ||
182 | bool CheckRecHitsBlock( | |
183 | const AliHLTComponentBlockData& block, | |
184 | AliHLTUInt32_t blockNumber | |
185 | ) const; | |
186 | ||
187 | bool CheckClustersBlock( | |
188 | const AliHLTComponentBlockData& block, | |
189 | AliHLTUInt32_t blockNumber | |
190 | ) const; | |
191 | ||
192 | bool CheckChannelsBlock( | |
193 | const AliHLTComponentBlockData& block, | |
194 | AliHLTUInt32_t blockNumber | |
195 | ) const; | |
196 | ||
197 | bool CheckMansoTracksBlock( | |
198 | const AliHLTComponentBlockData& block, | |
199 | AliHLTUInt32_t blockNumber | |
200 | ) const; | |
201 | ||
202 | bool CheckMansoCandidatesBlock( | |
203 | const AliHLTComponentBlockData& block, | |
204 | AliHLTUInt32_t blockNumber | |
205 | ) const; | |
206 | ||
207 | bool CheckSinglesDecisionBlock( | |
208 | const AliHLTComponentBlockData& block, | |
209 | AliHLTUInt32_t blockNumber | |
210 | ) const; | |
211 | ||
212 | bool CheckPairsDecisionBlock( | |
213 | const AliHLTComponentBlockData& block, | |
214 | AliHLTUInt32_t blockNumber | |
215 | ) const; | |
216 | ||
217 | template <class DataBlock> | |
218 | bool CheckBlockHeaderOnly( | |
219 | const AliHLTComponentBlockData& descriptor, | |
220 | AliHLTUInt32_t blockNumber, | |
221 | DataBlock& block, | |
222 | const char* name | |
223 | ) const; | |
224 | ||
225 | template <class DataBlock> | |
226 | bool CheckBlockIntegrity( | |
227 | const AliHLTComponentBlockData& descriptor, | |
228 | AliHLTUInt32_t blockNumber, | |
229 | DataBlock& block, | |
230 | const char* name | |
231 | ) const; | |
232 | ||
233 | bool AreMomentaCompatible( | |
234 | AliHLTFloat32_t px1, | |
235 | AliHLTFloat32_t py1, | |
236 | AliHLTFloat32_t pz1, | |
237 | AliHLTFloat32_t px2, | |
238 | AliHLTFloat32_t py2, | |
239 | AliHLTFloat32_t pz2 | |
240 | ) const; | |
241 | ||
242 | bool IsScalarTooLarge( | |
243 | const AliHLTComponentBlockData* block, | |
244 | AliHLTUInt32_t blockNumber, | |
245 | const char* blockTypeName, | |
246 | const char* scalarName, | |
247 | AliHLTUInt32_t scalarValue, | |
248 | AliHLTUInt32_t totalTrackCount | |
249 | ) const; | |
250 | ||
251 | bool IsScalarALargerThanB( | |
252 | const AliHLTComponentBlockData* block, | |
253 | AliHLTUInt32_t blockNumber, | |
254 | const char* blockTypeName, | |
255 | const char* scalarAName, | |
256 | AliHLTUInt32_t scalarAValue, | |
257 | const char* scalarBName, | |
258 | AliHLTUInt32_t scalarBValue | |
259 | ) const; | |
260 | ||
261 | void MarkBlock( | |
262 | const AliHLTComponentBlockData* blocks, | |
263 | bool* blockOk, | |
264 | AliHLTUInt32_t blockCount, | |
265 | const AliHLTComponentBlockData* blockToMark | |
266 | ) const; | |
267 | ||
268 | void MakeGlobalChecks( | |
269 | const AliHLTComponentBlockData* blocks, | |
270 | bool* blockOk, | |
271 | AliHLTUInt32_t blockCount, | |
272 | const AliHLTComponentBlockData** trigRecBlocks, | |
273 | AliHLTUInt32_t trigRecBlocksCount, | |
274 | const AliHLTComponentBlockData** trigRecDebugBlocks, | |
275 | AliHLTUInt32_t trigRecDebugBlocksCount, | |
276 | const AliHLTComponentBlockData** hitBlocks, | |
277 | AliHLTUInt32_t hitBlocksCount, | |
278 | const AliHLTComponentBlockData** clusterBlocks, | |
279 | AliHLTUInt32_t clusterBlocksCount, | |
280 | const AliHLTComponentBlockData** channelBlocks, | |
281 | AliHLTUInt32_t channelBlocksCount, | |
282 | const AliHLTComponentBlockData** mansoTrackBlocks, | |
283 | AliHLTUInt32_t mansoTrackBlocksCount, | |
284 | const AliHLTComponentBlockData** mansoCandidateBlocks, | |
285 | AliHLTUInt32_t mansoCandidateBlocksCount, | |
286 | const AliHLTComponentBlockData** singleDecisionBlocks, | |
287 | AliHLTUInt32_t singleDecisionBlocksCount, | |
288 | const AliHLTComponentBlockData** pairDecisionBlocks, | |
289 | AliHLTUInt32_t pairDecisionBlocksCount | |
290 | ) const; | |
291 | ||
292 | bool fIgnoreType; ///< Flag indicating if we should ignore the data block type as given in DoEvent by the framework. | |
293 | bool fIgnoreSpec; ///< Flag indicating if we should ignore the data block specification as given in DoEvent by the framework. | |
294 | bool fDontForward; ///< Flag indicating if we should not forward the input data blocks as output. | |
295 | bool fFilterBadBlocks; ///< Flag indicating if we should pass through only bad blocks to output. | |
296 | bool fNoGlobalChecks; ///< Flag indicating if we should perform global data consistancy checks between all the data blocks. | |
297 | bool fWarnForUnexpecedBlock; ///< Flag indicating if we should log a warning if we got a block of an unexpected type. | |
887a669c | 298 | bool fReturnError; ///< Flag indicating if we should return error codes from DoEvent. |
dba14d7d | 299 | |
300 | ClassDef(AliHLTMUONDataCheckerComponent, 0) // dHLT raw internal data block checking component. | |
301 | }; | |
302 | ||
303 | //______________________________________________________________________________ | |
304 | ||
305 | template <class DataBlock> | |
306 | bool AliHLTMUONDataCheckerComponent::CheckBlockHeaderOnly( | |
307 | const AliHLTComponentBlockData& descriptor, | |
308 | AliHLTUInt32_t blockNumber, | |
309 | DataBlock& block, | |
310 | const char* name | |
311 | ) const | |
312 | { | |
313 | /// Method for checking the integrity of dHLT raw internal data blocks, | |
314 | /// which only need their headers checked. | |
315 | /// \returns true if the block structure is OK and false otherwise. | |
316 | ||
317 | // 'false' set so that we do not check the common block header since it | |
318 | // will be done in IntegrityOk. | |
319 | if (not BlockStructureOk(block, false)) return false; | |
320 | ||
321 | AliHLTUInt32_t count = 256; | |
322 | AliHLTMUONUtils::WhyNotValid reason[256]; | |
323 | if (not AliHLTMUONUtils::IntegrityOk(block.BlockHeader(), &reason[0], count)) | |
324 | { | |
325 | for (AliHLTUInt32_t i = 0; i < count; i++) | |
326 | { | |
327 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
328 | " fPtr = %p and fSize = %u bytes." | |
329 | " Assuming this is a %s data block. Problem: %s", | |
330 | blockNumber, | |
331 | DataType2Text(descriptor.fDataType).c_str(), | |
332 | descriptor.fPtr, | |
333 | descriptor.fSize, | |
334 | name, | |
335 | AliHLTMUONUtils::FailureReasonToMessage(reason[i]) | |
336 | ); | |
337 | } | |
338 | } | |
339 | ||
340 | return true; | |
341 | } | |
342 | ||
343 | ||
344 | template <class DataBlock> | |
345 | bool AliHLTMUONDataCheckerComponent::CheckBlockIntegrity( | |
346 | const AliHLTComponentBlockData& descriptor, | |
347 | AliHLTUInt32_t blockNumber, | |
348 | DataBlock& block, | |
349 | const char* name | |
350 | ) const | |
351 | { | |
352 | /// Method for checking the integrity of dHLT raw internal data blocks. | |
353 | /// \returns true if the block structure is OK and false otherwise. | |
354 | ||
355 | // 'false' set so that we do not check the common block header since it | |
356 | // will be done in IntegrityOk. | |
357 | if (not BlockStructureOk(block, false)) return false; | |
358 | ||
359 | AliHLTUInt32_t count = 256; | |
360 | AliHLTMUONUtils::WhyNotValid reason[256]; | |
361 | AliHLTUInt32_t recordNum[256]; | |
362 | if (not AliHLTMUONUtils::IntegrityOk(block.BlockHeader(), &reason[0], &recordNum[0], count)) | |
363 | { | |
364 | for (AliHLTUInt32_t i = 0; i < count; i++) | |
365 | { | |
366 | if (AliHLTMUONUtils::RecordNumberWasSet(reason[i])) | |
367 | { | |
368 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
369 | " fPtr = %p and fSize = %u bytes." | |
370 | " Assuming this is a %s data block." | |
371 | " Problem with entry %d in data block: %s", | |
372 | blockNumber, | |
373 | DataType2Text(descriptor.fDataType).c_str(), | |
374 | descriptor.fPtr, | |
375 | descriptor.fSize, | |
376 | name, | |
377 | recordNum[i], | |
378 | AliHLTMUONUtils::FailureReasonToMessage(reason[i]) | |
379 | ); | |
380 | } | |
381 | else | |
382 | { | |
383 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
384 | " fPtr = %p and fSize = %u bytes." | |
385 | " Assuming this is a %s data block." | |
386 | " Problem: %s", | |
387 | blockNumber, | |
388 | DataType2Text(descriptor.fDataType).c_str(), | |
389 | descriptor.fPtr, | |
390 | descriptor.fSize, | |
391 | name, | |
392 | AliHLTMUONUtils::FailureReasonToMessage(reason[i]) | |
393 | ); | |
394 | } | |
395 | } | |
396 | } | |
397 | ||
398 | return true; | |
399 | } | |
400 | ||
401 | #endif // ALIHLTMUONDATACHECKERCOMPONENT_H | |
402 |