]>
Commit | Line | Data |
---|---|---|
dba14d7d | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: * | |
6 | * Artur Szostak <artursz@iafrica.com> * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
887a669c | 17 | /* $Id: AliHLTMUONDataCheckerComponent.cxx 26179 2008-05-29 22:27:27Z aszostak $ */ |
dba14d7d | 18 | |
19 | /// | |
20 | /// @file AliHLTMUONDataCheckerComponent.cxx | |
21 | /// @author Artur Szostak <artursz@iafrica.com> | |
887a669c | 22 | /// @date 27 May 2008 |
dba14d7d | 23 | /// @brief Implementation of the dHLT data integrity checker component. |
24 | /// | |
25 | /// This component is used to check the data integrity of dHLT raw internal data | |
26 | /// blocks. If there are any problems found then an appropriate error message is | |
27 | /// logged. | |
28 | /// | |
29 | ||
30 | #include "AliHLTMUONDataCheckerComponent.h" | |
31 | #include "AliHLTMUONConstants.h" | |
32 | #include "AliHLTLogging.h" | |
33 | #include "AliHLTSystem.h" | |
34 | #include "AliHLTDefinitions.h" | |
35 | #include "AliRawDataHeader.h" | |
36 | #include "AliMUONConstants.h" | |
37 | #include "AliMUONTrackerDDLDecoder.h" | |
38 | #include "AliMUONTrackerDDLDecoderEventHandler.h" | |
39 | #include "AliMUONTriggerDDLDecoder.h" | |
40 | #include "AliMUONTriggerDDLDecoderEventHandler.h" | |
41 | #include "AliMpDDLStore.h" | |
42 | #include "AliMpDEStore.h" | |
43 | #include "AliMpDEManager.h" | |
44 | #include "AliMpBusPatch.h" | |
45 | #include "AliMpDetElement.h" | |
46 | #include "AliMpSegmentation.h" | |
47 | #include "AliMpVSegmentation.h" | |
48 | #include "AliMpPad.h" | |
49 | #include <cstring> | |
50 | #include <cstdlib> | |
51 | #include <cmath> | |
52 | #include <cerrno> | |
53 | #include <cassert> | |
54 | ||
55 | ||
56 | namespace | |
57 | { | |
58 | /** | |
59 | * Routine to check if at least one corresponding DDL has been marked | |
60 | * for a particular chamber. | |
61 | */ | |
62 | bool ChamberMarkedInDDLList(AliHLTInt32_t chamber, bool ddl[22]) | |
63 | { | |
64 | if (chamber < 0 or chamber > 21) return false; | |
65 | switch (chamber) | |
66 | { | |
67 | case 0: return ddl[0] or ddl[1]; | |
68 | case 1: return ddl[2] or ddl[3]; | |
69 | case 2: return ddl[4] or ddl[5]; | |
70 | case 3: return ddl[6] or ddl[7]; | |
71 | case 4: return ddl[8] or ddl[9] or ddl[10] or ddl[11]; | |
72 | case 5: return ddl[8] or ddl[9] or ddl[10] or ddl[11]; | |
73 | case 6: return ddl[12] or ddl[13]; | |
74 | case 7: return ddl[14] or ddl[15]; | |
75 | case 8: return ddl[16] or ddl[17]; | |
76 | case 9: return ddl[18] or ddl[19]; | |
77 | case 10: return ddl[20] or ddl[21]; | |
78 | case 11: return ddl[20] or ddl[21]; | |
79 | case 12: return ddl[20] or ddl[21]; | |
80 | case 13: return ddl[20] or ddl[21]; | |
81 | default: return false; | |
82 | } | |
83 | } | |
84 | ||
85 | } // end of namespace | |
86 | ||
87 | ||
88 | ClassImp(AliHLTMUONDataCheckerComponent) | |
89 | ||
90 | ||
91 | AliHLTMUONDataCheckerComponent::AliHLTMUONDataCheckerComponent() : | |
92 | AliHLTMUONProcessor(), | |
93 | fIgnoreType(false), | |
94 | fIgnoreSpec(false), | |
95 | fDontForward(false), | |
96 | fFilterBadBlocks(false), | |
97 | fNoGlobalChecks(false), | |
887a669c | 98 | fWarnForUnexpecedBlock(false), |
99 | fReturnError(false) | |
dba14d7d | 100 | { |
101 | /// Default constructor. | |
102 | } | |
103 | ||
104 | ||
105 | AliHLTMUONDataCheckerComponent::~AliHLTMUONDataCheckerComponent() | |
106 | { | |
107 | /// Default destructor. | |
108 | } | |
109 | ||
110 | const char* AliHLTMUONDataCheckerComponent::GetComponentID() | |
111 | { | |
112 | /// Inherited from AliHLTComponent. Returns the component ID. | |
113 | ||
114 | return AliHLTMUONConstants::DataCheckerComponentId(); | |
115 | } | |
116 | ||
117 | ||
ffb64d3e | 118 | void AliHLTMUONDataCheckerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) |
dba14d7d | 119 | { |
120 | /// Inherited from AliHLTProcessor. Returns the list of expected input data types. | |
121 | /// At the moment this list is "any data type" since it is not known before | |
122 | /// hand what kind of input blocks we will get. | |
123 | ||
124 | assert( list.empty() ); | |
125 | list.push_back( kAliHLTAnyDataType ); | |
126 | } | |
127 | ||
128 | ||
129 | AliHLTComponentDataType AliHLTMUONDataCheckerComponent::GetOutputDataType() | |
130 | { | |
131 | /// Inherited from AliHLTComponent. Returns the output data type of | |
132 | /// "any data type" with MUON origin. | |
133 | ||
134 | return kAliHLTAnyDataType | kAliHLTDataOriginMUON; | |
135 | } | |
136 | ||
137 | ||
138 | void AliHLTMUONDataCheckerComponent::GetOutputDataSize( | |
139 | unsigned long& constBase, double& inputMultiplier | |
140 | ) | |
141 | { | |
142 | /// Inherited from AliHLTComponent. | |
143 | /// Returns an estimate of the expected output data size. | |
144 | ||
145 | // Both of these are zero because we will only ever pass on input data blocks | |
146 | // and never generate data in this component. | |
147 | constBase = 0; | |
148 | inputMultiplier = 0; | |
149 | } | |
150 | ||
151 | ||
152 | AliHLTComponent* AliHLTMUONDataCheckerComponent::Spawn() | |
153 | { | |
154 | /// Inherited from AliHLTComponent. Creates a new object instance. | |
155 | ||
156 | return new AliHLTMUONDataCheckerComponent; | |
157 | } | |
158 | ||
159 | ||
160 | int AliHLTMUONDataCheckerComponent::DoInit(int argc, const char** argv) | |
161 | { | |
162 | /// Inherited from AliHLTComponent. | |
163 | /// Parses the command line parameters and initialises the component. | |
164 | ||
165 | HLTInfo("Initialising dHLT data checker component."); | |
ffb64d3e | 166 | |
167 | // Inherit the parents functionality. | |
168 | int result = AliHLTMUONProcessor::DoInit(argc, argv); | |
169 | if (result != 0) return result; | |
dba14d7d | 170 | |
171 | // Initialise flags with default values. | |
172 | fIgnoreType = false; | |
173 | fIgnoreSpec = false; | |
174 | fDontForward = false; | |
175 | fFilterBadBlocks = false; | |
176 | fNoGlobalChecks = false; | |
177 | fWarnForUnexpecedBlock = false; | |
887a669c | 178 | fReturnError = false; |
dba14d7d | 179 | |
180 | for (int i = 0; i < argc; i++) | |
181 | { | |
ffb64d3e | 182 | if (ArgumentAlreadyHandled(i, argv[i])) continue; |
183 | ||
dba14d7d | 184 | if (strcmp(argv[i], "-ignoretype") == 0) |
185 | { | |
186 | fIgnoreType = true; | |
187 | HLTInfo("Ignoring data type of data blocks as given by framework."); | |
188 | continue; | |
189 | } | |
190 | if (strcmp(argv[i], "-ignorespec") == 0) | |
191 | { | |
192 | fIgnoreSpec = true; | |
193 | HLTInfo("Ignoring data specification of data blocks as given by framework."); | |
194 | continue; | |
195 | } | |
196 | if (strcmp(argv[i], "-dontforward") == 0) | |
197 | { | |
198 | fDontForward = true; | |
199 | HLTInfo("Not forwarding input data blocks."); | |
200 | continue; | |
201 | } | |
202 | if (strcmp(argv[i], "-filter") == 0) | |
203 | { | |
204 | fFilterBadBlocks = true; | |
205 | HLTInfo("Passing only bad blocks to output."); | |
206 | continue; | |
207 | } | |
887a669c | 208 | if (strcmp(argv[i], "-no_global_check") == 0) |
dba14d7d | 209 | { |
210 | fNoGlobalChecks = true; | |
211 | HLTInfo("Only per block data consistancy checks will be applied," | |
887a669c | 212 | " but no global checks will be made." |
dba14d7d | 213 | ); |
214 | continue; | |
215 | } | |
216 | if (strcmp(argv[i], "-warn_on_unexpected_block") == 0) | |
217 | { | |
218 | fWarnForUnexpecedBlock = true; | |
219 | continue; | |
220 | } | |
887a669c | 221 | if (strcmp(argv[i], "-return_error") == 0) |
222 | { | |
223 | fReturnError = true; | |
224 | continue; | |
225 | } | |
dba14d7d | 226 | |
227 | HLTError("Unknown option '%s'.", argv[i]); | |
228 | return -EINVAL; | |
229 | } | |
230 | ||
231 | return 0; | |
232 | } | |
233 | ||
234 | ||
235 | int AliHLTMUONDataCheckerComponent::DoDeinit() | |
236 | { | |
237 | /// Inherited from AliHLTComponent. Performs a cleanup of the component. | |
238 | ||
239 | HLTInfo("Deinitialising dHLT data checker component."); | |
240 | return 0; | |
241 | } | |
242 | ||
243 | ||
244 | int AliHLTMUONDataCheckerComponent::DoEvent( | |
245 | const AliHLTComponentEventData& evtData, | |
246 | const AliHLTComponentBlockData* blocks, | |
ffb64d3e | 247 | AliHLTComponentTriggerData& trigData, |
dba14d7d | 248 | AliHLTUInt8_t* /*outputPtr*/, |
249 | AliHLTUInt32_t& size, | |
ffb64d3e | 250 | AliHLTComponentBlockDataList& outputBlocks |
dba14d7d | 251 | ) |
252 | { | |
253 | /// Inherited from AliHLTProcessor. Processes the new event data. | |
254 | /// Here we go through the list of input data blocks and apply extensive | |
255 | /// data integrity checking on the data found. | |
256 | ||
257 | HLTDebug("Processing event %llu with %u input data blocks.", | |
258 | evtData.fEventID, evtData.fBlockCnt | |
259 | ); | |
260 | ||
261 | // Allocate an array of flags indicating if the data block is OK or not, | |
887a669c | 262 | // also arrays to store specific. |
263 | bool dataProblems = false; | |
dba14d7d | 264 | bool* blockOk = NULL; |
265 | typedef const AliHLTComponentBlockData* PAliHLTComponentBlockData; | |
266 | PAliHLTComponentBlockData* trigRecBlocks = NULL; | |
267 | PAliHLTComponentBlockData* trigRecDebugBlocks = NULL; | |
268 | PAliHLTComponentBlockData* hitBlocks = NULL; | |
269 | PAliHLTComponentBlockData* clusterBlocks = NULL; | |
270 | PAliHLTComponentBlockData* channelBlocks = NULL; | |
271 | PAliHLTComponentBlockData* mansoTrackBlocks = NULL; | |
272 | PAliHLTComponentBlockData* mansoCandidateBlocks = NULL; | |
273 | PAliHLTComponentBlockData* singleDecisionBlocks = NULL; | |
274 | PAliHLTComponentBlockData* pairDecisionBlocks = NULL; | |
275 | AliHLTUInt32_t trigRecBlocksCount = 0; | |
276 | AliHLTUInt32_t trigRecDebugBlocksCount = 0; | |
277 | AliHLTUInt32_t hitBlocksCount = 0; | |
278 | AliHLTUInt32_t clusterBlocksCount = 0; | |
279 | AliHLTUInt32_t channelBlocksCount = 0; | |
280 | AliHLTUInt32_t mansoTrackBlocksCount = 0; | |
281 | AliHLTUInt32_t mansoCandidateBlocksCount = 0; | |
282 | AliHLTUInt32_t singleDecisionBlocksCount = 0; | |
283 | AliHLTUInt32_t pairDecisionBlocksCount = 0; | |
284 | try | |
285 | { | |
286 | blockOk = new bool[evtData.fBlockCnt]; | |
287 | trigRecBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
288 | trigRecDebugBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
289 | hitBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
290 | clusterBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
291 | channelBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
292 | mansoTrackBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
293 | mansoCandidateBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
294 | singleDecisionBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
295 | pairDecisionBlocks = new PAliHLTComponentBlockData[evtData.fBlockCnt]; | |
296 | } | |
297 | catch (const std::bad_alloc&) | |
298 | { | |
299 | HLTError("Could not allocate more memory for internal arrays."); | |
300 | // Make sure to clean up if partially allocated memory. | |
301 | if (blockOk != NULL) delete [] blockOk; | |
302 | if (trigRecBlocks != NULL) delete [] trigRecBlocks; | |
303 | if (trigRecDebugBlocks != NULL) delete [] trigRecDebugBlocks; | |
304 | if (hitBlocks != NULL) delete [] hitBlocks; | |
305 | if (clusterBlocks != NULL) delete [] clusterBlocks; | |
306 | if (channelBlocks != NULL) delete [] channelBlocks; | |
307 | if (mansoTrackBlocks != NULL) delete [] mansoTrackBlocks; | |
308 | if (mansoCandidateBlocks != NULL) delete [] mansoCandidateBlocks; | |
309 | if (singleDecisionBlocks != NULL) delete [] singleDecisionBlocks; | |
310 | if (pairDecisionBlocks != NULL) delete [] pairDecisionBlocks; | |
311 | return -ENOMEM; | |
312 | } | |
313 | ||
314 | try | |
315 | { | |
316 | // Clear all the flags indicating if the blocks are ok. | |
317 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
318 | { | |
319 | blockOk[n] = false; | |
320 | } | |
321 | ||
322 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
323 | { | |
324 | HLTDebug("Handling block: %u, with fDataType = '%s', fPtr = %p and fSize = %u bytes.", | |
325 | n, DataType2Text(blocks[n].fDataType).c_str(), blocks[n].fPtr, blocks[n].fSize | |
326 | ); | |
327 | ||
328 | AliHLTMUONDataBlockType blockType = kUnknownDataBlock; | |
329 | ||
330 | if (fIgnoreType) | |
331 | { | |
332 | // Decode the block type of we must ignore the block type | |
333 | // as given by the HLT framework. | |
334 | if (blocks[n].fSize >= sizeof(AliHLTMUONDataBlockHeader)) | |
335 | { | |
336 | const AliHLTMUONDataBlockHeader* header = | |
337 | reinterpret_cast<const AliHLTMUONDataBlockHeader*>(blocks[n].fPtr); | |
338 | blockType = AliHLTMUONDataBlockType(header->fType); | |
339 | } | |
340 | } | |
341 | else | |
342 | { | |
343 | if (blocks[n].fDataType == AliHLTMUONConstants::DDLRawDataType()) | |
344 | { | |
345 | blockOk[n] = CheckRawDataBlock(blocks[n], n); | |
346 | continue; | |
347 | } | |
348 | else if (blocks[n].fDataType == AliHLTMUONConstants::TriggerRecordsBlockDataType()) | |
349 | { | |
350 | blockType = kTriggerRecordsDataBlock; | |
351 | } | |
352 | else if (blocks[n].fDataType == AliHLTMUONConstants::TrigRecsDebugBlockDataType()) | |
353 | { | |
354 | blockType = kTrigRecsDebugDataBlock; | |
355 | } | |
356 | else if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()) | |
357 | { | |
358 | blockType = kRecHitsDataBlock; | |
359 | } | |
360 | else if (blocks[n].fDataType == AliHLTMUONConstants::ClusterBlockDataType()) | |
361 | { | |
362 | blockType = kClustersDataBlock; | |
363 | } | |
364 | else if (blocks[n].fDataType == AliHLTMUONConstants::ChannelBlockDataType()) | |
365 | { | |
366 | blockType = kChannelsDataBlock; | |
367 | } | |
368 | else if (blocks[n].fDataType == AliHLTMUONConstants::MansoTracksBlockDataType()) | |
369 | { | |
370 | blockType = kMansoTracksDataBlock; | |
371 | } | |
372 | else if (blocks[n].fDataType == AliHLTMUONConstants::MansoCandidatesBlockDataType()) | |
373 | { | |
374 | blockType = kMansoCandidatesDataBlock; | |
375 | } | |
376 | else if (blocks[n].fDataType == AliHLTMUONConstants::SinglesDecisionBlockDataType()) | |
377 | { | |
378 | blockType = kSinglesDecisionDataBlock; | |
379 | } | |
380 | else if (blocks[n].fDataType == AliHLTMUONConstants::PairsDecisionBlockDataType()) | |
381 | { | |
382 | blockType = kPairsDecisionDataBlock; | |
383 | } | |
384 | else | |
385 | { | |
386 | // Log a message indicating that we got a data block that we | |
387 | // do not know how to handle. | |
388 | if (fWarnForUnexpecedBlock) | |
389 | HLTWarning("Received a data block of a type we cannot" | |
390 | " handle: '%s', spec: 0x%8.8X", | |
391 | DataType2Text(blocks[n].fDataType).c_str(), | |
392 | blocks[n].fSpecification | |
393 | ); | |
4e22efc4 | 394 | #ifdef __DEBUG |
dba14d7d | 395 | else |
396 | HLTDebug("Received a data block of a type we cannot" | |
397 | " handle: '%s', spec: 0x%8.8X", | |
398 | DataType2Text(blocks[n].fDataType).c_str(), | |
399 | blocks[n].fSpecification | |
400 | ); | |
4e22efc4 | 401 | #endif |
dba14d7d | 402 | } |
403 | } | |
404 | ||
405 | switch (blockType) | |
406 | { | |
407 | case kTriggerRecordsDataBlock: | |
408 | blockOk[n] = CheckTriggerRecordsBlock(blocks[n], n); | |
409 | trigRecBlocks[trigRecBlocksCount++] = &blocks[n]; | |
410 | break; | |
411 | case kTrigRecsDebugDataBlock: | |
412 | blockOk[n] = CheckTrigRecsDebugBlock(blocks[n], n); | |
413 | trigRecDebugBlocks[trigRecDebugBlocksCount++] = &blocks[n]; | |
414 | break; | |
415 | case kRecHitsDataBlock: | |
416 | blockOk[n] = CheckRecHitsBlock(blocks[n], n); | |
417 | hitBlocks[hitBlocksCount++] = &blocks[n]; | |
418 | break; | |
419 | case kClustersDataBlock: | |
420 | blockOk[n] = CheckClustersBlock(blocks[n], n); | |
421 | clusterBlocks[clusterBlocksCount++] = &blocks[n]; | |
422 | break; | |
423 | case kChannelsDataBlock: | |
424 | blockOk[n] = CheckChannelsBlock(blocks[n], n); | |
425 | channelBlocks[channelBlocksCount++] = &blocks[n]; | |
426 | break; | |
427 | case kMansoTracksDataBlock: | |
428 | blockOk[n] = CheckMansoTracksBlock(blocks[n], n); | |
429 | mansoTrackBlocks[mansoTrackBlocksCount++] = &blocks[n]; | |
430 | break; | |
431 | case kMansoCandidatesDataBlock: | |
432 | blockOk[n] = CheckMansoCandidatesBlock(blocks[n], n); | |
433 | mansoCandidateBlocks[mansoCandidateBlocksCount++] = &blocks[n]; | |
434 | break; | |
435 | case kSinglesDecisionDataBlock: | |
436 | blockOk[n] = CheckSinglesDecisionBlock(blocks[n], n); | |
437 | singleDecisionBlocks[singleDecisionBlocksCount++] = &blocks[n]; | |
438 | break; | |
439 | case kPairsDecisionDataBlock: | |
440 | blockOk[n] = CheckPairsDecisionBlock(blocks[n], n); | |
441 | pairDecisionBlocks[pairDecisionBlocksCount++] = &blocks[n]; | |
442 | break; | |
443 | default: | |
444 | HLTDebug("Received a data block for which we could not decode the data type." | |
445 | " fDataType = '%s', fSpecification = 0x%8.8X, fSize = %u bytes.", | |
446 | DataType2Text(blocks[n].fDataType).c_str(), | |
447 | blocks[n].fSpecification, | |
448 | blocks[n].fSize | |
449 | ); | |
450 | break; | |
451 | } | |
452 | } | |
453 | ||
454 | // Apply the global data consistancy checks if not suppressed by the user. | |
455 | if (not fNoGlobalChecks) | |
456 | { | |
457 | MakeGlobalChecks( | |
458 | blocks, blockOk, evtData.fBlockCnt, | |
459 | trigRecBlocks, trigRecBlocksCount, | |
460 | trigRecDebugBlocks, trigRecDebugBlocksCount, | |
461 | hitBlocks, hitBlocksCount, | |
462 | clusterBlocks, clusterBlocksCount, | |
463 | channelBlocks, channelBlocksCount, | |
464 | mansoTrackBlocks, mansoTrackBlocksCount, | |
465 | mansoCandidateBlocks, mansoCandidateBlocksCount, | |
466 | singleDecisionBlocks, singleDecisionBlocksCount, | |
467 | pairDecisionBlocks, pairDecisionBlocksCount | |
468 | ); | |
469 | } | |
470 | ||
471 | // Forward the input data blocks if we have not been asked to drop them. | |
472 | // Also remember to filter for bad blocks if so specified. | |
473 | if (not fDontForward) | |
474 | { | |
475 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
476 | { | |
477 | if (fFilterBadBlocks and blockOk[n]) continue; | |
478 | outputBlocks.push_back(blocks[n]); | |
479 | } | |
480 | } | |
887a669c | 481 | |
482 | // Set dataProblems flag is there was at least one block with problems. | |
483 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
484 | { | |
485 | if (not blockOk[n]) dataProblems = true; | |
486 | } | |
dba14d7d | 487 | } |
488 | finally | |
489 | ( | |
490 | // make sure to cleanup memory | |
491 | delete [] blockOk; | |
492 | delete [] trigRecBlocks; | |
493 | delete [] trigRecDebugBlocks; | |
494 | delete [] hitBlocks; | |
495 | delete [] clusterBlocks; | |
496 | delete [] channelBlocks; | |
497 | delete [] mansoTrackBlocks; | |
498 | delete [] mansoCandidateBlocks; | |
499 | delete [] singleDecisionBlocks; | |
500 | delete [] pairDecisionBlocks; | |
501 | ) | |
502 | ||
503 | // Finally we set the total size of output memory we consumed, which is | |
504 | // zero since we just copied the input descriptors to output if anything. | |
505 | size = 0; | |
ffb64d3e | 506 | |
507 | if (dataProblems and DumpDataOnError()) DumpEvent(evtData, trigData); | |
887a669c | 508 | |
509 | if (fReturnError) | |
510 | { | |
511 | // If we were requested to return errors if there were integrity | |
512 | // problems then check if any data blocks had problems and return | |
513 | // an error code. | |
514 | if (dataProblems) return -EFAULT; | |
515 | } | |
dba14d7d | 516 | return 0; |
517 | } | |
518 | ||
519 | ||
520 | bool AliHLTMUONDataCheckerComponent::IsSpecificationValid( | |
521 | const AliHLTComponentBlockData& block, | |
522 | AliHLTUInt32_t blockNumber, | |
523 | const char* name | |
524 | ) const | |
525 | { | |
526 | /// Checks if the specification bits are valid. | |
527 | /// \param block The block whose specification should be checked. | |
528 | /// \param blockNumber The block index number being checked. | |
529 | /// \param name The name of the type of block being checked. | |
530 | /// \returns true if the specification is valid and false otherwise. | |
531 | ||
532 | if (AliHLTMUONUtils::IsSpecValid(block.fSpecification)) | |
533 | return true; | |
534 | ||
535 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
536 | " fPtr = %p and fSize = %u bytes." | |
537 | " Assuming this is a %s data block." | |
538 | " Problem: The specification does not contain a valid pattern," | |
539 | " received 0x%8.8X for the specification.", | |
540 | blockNumber, | |
541 | DataType2Text(block.fDataType).c_str(), | |
542 | block.fPtr, | |
543 | block.fSize, | |
544 | name, | |
545 | block.fSpecification | |
546 | ); | |
547 | return false; | |
548 | } | |
549 | ||
550 | ||
551 | bool AliHLTMUONDataCheckerComponent::IsFromTrackerOnly( | |
552 | const AliHLTComponentBlockData& block, | |
553 | AliHLTUInt32_t blockNumber, | |
554 | const char* name | |
555 | ) const | |
556 | { | |
557 | /// Checks if the specification bits are valid and indicate the block | |
558 | /// contains data or information only from the tracker DDLs. | |
559 | /// \param block The block whose specification should be checked. | |
560 | /// \param blockNumber The block index number being checked. | |
561 | /// \param name The name of the type of block being checked. | |
562 | /// \returns true if the specification indicates data is only from tracker. | |
563 | ||
564 | bool result = IsSpecificationValid(block, blockNumber, name); | |
565 | ||
566 | if (AliHLTMUONUtils::ContainsDataFromTracker(block.fSpecification) and | |
567 | not AliHLTMUONUtils::ContainsDataFromTrigger(block.fSpecification) | |
568 | ) | |
569 | { | |
570 | return result; | |
571 | } | |
572 | ||
573 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
574 | " fPtr = %p and fSize = %u bytes." | |
575 | " Assuming this is a %s data block." | |
576 | " Problem: The data block does not contain data only from the" | |
577 | " tracker DDLs as expected." | |
578 | " Received 0x%8.8X for the specification.", | |
579 | blockNumber, | |
580 | DataType2Text(block.fDataType).c_str(), | |
581 | block.fPtr, | |
582 | block.fSize, | |
583 | name, | |
584 | block.fSpecification | |
585 | ); | |
586 | return false; | |
587 | } | |
588 | ||
589 | ||
590 | bool AliHLTMUONDataCheckerComponent::IsFromTriggerOnly( | |
591 | const AliHLTComponentBlockData& block, | |
592 | AliHLTUInt32_t blockNumber, | |
593 | const char* name | |
594 | ) const | |
595 | { | |
596 | /// Checks if the specification bits are valid and indicate the block | |
597 | /// contains data or information only from the trigger DDLs. | |
598 | /// \param block The block whose specification should be checked. | |
599 | /// \param blockNumber The block index number being checked. | |
600 | /// \param name The name of the type of block being checked. | |
601 | /// \returns true if the specification indicates data is only from trigger. | |
602 | ||
603 | bool result = IsSpecificationValid(block, blockNumber, name); | |
604 | ||
605 | if (AliHLTMUONUtils::ContainsDataFromTrigger(block.fSpecification) and | |
606 | not AliHLTMUONUtils::ContainsDataFromTracker(block.fSpecification) | |
607 | ) | |
608 | { | |
609 | return result; | |
610 | } | |
611 | ||
612 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
613 | " fPtr = %p and fSize = %u bytes." | |
614 | " Assuming this is a %s data block." | |
615 | " Problem: The data block does not contain data only from the" | |
616 | " trigger DDLs as expected." | |
617 | " Received 0x%8.8X for the specification.", | |
618 | blockNumber, | |
619 | DataType2Text(block.fDataType).c_str(), | |
620 | block.fPtr, | |
621 | block.fSize, | |
622 | name, | |
623 | block.fSpecification | |
624 | ); | |
625 | return false; | |
626 | } | |
627 | ||
628 | ||
629 | bool AliHLTMUONDataCheckerComponent::IsMomentumVectorOk( | |
630 | const AliHLTComponentBlockData& block, | |
631 | AliHLTUInt32_t blockNumber, | |
632 | const char* name, | |
633 | AliHLTUInt32_t entryNumber, | |
634 | AliHLTFloat32_t px, | |
635 | AliHLTFloat32_t py, | |
636 | AliHLTFloat32_t pz | |
637 | ) const | |
638 | { | |
639 | /// Checks if the momentum vector is reasonable. | |
640 | /// \param block The block from which the momentum vector data comes from. | |
641 | /// \param blockNumber The block index number. | |
642 | /// \param name The name of the type of block. | |
643 | /// \param entryNumber The entry index number of the structure holding | |
644 | /// the momentum vector data. | |
645 | /// \param px The X coordinate of the momentum vector (GeV/c). | |
646 | /// \param py The Y coordinate of the momentum vector (GeV/c). | |
647 | /// \param pz The Z coordinate of the momentum vector (GeV/c). | |
648 | /// \returns true if the momentum vector is valid and false otherwise. | |
649 | ||
650 | // If the momentum vector is nil then ignore it. | |
651 | if (px == 0 and py == 0 and pz == 0) return true; | |
652 | ||
653 | bool result = true; | |
654 | ||
655 | // If the momentum vector is sane then we should not have a particle with | |
656 | // more energy than 14 TeV and momentum should be in the negative direction. | |
657 | double momentum = sqrt(px*px + py*py + pz*pz); | |
658 | if (momentum > 14e3) | |
659 | { | |
660 | // Just warn since this is a data sanity problem rather | |
661 | // than a data integrity problem. | |
662 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
663 | " fPtr = %p and fSize = %u bytes." | |
664 | " Assuming this is a %s data block." | |
665 | " Problem with entry %d in block: The momentum vector" | |
666 | " p = {%f, %f, %f}, |p| = %f looks too big.", | |
667 | blockNumber, | |
668 | DataType2Text(block.fDataType).c_str(), | |
669 | block.fPtr, | |
670 | block.fSize, | |
671 | name, | |
672 | entryNumber, | |
673 | px, py, pz, | |
674 | momentum | |
675 | ); | |
676 | result = false; | |
677 | } | |
678 | ||
679 | if (pz > 0.) | |
680 | { | |
681 | // Just warn since this is a data sanity problem rather | |
682 | // than a data integrity problem. | |
683 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
684 | " fPtr = %p and fSize = %u bytes." | |
685 | " Assuming this is a %s data block." | |
686 | " Problem with entry %d in block: The momentum vector" | |
687 | " p = {%f, %f, %f} points away from the dimuon" | |
688 | " spectrometer (p_z > 0).", | |
689 | blockNumber, | |
690 | DataType2Text(block.fDataType).c_str(), | |
691 | block.fPtr, | |
692 | block.fSize, | |
693 | name, | |
694 | entryNumber, | |
695 | px, py, pz | |
696 | ); | |
697 | result = false; | |
698 | } | |
699 | ||
700 | return result; | |
701 | } | |
702 | ||
703 | ||
704 | bool AliHLTMUONDataCheckerComponent::AreMomentumCalcParamsOk( | |
705 | const AliHLTComponentBlockData& block, | |
706 | AliHLTUInt32_t blockNumber, | |
707 | const char* name, | |
708 | AliHLTUInt32_t entryNumber, | |
709 | AliHLTFloat32_t zmiddle, | |
710 | AliHLTFloat32_t bl | |
711 | ) const | |
712 | { | |
713 | /// Checks if the parameters for the momentum calculation are reasonable. | |
714 | /// \param block The block from which the parameter data comes from. | |
715 | /// \param blockNumber The block index number. | |
716 | /// \param name The name of the type of block. | |
717 | /// \param entryNumber The entry index number of the structure holding | |
718 | /// the parameter data data. | |
719 | /// \param zmiddle The z-coordinate of the middle of the magnetic field (cm). | |
720 | /// \param bl The integrated magnetic field (T.m). | |
721 | /// \returns true if the parameters are valid and false otherwise. | |
722 | ||
723 | bool result = true; | |
724 | ||
725 | // Check that the value of the fZmiddle value is somewhere | |
726 | // within the tracking / dipole magnetic field area. | |
727 | if (zmiddle < AliMUONConstants::AbsZEnd() or | |
728 | zmiddle < AliMUONConstants::MuonFilterZBeg() | |
729 | ) | |
730 | { | |
731 | // Just warn since this is a data sanity problem rather | |
732 | // than a data integrity problem. | |
733 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
734 | " fPtr = %p and fSize = %u bytes." | |
735 | " Assuming this is a %s data block." | |
736 | " Problem with entry %d in block: The Z coordinate %f cm" | |
737 | " used as the middle of the magnetic field in the momentum" | |
738 | " calculation is outside the dimuon spectrometers dipole" | |
739 | " magnetic field volume.", | |
740 | blockNumber, | |
741 | DataType2Text(block.fDataType).c_str(), | |
742 | block.fPtr, | |
743 | block.fSize, | |
744 | name, | |
745 | entryNumber, | |
746 | zmiddle | |
747 | ); | |
748 | result = false; | |
749 | } | |
750 | ||
751 | // Also check that the value of the 'bl' value is within a | |
752 | // reasonable range: |bl| < Lmax * Bmax, where | |
753 | // Lmax = max length from vertex to end of spectrometer, and | |
754 | // Bmax = max magnetic field of dipole, taken as 1 tesla. | |
755 | // Approximating Lmax * Bmax as 20 T.m | |
756 | if (fabs(bl) > 20.) | |
757 | { | |
758 | // Just warn since this is a data sanity problem rather | |
759 | // than a data integrity problem. | |
760 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
761 | " fPtr = %p and fSize = %u bytes." | |
762 | " Assuming this is a %s data block." | |
763 | " Problem with entry %d in block: The integrated magnetic" | |
764 | " field value %f T.m used in the momentum calculation" | |
765 | " has an unreasonably large absolute value.", | |
766 | blockNumber, | |
767 | DataType2Text(block.fDataType).c_str(), | |
768 | block.fPtr, | |
769 | block.fSize, | |
770 | name, | |
771 | entryNumber, | |
772 | bl | |
773 | ); | |
774 | result = false; | |
775 | } | |
776 | ||
777 | return result; | |
778 | } | |
779 | ||
780 | ||
781 | bool AliHLTMUONDataCheckerComponent::IsHitCoordinateOk( | |
782 | const AliHLTComponentBlockData& block, | |
783 | AliHLTUInt32_t blockNumber, | |
784 | const char* name, | |
785 | AliHLTUInt32_t entryNumber, | |
786 | const AliHLTMUONRecHitStruct& hit, | |
787 | AliHLTInt32_t minChamber, | |
788 | AliHLTInt32_t maxChamber, | |
789 | AliHLTInt32_t expectedChamber, | |
790 | bool ddl[22] | |
791 | ) const | |
792 | { | |
793 | /// Checks if the hit coordinate is compatible with a the location of a | |
794 | /// dimuon spectrometer chamber. Also, if expectedChamber is not -1, then | |
795 | /// the hit coordinate is checked if to comes from that chamber. | |
a090ff22 | 796 | /// We also check if the fFlags containing the chamber number and detector |
797 | /// element ID are correct. | |
dba14d7d | 798 | /// \param block The block from which the hit data comes from. |
799 | /// \param blockNumber The block index number. | |
800 | /// \param name The name of the type of block. | |
801 | /// \param entryNumber The entry index number of the hit. | |
802 | /// \param hit The hit data being checked. | |
803 | /// \param minChamber The minimum valid chamber number to check for. | |
804 | /// \param maxChamber The maximum valid chamber number to check for. | |
805 | /// \param expectedChamber If not -1 then this is the chamber number to | |
806 | /// check against. | |
807 | /// \param ddl The array decoded by AliHLTMUONUtils::UnpackSpecBits. | |
808 | /// \returns true if the hit is valid and false otherwise. | |
809 | ||
810 | assert( 0 <= minChamber and minChamber < 14 ); | |
811 | assert( 0 <= maxChamber and maxChamber < 14 ); | |
812 | ||
813 | bool result = true; | |
814 | ||
a090ff22 | 815 | AliHLTUInt8_t chNum = 0xFF; |
816 | AliHLTUInt16_t detElemId = 0xFFFF; | |
817 | AliHLTMUONUtils::UnpackRecHitFlags(hit.fFlags, chNum, detElemId); | |
818 | ||
dba14d7d | 819 | Int_t chamber = AliMUONConstants::ChamberNumber(hit.fZ, false); // false = do not warn. |
820 | if (chamber < minChamber or maxChamber < chamber) | |
821 | { | |
822 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
823 | " fPtr = %p and fSize = %u bytes." | |
824 | " Assuming this is a %s data block." | |
825 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
826 | " z = %f} cm has a z-coordinate that does not correspond" | |
827 | " to the nominal position of any chambers in the range" | |
828 | " [%d..%d].", | |
829 | blockNumber, | |
830 | DataType2Text(block.fDataType).c_str(), | |
831 | block.fPtr, | |
832 | block.fSize, | |
833 | name, | |
834 | entryNumber, | |
835 | hit.fX, hit.fY, hit.fZ, | |
836 | minChamber+1, | |
837 | maxChamber+1 | |
838 | ); | |
839 | return false; | |
840 | } | |
841 | ||
a090ff22 | 842 | if (chNum != chamber) |
843 | { | |
844 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
845 | " fPtr = %p and fSize = %u bytes." | |
846 | " Assuming this is a %s data block." | |
847 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
848 | " z = %f} cm has a chamber number %d that does not correspond" | |
849 | " to the expected chamber %d given by the z-coordinate.", | |
850 | blockNumber, | |
851 | DataType2Text(block.fDataType).c_str(), | |
852 | block.fPtr, | |
853 | block.fSize, | |
854 | name, | |
855 | entryNumber, | |
856 | hit.fX, hit.fY, hit.fZ, | |
857 | chNum+1, | |
858 | chamber+1 | |
859 | ); | |
860 | result = false; | |
8a9e21f6 | 861 | if (minChamber <= Int_t(chNum) and Int_t(chNum) <= maxChamber) |
a090ff22 | 862 | { |
863 | // Rather use the explicit value in the data if it | |
864 | // is in range. | |
865 | chamber = chNum; | |
866 | } | |
867 | } | |
868 | ||
dba14d7d | 869 | if (expectedChamber != -1 and chamber != expectedChamber) |
870 | { | |
871 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
872 | " fPtr = %p and fSize = %u bytes." | |
873 | " Assuming this is a %s data block." | |
874 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
875 | " z = %f} cm has a position that corresponds to chamber %d," | |
876 | " but expected it to be on chamber %d.", | |
877 | blockNumber, | |
878 | DataType2Text(block.fDataType).c_str(), | |
879 | block.fPtr, | |
880 | block.fSize, | |
881 | name, | |
882 | entryNumber, | |
883 | hit.fX, hit.fY, hit.fZ, | |
884 | chamber+1, | |
885 | expectedChamber+1 | |
886 | ); | |
887 | result = false; | |
888 | } | |
889 | ||
890 | AliHLTFloat32_t rmin = AliMUONConstants::Rmin(chamber / 2); | |
891 | AliHLTFloat32_t rmax = AliMUONConstants::Rmax(chamber / 2); | |
892 | AliHLTFloat32_t radius = sqrt(hit.fX*hit.fX + hit.fY*hit.fY); | |
893 | if (radius < rmin or rmax < radius) | |
894 | { | |
895 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
896 | " fPtr = %p and fSize = %u bytes." | |
897 | " Assuming this is a %s data block." | |
898 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
899 | " z = %f} cm has a position in the X-Y plane that does not" | |
900 | " correspond to the nominal position of chamber %d.", | |
901 | blockNumber, | |
902 | DataType2Text(block.fDataType).c_str(), | |
903 | block.fPtr, | |
904 | block.fSize, | |
905 | name, | |
906 | entryNumber, | |
907 | hit.fX, hit.fY, hit.fZ, | |
908 | chamber+1 | |
909 | ); | |
910 | result = false; | |
911 | } | |
912 | ||
913 | if (not fIgnoreSpec and not ChamberMarkedInDDLList(chamber, ddl)) | |
914 | { | |
915 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
916 | " fPtr = %p and fSize = %u bytes." | |
917 | " Assuming this is a %s data block." | |
918 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
919 | " z = %f} cm has a position that corresponds to chamber %d" | |
920 | " but the data block specification 0x%8.8X does have a" | |
921 | " corresponding DDL bit set.", | |
922 | blockNumber, | |
923 | DataType2Text(block.fDataType).c_str(), | |
924 | block.fPtr, | |
925 | block.fSize, | |
926 | name, | |
927 | entryNumber, | |
928 | hit.fX, hit.fY, hit.fZ, | |
929 | chamber+1, | |
930 | block.fSpecification | |
931 | ); | |
932 | result = false; | |
933 | } | |
934 | ||
a090ff22 | 935 | // Check that the detector element ID is valid and it corresponds to |
936 | // the chamber number. | |
937 | if (FetchMappingStores() == 0) // are stores loaded? | |
938 | { | |
939 | Bool_t warn = kFALSE; | |
940 | AliMpDEStore* store = AliMpDEStore::Instance(warn); | |
941 | AliMpDetElement* de = store->GetDetElement(Int_t(detElemId), warn); | |
942 | if (de == NULL) | |
943 | { | |
944 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
945 | " fPtr = %p and fSize = %u bytes." | |
946 | " Assuming this is a %s data block." | |
947 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
948 | " z = %f} cm has a detector element ID %d," | |
949 | " which is not valid.", | |
950 | blockNumber, | |
951 | DataType2Text(block.fDataType).c_str(), | |
952 | block.fPtr, | |
953 | block.fSize, | |
954 | name, | |
955 | entryNumber, | |
956 | hit.fX, hit.fY, hit.fZ, | |
957 | detElemId | |
958 | ); | |
959 | result = false; | |
960 | } | |
961 | ||
962 | // Check that the chamber number from the detector element number | |
963 | // has the expected value. | |
964 | Int_t ch = AliMpDEManager::GetChamberId(Int_t(detElemId), warn); | |
965 | if (ch != chamber) | |
966 | { | |
967 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
968 | " fPtr = %p and fSize = %u bytes." | |
969 | " Assuming this is a %s data block." | |
970 | " Problem with entry %d in block: The hit {x = %f, y = %f," | |
971 | " z = %f} cm has a detector element ID %d," | |
972 | " which does not correspond to the chamber %d.", | |
973 | blockNumber, | |
974 | DataType2Text(block.fDataType).c_str(), | |
975 | block.fPtr, | |
976 | block.fSize, | |
977 | name, | |
978 | entryNumber, | |
979 | hit.fX, hit.fY, hit.fZ, | |
8a9e21f6 | 980 | detElemId, |
a090ff22 | 981 | chamber+1 |
982 | ); | |
983 | result = false; | |
984 | } | |
985 | } | |
986 | else | |
987 | { | |
988 | HLTWarning("Cannot check a hit's detector element ID information" | |
989 | " without being able to load the mapping from CDB." | |
990 | ); | |
991 | result = false; | |
992 | } | |
993 | ||
dba14d7d | 994 | return result; |
995 | } | |
996 | ||
997 | ||
998 | bool AliHLTMUONDataCheckerComponent::IsMansoTrackOk( | |
999 | const AliHLTComponentBlockData& block, | |
1000 | AliHLTUInt32_t blockNumber, | |
1001 | const char* name, | |
1002 | AliHLTUInt32_t entryNumber, | |
1003 | const AliHLTMUONMansoTrackStruct& track, | |
1004 | bool ddl[22] | |
1005 | ) const | |
1006 | { | |
1007 | /// Checks if the Manso track structure is Ok. | |
1008 | /// \param block The block from which the track data comes from. | |
1009 | /// \param blockNumber The block index number. | |
1010 | /// \param name The name of the type of block. | |
1011 | /// \param entryNumber The entry index number of the structure in the | |
1012 | /// block being checked. | |
1013 | /// \param track The Manso track data being checked. | |
1014 | /// \param ddl The array decoded by AliHLTMUONUtils::UnpackSpecBits. | |
1015 | /// \returns true if the hit is valid and false otherwise. | |
1016 | ||
1017 | bool result = true; | |
1018 | ||
1019 | // Chi^2 should not be greater than the worst fit possible, estimated | |
1020 | // as the diameter of largest chamber times the number of points | |
1021 | // findable in a track. Max points is 10 tracker chambers times | |
1022 | // 2 cathodes + 4 trigger chambers. | |
1023 | if (track.fChi2 > AliMUONConstants::Dmax(6)*AliMUONConstants::Dmax(6)*(10*2+4)) | |
1024 | { | |
1025 | // Just a warning since this is not technically an | |
1026 | // integrity problem. | |
1027 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
1028 | " fPtr = %p and fSize = %u bytes." | |
1029 | " Assuming this is a %s data block." | |
1030 | " Problem with entry %d in block: The Manso track has" | |
1031 | " the chi squared value of %f that unreasonably big.", | |
1032 | blockNumber, | |
1033 | DataType2Text(block.fDataType).c_str(), | |
1034 | block.fPtr, | |
1035 | block.fSize, | |
1036 | name, | |
1037 | entryNumber, | |
1038 | track.fChi2 | |
1039 | ); | |
1040 | result = false; | |
1041 | } | |
1042 | ||
1043 | // Check if the momentum vector is reasonable. | |
1044 | bool momOk = IsMomentumVectorOk( | |
1045 | block, blockNumber, name, entryNumber, | |
1046 | track.fPx, track.fPy, track.fPz | |
1047 | ); | |
1048 | if (not momOk) result = false; | |
1049 | ||
1050 | AliHLTMUONParticleSign sign; | |
1051 | bool hitset[4]; | |
1052 | AliHLTMUONUtils::UnpackMansoTrackFlags(track.fFlags, sign, hitset); | |
1053 | ||
1054 | // Min and max allowed chamber numbers for hits: | |
1055 | Int_t minCh = 0; | |
1056 | Int_t maxCh = AliMUONConstants::NTrackingCh() - 1; | |
1057 | ||
1058 | // Check that this hit coordinates are OK. | |
1059 | for (AliHLTUInt32_t i = 0; i < 4; i++) | |
1060 | { | |
1061 | if (not hitset[i]) continue; // ignore hits that are not initialised. | |
1062 | bool hitOk = IsHitCoordinateOk( | |
1063 | block, blockNumber, name, entryNumber, track.fHit[i], | |
1064 | minCh, maxCh, i+6, ddl | |
1065 | ); | |
1066 | if (not hitOk) result = false; | |
1067 | } | |
1068 | ||
1069 | return result; | |
1070 | } | |
1071 | ||
1072 | ||
a090ff22 | 1073 | bool AliHLTMUONDataCheckerComponent::CheckDetElemIds( |
1074 | const AliHLTComponentBlockData& infoBlock, | |
1075 | AliHLTUInt32_t infoBlockNumber, | |
1076 | AliHLTUInt32_t infoEntryNumber, | |
1077 | const AliHLTMUONTrigRecInfoStruct& info, | |
1078 | const AliHLTComponentBlockData& trBlock, | |
1079 | AliHLTUInt32_t trBlockNumber, | |
1080 | AliHLTUInt32_t trEntryNumber, | |
1081 | const AliHLTMUONTriggerRecordStruct& tr | |
1082 | ) const | |
1083 | { | |
1084 | /// Checks if the detector element IDs are the same in the debug | |
1085 | /// information structure and the trigger record structure. | |
1086 | /// \param infoBlock The debug information block from which the 'info' | |
1087 | /// data comes from. | |
1088 | /// \param infoBlockNumber The debug information block index number. | |
1089 | /// \param infoEntryNumber The entry index number of the 'info' | |
1090 | /// structure in the debug information data block. | |
1091 | /// \param info The debug information structure being checked. | |
1092 | /// \param trBlock The trigger record block from which the 'tr' data | |
1093 | /// comes from. | |
1094 | /// \param trBlockNumber The trigger record block index number. | |
1095 | /// \param trEntryNumber The entry index number of the 'tr' structure | |
1096 | /// in the trigger record data block. | |
1097 | /// \param tr The trigger record structure being checked. | |
1098 | /// \returns true if the detector element IDs are the same and false | |
1099 | /// otherwise. | |
1100 | ||
1101 | bool result = true; | |
1102 | ||
1103 | for (int i = 0; i < 4; i++) | |
1104 | { | |
1105 | AliHLTUInt8_t chamber = 0xFF; | |
1106 | AliHLTUInt16_t detElemId = 0xFFFF; | |
1107 | AliHLTMUONUtils::UnpackRecHitFlags(tr.fHit[i].fFlags, chamber, detElemId); | |
1108 | if (info.fDetElemId[i] == detElemId) continue; | |
1109 | ||
1110 | HLTError("Problem found with trigger record debug information %d" | |
1111 | " in data block %d (fDataType = '%s', fPtr = %p, fSize" | |
1112 | " = %u bytes) and trigger record %d in data block %d" | |
1113 | " (fDataType = '%s', fPtr = %p, fSize = %u bytes):" | |
1114 | " The detection element ID %d for chamber %d in the debug" | |
1115 | " information, is not the same as %d" | |
1116 | " found in the trigger record.", | |
1117 | infoEntryNumber, | |
1118 | infoBlockNumber, | |
1119 | DataType2Text(infoBlock.fDataType).c_str(), | |
1120 | infoBlock.fPtr, | |
1121 | infoBlock.fSize, | |
1122 | trEntryNumber, | |
1123 | trBlockNumber, | |
1124 | DataType2Text(trBlock.fDataType).c_str(), | |
1125 | trBlock.fPtr, | |
1126 | trBlock.fSize, | |
1127 | info.fDetElemId[i], | |
1128 | i+11, | |
1129 | detElemId | |
1130 | ); | |
1131 | result = false; | |
1132 | } | |
1133 | ||
1134 | return result; | |
1135 | } | |
1136 | ||
1137 | ||
1138 | bool AliHLTMUONDataCheckerComponent::CheckDetElemIds( | |
1139 | const AliHLTComponentBlockData& clusterBlock, | |
1140 | AliHLTUInt32_t clusterBlockNumber, | |
1141 | AliHLTUInt32_t clusterEntryNumber, | |
1142 | const AliHLTMUONClusterStruct& cluster, | |
1143 | const AliHLTComponentBlockData& hitBlock, | |
1144 | AliHLTUInt32_t hitBlockNumber, | |
1145 | AliHLTUInt32_t hitEntryNumber, | |
1146 | const AliHLTMUONRecHitStruct& hit | |
1147 | ) const | |
1148 | { | |
1149 | /// Checks if the detector element IDs are the same in the cluster | |
1150 | /// structure and the reconstructed hit structure. | |
1151 | /// \param clusterBlock The cluster block from which the 'cluster' data | |
1152 | /// comes from. | |
1153 | /// \param clusterBlockNumber The cluster block index number. | |
1154 | /// \param clusterEntryNumber The entry index number of the 'cluster' | |
1155 | /// structure in the cluster data block. | |
1156 | /// \param cluster The cluster structure being checked. | |
1157 | /// \param hitBlock The reconstructed hit block from which the 'hit' | |
1158 | /// data comes from. | |
1159 | /// \param hitBlockNumber The reconstructed hit block index number. | |
1160 | /// \param hitEntryNumber The entry index number of the 'hit' structure | |
1161 | /// in the reconstructed hit data block. | |
1162 | /// \param hit The trigger record structure being checked. | |
1163 | /// \returns true if the detector element IDs are the same and false | |
1164 | /// otherwise. | |
1165 | ||
1166 | bool result = true; | |
1167 | ||
1168 | AliHLTUInt8_t chamber = 0xFF; | |
1169 | AliHLTUInt16_t detElemId = 0xFFFF; | |
1170 | AliHLTMUONUtils::UnpackRecHitFlags(hit.fFlags, chamber, detElemId); | |
1171 | if (cluster.fDetElemId != detElemId) | |
1172 | { | |
1173 | HLTError("Problem found with cluster %d in data block %d" | |
1174 | " (fDataType = '%s', fPtr = %p, fSize = %u bytes)" | |
1175 | " and reconstructed hit %d in data block %d" | |
1176 | " (fDataType = '%s', fPtr = %p, fSize = %u bytes):" | |
1177 | " The detection element ID %d in the cluster, is not" | |
1178 | " the same as %d found in the reconstructed hit.", | |
1179 | clusterEntryNumber, | |
1180 | clusterBlockNumber, | |
1181 | DataType2Text(clusterBlock.fDataType).c_str(), | |
1182 | clusterBlock.fPtr, | |
1183 | clusterBlock.fSize, | |
1184 | hitEntryNumber, | |
1185 | hitBlockNumber, | |
1186 | DataType2Text(hitBlock.fDataType).c_str(), | |
1187 | hitBlock.fPtr, | |
1188 | hitBlock.fSize, | |
1189 | cluster.fDetElemId, | |
1190 | detElemId | |
1191 | ); | |
1192 | result = false; | |
1193 | } | |
1194 | ||
1195 | return result; | |
1196 | } | |
1197 | ||
1198 | ||
dba14d7d | 1199 | namespace |
1200 | { | |
1201 | /** | |
1202 | * Class for logging errors found in raw DDL data. | |
1203 | */ | |
1204 | class AliHLTMUONDecoderHandler : public AliHLTLogging | |
1205 | { | |
1206 | public: | |
1207 | ||
1208 | /// Default constructor | |
1209 | AliHLTMUONDecoderHandler() : | |
1210 | AliHLTLogging(), | |
1211 | fBufferStart(NULL), | |
1212 | fDescriptor(NULL), | |
1213 | fBlockNumber(0) | |
1214 | { | |
1215 | } | |
1216 | ||
1217 | /// Default destructor. | |
1218 | virtual ~AliHLTMUONDecoderHandler() {} | |
1219 | ||
1220 | /// Sets the DDL raw data block descriptor. | |
1221 | void SetDescriptor(const AliHLTComponentBlockData* b) { fDescriptor = b; } | |
1222 | ||
1223 | /// Sets the block number of the raw data block descriptor. | |
1224 | void SetBlockNumber(AliHLTUInt32_t n) { fBlockNumber = n; } | |
1225 | ||
1226 | /// Logs an error message describing the problem with the DDL raw data. | |
1227 | template <typename ErrorCode, class DecoderHandler> | |
1228 | void LogError(ErrorCode code, const void* location, DecoderHandler& handler); | |
1229 | ||
1230 | protected: | |
1231 | // Do not allow copying of this class. | |
1232 | /// Not implemented | |
1233 | AliHLTMUONDecoderHandler(const AliHLTMUONDecoderHandler& rhs); // copy constructor | |
1234 | /// Not implemented | |
1235 | AliHLTMUONDecoderHandler& operator = (const AliHLTMUONDecoderHandler& rhs); // assignment operator | |
1236 | ||
1237 | const void* fBufferStart; ///< Pointer to the start of the current DDL payload buffer. | |
1238 | const AliHLTComponentBlockData* fDescriptor; ///< Descriptor for the DDL raw data block corresponding to the buffer. | |
1239 | AliHLTUInt32_t fBlockNumber; ///< The number / index of the block descriptor. | |
1240 | }; | |
1241 | ||
1242 | ||
1243 | template <typename ErrorCode, class DecoderHandler> | |
1244 | void AliHLTMUONDecoderHandler::LogError(ErrorCode code, const void* location, DecoderHandler& handler) | |
1245 | { | |
1246 | /// Logs a HLT error message describing the problem with the raw DDL data. | |
1247 | /// \param code The error code describing the problem. | |
1248 | /// \param location A pointer to the location in the raw data buffer | |
1249 | /// where the problem was found. | |
1250 | /// \param handler The decoder handler object. | |
1251 | ||
1252 | long bytepos = long(location) - long(fBufferStart) + sizeof(AliRawDataHeader); | |
1253 | ||
1254 | // create data type string. | |
1255 | char dataType[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]; | |
1256 | memset( dataType, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 ); | |
1257 | strncat( dataType, fDescriptor->fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize ); | |
1258 | strcat( dataType, ":" ); | |
1259 | strncat( dataType, fDescriptor->fDataType.fID, kAliHLTComponentDataTypefIDsize ); | |
1260 | ||
1261 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1262 | " fPtr = %p and fSize = %u bytes." | |
1263 | " Assuming this is a DDL raw data block." | |
1264 | " Problem: %s (Error code: %d, at byte %d)", | |
1265 | fBlockNumber, | |
1266 | &dataType[0], | |
1267 | fDescriptor->fPtr, | |
1268 | fDescriptor->fSize, | |
1269 | handler.ErrorCodeToMessage(code), | |
1270 | code, | |
1271 | bytepos | |
1272 | ); | |
1273 | }; | |
1274 | ||
1275 | ||
1276 | /** | |
1277 | * Class for logging decoding errors when checking tracker raw DDL data. | |
1278 | * Used in the AliHLTMUONDataCheckerComponent::CheckRawDataBlock method. | |
1279 | */ | |
1280 | class AliHLTMUONTrackerDecoderHandler : | |
1281 | public AliMUONTrackerDDLDecoderEventHandler, public AliHLTMUONDecoderHandler | |
1282 | { | |
1283 | public: | |
1284 | AliHLTMUONTrackerDecoderHandler() : | |
1285 | AliMUONTrackerDDLDecoderEventHandler(), | |
1286 | AliHLTMUONDecoderHandler(), | |
1287 | fMaxDigits(0), | |
1288 | fDigitCount(0), | |
1289 | fDigits(NULL), | |
1290 | fCurrentBusPatch(0), | |
1291 | fDataProblems(false) | |
1292 | {} | |
1293 | ||
1294 | virtual ~AliHLTMUONTrackerDecoderHandler() | |
1295 | { | |
1296 | if (fDigits != NULL) delete [] fDigits; | |
1297 | } | |
1298 | ||
1299 | /// Structure to store raw data words found in the raw data. | |
1300 | struct AliDigit | |
1301 | { | |
1302 | UInt_t fBusPatchId; ///< Bus patch ID for the data word. | |
1303 | UInt_t fDataWord; ///< Raw data word found in the DDL payload. | |
1304 | }; | |
1305 | ||
1306 | /// Returns the number of digits found. | |
1307 | UInt_t DigitCount() const { return fDigitCount; } | |
1308 | ||
1309 | /// Returns the array of digits found. | |
1310 | const AliDigit* Digits() const { return fDigits; } | |
1311 | ||
1312 | /// Returns true if there were problems with the data. | |
1313 | bool DataProblems() const { return fDataProblems; } | |
1314 | ||
1315 | // Methods inherited from AliMUONTrackerDDLDecoderEventHandler: | |
1316 | ||
1317 | /// Called for each new buffer. | |
1318 | void OnNewBuffer(const void* buffer, UInt_t bufferSize); | |
1319 | ||
a090ff22 | 1320 | /// Called for each new DSP header. |
1321 | void OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/); | |
1322 | ||
dba14d7d | 1323 | /// Called for each new bus patch. Just marks the current bus patch ID. |
1324 | void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/) | |
1325 | { | |
1326 | fCurrentBusPatch = header->fBusPatchId; | |
1327 | } | |
1328 | ||
1329 | /// Called for each new data word found. | |
1330 | void OnData(UInt_t data, bool /*parityError*/); | |
1331 | ||
1332 | /// Logs an error message if there was a decoding problem with the DDL payload. | |
1333 | void OnError(ErrorCode code, const void* location) | |
1334 | { | |
1335 | fDataProblems = true; | |
1336 | LogError(code, location, *this); | |
1337 | } | |
1338 | ||
1339 | private: | |
1340 | ||
1341 | // Do not allow copying of this object. | |
1342 | /// Not implemented. | |
1343 | AliHLTMUONTrackerDecoderHandler(const AliHLTMUONTrackerDecoderHandler& obj); | |
1344 | /// Not implemented. | |
1345 | AliHLTMUONTrackerDecoderHandler& operator = (const AliHLTMUONTrackerDecoderHandler& obj); | |
1346 | ||
1347 | UInt_t fMaxDigits; ///< Maximum number of digits that can be stored in fDigits. | |
1348 | UInt_t fDigitCount; ///< The number of digits currently stored in fDigits. | |
1349 | AliDigit* fDigits; ///< The array of digits found in the DDL data. | |
1350 | UInt_t fCurrentBusPatch; ///< The current bus patch ID being processed. | |
1351 | bool fDataProblems; ///< flag indicating there were problems with the data. | |
1352 | }; | |
1353 | ||
1354 | ||
1355 | void AliHLTMUONTrackerDecoderHandler::OnNewBuffer(const void* buffer, UInt_t bufferSize) | |
1356 | { | |
1357 | /// Called for a new buffer. It will reset internal counters and | |
1358 | /// resize the digits array if necessary. | |
1359 | ||
1360 | fDataProblems = false; | |
1361 | fDigitCount = 0; | |
1362 | fBufferStart = buffer; | |
1363 | ||
1364 | // Resize the fDigits array to be able to store | |
1365 | // all the digits in the data buffer. | |
1366 | UInt_t maxSize = bufferSize / sizeof(UInt_t) + 1; | |
1367 | if (maxSize > fMaxDigits) | |
1368 | { | |
1369 | if (fDigits != NULL) | |
1370 | { | |
1371 | delete [] fDigits; | |
1372 | fDigits = NULL; | |
1373 | fMaxDigits = 0; | |
1374 | } | |
1375 | try | |
1376 | { | |
1377 | fDigits = new AliDigit[maxSize]; | |
1378 | fMaxDigits = maxSize; | |
1379 | } | |
1380 | catch (const std::bad_alloc&) | |
1381 | { | |
1382 | HLTError("Could not allocate enough buffer space for internal arrays."); | |
1383 | return; | |
1384 | } | |
1385 | } | |
1386 | } | |
1387 | ||
1388 | ||
a090ff22 | 1389 | void AliHLTMUONTrackerDecoderHandler::OnNewDSP( |
1390 | const AliMUONDSPHeaderStruct* header, const void* /*data*/ | |
1391 | ) | |
1392 | { | |
1393 | if (header->fPaddingWord != 0 and header->fPaddingWord != 1) | |
1394 | { | |
1395 | // create data type string. | |
1396 | char dataType[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]; | |
1397 | memset( dataType, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 ); | |
1398 | strncat( dataType, fDescriptor->fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize ); | |
1399 | strcat( dataType, ":" ); | |
1400 | strncat( dataType, fDescriptor->fDataType.fID, kAliHLTComponentDataTypefIDsize ); | |
1401 | ||
1402 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1403 | " fPtr = %p and fSize = %u bytes." | |
1404 | " Assuming this is a tracker DDL raw data block." | |
1405 | " Problem: Found padding word marker 0x%8.8X in DSP" | |
1406 | " header with DSP ID %d which has an invalid value.", | |
1407 | fBlockNumber, | |
1408 | &dataType[0], | |
1409 | fDescriptor->fPtr, | |
1410 | fDescriptor->fSize, | |
1411 | header->fPaddingWord, | |
1412 | header->fDSPId | |
1413 | ); | |
1414 | fDataProblems = true; | |
1415 | return; | |
1416 | } | |
1417 | } | |
1418 | ||
1419 | ||
dba14d7d | 1420 | void AliHLTMUONTrackerDecoderHandler::OnData(UInt_t data, bool /*parityError*/) |
1421 | { | |
1422 | /// Called for each new data word found. This method will add | |
1423 | /// these to the list of digits and check if they are not duplicated. | |
1424 | ||
1425 | assert( fDigits != NULL ); | |
1426 | ||
a090ff22 | 1427 | if ((data & 0x60000000) != 0) |
1428 | { | |
1429 | // create data type string. | |
1430 | char dataType[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]; | |
1431 | memset( dataType, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 ); | |
1432 | strncat( dataType, fDescriptor->fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize ); | |
1433 | strcat( dataType, ":" ); | |
1434 | strncat( dataType, fDescriptor->fDataType.fID, kAliHLTComponentDataTypefIDsize ); | |
1435 | ||
1436 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1437 | " fPtr = %p and fSize = %u bytes." | |
1438 | " Assuming this is a tracker DDL raw data block." | |
1439 | " Problem: Found a data word 0x%8.8X for bus patch %d" | |
1440 | " whose bits 29 or 30 are not zero.", | |
1441 | fBlockNumber, | |
1442 | &dataType[0], | |
1443 | fDescriptor->fPtr, | |
1444 | fDescriptor->fSize, | |
1445 | data, | |
1446 | fCurrentBusPatch | |
1447 | ); | |
1448 | fDataProblems = true; | |
1449 | return; | |
1450 | } | |
1451 | ||
dba14d7d | 1452 | // Check if the data word + bus patch have been duplicated. |
1453 | for (UInt_t i = 0; i < fDigitCount; i++) | |
1454 | { | |
1455 | if (fDigits[i].fDataWord == data and fDigits[i].fBusPatchId == fCurrentBusPatch) | |
1456 | { | |
1457 | // create data type string. | |
1458 | char dataType[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]; | |
1459 | memset( dataType, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 ); | |
1460 | strncat( dataType, fDescriptor->fDataType.fOrigin, kAliHLTComponentDataTypefOriginSize ); | |
1461 | strcat( dataType, ":" ); | |
1462 | strncat( dataType, fDescriptor->fDataType.fID, kAliHLTComponentDataTypefIDsize ); | |
1463 | ||
1464 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1465 | " fPtr = %p and fSize = %u bytes." | |
1466 | " Assuming this is a tracker DDL raw data block." | |
1467 | " Problem: Found a duplicate data word 0x%8.8X for bus patch %d.", | |
1468 | fBlockNumber, | |
1469 | &dataType[0], | |
1470 | fDescriptor->fPtr, | |
1471 | fDescriptor->fSize, | |
1472 | data, | |
1473 | fCurrentBusPatch | |
1474 | ); | |
1475 | fDataProblems = true; | |
1476 | return; | |
1477 | } | |
1478 | } | |
1479 | ||
1480 | // Add the data word + bus patch to the list of decoded digits. | |
1481 | if (fDigitCount < fMaxDigits) | |
1482 | { | |
1483 | fDigits[fDigitCount].fBusPatchId = fCurrentBusPatch; | |
1484 | fDigits[fDigitCount].fDataWord = data; | |
1485 | fDigitCount++; | |
1486 | } | |
1487 | } | |
1488 | ||
1489 | /** | |
1490 | * Class for logging decoding errors when checking trigger raw DDL data. | |
1491 | * Used in the AliHLTMUONDataCheckerComponent::CheckRawDataBlock method. | |
1492 | */ | |
1493 | class AliHLTMUONTriggerDecoderHandler : | |
1494 | public AliMUONTriggerDDLDecoderEventHandler, public AliHLTMUONDecoderHandler | |
1495 | { | |
1496 | public: | |
1497 | // Methods inherited from AliMUONTriggerDDLDecoderEventHandler: | |
1498 | ||
1499 | /// Called for each new buffer. | |
1500 | void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/) | |
1501 | { | |
1502 | fBufferStart = buffer; | |
1503 | } | |
1504 | ||
1505 | /// Logs an error message if there was a decoding problem with the DDL payload. | |
1506 | void OnError(ErrorCode code, const void* location) | |
1507 | { | |
1508 | LogError(code, location, *this); | |
1509 | } | |
1510 | }; | |
1511 | ||
1512 | } // end of namespace | |
1513 | ||
1514 | ||
1515 | bool AliHLTMUONDataCheckerComponent::CheckRawDataBlock( | |
1516 | const AliHLTComponentBlockData& block, | |
1517 | AliHLTUInt32_t blockNumber | |
1518 | ) const | |
1519 | { | |
1520 | /// Checks the validity of a raw data block. | |
1521 | ||
1522 | bool result = true; | |
1523 | ||
1524 | if (fIgnoreSpec) | |
1525 | { | |
1526 | HLTWarning("Not able to check DDL raw data if -ignorespec is specified."); | |
1527 | return false; | |
1528 | } | |
1529 | ||
1530 | bool ddl[22]; | |
1531 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
1532 | ||
1533 | // Check that only one DDL was marked in the specification. | |
1534 | int ddlIndex = -1; | |
1535 | for (int i = 0; i < 22; i++) | |
1536 | { | |
1537 | if (not ddl[i]) continue; | |
1538 | ||
1539 | if (ddlIndex == -1) | |
1540 | { | |
1541 | ddlIndex = i; | |
1542 | continue; | |
1543 | } | |
1544 | ||
1545 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1546 | " fPtr = %p and fSize = %u bytes." | |
1547 | " Assuming this is a DDL raw data block." | |
1548 | " Problem: The specification indicates multiple" | |
1549 | " DDL sources, DDL %d and %d.", | |
1550 | blockNumber, | |
1551 | DataType2Text(block.fDataType).c_str(), | |
1552 | block.fPtr, | |
1553 | block.fSize, | |
1554 | ddlIndex, | |
1555 | i | |
1556 | ); | |
1557 | result = false; | |
1558 | } | |
1559 | ||
1560 | // Check the DDL common data header. | |
1561 | AliHLTUInt32_t totalDDLSize = block.fSize; | |
1562 | if (totalDDLSize < sizeof(AliRawDataHeader)) | |
1563 | { | |
1564 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1565 | " fPtr = %p and fSize = %u bytes." | |
1566 | " Assuming this is a DDL raw data block." | |
1567 | " Problem: The size of the data block is too short to contain" | |
1568 | " a valid common DDL data header. Size of buffer is only %d" | |
1569 | " bytes, but expected at least %d bytes.", | |
1570 | blockNumber, | |
1571 | DataType2Text(block.fDataType).c_str(), | |
1572 | block.fPtr, | |
1573 | block.fSize, | |
1574 | totalDDLSize, | |
1575 | sizeof(AliRawDataHeader) | |
1576 | ); | |
1577 | return false; | |
1578 | } | |
1579 | ||
1580 | const AliRawDataHeader* header = | |
1581 | reinterpret_cast<const AliRawDataHeader*>(block.fPtr); | |
1582 | ||
887a669c | 1583 | if (header->GetVersion() != 2) |
1584 | { | |
1585 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1586 | " fPtr = %p and fSize = %u bytes." | |
1587 | " Assuming this is a DDL raw data block." | |
1588 | " Problem: The common DDL data header indicates an" | |
1589 | " incorrect version number. Expected 2 but got %d.", | |
1590 | blockNumber, | |
1591 | DataType2Text(block.fDataType).c_str(), | |
1592 | block.fPtr, | |
1593 | block.fSize, | |
1594 | int( header->GetVersion() ) | |
1595 | ); | |
1596 | result = false; | |
1597 | } | |
1598 | ||
1599 | if (header->fSize != 0xFFFFFFFF and header->fSize != block.fSize) | |
1600 | { | |
1601 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1602 | " fPtr = %p and fSize = %u bytes." | |
1603 | " Assuming this is a DDL raw data block." | |
1604 | " Problem: The common DDL data header indicates an" | |
1605 | " incorrect DDL buffer size. Expected %d bytes but" | |
1606 | " size reported in header is %d bytes.", | |
1607 | blockNumber, | |
1608 | DataType2Text(block.fDataType).c_str(), | |
1609 | block.fPtr, | |
1610 | block.fSize, | |
1611 | block.fSize, | |
1612 | header->fSize | |
1613 | ); | |
1614 | result = false; | |
1615 | } | |
1616 | ||
1617 | if (header->fSize != 0xFFFFFFFF and header->fSize != block.fSize) | |
1618 | { | |
1619 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1620 | " fPtr = %p and fSize = %u bytes." | |
1621 | " Assuming this is a DDL raw data block." | |
1622 | " Problem: The common DDL data header indicates an" | |
1623 | " incorrect DDL buffer size. Expected %d bytes but" | |
1624 | " size reported in header is %d bytes.", | |
1625 | blockNumber, | |
1626 | DataType2Text(block.fDataType).c_str(), | |
1627 | block.fPtr, | |
1628 | block.fSize, | |
1629 | block.fSize, | |
1630 | header->fSize | |
1631 | ); | |
1632 | result = false; | |
1633 | } | |
1634 | ||
1635 | // Check that the bits that should be zero in the CDH are infact zero. | |
1636 | if ((header->fWord2 & 0x00C03000) != 0 or | |
1637 | (header->fEventID2 & 0xFF000000) != 0 or | |
1638 | (header->fStatusMiniEventID & 0xF0000000) != 0 or | |
1639 | (header->fROILowTriggerClassHigh & 0x0FFC0000) != 0 | |
1640 | ) | |
1641 | { | |
1642 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1643 | " fPtr = %p and fSize = %u bytes." | |
1644 | " Assuming this is a DDL raw data block." | |
1645 | " Problem: The common DDL data header has non-zero" | |
1646 | " bits that are reserved and must be set to zero.", | |
1647 | blockNumber, | |
1648 | DataType2Text(block.fDataType).c_str(), | |
1649 | block.fPtr, | |
1650 | block.fSize | |
1651 | ); | |
1652 | result = false; | |
1653 | } | |
1654 | ||
dba14d7d | 1655 | AliHLTUInt32_t payloadSize = block.fSize - sizeof(AliRawDataHeader); |
1656 | const AliHLTUInt8_t* payload = | |
1657 | reinterpret_cast<const AliHLTUInt8_t*>(header + 1); | |
1658 | ||
1659 | if (AliHLTMUONUtils::IsTriggerDDL(block.fSpecification)) | |
1660 | { | |
a090ff22 | 1661 | bool scalarEvent = ((header->GetL1TriggerMessage() & 0x1) == 0x1); |
dba14d7d | 1662 | AliMUONTriggerDDLDecoder<AliHLTMUONTriggerDecoderHandler> decoder; |
1663 | decoder.ExitOnError(false); | |
1664 | decoder.TryRecover(false); | |
1665 | decoder.AutoDetectScalars(false); | |
1666 | decoder.GetHandler().SetDescriptor(&block); | |
1667 | decoder.GetHandler().SetBlockNumber(blockNumber); | |
1668 | result = decoder.Decode(payload, payloadSize, scalarEvent); | |
1669 | } | |
1670 | else if (AliHLTMUONUtils::IsTrackerDDL(block.fSpecification)) | |
1671 | { | |
1672 | AliMUONTrackerDDLDecoder<AliHLTMUONTrackerDecoderHandler> decoder; | |
1673 | decoder.ExitOnError(false); | |
1674 | decoder.TryRecover(false); | |
1675 | decoder.SendDataOnParityError(true); | |
1676 | decoder.AutoDetectTrailer(true); | |
1677 | decoder.CheckForTrailer(true); | |
1678 | decoder.GetHandler().SetDescriptor(&block); | |
1679 | decoder.GetHandler().SetBlockNumber(blockNumber); | |
1680 | result = decoder.Decode(payload, payloadSize); | |
1681 | if (decoder.GetHandler().DataProblems()) result = false; | |
1682 | ||
1683 | if (FetchMappingStores() == 0) // are stores loaded? | |
1684 | { | |
1685 | Bool_t warn = kFALSE; | |
1686 | AliMpDDLStore* ddlStore = AliMpDDLStore::Instance(warn); | |
1687 | ||
1688 | // Check that the bus patch, manu ID and channel addresses are valid | |
1689 | // for each raw data word. | |
1690 | for (UInt_t i = 0; i < decoder.GetHandler().DigitCount(); i++) | |
1691 | { | |
1692 | UInt_t busPatchId = decoder.GetHandler().Digits()[i].fBusPatchId; | |
1693 | UInt_t dataWord = decoder.GetHandler().Digits()[i].fDataWord; | |
1694 | ||
1695 | UShort_t manuId; UChar_t channelId; UShort_t adc; | |
1696 | AliMUONTrackerDDLDecoderEventHandler::UnpackADC( | |
1697 | dataWord, manuId, channelId, adc | |
1698 | ); | |
1699 | ||
1700 | // Check if the bus patch is valid. | |
1701 | AliMpBusPatch* busPatch = ddlStore->GetBusPatch(busPatchId, warn); | |
1702 | if (busPatch == NULL) | |
1703 | { | |
1704 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1705 | " fPtr = %p and fSize = %u bytes." | |
1706 | " Assuming this is a tracker DDL raw data block." | |
1707 | " Problem: Found a bus patch identifier %d that" | |
1708 | " is not valid.", | |
1709 | blockNumber, | |
1710 | DataType2Text(block.fDataType).c_str(), | |
1711 | block.fPtr, | |
1712 | block.fSize, | |
1713 | busPatchId | |
1714 | ); | |
1715 | result = false; | |
1716 | continue; | |
1717 | } | |
1718 | ||
1719 | // We can check that the bus patch is for the DDL | |
1720 | // which is also indicated by the specification bits. | |
1721 | if (not fIgnoreSpec and busPatch->GetDdlId() != ddlIndex) | |
1722 | { | |
1723 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1724 | " fPtr = %p and fSize = %u bytes." | |
1725 | " Assuming this is a tracker DDL raw data block." | |
1726 | " Problem: Found a bus patch identifier %d for" | |
1727 | " DDL %d, but the data block specification 0x%8.8X" | |
1728 | " indicates a different DDL of %d.", | |
1729 | blockNumber, | |
1730 | DataType2Text(block.fDataType).c_str(), | |
1731 | block.fPtr, | |
1732 | block.fSize, | |
1733 | busPatchId, | |
1734 | busPatch->GetDdlId(), | |
1735 | block.fSpecification, | |
1736 | ddlIndex | |
1737 | ); | |
1738 | result = false; | |
1739 | continue; | |
1740 | } | |
1741 | ||
1742 | // Check if the MANU ID is valid. | |
1743 | if (not busPatch->HasManu(manuId)) | |
1744 | { | |
1745 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1746 | " fPtr = %p and fSize = %u bytes." | |
1747 | " Assuming this is a tracker DDL raw data block." | |
1748 | " Problem: Found a MANU identifier %d on bus patch %d" | |
1749 | " that is not valid.", | |
1750 | blockNumber, | |
1751 | DataType2Text(block.fDataType).c_str(), | |
1752 | block.fPtr, | |
1753 | block.fSize, | |
1754 | manuId, | |
1755 | busPatchId | |
1756 | ); | |
1757 | result = false; | |
1758 | continue; | |
1759 | } | |
1760 | ||
1761 | // Now try to fetch the detector element to check the MANU channel. | |
1762 | AliMpDetElement* de = ddlStore->GetDetElement(busPatch->GetDEId(), warn); | |
1763 | if (de == NULL) | |
1764 | { | |
1765 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1766 | " fPtr = %p and fSize = %u bytes." | |
1767 | " Assuming this is a tracker DDL raw data block." | |
1768 | " Problem: Found a bus patch identifier %d that" | |
1769 | " does not correspond to a detector element.", | |
1770 | blockNumber, | |
1771 | DataType2Text(block.fDataType).c_str(), | |
1772 | block.fPtr, | |
1773 | block.fSize, | |
1774 | busPatchId | |
1775 | ); | |
1776 | result = false; | |
1777 | continue; | |
1778 | } | |
1779 | ||
1780 | if (not de->IsConnectedChannel(manuId, channelId)) | |
1781 | { | |
1782 | // Just a warning because this is marked not | |
1783 | // to be an error in the AliMUONDigitMaker. | |
1784 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
1785 | " fPtr = %p and fSize = %u bytes." | |
1786 | " Assuming this is a tracker DDL raw data block." | |
1787 | " Problem: Found a channel with address %d on" | |
1788 | " MANU ID %d and bus patch %d that is not connected.", | |
1789 | blockNumber, | |
1790 | DataType2Text(block.fDataType).c_str(), | |
1791 | block.fPtr, | |
1792 | block.fSize, | |
1793 | channelId, | |
1794 | manuId, | |
1795 | busPatchId | |
1796 | ); | |
1797 | result = false; | |
1798 | continue; | |
1799 | } | |
1800 | ||
1801 | // Need to also load the correct segmentation to check the channel. | |
1802 | const AliMpVSegmentation* seg = | |
1803 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics( | |
1804 | busPatch->GetDEId(), manuId | |
1805 | ); | |
1806 | if (seg == NULL) | |
1807 | { | |
1808 | HLTError("Could not load segmentation for detector element %d" | |
1809 | " and MANU ID %d.", | |
1810 | busPatch->GetDEId(), manuId | |
1811 | ); | |
1812 | result = false; | |
1813 | continue; | |
1814 | } | |
1815 | ||
168e9c4d | 1816 | AliMpPad pad = seg->PadByLocation(manuId, channelId, warn); |
dba14d7d | 1817 | if (not pad.IsValid()) |
1818 | { | |
1819 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1820 | " fPtr = %p and fSize = %u bytes." | |
1821 | " Assuming this is a tracker DDL raw data block." | |
1822 | " Problem: Found a channel with address %d on" | |
1823 | " MANU ID %d and bus patch %d that is not valid.", | |
1824 | blockNumber, | |
1825 | DataType2Text(block.fDataType).c_str(), | |
1826 | block.fPtr, | |
1827 | block.fSize, | |
1828 | channelId, | |
1829 | manuId, | |
1830 | busPatchId | |
1831 | ); | |
1832 | result = false; | |
1833 | continue; | |
1834 | } | |
1835 | } | |
1836 | } | |
1837 | else | |
1838 | { | |
1839 | HLTWarning("Cannot check if the bus patch IDs, MANU ID and" | |
1840 | " channel addresses for DDL raw data are valid without" | |
1841 | " being able to load the mapping from CDB." | |
1842 | ); | |
1843 | result = false; | |
1844 | } | |
1845 | } | |
1846 | else | |
1847 | { | |
1848 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1849 | " fPtr = %p and fSize = %u bytes." | |
1850 | " Assuming this is a DDL raw data block." | |
1851 | " Problem: The specification does not contain a valid pattern," | |
1852 | " received 0x%8.8X for the specification.", | |
1853 | blockNumber, | |
1854 | DataType2Text(block.fDataType).c_str(), | |
1855 | block.fPtr, | |
1856 | block.fSize, | |
1857 | block.fSpecification | |
1858 | ); | |
1859 | result = false; | |
1860 | } | |
1861 | ||
1862 | return result; | |
1863 | } | |
1864 | ||
1865 | ||
1866 | bool AliHLTMUONDataCheckerComponent::CheckTriggerRecordsBlock( | |
1867 | const AliHLTComponentBlockData& block, | |
1868 | AliHLTUInt32_t blockNumber | |
1869 | ) const | |
1870 | { | |
1871 | /// Checks the validity of a trigger records block. | |
1872 | ||
1873 | bool result = true; | |
1874 | const char* name = "trigger records"; | |
1875 | ||
1876 | if (not fIgnoreSpec) | |
1877 | { | |
1878 | if (not IsFromTriggerOnly(block, blockNumber, name)) | |
1879 | result = false; | |
1880 | } | |
1881 | ||
1882 | AliHLTMUONTriggerRecordsBlockReader inblock(block.fPtr, block.fSize); | |
1883 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
1884 | return false; | |
1885 | ||
1886 | bool ddl[22]; | |
1887 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
1888 | ||
1889 | // Min and max allowed chamber numbers for hits: | |
1890 | Int_t minCh = AliMUONConstants::NCh() - AliMUONConstants::NTriggerCh(); | |
1891 | Int_t maxCh = AliMUONConstants::NCh() - 1; | |
1892 | ||
1893 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
1894 | { | |
1895 | // Check that each hit in each trigger record has a reasonable coordinate. | |
1896 | AliHLTMUONParticleSign sign; | |
1897 | bool hitset[4]; | |
1898 | AliHLTMUONUtils::UnpackTriggerRecordFlags(inblock[i].fFlags, sign, hitset); | |
1899 | ||
1900 | for (Int_t j = 0; j < 4; j++) // loop over 4 trigger chamber hits. | |
1901 | { | |
1902 | if (not hitset[i]) continue; // ignore hits that are not initialised. | |
1903 | bool hitOk = IsHitCoordinateOk( | |
1904 | block, blockNumber, name, i, inblock[i].fHit[j], | |
1905 | minCh, maxCh, j+10, ddl | |
1906 | ); | |
1907 | if (not hitOk) result = false; | |
1908 | } | |
1909 | ||
1910 | // We can also check the momentum vector. | |
1911 | bool momOk = IsMomentumVectorOk( | |
1912 | block, blockNumber, name, i, | |
1913 | inblock[i].fPx, inblock[i].fPy, inblock[i].fPz | |
1914 | ); | |
1915 | if (not momOk) result = false; | |
1916 | } | |
1917 | ||
1918 | // Need to check that no entries have duplicated data but with a different | |
1919 | // ID number. | |
1920 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
1921 | { | |
1922 | AliHLTMUONTriggerRecordStruct ti = inblock[i]; | |
1923 | ti.fId = -1; | |
1924 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
1925 | { | |
1926 | AliHLTMUONTriggerRecordStruct tj = inblock[j]; | |
1927 | tj.fId = ti.fId; | |
1928 | ||
1929 | if (ti == tj) | |
1930 | { | |
1931 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1932 | " fPtr = %p and fSize = %u bytes." | |
1933 | " Assuming this is a %s data block." | |
1934 | " Problem: The trigger records %d and %d contain the" | |
1935 | " same data. The data might have been duplicated.", | |
1936 | blockNumber, | |
1937 | DataType2Text(block.fDataType).c_str(), | |
1938 | block.fPtr, | |
1939 | block.fSize, | |
1940 | name, | |
1941 | i, j | |
1942 | ); | |
1943 | result = false; | |
1944 | } | |
1945 | } | |
1946 | } | |
1947 | ||
1948 | return result; | |
1949 | } | |
1950 | ||
1951 | ||
1952 | bool AliHLTMUONDataCheckerComponent::CheckTrigRecsDebugBlock( | |
1953 | const AliHLTComponentBlockData& block, | |
1954 | AliHLTUInt32_t blockNumber | |
1955 | ) const | |
1956 | { | |
1957 | /// Checks the validity of a trigger records debug block. | |
1958 | ||
1959 | bool result = true; | |
1960 | const char* name = "trigger records debug information"; | |
1961 | ||
1962 | if (not fIgnoreSpec) | |
1963 | { | |
1964 | if (not IsFromTriggerOnly(block, blockNumber, name)) | |
1965 | result = false; | |
1966 | } | |
1967 | ||
1968 | AliHLTMUONTrigRecsDebugBlockReader inblock(block.fPtr, block.fSize); | |
1969 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
1970 | return false; | |
1971 | ||
1972 | bool ddl[22]; | |
1973 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
1974 | ||
1975 | // Check that each detector element ID is valid and the corresponding DDL | |
1976 | // bit is set in the data block specification. | |
1977 | if (FetchMappingStores() == 0) // are stores loaded? | |
1978 | { | |
1979 | Bool_t warn = kFALSE; | |
1980 | AliMpDEStore* store = AliMpDEStore::Instance(warn); | |
1981 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
1982 | for (AliHLTUInt32_t j = 0; j < 4; j++) | |
1983 | { | |
1984 | const AliHLTMUONTrigRecInfoStruct& trig = inblock[i]; | |
1985 | AliMpDetElement* de = store->GetDetElement(trig.fDetElemId[j], warn); | |
1986 | if (de == NULL) | |
1987 | { | |
1988 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
1989 | " fPtr = %p and fSize = %u bytes." | |
1990 | " Assuming this is a %s data block." | |
1991 | " Problem: The detector element number %d on chamber" | |
1992 | " %d for trigger record debug structure %d is not valid.", | |
1993 | blockNumber, | |
1994 | DataType2Text(block.fDataType).c_str(), | |
1995 | block.fPtr, | |
1996 | block.fSize, | |
1997 | name, | |
1998 | trig.fDetElemId[j], | |
1999 | j+11, | |
2000 | i | |
2001 | ); | |
2002 | result = false; | |
2003 | continue; | |
2004 | } | |
2005 | ||
2006 | // Check that the chamber number from the detector element number | |
2007 | // has the expected value. | |
2008 | Int_t chamber = AliMpDEManager::GetChamberId(trig.fDetElemId[j], warn); | |
2009 | if (chamber != Int_t(j+10)) | |
2010 | { | |
2011 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2012 | " fPtr = %p and fSize = %u bytes." | |
2013 | " Assuming this is a %s data block." | |
2014 | " Problem: The detector element number %d for trigger" | |
2015 | " record debug structure %d, corresponds to chamber" | |
2016 | " %d, but we expected a hit for chamber %d.", | |
2017 | blockNumber, | |
2018 | DataType2Text(block.fDataType).c_str(), | |
2019 | block.fPtr, | |
2020 | block.fSize, | |
2021 | name, | |
2022 | trig.fDetElemId[j], | |
2023 | i, | |
2024 | chamber+1, | |
2025 | j+11 | |
2026 | ); | |
2027 | result = false; | |
2028 | } | |
2029 | ||
2030 | if (fIgnoreSpec) continue; | |
2031 | if (0 <= de->GetDdlId() and de->GetDdlId() < 22 and ddl[de->GetDdlId()]) | |
2032 | { | |
2033 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2034 | " fPtr = %p and fSize = %u bytes." | |
2035 | " Assuming this is a %s data block." | |
2036 | " Problem: The detector element number %d for trigger" | |
2037 | " record %d corresponds to DDL number %d, but the" | |
2038 | " data block specification 0x%8.8X does not have the" | |
2039 | " corresponding bit set.", | |
2040 | blockNumber, | |
2041 | DataType2Text(block.fDataType).c_str(), | |
2042 | block.fPtr, | |
2043 | block.fSize, | |
2044 | name, | |
2045 | trig.fDetElemId[j], | |
2046 | i, | |
2047 | de->GetDdlId(), | |
2048 | block.fSpecification | |
2049 | ); | |
2050 | result = false; | |
2051 | } | |
2052 | } | |
2053 | } | |
2054 | else | |
2055 | { | |
2056 | HLTWarning("Cannot check trigger record debug information without" | |
2057 | " being able to load the mapping from CDB." | |
2058 | ); | |
2059 | result = false; | |
2060 | } | |
2061 | ||
2062 | // Need to check that no entries have duplicated data but with a different | |
2063 | // ID number. | |
2064 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2065 | { | |
2066 | AliHLTMUONTrigRecInfoStruct ti = inblock[i]; | |
2067 | ti.fTrigRecId = -1; | |
2068 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
2069 | { | |
2070 | AliHLTMUONTrigRecInfoStruct tj = inblock[j]; | |
2071 | tj.fTrigRecId = ti.fTrigRecId; | |
2072 | ||
2073 | if (ti == tj) | |
2074 | { | |
2075 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2076 | " fPtr = %p and fSize = %u bytes." | |
2077 | " Assuming this is a %s data block." | |
2078 | " Problem: The trigger record debug information" | |
2079 | " structures %d and %d contain the same data." | |
2080 | " The data might have been duplicated.", | |
2081 | blockNumber, | |
2082 | DataType2Text(block.fDataType).c_str(), | |
2083 | block.fPtr, | |
2084 | block.fSize, | |
2085 | name, | |
2086 | i, j | |
2087 | ); | |
2088 | result = false; | |
2089 | } | |
2090 | } | |
2091 | ||
2092 | // Can also check that the value of the fZmiddle and fBl. | |
2093 | bool paramsOk = AreMomentumCalcParamsOk( | |
2094 | block, blockNumber, name, i, ti.fZmiddle, ti.fBl | |
2095 | ); | |
2096 | if (not paramsOk) result = false; | |
2097 | } | |
2098 | ||
2099 | return result; | |
2100 | } | |
2101 | ||
2102 | ||
2103 | bool AliHLTMUONDataCheckerComponent::CheckRecHitsBlock( | |
2104 | const AliHLTComponentBlockData& block, | |
2105 | AliHLTUInt32_t blockNumber | |
2106 | ) const | |
2107 | { | |
2108 | /// Checks the validity of a reconstructed hits block. | |
2109 | ||
2110 | bool result = true; | |
2111 | const char* name = "reconstructed hits"; | |
2112 | ||
2113 | if (not fIgnoreSpec) | |
2114 | { | |
2115 | if (not IsFromTrackerOnly(block, blockNumber, name)) | |
2116 | result = false; | |
2117 | } | |
2118 | ||
2119 | AliHLTMUONRecHitsBlockReader inblock(block.fPtr, block.fSize); | |
a090ff22 | 2120 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) |
dba14d7d | 2121 | return false; |
2122 | ||
2123 | bool ddl[22]; | |
2124 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
2125 | ||
2126 | // Check that each hit has a reasonable coordinate. | |
2127 | Int_t minCh = 0; | |
2128 | Int_t maxCh = AliMUONConstants::NTrackingCh() - 1; | |
2129 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2130 | { | |
2131 | bool hitOk = IsHitCoordinateOk( | |
2132 | block, blockNumber, name, i, inblock[i], | |
2133 | minCh, maxCh, -1, ddl | |
2134 | ); | |
2135 | if (not hitOk) result = false; | |
2136 | } | |
2137 | ||
2138 | return result; | |
2139 | } | |
2140 | ||
2141 | ||
2142 | bool AliHLTMUONDataCheckerComponent::CheckClustersBlock( | |
2143 | const AliHLTComponentBlockData& block, | |
2144 | AliHLTUInt32_t blockNumber | |
2145 | ) const | |
2146 | { | |
2147 | /// Checks the validity of a clusters block. | |
2148 | ||
2149 | bool result = true; | |
2150 | const char* name = "clusters"; | |
2151 | ||
2152 | if (not fIgnoreSpec) | |
2153 | { | |
2154 | if (not IsFromTrackerOnly(block, blockNumber, name)) | |
2155 | result = false; | |
2156 | } | |
2157 | ||
2158 | AliHLTMUONClustersBlockReader inblock(block.fPtr, block.fSize); | |
2159 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2160 | return false; | |
2161 | ||
2162 | bool ddl[22]; | |
2163 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
2164 | ||
2165 | if (FetchMappingStores() == 0) // are stores loaded? | |
2166 | { | |
2167 | Bool_t warn = kFALSE; | |
2168 | AliMpDEStore* store = AliMpDEStore::Instance(warn); | |
2169 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2170 | { | |
2171 | const AliHLTMUONClusterStruct& cluster = inblock[i]; | |
2172 | ||
2173 | // Check that the detector element ID is valid. | |
2174 | AliMpDetElement* de = store->GetDetElement(cluster.fDetElemId, warn); | |
2175 | if (de == NULL) | |
2176 | { | |
2177 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2178 | " fPtr = %p and fSize = %u bytes." | |
2179 | " Assuming this is a %s data block." | |
2180 | " Problem: The detector element number %d for cluster" | |
2181 | " %d is not valid.", | |
2182 | blockNumber, | |
2183 | DataType2Text(block.fDataType).c_str(), | |
2184 | block.fPtr, | |
2185 | block.fSize, | |
2186 | name, | |
2187 | cluster.fDetElemId, | |
2188 | i | |
2189 | ); | |
2190 | result = false; | |
2191 | continue; | |
2192 | } | |
2193 | ||
2194 | // Check that the chamber number found from the hit coordinate and | |
2195 | // that from the detector element number are the same. | |
2196 | Int_t chamberFromHit = AliMUONConstants::ChamberNumber(cluster.fHit.fZ, warn); | |
2197 | Int_t chamberFromDE = AliMpDEManager::GetChamberId(cluster.fDetElemId, warn); | |
2198 | if (chamberFromHit != chamberFromDE) | |
2199 | { | |
2200 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2201 | " fPtr = %p and fSize = %u bytes." | |
2202 | " Assuming this is a %s data block." | |
2203 | " Problem: The detector element number %d for" | |
2204 | " cluster %d, corresponds to chamber %d, but" | |
2205 | " found a different chamber number %d for the" | |
2206 | " corresponding hit coordinate {x = %f, y = %f," | |
2207 | " z = %f}.", | |
2208 | blockNumber, | |
2209 | DataType2Text(block.fDataType).c_str(), | |
2210 | block.fPtr, | |
2211 | block.fSize, | |
2212 | name, | |
2213 | cluster.fDetElemId, | |
2214 | i, | |
2215 | chamberFromDE+1, | |
2216 | chamberFromHit+1, | |
2217 | cluster.fHit.fX, | |
2218 | cluster.fHit.fY, | |
2219 | cluster.fHit.fZ | |
2220 | ); | |
2221 | result = false; | |
2222 | } | |
2223 | ||
2224 | // Make sure the corresponding DDL bit is set in the data | |
2225 | // block specification. | |
2226 | if (fIgnoreSpec) continue; | |
2227 | if (0 <= de->GetDdlId() and de->GetDdlId() < 22 and ddl[de->GetDdlId()]) | |
2228 | { | |
2229 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2230 | " fPtr = %p and fSize = %u bytes." | |
2231 | " Assuming this is a %s data block." | |
2232 | " Problem: The detector element number %d for cluster" | |
2233 | " %d corresponds to DDL number %d, but the data" | |
2234 | " block specification 0x%8.8X does not have the" | |
2235 | " corresponding bit set.", | |
2236 | blockNumber, | |
2237 | DataType2Text(block.fDataType).c_str(), | |
2238 | block.fPtr, | |
2239 | block.fSize, | |
2240 | name, | |
2241 | cluster.fDetElemId, | |
2242 | i, | |
2243 | de->GetDdlId(), | |
2244 | block.fSpecification | |
2245 | ); | |
2246 | result = false; | |
2247 | } | |
2248 | } | |
2249 | } | |
2250 | else | |
2251 | { | |
2252 | HLTWarning("Cannot check cluster information without being able" | |
2253 | " to load the mapping from CDB." | |
2254 | ); | |
2255 | result = false; | |
2256 | } | |
2257 | ||
2258 | // Min and max chamber numbers allowed for the cluster hits. | |
2259 | Int_t minCh = 0; | |
2260 | Int_t maxCh = AliMUONConstants::NTrackingCh() - 1; | |
2261 | ||
2262 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2263 | { | |
2264 | // Need to check that no cluster data has duplicated data but with | |
2265 | // a different ID number. | |
2266 | AliHLTMUONClusterStruct ci = inblock[i]; | |
2267 | ci.fId = -1; | |
2268 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
2269 | { | |
2270 | AliHLTMUONClusterStruct cj = inblock[j]; | |
2271 | cj.fId = ci.fId; | |
2272 | ||
2273 | if (ci == cj) | |
2274 | { | |
2275 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2276 | " fPtr = %p and fSize = %u bytes." | |
2277 | " Assuming this is a %s data block." | |
2278 | " Problem: The cluster structures %d and %d contain" | |
2279 | " the same data. The data might have been duplicated.", | |
2280 | blockNumber, | |
2281 | DataType2Text(block.fDataType).c_str(), | |
2282 | block.fPtr, | |
2283 | block.fSize, | |
2284 | name, | |
2285 | i, j | |
2286 | ); | |
2287 | result = false; | |
2288 | } | |
2289 | } | |
2290 | ||
2291 | // Check that the hit structure in the cluster corresponds | |
2292 | // to a tracker chamber. | |
2293 | bool hitOk = IsHitCoordinateOk( | |
2294 | block, blockNumber, name, i, ci.fHit, | |
2295 | minCh, maxCh, -1, ddl | |
2296 | ); | |
2297 | if (not hitOk) result = false; | |
2298 | } | |
2299 | ||
2300 | return result; | |
2301 | } | |
2302 | ||
2303 | ||
2304 | bool AliHLTMUONDataCheckerComponent::CheckChannelsBlock( | |
2305 | const AliHLTComponentBlockData& block, | |
2306 | AliHLTUInt32_t blockNumber | |
2307 | ) const | |
2308 | { | |
2309 | /// Checks the validity of a channels block. | |
2310 | ||
2311 | bool result = true; | |
2312 | const char* name = "channels"; | |
2313 | ||
2314 | if (not fIgnoreSpec) | |
2315 | { | |
2316 | if (not IsFromTrackerOnly(block, blockNumber, name)) | |
2317 | result = false; | |
2318 | } | |
2319 | ||
2320 | AliHLTMUONChannelsBlockReader inblock(block.fPtr, block.fSize); | |
2321 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2322 | return false; | |
2323 | ||
2324 | bool ddl[22]; | |
2325 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
2326 | ||
2327 | if (FetchMappingStores() == 0) // are stores loaded? | |
2328 | { | |
2329 | Bool_t warn = kFALSE; | |
2330 | AliMpDDLStore* store = AliMpDDLStore::Instance(warn); | |
2331 | ||
2332 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2333 | { | |
2334 | const AliHLTMUONChannelStruct& channel = inblock[i]; | |
2335 | ||
2336 | // Check if the bus patch is valid. | |
2337 | AliMpBusPatch* busPatch = store->GetBusPatch(channel.fBusPatch, warn); | |
2338 | if (busPatch == NULL) | |
2339 | { | |
2340 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2341 | " fPtr = %p and fSize = %u bytes." | |
2342 | " Assuming this is a %s data block." | |
2343 | " Problem: Found a bus patch identifier %d that" | |
2344 | " is not valid.", | |
2345 | blockNumber, | |
2346 | DataType2Text(block.fDataType).c_str(), | |
2347 | block.fPtr, | |
2348 | block.fSize, | |
2349 | name, | |
2350 | channel.fBusPatch | |
2351 | ); | |
2352 | result = false; | |
2353 | continue; | |
2354 | } | |
2355 | ||
2356 | // We can check that the bus patch is for a DDL | |
2357 | // which is also indicated by the specification bits. | |
2358 | if (not fIgnoreSpec and ( | |
2359 | not (0 <= busPatch->GetDdlId() and busPatch->GetDdlId() < 20) | |
2360 | or (0 <= busPatch->GetDdlId() and busPatch->GetDdlId() < 20 | |
2361 | and not ddl[busPatch->GetDdlId()]) | |
2362 | )) | |
2363 | { | |
2364 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2365 | " fPtr = %p and fSize = %u bytes." | |
2366 | " Assuming this is a %s data block." | |
2367 | " Problem: Found a bus patch identifier %d for" | |
2368 | " DDL %d, but the data block specification 0x%8.8X" | |
2369 | " does not have the corresponding bit set.", | |
2370 | blockNumber, | |
2371 | DataType2Text(block.fDataType).c_str(), | |
2372 | block.fPtr, | |
2373 | block.fSize, | |
2374 | name, | |
2375 | channel.fBusPatch, | |
2376 | busPatch->GetDdlId(), | |
2377 | block.fSpecification | |
2378 | ); | |
2379 | result = false; | |
2380 | continue; | |
2381 | } | |
2382 | ||
2383 | // Check if the MANU ID is valid. | |
2384 | if (not busPatch->HasManu(channel.fManu)) | |
2385 | { | |
2386 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2387 | " fPtr = %p and fSize = %u bytes." | |
2388 | " Assuming this is a %s data block." | |
2389 | " Problem: Found a MANU identifier %d on bus patch %d" | |
2390 | " that is not valid.", | |
2391 | blockNumber, | |
2392 | DataType2Text(block.fDataType).c_str(), | |
2393 | block.fPtr, | |
2394 | block.fSize, | |
2395 | name, | |
2396 | channel.fManu, | |
2397 | channel.fBusPatch | |
2398 | ); | |
2399 | result = false; | |
2400 | continue; | |
2401 | } | |
2402 | ||
2403 | // Now try to fetch the detector element to check the MANU channel. | |
2404 | AliMpDetElement* de = store->GetDetElement(busPatch->GetDEId(), warn); | |
2405 | if (de == NULL) | |
2406 | { | |
2407 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2408 | " fPtr = %p and fSize = %u bytes." | |
2409 | " Assuming this is a %s data block." | |
2410 | " Problem: Found a bus patch identifier %d that" | |
2411 | " does not correspond to a detector element.", | |
2412 | blockNumber, | |
2413 | DataType2Text(block.fDataType).c_str(), | |
2414 | block.fPtr, | |
2415 | block.fSize, | |
2416 | name, | |
2417 | channel.fBusPatch | |
2418 | ); | |
2419 | result = false; | |
2420 | continue; | |
2421 | } | |
2422 | ||
2423 | if (not de->IsConnectedChannel(channel.fManu, channel.fChannelAddress)) | |
2424 | { | |
2425 | // Just a warning because this is marked not | |
2426 | // to be an error in the AliMUONDigitMaker. | |
2427 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
2428 | " fPtr = %p and fSize = %u bytes." | |
2429 | " Assuming this is a %s data block." | |
2430 | " Problem: Found a channel with address %d on" | |
2431 | " MANU ID %d and bus patch %d that is not connected.", | |
2432 | blockNumber, | |
2433 | DataType2Text(block.fDataType).c_str(), | |
2434 | block.fPtr, | |
2435 | block.fSize, | |
2436 | name, | |
2437 | channel.fChannelAddress, | |
2438 | channel.fManu, | |
2439 | channel.fBusPatch | |
2440 | ); | |
2441 | result = false; | |
2442 | continue; | |
2443 | } | |
2444 | ||
2445 | // Need to also load the correct segmentation to check the channel. | |
2446 | const AliMpVSegmentation* seg = | |
2447 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics( | |
2448 | busPatch->GetDEId(), channel.fManu | |
2449 | ); | |
2450 | if (seg == NULL) | |
2451 | { | |
2452 | HLTError("Could not load segmentation for detector element %d" | |
2453 | " and MANU ID %d.", | |
2454 | busPatch->GetDEId(), channel.fManu | |
2455 | ); | |
2456 | result = false; | |
2457 | continue; | |
2458 | } | |
2459 | ||
2460 | AliMpPad pad = seg->PadByLocation( | |
168e9c4d | 2461 | channel.fManu, channel.fChannelAddress, |
dba14d7d | 2462 | warn |
2463 | ); | |
2464 | if (not pad.IsValid()) | |
2465 | { | |
2466 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2467 | " fPtr = %p and fSize = %u bytes." | |
2468 | " Assuming this is a %s data block." | |
2469 | " Problem: Found a channel with address %d on" | |
2470 | " MANU ID %d and bus patch %d that is not valid.", | |
2471 | blockNumber, | |
2472 | DataType2Text(block.fDataType).c_str(), | |
2473 | block.fPtr, | |
2474 | block.fSize, | |
2475 | name, | |
2476 | channel.fChannelAddress, | |
2477 | channel.fManu, | |
2478 | channel.fBusPatch | |
2479 | ); | |
2480 | result = false; | |
2481 | continue; | |
2482 | } | |
2483 | } | |
2484 | } | |
2485 | else | |
2486 | { | |
2487 | HLTWarning("Cannot check channel information without being able" | |
2488 | " to load the mapping from CDB." | |
2489 | ); | |
2490 | result = false; | |
2491 | } | |
2492 | ||
2493 | // Need to check that no channel data has duplicated data but with | |
2494 | // a different cluster ID number. | |
2495 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2496 | { | |
2497 | AliHLTMUONChannelStruct ci = inblock[i]; | |
2498 | ci.fClusterId = -1; | |
2499 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
2500 | { | |
2501 | AliHLTMUONChannelStruct cj = inblock[j]; | |
2502 | cj.fClusterId = ci.fClusterId; | |
2503 | ||
2504 | if (ci == cj) | |
2505 | { | |
2506 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2507 | " fPtr = %p and fSize = %u bytes." | |
2508 | " Assuming this is a %s data block." | |
2509 | " Problem: The channel structures %d and %d contain" | |
2510 | " the same data. The data might have been duplicated.", | |
2511 | blockNumber, | |
2512 | DataType2Text(block.fDataType).c_str(), | |
2513 | block.fPtr, | |
2514 | block.fSize, | |
2515 | name, | |
2516 | i, j | |
2517 | ); | |
2518 | result = false; | |
2519 | } | |
2520 | } | |
2521 | } | |
2522 | ||
2523 | return result; | |
2524 | } | |
2525 | ||
2526 | ||
2527 | bool AliHLTMUONDataCheckerComponent::CheckMansoTracksBlock( | |
2528 | const AliHLTComponentBlockData& block, | |
2529 | AliHLTUInt32_t blockNumber | |
2530 | ) const | |
2531 | { | |
2532 | /// Checks the validity of a Manso tracks block. | |
2533 | ||
2534 | bool result = true; | |
2535 | const char* name = "Manso tracks"; | |
2536 | ||
2537 | if (not fIgnoreSpec) | |
2538 | { | |
2539 | if (not IsSpecificationValid(block, blockNumber, name)) | |
2540 | result = false; | |
2541 | } | |
2542 | ||
2543 | AliHLTMUONMansoTracksBlockReader inblock(block.fPtr, block.fSize); | |
2544 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2545 | return false; | |
2546 | ||
2547 | bool ddl[22]; | |
2548 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
2549 | ||
2550 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2551 | { | |
2552 | // Need to check that no entries have duplicated data but with | |
2553 | // a different track ID number. | |
2554 | AliHLTMUONMansoTrackStruct ti = inblock[i]; | |
2555 | ti.fId = -1; | |
2556 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
2557 | { | |
2558 | AliHLTMUONMansoTrackStruct tj = inblock[j]; | |
2559 | tj.fId = ti.fId; | |
2560 | ||
2561 | if (ti == tj) | |
2562 | { | |
2563 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2564 | " fPtr = %p and fSize = %u bytes." | |
2565 | " Assuming this is a %s data block." | |
2566 | " Problem: The Manso tracks %d and %d contain the" | |
2567 | " same data. The data might have been duplicated.", | |
2568 | blockNumber, | |
2569 | DataType2Text(block.fDataType).c_str(), | |
2570 | block.fPtr, | |
2571 | block.fSize, | |
2572 | name, | |
2573 | i, j | |
2574 | ); | |
2575 | result = false; | |
2576 | } | |
2577 | } | |
2578 | ||
2579 | bool trackOk = IsMansoTrackOk(block, blockNumber, name, i, ti, ddl); | |
2580 | if (not trackOk) result = false; | |
2581 | } | |
2582 | ||
2583 | return result; | |
2584 | } | |
2585 | ||
2586 | ||
2587 | bool AliHLTMUONDataCheckerComponent::CheckMansoCandidatesBlock( | |
2588 | const AliHLTComponentBlockData& block, | |
2589 | AliHLTUInt32_t blockNumber | |
2590 | ) const | |
2591 | { | |
2592 | /// Checks the validity of a Manso candidates block. | |
2593 | ||
2594 | bool result = true; | |
2595 | const char* name = "Manso track candidates"; | |
2596 | ||
2597 | if (not fIgnoreSpec) | |
2598 | { | |
2599 | if (not IsSpecificationValid(block, blockNumber, name)) | |
2600 | result = false; | |
2601 | } | |
2602 | ||
2603 | AliHLTMUONMansoCandidatesBlockReader inblock(block.fPtr, block.fSize); | |
2604 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2605 | return false; | |
2606 | ||
2607 | bool ddl[22]; | |
2608 | AliHLTMUONUtils::UnpackSpecBits(block.fSpecification, ddl); | |
2609 | ||
2610 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
2611 | { | |
2612 | // Need to check that no entries have duplicated data but with a | |
2613 | // different track ID number. | |
2614 | AliHLTMUONMansoCandidateStruct ti = inblock[i]; | |
2615 | ti.fTrack.fId = -1; | |
2616 | for (AliHLTUInt32_t j = i+1; j < inblock.Nentries(); j++) | |
2617 | { | |
2618 | AliHLTMUONMansoCandidateStruct tj = inblock[j]; | |
2619 | tj.fTrack.fId = ti.fTrack.fId; | |
2620 | ||
2621 | if (ti == tj) | |
2622 | { | |
2623 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2624 | " fPtr = %p and fSize = %u bytes." | |
2625 | " Assuming this is a %s data block." | |
2626 | " Problem: The Manso track candidates %d and %d" | |
2627 | " contain the same data." | |
2628 | " The data might have been duplicated.", | |
2629 | blockNumber, | |
2630 | DataType2Text(block.fDataType).c_str(), | |
2631 | block.fPtr, | |
2632 | block.fSize, | |
2633 | name, | |
2634 | i, j | |
2635 | ); | |
2636 | result = false; | |
2637 | } | |
2638 | } | |
2639 | ||
2640 | bool trackOk = IsMansoTrackOk(block, blockNumber, name, i, ti.fTrack, ddl); | |
2641 | if (not trackOk) result = false; | |
2642 | ||
2643 | // Check that each ROI has a centre point somewhere on the correct | |
2644 | // corresponding chamber and that the Radius is not bigger thant | |
2645 | // the diameter of the chamber which would be pointless. | |
2646 | for (AliHLTInt32_t j = 0; j < 4; j++) | |
2647 | { | |
2648 | if (ti.fRoI[j].fRadius == -1) continue; // Ignore invalid ROIs | |
2649 | ||
2650 | Int_t chamber = AliMUONConstants::ChamberNumber( | |
2651 | ti.fRoI[j].fZ, false // false = do not warn. | |
2652 | ); | |
2653 | if (chamber != j+6) | |
2654 | { | |
2655 | HLTError("Problem found with data block %d, fDataType = '%s'," | |
2656 | " fPtr = %p and fSize = %u bytes." | |
2657 | " Assuming this is a %s data block." | |
2658 | " Problem: The region of interest on chamber %d for" | |
2659 | " Manso track candidate %d has a z-coordinate of %f" | |
2660 | " cm that does not correspond to that chamber.", | |
2661 | blockNumber, | |
2662 | DataType2Text(block.fDataType).c_str(), | |
2663 | block.fPtr, | |
2664 | block.fSize, | |
2665 | name, | |
2666 | j+6+1, | |
2667 | i, | |
2668 | ti.fRoI[j].fZ | |
2669 | ); | |
2670 | result = false; | |
2671 | } | |
2672 | ||
2673 | double x = ti.fRoI[j].fX; | |
2674 | double y = ti.fRoI[j].fY; | |
2675 | double r = sqrt(x*x + y*y); | |
2676 | if (r > AliMUONConstants::Dmax((j+6)/2)) | |
2677 | { | |
2678 | // Just a warning since this is not a data integrity problem | |
2679 | // but rather just a data sanity problem. | |
2680 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
2681 | " fPtr = %p and fSize = %u bytes." | |
2682 | " Assuming this is a %s data block." | |
2683 | " Problem: The region of interest coordinate {x = %f," | |
2684 | " y = %f} cm on chamber %d for Manso track candidate %d" | |
2685 | " does not correspond to that chamber.", | |
2686 | blockNumber, | |
2687 | DataType2Text(block.fDataType).c_str(), | |
2688 | block.fPtr, | |
2689 | block.fSize, | |
2690 | name, | |
2691 | ti.fRoI[j].fX, | |
2692 | ti.fRoI[j].fY, | |
2693 | j+6+1, | |
2694 | i | |
2695 | ); | |
2696 | result = false; | |
2697 | } | |
2698 | ||
2699 | if (ti.fRoI[j].fRadius > AliMUONConstants::Dmax((j+6)/2)) | |
2700 | { | |
2701 | // Just a warning since this is not a data integrity problem | |
2702 | // but rather just a data sanity problem. | |
2703 | HLTWarning("Problem found with data block %d, fDataType = '%s'," | |
2704 | " fPtr = %p and fSize = %u bytes." | |
2705 | " Assuming this is a %s data block." | |
2706 | " Problem: The region of interest radius of %f cm" | |
2707 | " on chamber %d for Manso track candidate %d" | |
2708 | " is bigger than the chamber diameter %f cm.", | |
2709 | blockNumber, | |
2710 | DataType2Text(block.fDataType).c_str(), | |
2711 | block.fPtr, | |
2712 | block.fSize, | |
2713 | name, | |
2714 | ti.fRoI[j].fRadius, | |
2715 | j+6+1, | |
2716 | i, | |
2717 | AliMUONConstants::Dmax((j+6)/2) | |
2718 | ); | |
2719 | result = false; | |
2720 | } | |
2721 | } | |
2722 | } | |
2723 | ||
2724 | return result; | |
2725 | } | |
2726 | ||
2727 | ||
2728 | bool AliHLTMUONDataCheckerComponent::CheckSinglesDecisionBlock( | |
2729 | const AliHLTComponentBlockData& block, | |
2730 | AliHLTUInt32_t blockNumber | |
2731 | ) const | |
2732 | { | |
2733 | /// Checks the validity of a single tracks trigger decision block. | |
2734 | ||
2735 | bool result = true; | |
2736 | const char* name = "singles decision"; | |
2737 | ||
2738 | if (not fIgnoreSpec) | |
2739 | { | |
2740 | if (not IsSpecificationValid(block, blockNumber, name)) | |
2741 | result = false; | |
2742 | } | |
2743 | ||
2744 | AliHLTMUONSinglesDecisionBlockReader inblock(block.fPtr, block.fSize); | |
2745 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2746 | return false; | |
2747 | ||
2748 | return result; | |
2749 | } | |
2750 | ||
2751 | ||
2752 | bool AliHLTMUONDataCheckerComponent::CheckPairsDecisionBlock( | |
2753 | const AliHLTComponentBlockData& block, | |
2754 | AliHLTUInt32_t blockNumber | |
2755 | ) const | |
2756 | { | |
2757 | /// Checks the validity of a track pairs trigger decision block. | |
2758 | ||
2759 | bool result = true; | |
2760 | const char* name = "pairs decision"; | |
2761 | ||
2762 | if (not fIgnoreSpec) | |
2763 | { | |
2764 | if (not IsSpecificationValid(block, blockNumber, name)) | |
2765 | result = false; | |
2766 | } | |
2767 | ||
2768 | AliHLTMUONPairsDecisionBlockReader inblock(block.fPtr, block.fSize); | |
2769 | if (not CheckBlockIntegrity(block, blockNumber, inblock, name)) | |
2770 | return false; | |
2771 | ||
2772 | return result; | |
2773 | } | |
2774 | ||
2775 | ||
2776 | bool AliHLTMUONDataCheckerComponent::AreMomentaCompatible( | |
2777 | AliHLTFloat32_t px1, | |
2778 | AliHLTFloat32_t py1, | |
2779 | AliHLTFloat32_t pz1, | |
2780 | AliHLTFloat32_t px2, | |
2781 | AliHLTFloat32_t py2, | |
2782 | AliHLTFloat32_t pz2 | |
2783 | ) const | |
2784 | { | |
2785 | /// Checks to see if the two momenta vectors are compatible or not. | |
2786 | /// The vectors should not have an angle more than 10 degrees between | |
2787 | /// them and their magnitudes should not be more different than 50%. | |
2788 | ||
a3d4b6ba | 2789 | double p1 = sqrt(double(px1)*double(px1) + double(py1)*double(py1) + double(pz1)*double(pz1)); |
2790 | double p2 = sqrt(double(px2)*double(px2) + double(py2)*double(py2) + double(pz2)*double(pz2)); | |
dba14d7d | 2791 | if (p1 == 0 and p2 == 0) return true; |
2792 | if (fabs(p1 - p2) / ((p1 + p2)*0.5) > 0.5) return false; | |
2793 | double denom = p1 * p2; | |
2794 | if (denom == 0) return false; | |
a3d4b6ba | 2795 | double ratio = (double(px1)*double(px2) + double(py1)*double(py2) + double(pz1)*double(pz2)) / denom; |
2796 | if (ratio < -1) return true; | |
2797 | if (ratio > 1) return true; | |
2798 | double angle = acos(ratio); | |
dba14d7d | 2799 | if (angle > 3.14159265358979323846 * 10. / 180.) return false; |
2800 | return true; | |
2801 | } | |
2802 | ||
2803 | ||
2804 | bool AliHLTMUONDataCheckerComponent::IsScalarTooLarge( | |
2805 | const AliHLTComponentBlockData* block, | |
2806 | AliHLTUInt32_t blockNumber, | |
2807 | const char* blockTypeName, | |
2808 | const char* scalarName, | |
2809 | AliHLTUInt32_t scalarValue, | |
2810 | AliHLTUInt32_t totalTrackCount | |
2811 | ) const | |
2812 | { | |
2813 | /// Checks if the scalar value is larger than the number of Manso | |
2814 | /// tracks in the event. | |
2815 | ||
2816 | if (scalarValue > totalTrackCount) | |
2817 | { | |
2818 | HLTError("Problem found with %s trigger decision" | |
2819 | " data block %d, fDataType = '%s', fPtr = %p and" | |
2820 | " fSize = %u bytes." | |
2821 | " Problem: The %s scalar with value %d is larger" | |
2822 | " than the total number of Manso tracks found for the" | |
2823 | " event (%d tracks).", | |
2824 | blockTypeName, | |
2825 | blockNumber, | |
2826 | DataType2Text(block->fDataType).c_str(), | |
2827 | block->fPtr, | |
2828 | block->fSize, | |
2829 | scalarName, | |
2830 | scalarValue, | |
2831 | totalTrackCount | |
2832 | ); | |
2833 | return true; | |
2834 | } | |
2835 | else | |
2836 | { | |
2837 | return false; | |
2838 | } | |
2839 | } | |
2840 | ||
2841 | ||
2842 | bool AliHLTMUONDataCheckerComponent::IsScalarALargerThanB( | |
2843 | const AliHLTComponentBlockData* block, | |
2844 | AliHLTUInt32_t blockNumber, | |
2845 | const char* blockTypeName, | |
2846 | const char* scalarAName, | |
2847 | AliHLTUInt32_t scalarAValue, | |
2848 | const char* scalarBName, | |
2849 | AliHLTUInt32_t scalarBValue | |
2850 | ) const | |
2851 | { | |
2852 | /// Checks if the scalar value is larger than the number of Manso | |
2853 | /// tracks in the event. | |
2854 | ||
2855 | if (scalarAValue > scalarBValue) | |
2856 | { | |
2857 | HLTError("Problem found with %s trigger decision" | |
2858 | " data block %d, fDataType = '%s', fPtr = %p and" | |
2859 | " fSize = %u bytes." | |
2860 | " Problem: The %s scalar with value %d is larger" | |
2861 | " than scalar %s with value %d, but is should not be.", | |
2862 | blockTypeName, | |
2863 | blockNumber, | |
2864 | DataType2Text(block->fDataType).c_str(), | |
2865 | block->fPtr, | |
2866 | block->fSize, | |
2867 | scalarAName, | |
2868 | scalarAValue, | |
2869 | scalarBName, | |
2870 | scalarBValue | |
2871 | ); | |
2872 | return true; | |
2873 | } | |
2874 | else | |
2875 | { | |
2876 | return false; | |
2877 | } | |
2878 | } | |
2879 | ||
2880 | ||
2881 | void AliHLTMUONDataCheckerComponent::MarkBlock( | |
2882 | const AliHLTComponentBlockData* blocks, | |
2883 | bool* blockOk, | |
2884 | AliHLTUInt32_t blockCount, | |
2885 | const AliHLTComponentBlockData* blockToMark | |
2886 | ) const | |
2887 | { | |
2888 | /// Tries to find the 'blockToMark' in the list of blocks and sets the | |
2889 | /// corresponding 'blockOk' flag to false. | |
2890 | ||
2891 | for (AliHLTUInt32_t i = 0; i < blockCount; i++) | |
2892 | { | |
2893 | if (&blocks[i] == blockToMark) | |
2894 | { | |
2895 | blockOk[i] = false; | |
2896 | return; | |
2897 | } | |
2898 | } | |
2899 | } | |
2900 | ||
2901 | ||
2902 | void AliHLTMUONDataCheckerComponent::MakeGlobalChecks( | |
2903 | const AliHLTComponentBlockData* blocks, | |
2904 | bool* blockOk, | |
2905 | AliHLTUInt32_t blockCount, | |
2906 | const AliHLTComponentBlockData** trigRecBlocks, | |
2907 | AliHLTUInt32_t trigRecBlocksCount, | |
2908 | const AliHLTComponentBlockData** trigRecDebugBlocks, | |
2909 | AliHLTUInt32_t trigRecDebugBlocksCount, | |
2910 | const AliHLTComponentBlockData** hitBlocks, | |
2911 | AliHLTUInt32_t hitBlocksCount, | |
2912 | const AliHLTComponentBlockData** clusterBlocks, | |
2913 | AliHLTUInt32_t clusterBlocksCount, | |
2914 | const AliHLTComponentBlockData** channelBlocks, | |
2915 | AliHLTUInt32_t channelBlocksCount, | |
2916 | const AliHLTComponentBlockData** mansoTrackBlocks, | |
2917 | AliHLTUInt32_t mansoTrackBlocksCount, | |
2918 | const AliHLTComponentBlockData** mansoCandidateBlocks, | |
2919 | AliHLTUInt32_t mansoCandidateBlocksCount, | |
2920 | const AliHLTComponentBlockData** singleDecisionBlocks, | |
2921 | AliHLTUInt32_t singleDecisionBlocksCount, | |
2922 | const AliHLTComponentBlockData** pairDecisionBlocks, | |
2923 | AliHLTUInt32_t pairDecisionBlocksCount | |
2924 | ) const | |
2925 | { | |
2926 | /// The following set of global checks are performed: | |
2927 | /// 1) Checks if all the ID numbers in all the blocks are unique. | |
2928 | /// 2) Check if all the structures are unique up to their ID numbers, | |
2929 | /// that it, make sure there are no structures with the same data but | |
2930 | /// for a different ID number. | |
2931 | /// 3) Check if the reference ID numbers are correct, i.e. are the | |
2932 | /// trigger record ID numbers in the track structures found in any of | |
2933 | /// the trigger record data blocks. | |
2934 | /// 4) Do the number of channels claimed in the cluster correspond to | |
2935 | /// the number of channel structures. | |
2936 | /// 5) Check that the momentum vectors between the Manso tracks and | |
2937 | /// the corresponding trigger record are compatible. | |
2938 | /// 6) Check that the trigger decision scalars are reasonable. | |
a090ff22 | 2939 | /// 7) Check that the detector element IDs are the same between rec |
2940 | /// hits and clusters / trigger record debug blocks. | |
dba14d7d | 2941 | |
2942 | // Check if all the trigger record identifiers and data are unique. | |
2943 | for (AliHLTUInt32_t bi = 0; bi < trigRecBlocksCount; bi++) | |
2944 | { | |
2945 | AliHLTMUONTriggerRecordsBlockReader inblocki(trigRecBlocks[bi]->fPtr, trigRecBlocks[bi]->fSize); | |
2946 | if (not inblocki.BufferSizeOk()) continue; | |
2947 | for (AliHLTUInt32_t bj = bi+1; bj < trigRecBlocksCount; bj++) | |
2948 | { | |
2949 | AliHLTMUONTriggerRecordsBlockReader inblockj(trigRecBlocks[bj]->fPtr, trigRecBlocks[bj]->fSize); | |
2950 | if (not inblockj.BufferSizeOk()) continue; | |
2951 | ||
2952 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
2953 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
2954 | { | |
2955 | if (inblocki[i].fId == inblockj[j].fId) | |
2956 | { | |
2957 | HLTError("Problem found with trigger record data block %d," | |
2958 | " fDataType = '%s', fPtr = %p and fSize = %u bytes," | |
2959 | " and trigger record data block %d," | |
2960 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
2961 | " Problem: Trigger record %d in block %d and entry" | |
2962 | " %d in block %d have the same identfier, but they" | |
2963 | " should be unique.", | |
2964 | bi, | |
2965 | DataType2Text(trigRecBlocks[bi]->fDataType).c_str(), | |
2966 | trigRecBlocks[bi]->fPtr, | |
2967 | trigRecBlocks[bi]->fSize, | |
2968 | bj, | |
2969 | DataType2Text(trigRecBlocks[bj]->fDataType).c_str(), | |
2970 | trigRecBlocks[bj]->fPtr, | |
2971 | trigRecBlocks[bj]->fSize, | |
2972 | bi, i, | |
2973 | bj, j | |
2974 | ); | |
2975 | MarkBlock(blocks, blockOk, blockCount, trigRecBlocks[bi]); | |
2976 | MarkBlock(blocks, blockOk, blockCount, trigRecBlocks[bj]); | |
2977 | } | |
2978 | ||
2979 | AliHLTMUONTriggerRecordStruct a = inblocki[i]; | |
2980 | AliHLTMUONTriggerRecordStruct b = inblockj[j]; | |
2981 | a.fId = b.fId = -1; | |
2982 | if (a == b) | |
2983 | { | |
2984 | HLTError("Problem found with trigger record data block %d," | |
2985 | " fDataType = '%s', fPtr = %p and fSize = %u bytes," | |
2986 | " and trigger record data block %d," | |
2987 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
2988 | " Problem: Trigger record %d in block %d and entry" | |
2989 | " %d in block %d have the same data." | |
2990 | " The data may have been duplicated.", | |
2991 | bi, | |
2992 | DataType2Text(trigRecBlocks[bi]->fDataType).c_str(), | |
2993 | trigRecBlocks[bi]->fPtr, | |
2994 | trigRecBlocks[bi]->fSize, | |
2995 | bj, | |
2996 | DataType2Text(trigRecBlocks[bj]->fDataType).c_str(), | |
2997 | trigRecBlocks[bj]->fPtr, | |
2998 | trigRecBlocks[bj]->fSize, | |
2999 | bi, i, | |
3000 | bj, j | |
3001 | ); | |
3002 | MarkBlock(blocks, blockOk, blockCount, trigRecBlocks[bi]); | |
3003 | MarkBlock(blocks, blockOk, blockCount, trigRecBlocks[bj]); | |
3004 | } | |
3005 | } | |
3006 | } | |
3007 | } | |
3008 | ||
3009 | for (AliHLTUInt32_t bi = 0; bi < trigRecDebugBlocksCount; bi++) | |
3010 | { | |
3011 | AliHLTMUONTrigRecsDebugBlockReader inblocki(trigRecDebugBlocks[bi]->fPtr, trigRecDebugBlocks[bi]->fSize); | |
3012 | if (not inblocki.BufferSizeOk()) continue; | |
3013 | ||
dba14d7d | 3014 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) |
3015 | { | |
a090ff22 | 3016 | // Check if all the trigger record IDs in the debug information structures exist. |
dba14d7d | 3017 | bool found = false; |
3018 | ||
3019 | for (AliHLTUInt32_t bj = 0; bj < trigRecBlocksCount and not found; bj++) | |
3020 | { | |
3021 | AliHLTMUONTriggerRecordsBlockReader inblockj(trigRecBlocks[bj]->fPtr, trigRecBlocks[bj]->fSize); | |
3022 | if (not inblockj.BufferSizeOk()) continue; | |
3023 | ||
3024 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3025 | { | |
3026 | if (inblocki[i].fTrigRecId == inblockj[j].fId) | |
3027 | { | |
3028 | found = true; | |
a090ff22 | 3029 | |
3030 | // Since we found the corresponding trigger record, | |
3031 | // check if the detector element IDs are the same. | |
3032 | bool deOk = CheckDetElemIds( | |
3033 | *trigRecDebugBlocks[bi], bi, i, inblocki[i], | |
3034 | *trigRecBlocks[bj], bj, j, inblockj[j] | |
3035 | ); | |
3036 | if (not deOk) | |
3037 | { | |
3038 | MarkBlock(blocks, blockOk, blockCount, trigRecDebugBlocks[bi]); | |
3039 | MarkBlock(blocks, blockOk, blockCount, trigRecBlocks[bj]); | |
3040 | } | |
3041 | ||
dba14d7d | 3042 | break; |
3043 | } | |
3044 | } | |
3045 | } | |
3046 | ||
3047 | if (not found) | |
3048 | { | |
3049 | HLTError("Problem found with trigger record debug information" | |
3050 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3051 | " fSize = %u bytes." | |
3052 | " Problem with entry %d in block: The trigger record" | |
3053 | " identifier %d does not exist in any trigger record" | |
3054 | " data block.", | |
3055 | bi, | |
3056 | DataType2Text(trigRecDebugBlocks[bi]->fDataType).c_str(), | |
3057 | trigRecDebugBlocks[bi]->fPtr, | |
3058 | trigRecDebugBlocks[bi]->fSize, | |
3059 | i, inblocki[i].fTrigRecId | |
3060 | ); | |
3061 | MarkBlock(blocks, blockOk, blockCount, trigRecDebugBlocks[bi]); | |
3062 | } | |
3063 | } | |
3064 | ||
3065 | // Check if all the trigger record debug information structures are unique. | |
3066 | for (AliHLTUInt32_t bj = bi+1; bj < trigRecDebugBlocksCount; bj++) | |
3067 | { | |
3068 | AliHLTMUONTrigRecsDebugBlockReader inblockj(trigRecDebugBlocks[bj]->fPtr, trigRecDebugBlocks[bj]->fSize); | |
3069 | if (not inblockj.BufferSizeOk()) continue; | |
3070 | ||
3071 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3072 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3073 | { | |
3074 | AliHLTMUONTrigRecInfoStruct a = inblocki[i]; | |
3075 | AliHLTMUONTrigRecInfoStruct b = inblockj[j]; | |
3076 | a.fTrigRecId = b.fTrigRecId = -1; | |
3077 | if (a == b) | |
3078 | { | |
3079 | HLTError("Problem found with trigger record debug information" | |
3080 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3081 | " fSize = %u bytes, and trigger record debug" | |
3082 | " information data block %d," | |
3083 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3084 | " Problem: The trigger record debug inforamtion" | |
3085 | " structure %d in block %d and entry" | |
3086 | " %d in block %d have the same data." | |
3087 | " The data may have been duplicated.", | |
3088 | bi, | |
3089 | DataType2Text(trigRecDebugBlocks[bi]->fDataType).c_str(), | |
3090 | trigRecDebugBlocks[bi]->fPtr, | |
3091 | trigRecDebugBlocks[bi]->fSize, | |
3092 | bj, | |
3093 | DataType2Text(trigRecDebugBlocks[bj]->fDataType).c_str(), | |
3094 | trigRecDebugBlocks[bj]->fPtr, | |
3095 | trigRecDebugBlocks[bj]->fSize, | |
3096 | bi, i, | |
3097 | bj, j | |
3098 | ); | |
3099 | MarkBlock(blocks, blockOk, blockCount, trigRecDebugBlocks[bi]); | |
3100 | MarkBlock(blocks, blockOk, blockCount, trigRecDebugBlocks[bj]); | |
3101 | } | |
3102 | } | |
3103 | } | |
3104 | } | |
3105 | ||
3106 | // Check that all the reconstructed hits are unique. | |
3107 | for (AliHLTUInt32_t bi = 0; bi < hitBlocksCount; bi++) | |
3108 | { | |
3109 | AliHLTMUONRecHitsBlockReader inblocki(hitBlocks[bi]->fPtr, hitBlocks[bi]->fSize); | |
3110 | if (not inblocki.BufferSizeOk()) continue; | |
3111 | for (AliHLTUInt32_t bj = bi+1; bj < hitBlocksCount; bj++) | |
3112 | { | |
3113 | AliHLTMUONRecHitsBlockReader inblockj(hitBlocks[bj]->fPtr, hitBlocks[bj]->fSize); | |
3114 | if (not inblockj.BufferSizeOk()) continue; | |
3115 | ||
3116 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3117 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3118 | { | |
3119 | if (inblocki[i] == inblockj[j]) | |
3120 | { | |
3121 | HLTError("Problem found with reconstructed hit data block %d," | |
3122 | " fDataType = '%s', fPtr = %p and fSize = %u bytes," | |
3123 | " and reconstructed hit data block %d," | |
3124 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3125 | " Problem: Reconstructed hit %d in block %d and entry" | |
3126 | " %d in block %d are the same, but all hits" | |
3127 | " should be unique.", | |
3128 | bi, | |
3129 | DataType2Text(hitBlocks[bi]->fDataType).c_str(), | |
3130 | hitBlocks[bi]->fPtr, | |
3131 | hitBlocks[bi]->fSize, | |
3132 | bj, | |
3133 | DataType2Text(hitBlocks[bj]->fDataType).c_str(), | |
3134 | hitBlocks[bj]->fPtr, | |
3135 | hitBlocks[bj]->fSize, | |
3136 | bi, i, | |
3137 | bj, j | |
3138 | ); | |
3139 | MarkBlock(blocks, blockOk, blockCount, hitBlocks[bi]); | |
3140 | MarkBlock(blocks, blockOk, blockCount, hitBlocks[bj]); | |
3141 | } | |
3142 | } | |
3143 | } | |
3144 | } | |
3145 | ||
3146 | for (AliHLTUInt32_t bi = 0; bi < clusterBlocksCount; bi++) | |
3147 | { | |
3148 | AliHLTMUONClustersBlockReader inblocki(clusterBlocks[bi]->fPtr, clusterBlocks[bi]->fSize); | |
3149 | if (not inblocki.BufferSizeOk()) continue; | |
3150 | ||
3151 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3152 | { | |
3153 | // Check if all the reconstructed hit coordinates in the cluster structures exist. | |
3154 | bool found = false; | |
3155 | ||
3156 | for (AliHLTUInt32_t bj = 0; bj < hitBlocksCount and not found; bj++) | |
3157 | { | |
3158 | AliHLTMUONRecHitsBlockReader inblockj(hitBlocks[bj]->fPtr, hitBlocks[bj]->fSize); | |
3159 | if (not inblockj.BufferSizeOk()) continue; | |
3160 | ||
3161 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3162 | { | |
3163 | if (inblocki[i].fHit == inblockj[j]) | |
3164 | { | |
3165 | found = true; | |
a090ff22 | 3166 | |
3167 | // Since we found the corresponding cluster, | |
3168 | // check if the detector element IDs are the same. | |
3169 | bool deOk = CheckDetElemIds( | |
3170 | *clusterBlocks[bi], bi, i, inblocki[i], | |
3171 | *hitBlocks[bj], bj, j, inblockj[j] | |
3172 | ); | |
3173 | if (not deOk) | |
3174 | { | |
3175 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bi]); | |
3176 | MarkBlock(blocks, blockOk, blockCount, hitBlocks[bj]); | |
3177 | } | |
3178 | ||
dba14d7d | 3179 | break; |
3180 | } | |
3181 | } | |
3182 | } | |
3183 | ||
3184 | // If the hit was not found then it should be nil. | |
3185 | if (not found and (inblocki[i].fHit != AliHLTMUONConstants::NilRecHitStruct())) | |
3186 | { | |
3187 | HLTError("Problem found with cluster data block %d," | |
3188 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3189 | " Problem with entry %d in block: The cluster hit" | |
3190 | " coordinate {x = %f, y = %f, z = %f} does not exist" | |
3191 | " in any reconstructed hit data block.", | |
3192 | bi, | |
3193 | DataType2Text(clusterBlocks[bi]->fDataType).c_str(), | |
3194 | clusterBlocks[bi]->fPtr, | |
3195 | clusterBlocks[bi]->fSize, | |
3196 | i, | |
3197 | inblocki[i].fHit.fX, | |
3198 | inblocki[i].fHit.fY, | |
3199 | inblocki[i].fHit.fZ | |
3200 | ); | |
3201 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bi]); | |
3202 | } | |
3203 | ||
3204 | // Check that the fNchannels value is correct. | |
3205 | AliHLTUInt32_t count = 0; | |
3206 | for (AliHLTUInt32_t bj = 0; bj < channelBlocksCount and not found; bj++) | |
3207 | { | |
3208 | AliHLTMUONChannelsBlockReader inblockj(channelBlocks[bj]->fPtr, channelBlocks[bj]->fSize); | |
3209 | if (not inblockj.BufferSizeOk()) continue; | |
3210 | ||
3211 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3212 | { | |
3213 | if (inblocki[i].fId == inblockj[j].fClusterId) | |
3214 | { | |
3215 | count++; | |
3216 | } | |
3217 | } | |
3218 | } | |
3219 | ||
3220 | if (inblocki[i].fNchannels != count) | |
3221 | { | |
3222 | HLTError("Problem found with cluster data block %d," | |
3223 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3224 | " Problem with entry %d in block: The number of" | |
3225 | " channels in the cluster is reported as %d, but" | |
3226 | " only %d channel structures were found.", | |
3227 | bi, | |
3228 | DataType2Text(clusterBlocks[bi]->fDataType).c_str(), | |
3229 | clusterBlocks[bi]->fPtr, | |
3230 | clusterBlocks[bi]->fSize, | |
3231 | i, | |
3232 | inblocki[i].fNchannels, | |
3233 | count | |
3234 | ); | |
3235 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bi]); | |
3236 | } | |
3237 | } | |
3238 | ||
3239 | // Check if all the cluster structures are unique up to the identifier | |
3240 | // and have unique identifiers. | |
3241 | for (AliHLTUInt32_t bj = bi+1; bj < clusterBlocksCount; bj++) | |
3242 | { | |
3243 | AliHLTMUONClustersBlockReader inblockj(clusterBlocks[bj]->fPtr, clusterBlocks[bj]->fSize); | |
3244 | if (not inblockj.BufferSizeOk()) continue; | |
3245 | ||
3246 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3247 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3248 | { | |
3249 | if (inblocki[i].fId == inblockj[j].fId) | |
3250 | { | |
3251 | HLTError("Problem found with cluster" | |
3252 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3253 | " fSize = %u bytes, and cluster data block %d," | |
3254 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3255 | " Problem: The cluster %d in block %d and entry" | |
3256 | " %d in block %d have the same identifier, but they" | |
3257 | " should be unique.", | |
3258 | bi, | |
3259 | DataType2Text(clusterBlocks[bi]->fDataType).c_str(), | |
3260 | clusterBlocks[bi]->fPtr, | |
3261 | clusterBlocks[bi]->fSize, | |
3262 | bj, | |
3263 | DataType2Text(clusterBlocks[bj]->fDataType).c_str(), | |
3264 | clusterBlocks[bj]->fPtr, | |
3265 | clusterBlocks[bj]->fSize, | |
3266 | bi, i, | |
3267 | bj, j | |
3268 | ); | |
3269 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bi]); | |
3270 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bj]); | |
3271 | } | |
3272 | ||
3273 | AliHLTMUONClusterStruct a = inblocki[i]; | |
3274 | AliHLTMUONClusterStruct b = inblockj[j]; | |
3275 | a.fId = b.fId = -1; | |
3276 | if (a == b) | |
3277 | { | |
3278 | HLTError("Problem found with cluster" | |
3279 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3280 | " fSize = %u bytes, and cluster data block %d," | |
3281 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3282 | " Problem: The cluster %d in block %d and entry" | |
3283 | " %d in block %d have the same data." | |
3284 | " The data may have been duplicated.", | |
3285 | bi, | |
3286 | DataType2Text(clusterBlocks[bi]->fDataType).c_str(), | |
3287 | clusterBlocks[bi]->fPtr, | |
3288 | clusterBlocks[bi]->fSize, | |
3289 | bj, | |
3290 | DataType2Text(clusterBlocks[bj]->fDataType).c_str(), | |
3291 | clusterBlocks[bj]->fPtr, | |
3292 | clusterBlocks[bj]->fSize, | |
3293 | bi, i, | |
3294 | bj, j | |
3295 | ); | |
3296 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bi]); | |
3297 | MarkBlock(blocks, blockOk, blockCount, clusterBlocks[bj]); | |
3298 | } | |
3299 | } | |
3300 | } | |
3301 | } | |
3302 | ||
3303 | for (AliHLTUInt32_t bi = 0; bi < channelBlocksCount; bi++) | |
3304 | { | |
3305 | AliHLTMUONChannelsBlockReader inblocki(channelBlocks[bi]->fPtr, channelBlocks[bi]->fSize); | |
3306 | if (not inblocki.BufferSizeOk()) continue; | |
3307 | ||
3308 | // Check if all the cluster IDs in the channel structures exist. | |
3309 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3310 | { | |
3311 | bool found = false; | |
3312 | ||
3313 | for (AliHLTUInt32_t bj = 0; bj < clusterBlocksCount and not found; bj++) | |
3314 | { | |
3315 | AliHLTMUONClustersBlockReader inblockj(clusterBlocks[bj]->fPtr, clusterBlocks[bj]->fSize); | |
3316 | if (not inblockj.BufferSizeOk()) continue; | |
3317 | ||
3318 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3319 | { | |
3320 | if (inblocki[i].fClusterId == inblockj[j].fId) | |
3321 | { | |
3322 | found = true; | |
3323 | break; | |
3324 | } | |
3325 | } | |
3326 | } | |
3327 | ||
3328 | if (not found) | |
3329 | { | |
3330 | HLTError("Problem found with channel" | |
3331 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3332 | " fSize = %u bytes." | |
3333 | " Problem with entry %d in block: The cluster" | |
3334 | " identifier %d does not exist in any cluster" | |
3335 | " data block.", | |
3336 | bi, | |
3337 | DataType2Text(channelBlocks[bi]->fDataType).c_str(), | |
3338 | channelBlocks[bi]->fPtr, | |
3339 | channelBlocks[bi]->fSize, | |
3340 | i, inblocki[i].fClusterId | |
3341 | ); | |
3342 | MarkBlock(blocks, blockOk, blockCount, channelBlocks[bi]); | |
3343 | } | |
3344 | } | |
3345 | ||
3346 | // Check if all the channel structures are unique up to the cluster ID. | |
3347 | for (AliHLTUInt32_t bj = bi+1; bj < channelBlocksCount; bj++) | |
3348 | { | |
3349 | AliHLTMUONChannelsBlockReader inblockj(channelBlocks[bj]->fPtr, channelBlocks[bj]->fSize); | |
3350 | if (not inblockj.BufferSizeOk()) continue; | |
3351 | ||
3352 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3353 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3354 | { | |
3355 | AliHLTMUONChannelStruct a = inblocki[i]; | |
3356 | AliHLTMUONChannelStruct b = inblockj[j]; | |
3357 | a.fClusterId = b.fClusterId = -1; | |
3358 | if (a == b) | |
3359 | { | |
3360 | HLTError("Problem found with channel" | |
3361 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3362 | " fSize = %u bytes, and channel data block %d," | |
3363 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3364 | " Problem: The channel %d in block %d and entry" | |
3365 | " %d in block %d have the same data." | |
3366 | " The data may have been duplicated.", | |
3367 | bi, | |
3368 | DataType2Text(channelBlocks[bi]->fDataType).c_str(), | |
3369 | channelBlocks[bi]->fPtr, | |
3370 | channelBlocks[bi]->fSize, | |
3371 | bj, | |
3372 | DataType2Text(channelBlocks[bj]->fDataType).c_str(), | |
3373 | channelBlocks[bj]->fPtr, | |
3374 | channelBlocks[bj]->fSize, | |
3375 | bi, i, | |
3376 | bj, j | |
3377 | ); | |
3378 | MarkBlock(blocks, blockOk, blockCount, channelBlocks[bi]); | |
3379 | MarkBlock(blocks, blockOk, blockCount, channelBlocks[bj]); | |
3380 | } | |
3381 | } | |
3382 | } | |
3383 | } | |
3384 | ||
3385 | // Will need the total number of tracks later for comparison to trigger scalars. | |
3386 | AliHLTUInt32_t totalTrackCount = 0; | |
3387 | ||
3388 | for (AliHLTUInt32_t bi = 0; bi < mansoTrackBlocksCount; bi++) | |
3389 | { | |
3390 | AliHLTMUONMansoTracksBlockReader inblocki(mansoTrackBlocks[bi]->fPtr, mansoTrackBlocks[bi]->fSize); | |
3391 | if (not inblocki.BufferSizeOk()) continue; | |
3392 | ||
3393 | totalTrackCount += inblocki.Nentries(); | |
3394 | ||
3395 | // Check if all the trigger record IDs in the Manso track structures exist. | |
3396 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3397 | { | |
3398 | bool found = false; | |
3399 | ||
3400 | for (AliHLTUInt32_t bj = 0; bj < trigRecBlocksCount and not found; bj++) | |
3401 | { | |
3402 | AliHLTMUONTriggerRecordsBlockReader inblockj(trigRecBlocks[bj]->fPtr, trigRecBlocks[bj]->fSize); | |
3403 | if (not inblockj.BufferSizeOk()) continue; | |
3404 | ||
3405 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3406 | { | |
3407 | if (inblocki[i].fTrigRec == inblockj[j].fId) | |
3408 | { | |
3409 | // At this point we can check if the momentum | |
3410 | // is compatible with the trigger record. | |
3411 | if (not AreMomentaCompatible( | |
3412 | inblocki[i].fPx, inblocki[i].fPy, inblocki[i].fPz, | |
3413 | inblockj[j].fPx, inblockj[j].fPy, inblockj[j].fPz | |
3414 | ) | |
3415 | ) | |
3416 | { | |
3417 | HLTWarning("Problem found with Manso track" | |
3418 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3419 | " fSize = %u bytes." | |
3420 | " Problem with Manso track %d in block: The momentum" | |
3421 | " vector of the track p = {%f, %f, %f} GeV/c is not" | |
3422 | " compatible with the momentum vector of the trigger" | |
3423 | " record with p = {%f, %f, %f} GeV/c.", | |
3424 | bi, | |
3425 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3426 | mansoTrackBlocks[bi]->fPtr, | |
3427 | mansoTrackBlocks[bi]->fSize, | |
3428 | i, inblocki[i].fPx, inblocki[i].fPy, inblocki[i].fPz, | |
3429 | inblockj[j].fPx, inblockj[j].fPy, inblockj[j].fPz | |
3430 | ); | |
3431 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3432 | } | |
3433 | ||
3434 | found = true; | |
3435 | break; | |
3436 | } | |
3437 | } | |
3438 | } | |
3439 | ||
3440 | if (not found) | |
3441 | { | |
3442 | HLTError("Problem found with Manso track" | |
3443 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3444 | " fSize = %u bytes." | |
3445 | " Problem with Manso track %d in block: The trigger" | |
3446 | " record identifier %d does not exist in any trigger" | |
3447 | " record data block.", | |
3448 | bi, | |
3449 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3450 | mansoTrackBlocks[bi]->fPtr, | |
3451 | mansoTrackBlocks[bi]->fSize, | |
3452 | i, inblocki[i].fTrigRec | |
3453 | ); | |
3454 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3455 | } | |
3456 | } | |
3457 | ||
3458 | // Check if all the hits in the Manso track structures exist. | |
3459 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3460 | { | |
3461 | AliHLTMUONParticleSign sign; | |
3462 | bool hitset[4]; | |
3463 | AliHLTMUONUtils::UnpackMansoTrackFlags(inblocki[i].fFlags, sign, hitset); | |
3464 | ||
3465 | for (AliHLTUInt32_t n = 0; n < 4; n++) | |
3466 | { | |
3467 | if (not hitset[n]) continue; | |
3468 | bool found = false; | |
3469 | ||
3470 | for (AliHLTUInt32_t bj = 0; bj < hitBlocksCount and not found; bj++) | |
3471 | { | |
3472 | AliHLTMUONRecHitsBlockReader inblockj(hitBlocks[bj]->fPtr, hitBlocks[bj]->fSize); | |
3473 | if (not inblockj.BufferSizeOk()) continue; | |
3474 | ||
3475 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3476 | { | |
3477 | if (inblocki[i].fHit[n] == inblockj[j]) | |
3478 | { | |
3479 | found = true; | |
3480 | break; | |
3481 | } | |
3482 | } | |
3483 | } | |
3484 | ||
3485 | if (not found) | |
3486 | { | |
3487 | HLTError("Problem found with Manso track" | |
3488 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3489 | " fSize = %u bytes." | |
3490 | " Problem with Manso track %d in block: The hit" | |
3491 | " for chamber %d does not exist in any" | |
3492 | " reconstructed hits data block.", | |
3493 | bi, | |
3494 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3495 | mansoTrackBlocks[bi]->fPtr, | |
3496 | mansoTrackBlocks[bi]->fSize, | |
3497 | i, n+6+1 | |
3498 | ); | |
3499 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3500 | } | |
3501 | } | |
3502 | } | |
3503 | ||
3504 | // Check if all the Manso track structures are unique up to the ID and | |
3505 | // have unique identifiers. | |
3506 | for (AliHLTUInt32_t bj = bi+1; bj < mansoTrackBlocksCount; bj++) | |
3507 | { | |
3508 | AliHLTMUONMansoTracksBlockReader inblockj(mansoTrackBlocks[bj]->fPtr, mansoTrackBlocks[bj]->fSize); | |
3509 | if (not inblockj.BufferSizeOk()) continue; | |
3510 | ||
3511 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3512 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3513 | { | |
3514 | if (inblocki[i].fId == inblockj[j].fId) | |
3515 | { | |
3516 | HLTError("Problem found with Manso track" | |
3517 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3518 | " fSize = %u bytes, and Manso track data block %d," | |
3519 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3520 | " Problem: The Manso track %d in block %d and entry" | |
3521 | " %d in block %d have the same identifier, but they" | |
3522 | " should be unique.", | |
3523 | bi, | |
3524 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3525 | mansoTrackBlocks[bi]->fPtr, | |
3526 | mansoTrackBlocks[bi]->fSize, | |
3527 | bj, | |
3528 | DataType2Text(mansoTrackBlocks[bj]->fDataType).c_str(), | |
3529 | mansoTrackBlocks[bj]->fPtr, | |
3530 | mansoTrackBlocks[bj]->fSize, | |
3531 | bi, i, | |
3532 | bj, j | |
3533 | ); | |
3534 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3535 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bj]); | |
3536 | } | |
3537 | ||
3538 | AliHLTMUONMansoTrackStruct a = inblocki[i]; | |
3539 | AliHLTMUONMansoTrackStruct b = inblockj[j]; | |
3540 | a.fId = b.fId = -1; | |
3541 | if (a == b) | |
3542 | { | |
3543 | HLTError("Problem found with Manso track" | |
3544 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3545 | " fSize = %u bytes, and Manso track data block %d," | |
3546 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3547 | " Problem: The Manso track %d in block %d and entry" | |
3548 | " %d in block %d have the same data." | |
3549 | " The data may have been duplicated.", | |
3550 | bi, | |
3551 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3552 | mansoTrackBlocks[bi]->fPtr, | |
3553 | mansoTrackBlocks[bi]->fSize, | |
3554 | bj, | |
3555 | DataType2Text(mansoTrackBlocks[bj]->fDataType).c_str(), | |
3556 | mansoTrackBlocks[bj]->fPtr, | |
3557 | mansoTrackBlocks[bj]->fSize, | |
3558 | bi, i, | |
3559 | bj, j | |
3560 | ); | |
3561 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3562 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bj]); | |
3563 | } | |
3564 | } | |
3565 | } | |
3566 | } | |
3567 | ||
3568 | for (AliHLTUInt32_t bi = 0; bi < mansoCandidateBlocksCount; bi++) | |
3569 | { | |
3570 | AliHLTMUONMansoCandidatesBlockReader inblocki(mansoCandidateBlocks[bi]->fPtr, mansoCandidateBlocks[bi]->fSize); | |
3571 | if (not inblocki.BufferSizeOk()) continue; | |
3572 | ||
3573 | // Check if all the trigger record IDs in the Manso track candidate structures exist. | |
3574 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3575 | { | |
3576 | bool found = false; | |
3577 | ||
3578 | for (AliHLTUInt32_t bj = 0; bj < trigRecBlocksCount and not found; bj++) | |
3579 | { | |
3580 | AliHLTMUONTriggerRecordsBlockReader inblockj(trigRecBlocks[bj]->fPtr, trigRecBlocks[bj]->fSize); | |
3581 | if (not inblockj.BufferSizeOk()) continue; | |
3582 | ||
3583 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3584 | { | |
3585 | if (inblocki[i].fTrack.fTrigRec == inblockj[j].fId) | |
3586 | { | |
3587 | // At this point we can check if the momentum | |
3588 | // is compatible with the trigger record. | |
3589 | if (not AreMomentaCompatible( | |
3590 | inblocki[i].fTrack.fPx, inblocki[i].fTrack.fPy, inblocki[i].fTrack.fPz, | |
3591 | inblockj[j].fPx, inblockj[j].fPy, inblockj[j].fPz | |
3592 | ) | |
3593 | ) | |
3594 | { | |
3595 | HLTWarning("Problem found with Manso track candidate" | |
3596 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3597 | " fSize = %u bytes." | |
3598 | " Problem with track candidate %d in block: The momentum" | |
3599 | " vector of the candidate p = {%f, %f, %f} GeV/c is not" | |
3600 | " compatible with the momentum vector of the trigger" | |
3601 | " record with p = {%f, %f, %f} GeV/c.", | |
3602 | bi, | |
3603 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3604 | mansoTrackBlocks[bi]->fPtr, | |
3605 | mansoTrackBlocks[bi]->fSize, | |
3606 | i, | |
3607 | inblocki[i].fTrack.fPx, inblocki[i].fTrack.fPy, inblocki[i].fTrack.fPz, | |
3608 | inblockj[j].fPx, inblockj[j].fPy, inblockj[j].fPz | |
3609 | ); | |
3610 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3611 | } | |
3612 | ||
3613 | found = true; | |
3614 | break; | |
3615 | } | |
3616 | } | |
3617 | } | |
3618 | ||
3619 | if (not found) | |
3620 | { | |
3621 | HLTError("Problem found with Manso track candidate" | |
3622 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3623 | " fSize = %u bytes." | |
3624 | " Problem with track candidate %d in block: The trigger" | |
3625 | " record identifier %d does not exist in any trigger" | |
3626 | " record data block.", | |
3627 | bi, | |
3628 | DataType2Text(mansoCandidateBlocks[bi]->fDataType).c_str(), | |
3629 | mansoCandidateBlocks[bi]->fPtr, | |
3630 | mansoCandidateBlocks[bi]->fSize, | |
3631 | i, inblocki[i].fTrack.fTrigRec | |
3632 | ); | |
3633 | MarkBlock(blocks, blockOk, blockCount, mansoCandidateBlocks[bi]); | |
3634 | } | |
3635 | } | |
3636 | ||
3637 | // Check if all the hits in the Manso track candidate structures exist. | |
3638 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3639 | { | |
3640 | AliHLTMUONParticleSign sign; | |
3641 | bool hitset[4]; | |
3642 | AliHLTMUONUtils::UnpackMansoTrackFlags(inblocki[i].fTrack.fFlags, sign, hitset); | |
3643 | ||
3644 | for (AliHLTUInt32_t n = 0; n < 4; n++) | |
3645 | { | |
3646 | if (not hitset[n]) continue; | |
3647 | bool found = false; | |
3648 | ||
3649 | for (AliHLTUInt32_t bj = 0; bj < hitBlocksCount and not found; bj++) | |
3650 | { | |
3651 | AliHLTMUONRecHitsBlockReader inblockj(hitBlocks[bj]->fPtr, hitBlocks[bj]->fSize); | |
3652 | if (not inblockj.BufferSizeOk()) continue; | |
3653 | ||
3654 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3655 | { | |
3656 | if (inblocki[i].fTrack.fHit[n] == inblockj[j]) | |
3657 | { | |
3658 | found = true; | |
3659 | break; | |
3660 | } | |
3661 | } | |
3662 | } | |
3663 | ||
3664 | if (not found) | |
3665 | { | |
3666 | HLTError("Problem found with Manso track candidate" | |
3667 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3668 | " fSize = %u bytes." | |
3669 | " Problem with track candidate %d in block: The hit" | |
3670 | " for chamber %d does not exist in any" | |
3671 | " reconstructed hits data block.", | |
3672 | bi, | |
3673 | DataType2Text(mansoTrackBlocks[bi]->fDataType).c_str(), | |
3674 | mansoTrackBlocks[bi]->fPtr, | |
3675 | mansoTrackBlocks[bi]->fSize, | |
3676 | i, n+6+1 | |
3677 | ); | |
3678 | MarkBlock(blocks, blockOk, blockCount, mansoTrackBlocks[bi]); | |
3679 | } | |
3680 | } | |
3681 | } | |
3682 | ||
3683 | // Check if all the Manso track candidate structures are unique up to the | |
3684 | // track ID and have unique identifiers. | |
3685 | for (AliHLTUInt32_t bj = bi+1; bj < mansoCandidateBlocksCount; bj++) | |
3686 | { | |
3687 | AliHLTMUONMansoCandidatesBlockReader inblockj(mansoCandidateBlocks[bj]->fPtr, mansoCandidateBlocks[bj]->fSize); | |
3688 | if (not inblockj.BufferSizeOk()) continue; | |
3689 | ||
3690 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3691 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3692 | { | |
3693 | if (inblocki[i].fTrack.fId == inblockj[j].fTrack.fId) | |
3694 | { | |
3695 | HLTError("Problem found with Manso track candidate" | |
3696 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3697 | " fSize = %u bytes, and Manso track candidate data block %d," | |
3698 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3699 | " Problem: The track candidate %d in block %d and entry" | |
3700 | " %d in block %d have the same identifier, but they" | |
3701 | " should be unique.", | |
3702 | bi, | |
3703 | DataType2Text(mansoCandidateBlocks[bi]->fDataType).c_str(), | |
3704 | mansoCandidateBlocks[bi]->fPtr, | |
3705 | mansoCandidateBlocks[bi]->fSize, | |
3706 | bj, | |
3707 | DataType2Text(mansoCandidateBlocks[bj]->fDataType).c_str(), | |
3708 | mansoCandidateBlocks[bj]->fPtr, | |
3709 | mansoCandidateBlocks[bj]->fSize, | |
3710 | bi, i, | |
3711 | bj, j | |
3712 | ); | |
3713 | MarkBlock(blocks, blockOk, blockCount, mansoCandidateBlocks[bi]); | |
3714 | MarkBlock(blocks, blockOk, blockCount, mansoCandidateBlocks[bj]); | |
3715 | } | |
3716 | ||
3717 | AliHLTMUONMansoCandidateStruct a = inblocki[i]; | |
3718 | AliHLTMUONMansoCandidateStruct b = inblockj[j]; | |
3719 | a.fTrack.fId = b.fTrack.fId = -1; | |
3720 | if (a == b) | |
3721 | { | |
3722 | HLTError("Problem found with Manso track candidate" | |
3723 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3724 | " fSize = %u bytes, and Manso track candidate data block %d," | |
3725 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3726 | " Problem: The track candidate %d in block %d and entry" | |
3727 | " %d in block %d have the same data." | |
3728 | " The data may have been duplicated.", | |
3729 | bi, | |
3730 | DataType2Text(mansoCandidateBlocks[bi]->fDataType).c_str(), | |
3731 | mansoCandidateBlocks[bi]->fPtr, | |
3732 | mansoCandidateBlocks[bi]->fSize, | |
3733 | bj, | |
3734 | DataType2Text(mansoCandidateBlocks[bj]->fDataType).c_str(), | |
3735 | mansoCandidateBlocks[bj]->fPtr, | |
3736 | mansoCandidateBlocks[bj]->fSize, | |
3737 | bi, i, | |
3738 | bj, j | |
3739 | ); | |
3740 | MarkBlock(blocks, blockOk, blockCount, mansoCandidateBlocks[bi]); | |
3741 | MarkBlock(blocks, blockOk, blockCount, mansoCandidateBlocks[bj]); | |
3742 | } | |
3743 | } | |
3744 | } | |
3745 | } | |
3746 | ||
3747 | for (AliHLTUInt32_t bi = 0; bi < singleDecisionBlocksCount; bi++) | |
3748 | { | |
3749 | AliHLTMUONSinglesDecisionBlockReader inblocki(singleDecisionBlocks[bi]->fPtr, singleDecisionBlocks[bi]->fSize); | |
3750 | if (not inblocki.BufferSizeOk()) continue; | |
3751 | ||
3752 | // Check that the scalars are within reasonable limits. | |
3753 | const AliHLTMUONSinglesDecisionBlockStruct& hdr = inblocki.BlockHeader(); | |
3754 | const AliHLTComponentBlockData* block = singleDecisionBlocks[bi]; | |
3755 | if (IsScalarTooLarge(block, bi, "single track", "fNlowPt", hdr.fNlowPt, totalTrackCount) or | |
3756 | IsScalarTooLarge(block, bi, "single track", "fNhighPt", hdr.fNhighPt, totalTrackCount) or | |
210736fa | 3757 | IsScalarALargerThanB(block, bi, "single track", "fNhighPt", hdr.fNhighPt, "fNlowPt", hdr.fNlowPt) |
dba14d7d | 3758 | ) |
3759 | { | |
3760 | MarkBlock(blocks, blockOk, blockCount, block); | |
3761 | } | |
3762 | ||
3763 | // Check if all the Manso track IDs in the trigger decision structures exist. | |
3764 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3765 | { | |
3766 | bool found = false; | |
3767 | ||
3768 | for (AliHLTUInt32_t bj = 0; bj < mansoTrackBlocksCount and not found; bj++) | |
3769 | { | |
3770 | AliHLTMUONMansoTracksBlockReader inblockj(mansoTrackBlocks[bj]->fPtr, mansoTrackBlocks[bj]->fSize); | |
3771 | if (not inblockj.BufferSizeOk()) continue; | |
3772 | ||
3773 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3774 | { | |
3775 | if (inblocki[i].fTrackId == inblockj[j].fId) | |
3776 | { | |
3777 | found = true; | |
3778 | break; | |
3779 | } | |
3780 | } | |
3781 | } | |
3782 | ||
3783 | if (not found) | |
3784 | { | |
3785 | HLTError("Problem found with single track trigger decision" | |
3786 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3787 | " fSize = %u bytes." | |
3788 | " Problem with decision %d in block: The track" | |
3789 | " identifier %d does not exist in any Manso tracks" | |
3790 | " data block.", | |
3791 | bi, | |
3792 | DataType2Text(singleDecisionBlocks[bi]->fDataType).c_str(), | |
3793 | singleDecisionBlocks[bi]->fPtr, | |
3794 | singleDecisionBlocks[bi]->fSize, | |
3795 | i, inblocki[i].fTrackId | |
3796 | ); | |
3797 | MarkBlock(blocks, blockOk, blockCount, singleDecisionBlocks[bi]); | |
3798 | } | |
3799 | } | |
3800 | ||
3801 | // Check if all the trigger decision structures are unique up to the ID and | |
3802 | // have unique Manso track identifiers. | |
3803 | for (AliHLTUInt32_t bj = bi+1; bj < singleDecisionBlocksCount; bj++) | |
3804 | { | |
3805 | AliHLTMUONSinglesDecisionBlockReader inblockj(singleDecisionBlocks[bj]->fPtr, singleDecisionBlocks[bj]->fSize); | |
3806 | if (not inblockj.BufferSizeOk()) continue; | |
3807 | ||
3808 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3809 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3810 | { | |
3811 | if (inblocki[i].fTrackId == inblockj[j].fTrackId) | |
3812 | { | |
3813 | HLTError("Problem found with single track trigger decision" | |
3814 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3815 | " fSize = %u bytes, and single track trigger decision" | |
3816 | " data block %d," | |
3817 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3818 | " Problem: The trigger decision %d in block %d and entry" | |
3819 | " %d in block %d have the same Manso track identifier," | |
3820 | " but they should be unique.", | |
3821 | bi, | |
3822 | DataType2Text(singleDecisionBlocks[bi]->fDataType).c_str(), | |
3823 | singleDecisionBlocks[bi]->fPtr, | |
3824 | singleDecisionBlocks[bi]->fSize, | |
3825 | bj, | |
3826 | DataType2Text(singleDecisionBlocks[bj]->fDataType).c_str(), | |
3827 | singleDecisionBlocks[bj]->fPtr, | |
3828 | singleDecisionBlocks[bj]->fSize, | |
3829 | bi, i, | |
3830 | bj, j | |
3831 | ); | |
3832 | MarkBlock(blocks, blockOk, blockCount, singleDecisionBlocks[bi]); | |
3833 | MarkBlock(blocks, blockOk, blockCount, singleDecisionBlocks[bj]); | |
3834 | } | |
3835 | ||
3836 | AliHLTMUONTrackDecisionStruct a = inblocki[i]; | |
3837 | AliHLTMUONTrackDecisionStruct b = inblockj[j]; | |
3838 | a.fTrackId = b.fTrackId = -1; | |
3839 | if (a == b) | |
3840 | { | |
3841 | HLTError("Problem found with single track trigger decision" | |
3842 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3843 | " fSize = %u bytes, and single track trigger decision" | |
3844 | " data block %d," | |
3845 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3846 | " Problem: The trigger decision %d in block %d and entry" | |
3847 | " %d in block %d have the same data." | |
3848 | " The data may have been duplicated.", | |
3849 | bi, | |
3850 | DataType2Text(singleDecisionBlocks[bi]->fDataType).c_str(), | |
3851 | singleDecisionBlocks[bi]->fPtr, | |
3852 | singleDecisionBlocks[bi]->fSize, | |
3853 | bj, | |
3854 | DataType2Text(singleDecisionBlocks[bj]->fDataType).c_str(), | |
3855 | singleDecisionBlocks[bj]->fPtr, | |
3856 | singleDecisionBlocks[bj]->fSize, | |
3857 | bi, i, | |
3858 | bj, j | |
3859 | ); | |
3860 | MarkBlock(blocks, blockOk, blockCount, singleDecisionBlocks[bi]); | |
3861 | MarkBlock(blocks, blockOk, blockCount, singleDecisionBlocks[bj]); | |
3862 | } | |
3863 | } | |
3864 | } | |
3865 | } | |
3866 | ||
3867 | for (AliHLTUInt32_t bi = 0; bi < pairDecisionBlocksCount; bi++) | |
3868 | { | |
3869 | AliHLTMUONPairsDecisionBlockReader inblocki(pairDecisionBlocks[bi]->fPtr, pairDecisionBlocks[bi]->fSize); | |
3870 | if (not inblocki.BufferSizeOk()) continue; | |
3871 | ||
3872 | AliHLTUInt32_t maxPairs = totalTrackCount * (totalTrackCount-1) / 2; | |
3873 | const AliHLTMUONPairsDecisionBlockStruct& hdr = inblocki.BlockHeader(); | |
3874 | const AliHLTComponentBlockData* block = pairDecisionBlocks[bi]; | |
3875 | if (IsScalarTooLarge(block, bi, "track pair", "fNunlikeAnyPt", hdr.fNunlikeAnyPt, maxPairs) or | |
3876 | IsScalarTooLarge(block, bi, "track pair", "fNunlikeLowPt", hdr.fNunlikeLowPt, maxPairs) or | |
3877 | IsScalarTooLarge(block, bi, "track pair", "fNunlikeHighPt", hdr.fNunlikeHighPt, maxPairs) or | |
3878 | IsScalarTooLarge(block, bi, "track pair", "fNlikeAnyPt", hdr.fNlikeAnyPt, maxPairs) or | |
3879 | IsScalarTooLarge(block, bi, "track pair", "fNlikeLowPt", hdr.fNlikeLowPt, maxPairs) or | |
3880 | IsScalarTooLarge(block, bi, "track pair", "fNlikeHighPt", hdr.fNlikeHighPt, maxPairs) or | |
3881 | IsScalarTooLarge(block, bi, "track pair", "fNmassAny", hdr.fNmassAny, maxPairs) or | |
3882 | IsScalarTooLarge(block, bi, "track pair", "fNmassLow", hdr.fNmassLow, maxPairs) or | |
3883 | IsScalarTooLarge(block, bi, "track pair", "fNmassHigh", hdr.fNmassHigh, maxPairs) or | |
210736fa | 3884 | IsScalarALargerThanB(block, bi, "track pair", "fNunlikeHighPt", hdr.fNunlikeHighPt, "fNunlikeLowPt", hdr.fNunlikeLowPt) or |
3885 | IsScalarALargerThanB(block, bi, "track pair", "fNunlikeLowPt", hdr.fNunlikeLowPt, "fNunlikeAnyPt", hdr.fNunlikeAnyPt) or | |
3886 | IsScalarALargerThanB(block, bi, "track pair", "fNlikeHighPt", hdr.fNlikeHighPt, "fNlikeLowPt", hdr.fNlikeLowPt) or | |
3887 | IsScalarALargerThanB(block, bi, "track pair", "fNlikeLowPt", hdr.fNlikeLowPt, "fNlikeAnyPt", hdr.fNlikeAnyPt) or | |
3888 | IsScalarALargerThanB(block, bi, "track pair", "fNmassHigh", hdr.fNmassHigh, "fNmassLow", hdr.fNmassLow) or | |
3889 | IsScalarALargerThanB(block, bi, "track pair", "fNmassLow", hdr.fNmassLow, "fNmassAny", hdr.fNmassAny) | |
dba14d7d | 3890 | ) |
3891 | { | |
3892 | MarkBlock(blocks, blockOk, blockCount, block); | |
3893 | } | |
3894 | ||
3895 | // Check if all the Manso track IDs in the trigger decision structures exist. | |
3896 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3897 | { | |
3898 | bool found = false; | |
3899 | ||
3900 | for (AliHLTUInt32_t bj = 0; bj < mansoTrackBlocksCount and not found; bj++) | |
3901 | { | |
3902 | AliHLTMUONMansoTracksBlockReader inblockj(mansoTrackBlocks[bj]->fPtr, mansoTrackBlocks[bj]->fSize); | |
3903 | if (not inblockj.BufferSizeOk()) continue; | |
3904 | ||
3905 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3906 | { | |
3907 | if (inblocki[i].fTrackAId == inblockj[j].fId) | |
3908 | { | |
3909 | found = true; | |
3910 | break; | |
3911 | } | |
3912 | } | |
3913 | } | |
3914 | ||
3915 | if (not found) | |
3916 | { | |
3917 | HLTError("Problem found with track pair trigger decision" | |
3918 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3919 | " fSize = %u bytes." | |
3920 | " Problem with decision %d in block: The track" | |
3921 | " identifier %d does not exist in any Manso tracks" | |
3922 | " data block.", | |
3923 | bi, | |
3924 | DataType2Text(pairDecisionBlocks[bi]->fDataType).c_str(), | |
3925 | pairDecisionBlocks[bi]->fPtr, | |
3926 | pairDecisionBlocks[bi]->fSize, | |
3927 | i, inblocki[i].fTrackAId | |
3928 | ); | |
3929 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bi]); | |
3930 | } | |
3931 | ||
3932 | found = false; | |
3933 | ||
3934 | for (AliHLTUInt32_t bj = 0; bj < mansoTrackBlocksCount and not found; bj++) | |
3935 | { | |
3936 | AliHLTMUONMansoTracksBlockReader inblockj(mansoTrackBlocks[bj]->fPtr, mansoTrackBlocks[bj]->fSize); | |
3937 | if (not inblockj.BufferSizeOk()) continue; | |
3938 | ||
3939 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3940 | { | |
3941 | if (inblocki[i].fTrackBId == inblockj[j].fId) | |
3942 | { | |
3943 | found = true; | |
3944 | break; | |
3945 | } | |
3946 | } | |
3947 | } | |
3948 | ||
3949 | if (not found) | |
3950 | { | |
3951 | HLTError("Problem found with track pair trigger decision" | |
3952 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3953 | " fSize = %u bytes." | |
3954 | " Problem with decision %d in block: The track" | |
3955 | " identifier %d does not exist in any Manso tracks" | |
3956 | " data block.", | |
3957 | bi, | |
3958 | DataType2Text(pairDecisionBlocks[bi]->fDataType).c_str(), | |
3959 | pairDecisionBlocks[bi]->fPtr, | |
3960 | pairDecisionBlocks[bi]->fSize, | |
3961 | i, inblocki[i].fTrackBId | |
3962 | ); | |
3963 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bi]); | |
3964 | } | |
3965 | } | |
3966 | ||
3967 | // Check if all the trigger decision structures are unique up to the ID and | |
3968 | // have unique Manso track identifier pairs. | |
3969 | for (AliHLTUInt32_t bj = bi+1; bj < pairDecisionBlocksCount; bj++) | |
3970 | { | |
3971 | AliHLTMUONPairsDecisionBlockReader inblockj(pairDecisionBlocks[bj]->fPtr, pairDecisionBlocks[bj]->fSize); | |
3972 | if (not inblockj.BufferSizeOk()) continue; | |
3973 | ||
3974 | for (AliHLTUInt32_t i = 0; i < inblocki.Nentries(); i++) | |
3975 | for (AliHLTUInt32_t j = 0; j < inblockj.Nentries(); j++) | |
3976 | { | |
3977 | if (inblocki[i].fTrackAId == inblockj[j].fTrackAId and | |
3978 | inblocki[i].fTrackBId == inblockj[j].fTrackBId | |
3979 | ) | |
3980 | { | |
3981 | HLTError("Problem found with track pair trigger decision" | |
3982 | " data block %d, fDataType = '%s', fPtr = %p and" | |
3983 | " fSize = %u bytes, and track pair trigger decision" | |
3984 | " data block %d," | |
3985 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
3986 | " Problem: The trigger decision %d in block %d and entry" | |
3987 | " %d in block %d have the same Manso track identifier pair," | |
3988 | " but the pair should be unique.", | |
3989 | bi, | |
3990 | DataType2Text(pairDecisionBlocks[bi]->fDataType).c_str(), | |
3991 | pairDecisionBlocks[bi]->fPtr, | |
3992 | pairDecisionBlocks[bi]->fSize, | |
3993 | bj, | |
3994 | DataType2Text(pairDecisionBlocks[bj]->fDataType).c_str(), | |
3995 | pairDecisionBlocks[bj]->fPtr, | |
3996 | pairDecisionBlocks[bj]->fSize, | |
3997 | bi, i, | |
3998 | bj, j | |
3999 | ); | |
4000 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bi]); | |
4001 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bj]); | |
4002 | } | |
4003 | ||
4004 | AliHLTMUONPairDecisionStruct a = inblocki[i]; | |
4005 | AliHLTMUONPairDecisionStruct b = inblockj[j]; | |
4006 | a.fTrackAId = a.fTrackBId = b.fTrackAId = b.fTrackBId = -1; | |
4007 | if (a == b) | |
4008 | { | |
4009 | HLTError("Problem found with track pair trigger decision" | |
4010 | " data block %d, fDataType = '%s', fPtr = %p and" | |
4011 | " fSize = %u bytes, and track pair trigger decision" | |
4012 | " data block %d," | |
4013 | " fDataType = '%s', fPtr = %p and fSize = %u bytes." | |
4014 | " Problem: The trigger decision %d in block %d and entry" | |
4015 | " %d in block %d have the same data." | |
4016 | " The data may have been duplicated.", | |
4017 | bi, | |
4018 | DataType2Text(pairDecisionBlocks[bi]->fDataType).c_str(), | |
4019 | pairDecisionBlocks[bi]->fPtr, | |
4020 | pairDecisionBlocks[bi]->fSize, | |
4021 | bj, | |
4022 | DataType2Text(pairDecisionBlocks[bj]->fDataType).c_str(), | |
4023 | pairDecisionBlocks[bj]->fPtr, | |
4024 | pairDecisionBlocks[bj]->fSize, | |
4025 | bi, i, | |
4026 | bj, j | |
4027 | ); | |
4028 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bi]); | |
4029 | MarkBlock(blocks, blockOk, blockCount, pairDecisionBlocks[bj]); | |
4030 | } | |
4031 | } | |
4032 | } | |
4033 | } | |
4034 | } | |
4035 |