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>
71 * @ingroup alihlt_dimuon_component
73 class AliHLTMUONDataCheckerComponent : public AliHLTMUONProcessor
76 AliHLTMUONDataCheckerComponent();
77 virtual ~AliHLTMUONDataCheckerComponent();
79 // Public functions to implement AliHLTComponent's interface.
80 // These functions are required for the component registration process.
82 virtual const char* GetComponentID();
83 virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list);
84 virtual AliHLTComponentDataType GetOutputDataType();
85 virtual void GetOutputDataSize(unsigned long& constBase, double& inputMultiplier);
86 virtual AliHLTComponent* Spawn();
90 // Protected functions to implement AliHLTComponent's interface.
91 // These functions provide initialization as well as the actual processing
92 // capabilities of the component.
94 virtual int DoInit(int argc, const char** argv);
95 virtual int DoDeinit();
97 const AliHLTComponentEventData& evtData,
98 const AliHLTComponentBlockData* blocks,
99 AliHLTComponentTriggerData& trigData,
100 AliHLTUInt8_t* outputPtr,
101 AliHLTUInt32_t& size,
102 AliHLTComponentBlockDataList& outputBlocks
105 using AliHLTProcessor::DoEvent;
109 // Do not allow copying of this class.
110 AliHLTMUONDataCheckerComponent(const AliHLTMUONDataCheckerComponent& /*obj*/);
111 AliHLTMUONDataCheckerComponent& operator = (const AliHLTMUONDataCheckerComponent& /*obj*/);
113 bool IsSpecificationValid(
114 const AliHLTComponentBlockData& block,
115 AliHLTUInt32_t blockNumber,
119 bool IsFromTrackerOnly(
120 const AliHLTComponentBlockData& block,
121 AliHLTUInt32_t blockNumber,
125 bool IsFromTriggerOnly(
126 const AliHLTComponentBlockData& block,
127 AliHLTUInt32_t blockNumber,
131 bool IsMomentumVectorOk(
132 const AliHLTComponentBlockData& block,
133 AliHLTUInt32_t blockNumber,
135 AliHLTUInt32_t entryNumber,
141 bool AreMomentumCalcParamsOk(
142 const AliHLTComponentBlockData& block,
143 AliHLTUInt32_t blockNumber,
145 AliHLTUInt32_t entryNumber,
146 AliHLTFloat32_t zmiddle,
150 bool IsHitCoordinateOk(
151 const AliHLTComponentBlockData& block,
152 AliHLTUInt32_t blockNumber,
154 AliHLTUInt32_t entryNumber,
155 const AliHLTMUONRecHitStruct& hit,
156 AliHLTInt32_t minChamber,
157 AliHLTInt32_t maxChamber,
158 AliHLTInt32_t expectedChamber,
163 const AliHLTComponentBlockData& block,
164 AliHLTUInt32_t blockNumber,
166 AliHLTUInt32_t entryNumber,
167 const AliHLTMUONMansoTrackStruct& track,
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
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
193 bool CheckRawDataBlock(
194 const AliHLTComponentBlockData& block,
195 AliHLTUInt32_t blockNumber
198 bool CheckTriggerRecordsBlock(
199 const AliHLTComponentBlockData& block,
200 AliHLTUInt32_t blockNumber
203 bool CheckTrigRecsDebugBlock(
204 const AliHLTComponentBlockData& block,
205 AliHLTUInt32_t blockNumber
208 bool CheckRecHitsBlock(
209 const AliHLTComponentBlockData& block,
210 AliHLTUInt32_t blockNumber
213 bool CheckClustersBlock(
214 const AliHLTComponentBlockData& block,
215 AliHLTUInt32_t blockNumber
218 bool CheckChannelsBlock(
219 const AliHLTComponentBlockData& block,
220 AliHLTUInt32_t blockNumber
223 bool CheckMansoTracksBlock(
224 const AliHLTComponentBlockData& block,
225 AliHLTUInt32_t blockNumber
228 bool CheckMansoCandidatesBlock(
229 const AliHLTComponentBlockData& block,
230 AliHLTUInt32_t blockNumber
233 bool CheckSinglesDecisionBlock(
234 const AliHLTComponentBlockData& block,
235 AliHLTUInt32_t blockNumber
238 bool CheckPairsDecisionBlock(
239 const AliHLTComponentBlockData& block,
240 AliHLTUInt32_t blockNumber
243 template <class DataBlock>
244 bool CheckBlockHeaderOnly(
245 const AliHLTComponentBlockData& descriptor,
246 AliHLTUInt32_t blockNumber,
251 template <class DataBlock>
252 bool CheckBlockIntegrity(
253 const AliHLTComponentBlockData& descriptor,
254 AliHLTUInt32_t blockNumber,
259 bool AreMomentaCompatible(
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
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
288 const AliHLTComponentBlockData* blocks,
290 AliHLTUInt32_t blockCount,
291 const AliHLTComponentBlockData* blockToMark
294 void MakeGlobalChecks(
295 const AliHLTComponentBlockData* blocks,
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
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.
324 bool fReturnError; ///< Flag indicating if we should return error codes from DoEvent.
326 ClassDef(AliHLTMUONDataCheckerComponent, 0) // dHLT raw internal data block checking component.
329 //______________________________________________________________________________
331 template <class DataBlock>
332 bool AliHLTMUONDataCheckerComponent::CheckBlockHeaderOnly(
333 const AliHLTComponentBlockData& descriptor,
334 AliHLTUInt32_t blockNumber,
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.
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;
347 AliHLTUInt32_t count = 256;
348 AliHLTMUONUtils::WhyNotValid reason[256];
349 if (not AliHLTMUONUtils::IntegrityOk(block.BlockHeader(), &reason[0], count))
351 for (AliHLTUInt32_t i = 0; i < count; i++)
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",
357 DataType2Text(descriptor.fDataType).c_str(),
361 AliHLTMUONUtils::FailureReasonToMessage(reason[i])
370 template <class DataBlock>
371 bool AliHLTMUONDataCheckerComponent::CheckBlockIntegrity(
372 const AliHLTComponentBlockData& descriptor,
373 AliHLTUInt32_t blockNumber,
378 /// Method for checking the integrity of dHLT raw internal data blocks.
379 /// \returns true if the block structure is OK and false otherwise.
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;
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))
390 for (AliHLTUInt32_t i = 0; i < count; i++)
392 if (AliHLTMUONUtils::RecordNumberWasSet(reason[i]))
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",
399 DataType2Text(descriptor.fDataType).c_str(),
404 AliHLTMUONUtils::FailureReasonToMessage(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."
414 DataType2Text(descriptor.fDataType).c_str(),
418 AliHLTMUONUtils::FailureReasonToMessage(reason[i])
427 #endif // ALIHLTMUONDATACHECKERCOMPONENT_H