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