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