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