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 */
7 // $Id: AliHLTMUONDataCheckerComponent.h 26179 2008-05-29 22:27:27Z aszostak $
10 /// @file AliHLTMUONDataCheckerComponent.h
11 /// @author Artur Szostak <artursz@iafrica.com>
13 /// @brief Declaration of a component to check and validate the integrity of dHLT data.
16 #include "AliHLTMUONProcessor.h"
18 #if __GNUC__ && __GNUC__ < 3
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;
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
34 * The component should be rather used only for debugging and testing since the
35 * validation procedure can be slow.<br>
37 * Component ID: \b MUONDataChecker <br>
38 * Library: \b libAliHLTMUON.so <br>
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
52 * (default behaviour is not to forward all data blocks)<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>
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>
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
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>
85 * @ingroup alihlt_dimuon_component
87 class AliHLTMUONDataCheckerComponent : public AliHLTMUONProcessor
90 AliHLTMUONDataCheckerComponent();
91 virtual ~AliHLTMUONDataCheckerComponent();
93 // Public functions to implement AliHLTComponent's interface.
94 // These functions are required for the component registration process.
96 virtual const char* GetComponentID();
97 virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
98 virtual AliHLTComponentDataType GetOutputDataType();
99 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
100 virtual AliHLTComponent* Spawn();
104 // Protected functions to implement AliHLTComponent's interface.
105 // These functions provide initialization as well as the actual processing
106 // capabilities of the component.
108 virtual int DoInit(int argc, const char** argv);
109 virtual int DoDeinit();
111 const AliHLTComponentEventData& evtData,
112 const AliHLTComponentBlockData* blocks,
113 AliHLTComponentTriggerData& trigData,
114 AliHLTUInt8_t* outputPtr,
115 AliHLTUInt32_t& size,
116 AliHLTComponentBlockDataList& outputBlocks
118 virtual bool IgnoreArgument(const char* arg) const;
120 using AliHLTProcessor::DoEvent;
124 // Do not allow copying of this class.
125 AliHLTMUONDataCheckerComponent(const AliHLTMUONDataCheckerComponent& /*obj*/);
126 AliHLTMUONDataCheckerComponent& operator = (const AliHLTMUONDataCheckerComponent& /*obj*/);
128 bool IsSpecificationValid(
129 const AliHLTComponentBlockData& block,
130 AliHLTUInt32_t blockNumber,
134 bool IsFromTrackerOnly(
135 const AliHLTComponentBlockData& block,
136 AliHLTUInt32_t blockNumber,
140 bool IsFromTriggerOnly(
141 const AliHLTComponentBlockData& block,
142 AliHLTUInt32_t blockNumber,
146 bool IsMomentumVectorOk(
147 const AliHLTComponentBlockData& block,
148 AliHLTUInt32_t blockNumber,
150 AliHLTUInt32_t entryNumber,
156 bool AreMomentumCalcParamsOk(
157 const AliHLTComponentBlockData& block,
158 AliHLTUInt32_t blockNumber,
160 AliHLTUInt32_t entryNumber,
161 AliHLTFloat32_t zmiddle,
165 bool IsHitCoordinateOk(
166 const AliHLTComponentBlockData& block,
167 AliHLTUInt32_t blockNumber,
169 AliHLTUInt32_t entryNumber,
170 const AliHLTMUONRecHitStruct& hit,
171 AliHLTInt32_t minChamber,
172 AliHLTInt32_t maxChamber,
173 AliHLTInt32_t expectedChamber,
178 const AliHLTComponentBlockData& block,
179 AliHLTUInt32_t blockNumber,
181 AliHLTUInt32_t entryNumber,
182 const AliHLTMUONMansoTrackStruct& track,
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
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
208 bool CheckRawDataBlock(
209 const AliHLTComponentBlockData& block,
210 AliHLTUInt32_t blockNumber
213 bool CheckTriggerRecordsBlock(
214 const AliHLTComponentBlockData& block,
215 AliHLTUInt32_t blockNumber
218 bool CheckTrigRecsDebugBlock(
219 const AliHLTComponentBlockData& block,
220 AliHLTUInt32_t blockNumber
223 bool CheckRecHitsBlock(
224 const AliHLTComponentBlockData& block,
225 AliHLTUInt32_t blockNumber
228 bool CheckClustersBlock(
229 const AliHLTComponentBlockData& block,
230 AliHLTUInt32_t blockNumber
233 bool CheckChannelsBlock(
234 const AliHLTComponentBlockData& block,
235 AliHLTUInt32_t blockNumber
238 bool CheckMansoTracksBlock(
239 const AliHLTComponentBlockData& block,
240 AliHLTUInt32_t blockNumber
243 bool CheckMansoCandidatesBlock(
244 const AliHLTComponentBlockData& block,
245 AliHLTUInt32_t blockNumber
248 bool CheckSinglesDecisionBlock(
249 const AliHLTComponentBlockData& block,
250 AliHLTUInt32_t blockNumber
253 bool CheckPairsDecisionBlock(
254 const AliHLTComponentBlockData& block,
255 AliHLTUInt32_t blockNumber
258 template <class DataBlock>
259 bool CheckBlockHeaderOnly(
260 const AliHLTComponentBlockData& descriptor,
261 AliHLTUInt32_t blockNumber,
266 template <class DataBlock>
267 bool CheckBlockIntegrity(
268 const AliHLTComponentBlockData& descriptor,
269 AliHLTUInt32_t blockNumber,
274 bool AreMomentaCompatible(
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
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
303 const AliHLTComponentBlockData* blocks,
305 AliHLTUInt32_t blockCount,
306 const AliHLTComponentBlockData* blockToMark
309 void MakeGlobalChecks(
310 const AliHLTComponentBlockData* blocks,
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
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.
339 bool fReturnError; ///< Flag indicating if we should return error codes from DoEvent.
341 ClassDef(AliHLTMUONDataCheckerComponent, 0) // dHLT raw internal data block checking component.
344 //______________________________________________________________________________
346 template <class DataBlock>
347 bool AliHLTMUONDataCheckerComponent::CheckBlockHeaderOnly(
348 const AliHLTComponentBlockData& descriptor,
349 AliHLTUInt32_t blockNumber,
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.
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;
362 AliHLTUInt32_t count = 256;
363 AliHLTMUONUtils::WhyNotValid reason[256];
364 if (not AliHLTMUONUtils::IntegrityOk(block.BlockHeader(), &reason[0], count))
366 for (AliHLTUInt32_t i = 0; i < count; i++)
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",
372 DataType2Text(descriptor.fDataType).c_str(),
376 AliHLTMUONUtils::FailureReasonToMessage(reason[i])
385 template <class DataBlock>
386 bool AliHLTMUONDataCheckerComponent::CheckBlockIntegrity(
387 const AliHLTComponentBlockData& descriptor,
388 AliHLTUInt32_t blockNumber,
393 /// Method for checking the integrity of dHLT raw internal data blocks.
394 /// \returns true if the block structure is OK and false otherwise.
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;
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))
405 for (AliHLTUInt32_t i = 0; i < count; i++)
407 if (AliHLTMUONUtils::RecordNumberWasSet(reason[i]))
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",
414 DataType2Text(descriptor.fDataType).c_str(),
419 AliHLTMUONUtils::FailureReasonToMessage(reason[i])
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."
429 DataType2Text(descriptor.fDataType).c_str(),
433 AliHLTMUONUtils::FailureReasonToMessage(reason[i])
442 #endif // ALIHLTMUONDATACHECKERCOMPONENT_H