]>
Commit | Line | Data |
---|---|---|
b92524d0 | 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 | * Indranil Das <indra.das@saha.ac.in> * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /* $Id$ */ | |
19 | ||
6253e09b | 20 | /// |
21 | /// @file AliHLTMUONMansoTrackerFSMComponent.cxx | |
22 | /// @author Artur Szostak <artursz@iafrica.com>, | |
23 | /// Indranil Das <indra.das@saha.ac.in> | |
24 | /// @date | |
25 | /// @brief Implementation of AliHLTMUONMansoTrackerFSMComponent class. | |
26 | /// | |
b92524d0 | 27 | |
28 | #include "AliHLTMUONMansoTrackerFSMComponent.h" | |
29 | #include "AliHLTMUONConstants.h" | |
30 | #include "AliHLTMUONUtils.h" | |
31 | #include "AliHLTMUONMansoTrackerFSM.h" | |
32 | #include "AliHLTMUONDataBlockReader.h" | |
33 | #include "AliHLTMUONDataBlockWriter.h" | |
34 | #include <cstdlib> | |
d42549e3 | 35 | #include <cstring> |
b92524d0 | 36 | #include <cerrno> |
5bf92d6f | 37 | #include <new> |
b92524d0 | 38 | |
b92524d0 | 39 | ClassImp(AliHLTMUONMansoTrackerFSMComponent); |
40 | ||
41 | ||
42 | AliHLTMUONMansoTrackerFSMComponent::AliHLTMUONMansoTrackerFSMComponent() : | |
43 | AliHLTProcessor(), | |
44 | AliHLTMUONMansoTrackerFSMCallback(), | |
45 | fTracker(NULL), | |
46 | fTrackCount(0), | |
d42549e3 | 47 | fBlock(NULL), |
5bf92d6f | 48 | fRecHitBlockArraySize(0), |
d42549e3 | 49 | fWarnForUnexpecedBlock(false) |
b92524d0 | 50 | { |
6253e09b | 51 | /// |
52 | /// Default constructor. | |
53 | /// | |
5bf92d6f | 54 | |
55 | for (Int_t i = 0; i < 4; i++) | |
56 | { | |
57 | fRecHitBlockCount[i] = 0; | |
58 | fRecHitBlock[i] = NULL; | |
59 | } | |
b92524d0 | 60 | } |
61 | ||
62 | ||
63 | AliHLTMUONMansoTrackerFSMComponent::~AliHLTMUONMansoTrackerFSMComponent() | |
64 | { | |
6253e09b | 65 | /// |
66 | /// Default destructor. | |
67 | /// | |
68 | ||
a6b16447 | 69 | // Should never have the following 2 pointers non-NULL since DoDeinit |
70 | // should have been called before, but handle this case anyway. | |
71 | if (fTracker != NULL) delete fTracker; | |
72 | ||
73 | // Remember that only fRecHitBlock[0] stores the pointer to the allocated | |
74 | // memory. The other pointers are just reletive to this. | |
75 | if (fRecHitBlock[0] != NULL) delete [] fRecHitBlock[0]; | |
b92524d0 | 76 | } |
77 | ||
78 | ||
79 | const char* AliHLTMUONMansoTrackerFSMComponent::GetComponentID() | |
80 | { | |
6253e09b | 81 | /// |
82 | /// Inherited from AliHLTComponent. Returns the component ID. | |
83 | /// | |
84 | ||
b92524d0 | 85 | return AliHLTMUONConstants::MansoTrackerFSMId(); |
86 | } | |
87 | ||
88 | ||
89 | void AliHLTMUONMansoTrackerFSMComponent::GetInputDataTypes( | |
90 | vector<AliHLTComponentDataType>& list | |
91 | ) | |
92 | { | |
6253e09b | 93 | /// |
94 | /// Inherited from AliHLTProcessor. Returns the list of expected input data types. | |
95 | /// | |
96 | ||
b92524d0 | 97 | assert( list.empty() ); |
98 | list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() ); | |
99 | list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() ); | |
100 | } | |
101 | ||
102 | ||
103 | AliHLTComponentDataType AliHLTMUONMansoTrackerFSMComponent::GetOutputDataType() | |
104 | { | |
6253e09b | 105 | /// |
106 | /// Inherited from AliHLTComponent. Returns the output data type. | |
107 | /// | |
108 | ||
b92524d0 | 109 | return AliHLTMUONConstants::MansoTracksBlockDataType(); |
110 | } | |
111 | ||
112 | ||
113 | void AliHLTMUONMansoTrackerFSMComponent::GetOutputDataSize( | |
114 | unsigned long& constBase, double& inputMultiplier | |
115 | ) | |
116 | { | |
6253e09b | 117 | /// |
118 | /// Inherited from AliHLTComponent. Returns an estimate of the expected output data size. | |
119 | /// | |
120 | ||
b92524d0 | 121 | constBase = sizeof(AliHLTMUONMansoTracksBlockStruct); |
122 | inputMultiplier = 1; | |
123 | } | |
124 | ||
125 | ||
126 | AliHLTComponent* AliHLTMUONMansoTrackerFSMComponent::Spawn() | |
127 | { | |
6253e09b | 128 | /// |
129 | /// Inherited from AliHLTComponent. Creates a new object instance. | |
130 | /// | |
131 | ||
b92524d0 | 132 | return new AliHLTMUONMansoTrackerFSMComponent; |
133 | } | |
134 | ||
135 | ||
136 | int AliHLTMUONMansoTrackerFSMComponent::DoInit(int argc, const char** argv) | |
137 | { | |
6253e09b | 138 | /// |
139 | /// Inherited from AliHLTComponent. | |
140 | /// Parses the command line parameters and initialises the component. | |
141 | /// | |
142 | ||
6ec6a7c1 | 143 | HLTInfo("Initialising dHLT manso tracker FSM component."); |
144 | ||
a6b16447 | 145 | // Just in case for whatever reason we still have some of the internal |
146 | // object allocated previously still hanging around delete them now. | |
147 | FreeMemory(); | |
148 | ||
5bf92d6f | 149 | try |
150 | { | |
151 | fTracker = new AliHLTMUONMansoTrackerFSM(); | |
152 | } | |
153 | catch (const std::bad_alloc&) | |
154 | { | |
155 | HLTError("Could not allocate more memory for the tracker component."); | |
156 | return -ENOMEM; | |
157 | } | |
b92524d0 | 158 | fTracker->SetCallback(this); |
d42549e3 | 159 | |
160 | fWarnForUnexpecedBlock = false; | |
161 | ||
162 | for (int i = 0; i < argc; i++) | |
163 | { | |
164 | if (strcmp(argv[i], "-warn_on_unexpected_block") == 0) | |
47415aa9 | 165 | { |
d42549e3 | 166 | fWarnForUnexpecedBlock = true; |
47415aa9 | 167 | continue; |
168 | } | |
169 | ||
170 | HLTError("Unknown option '%s'.", argv[i]); | |
a6b16447 | 171 | FreeMemory(); // Make sure we cleanup to avoid partial initialisation. |
172 | return -EINVAL; | |
d42549e3 | 173 | } |
174 | ||
5bf92d6f | 175 | const int initArraySize = 10; |
a6b16447 | 176 | // Allocate some initial memory for the reconstructed hit arrays. |
5bf92d6f | 177 | try |
178 | { | |
179 | fRecHitBlock[0] = new AliRecHitBlockInfo[initArraySize*4]; | |
180 | } | |
181 | catch (const std::bad_alloc&) | |
182 | { | |
183 | HLTError("Could not allocate more memory for the reconstructed hit arrays."); | |
a6b16447 | 184 | FreeMemory(); // Make sure we cleanup to avoid partial initialisation. |
5bf92d6f | 185 | return -ENOMEM; |
186 | } | |
187 | // Only set the arrays' size once we have successfully allocated the memory for the arrays. | |
188 | fRecHitBlockArraySize = initArraySize; | |
189 | // Now we need to set the pointers fRecHitBlock[i] {i>0} relative to fRecHitBlock[0]. | |
190 | for (Int_t i = 1; i < 4; i++) | |
191 | { | |
192 | fRecHitBlock[i] = fRecHitBlock[i-1] + fRecHitBlockArraySize; | |
193 | } | |
194 | // And reset the number of records actually stored in the arrays. | |
195 | for (Int_t i = 0; i < 4; i++) | |
196 | { | |
197 | fRecHitBlockCount[i] = 0; | |
198 | } | |
199 | ||
b92524d0 | 200 | return 0; |
201 | } | |
202 | ||
203 | ||
204 | int AliHLTMUONMansoTrackerFSMComponent::DoDeinit() | |
205 | { | |
6253e09b | 206 | /// |
207 | /// Inherited from AliHLTComponent. Performs a cleanup of the component. | |
208 | /// | |
209 | ||
6ec6a7c1 | 210 | HLTInfo("Deinitialising dHLT manso tracker FSM component."); |
a6b16447 | 211 | FreeMemory(); |
b92524d0 | 212 | return 0; |
213 | } | |
214 | ||
215 | ||
216 | int AliHLTMUONMansoTrackerFSMComponent::DoEvent( | |
217 | const AliHLTComponentEventData& evtData, | |
5def1693 | 218 | const AliHLTComponentBlockData* blocks, |
219 | AliHLTComponentTriggerData& /*trigData*/, | |
220 | AliHLTUInt8_t* outputPtr, | |
b92524d0 | 221 | AliHLTUInt32_t& size, |
222 | std::vector<AliHLTComponentBlockData>& outputBlocks | |
223 | ) | |
224 | { | |
6253e09b | 225 | /// |
226 | /// Inherited from AliHLTProcessor. Processes the new event data. | |
227 | /// | |
228 | ||
b92524d0 | 229 | Reset(); |
230 | AliHLTUInt32_t specification = 0; // Contains the output data block spec bits. | |
231 | ||
a6b16447 | 232 | // Resize the rec hit arrays if we possibly will need more space. |
233 | // To guarantee that they will not overflow we need to make sure each | |
234 | // array is at least as big as the number of input data blocks. | |
5bf92d6f | 235 | if (fRecHitBlockArraySize < evtData.fBlockCnt) |
236 | { | |
237 | // Release the old memory block and allocate more memory. | |
a6b16447 | 238 | if (fRecHitBlock[0] != NULL) |
239 | { | |
240 | delete [] fRecHitBlock[0]; | |
241 | } | |
242 | ||
5bf92d6f | 243 | // Reset the number of records actually stored in the arrays. |
244 | for (Int_t i = 0; i < 4; i++) | |
245 | { | |
246 | fRecHitBlockCount[i] = 0; | |
247 | } | |
248 | ||
249 | try | |
250 | { | |
251 | fRecHitBlock[0] = new AliRecHitBlockInfo[evtData.fBlockCnt*4]; | |
252 | } | |
253 | catch (const std::bad_alloc&) | |
254 | { | |
255 | HLTError("Could not allocate more memory for the reconstructed hit arrays."); | |
256 | // Ok so now we need to clear all the pointers because we actually | |
257 | // deleted the memory. | |
258 | fRecHitBlockArraySize = 0; | |
259 | for (Int_t i = 0; i < 4; i++) | |
260 | { | |
261 | fRecHitBlock[i] = NULL; | |
262 | } | |
263 | return -ENOMEM; | |
264 | } | |
265 | // Only set the arrays' size once we have successfully allocated the memory for the arrays. | |
266 | fRecHitBlockArraySize = evtData.fBlockCnt; | |
267 | // Now we need to set the pointers fRecHitBlock[i] {i>0} relative to fRecHitBlock[0]. | |
268 | for (Int_t i = 1; i < 4; i++) | |
269 | { | |
270 | fRecHitBlock[i] = fRecHitBlock[i-1] + fRecHitBlockArraySize; | |
271 | } | |
272 | } | |
273 | ||
b92524d0 | 274 | AliHLTMUONMansoTracksBlockWriter block(outputPtr, size); |
275 | fBlock = █ | |
276 | ||
277 | if (not block.InitCommonHeader()) | |
278 | { | |
279 | Logging(kHLTLogError, | |
280 | "AliHLTMUONMansoTrackerFSMComponent::DoEvent", | |
281 | "Buffer overflow", | |
282 | "The buffer is only %d bytes in size. We need a minimum of %d bytes.", | |
283 | size, sizeof(AliHLTMUONMansoTracksBlockWriter::HeaderType) | |
284 | ); | |
285 | size = 0; // Important to tell framework that nothing was generated. | |
5bf92d6f | 286 | return -ENOBUFS; |
b92524d0 | 287 | } |
288 | ||
289 | // Loop over all input blocks in the event and add the ones that contain | |
290 | // reconstructed hits into the hit buffers. The blocks containing trigger | |
291 | // records are ignored for now and will be processed later. | |
292 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
293 | { | |
294 | if (blocks[n].fDataType == AliHLTMUONConstants::RecHitsBlockDataType()) | |
295 | { | |
296 | specification |= blocks[n].fSpecification; | |
297 | ||
298 | AliHLTMUONRecHitsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
299 | if (not inblock.BufferSizeOk()) | |
300 | { | |
d42549e3 | 301 | size_t headerSize = sizeof(AliHLTMUONRecHitsBlockReader::HeaderType); |
302 | if (blocks[n].fSize < headerSize) | |
303 | { | |
304 | HLTError("Received a reconstructed hits data block with a size of %d bytes," | |
305 | " which is smaller than the minimum valid header size of %d bytes." | |
306 | " The block must be corrupt.", | |
307 | blocks[n].fSize, headerSize | |
308 | ); | |
309 | continue; | |
310 | } | |
311 | ||
312 | size_t expectedWidth = sizeof(AliHLTMUONRecHitsBlockReader::ElementType); | |
313 | if (inblock.CommonBlockHeader().fRecordWidth != expectedWidth) | |
314 | { | |
315 | HLTError("Received a reconstructed hits data block with a record" | |
316 | " width of %d bytes, but the expected value is %d bytes." | |
317 | " The block might be corrupt.", | |
47415aa9 | 318 | inblock.CommonBlockHeader().fRecordWidth, expectedWidth |
d42549e3 | 319 | ); |
320 | continue; | |
321 | } | |
322 | ||
323 | HLTError("Received a reconstructed hits data block with a size of %d bytes," | |
324 | " but the block header claims the block should be %d bytes." | |
325 | " The block might be corrupt.", | |
326 | blocks[n].fSize, inblock.BytesUsed() | |
b92524d0 | 327 | ); |
328 | continue; | |
329 | } | |
330 | ||
4a9f11d4 | 331 | if (inblock.Nentries() != 0) |
332 | AddRecHits(blocks[n].fSpecification, inblock.GetArray(), inblock.Nentries()); | |
333 | else | |
334 | { | |
d42549e3 | 335 | Logging(kHLTLogDebug, |
4a9f11d4 | 336 | "AliHLTMUONMansoTrackerFSMComponent::DoEvent", |
337 | "Block empty", | |
338 | "Received a reconstructed hits data block which contains no entries." | |
339 | ); | |
340 | } | |
b92524d0 | 341 | } |
342 | else if (blocks[n].fDataType != AliHLTMUONConstants::TriggerRecordsBlockDataType()) | |
343 | { | |
344 | // Log a message indicating that we got a data block that we | |
345 | // do not know how to handle. | |
346 | char id[kAliHLTComponentDataTypefIDsize+1]; | |
347 | for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) | |
348 | id[i] = blocks[n].fDataType.fID[i]; | |
349 | id[kAliHLTComponentDataTypefIDsize] = '\0'; | |
350 | char origin[kAliHLTComponentDataTypefOriginSize+1]; | |
351 | for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) | |
352 | origin[i] = blocks[n].fDataType.fOrigin[i]; | |
353 | origin[kAliHLTComponentDataTypefOriginSize] = '\0'; | |
354 | ||
d42549e3 | 355 | if (fWarnForUnexpecedBlock) |
356 | HLTWarning("Received a data block of a type we cannot handle: %s origin: %s", | |
357 | static_cast<char*>(id), static_cast<char*>(origin) | |
358 | ); | |
359 | else | |
360 | HLTDebug("Received a data block of a type we cannot handle: %s origin: %s", | |
361 | static_cast<char*>(id), static_cast<char*>(origin) | |
362 | ); | |
b92524d0 | 363 | } |
364 | } | |
365 | ||
366 | // Again loop over all input blocks in the event, but this time look for | |
367 | // the trigger record blocks and process these. | |
368 | for (AliHLTUInt32_t n = 0; n < evtData.fBlockCnt; n++) | |
369 | { | |
370 | if (blocks[n].fDataType != AliHLTMUONConstants::TriggerRecordsBlockDataType()) | |
371 | continue; | |
372 | ||
373 | AliHLTMUONTriggerRecordsBlockReader inblock(blocks[n].fPtr, blocks[n].fSize); | |
374 | if (not inblock.BufferSizeOk()) | |
375 | { | |
d42549e3 | 376 | size_t headerSize = sizeof(AliHLTMUONTriggerRecordsBlockReader::HeaderType); |
377 | if (blocks[n].fSize < headerSize) | |
378 | { | |
379 | HLTError("Received a trigger records data block with a size of %d bytes," | |
380 | " which is smaller than the minimum valid header size of %d bytes." | |
381 | " The block must be corrupt.", | |
382 | blocks[n].fSize, headerSize | |
383 | ); | |
384 | continue; | |
385 | } | |
386 | ||
387 | size_t expectedWidth = sizeof(AliHLTMUONTriggerRecordsBlockReader::ElementType); | |
388 | if (inblock.CommonBlockHeader().fRecordWidth != expectedWidth) | |
389 | { | |
390 | HLTError("Received a trigger records data block with a record" | |
391 | " width of %d bytes, but the expected value is %d bytes." | |
392 | " The block might be corrupt.", | |
47415aa9 | 393 | inblock.CommonBlockHeader().fRecordWidth, expectedWidth |
d42549e3 | 394 | ); |
395 | continue; | |
396 | } | |
397 | ||
398 | HLTError("Received a trigger records data block with a size of %d bytes," | |
399 | " but the block header claims the block should be %d bytes." | |
400 | " The block might be corrupt.", | |
401 | blocks[n].fSize, inblock.BytesUsed() | |
b92524d0 | 402 | ); |
403 | continue; | |
404 | } | |
405 | DebugTrace("Processing a trigger block with " | |
406 | << inblock.Nentries() << " entries." | |
407 | ); | |
408 | ||
409 | specification |= blocks[n].fSpecification; | |
410 | ||
411 | for (AliHLTUInt32_t i = 0; i < inblock.Nentries(); i++) | |
412 | { | |
413 | fTracker->FindTrack(inblock[i]); | |
414 | ||
415 | // Reset the tracker so that we do not double count tracks. | |
416 | fTracker->Reset(); | |
417 | } | |
418 | } | |
419 | ||
420 | AliHLTComponentBlockData bd; | |
421 | FillBlockData(bd); | |
422 | bd.fPtr = outputPtr; | |
423 | bd.fOffset = 0; | |
424 | bd.fSize = block.BytesUsed(); | |
425 | bd.fDataType = AliHLTMUONConstants::MansoTracksBlockDataType(); | |
426 | bd.fSpecification = specification; | |
427 | outputBlocks.push_back(bd); | |
428 | size = block.BytesUsed(); | |
429 | ||
430 | return 0; | |
431 | } | |
432 | ||
433 | ||
434 | void AliHLTMUONMansoTrackerFSMComponent::Reset() | |
435 | { | |
6253e09b | 436 | /// |
437 | /// Reset the track count and reconstructed hit data block arrays. | |
438 | /// | |
439 | ||
b92524d0 | 440 | DebugTrace("Resetting AliHLTMUONMansoTrackerFSMComponent."); |
441 | ||
442 | //fTracker->Reset(); // Not necessary here because it is done after every FindTrack call. | |
443 | fTrackCount = 0; | |
444 | fBlock = NULL; // Do not delete. Already done implicitly at the end of DoEvent. | |
445 | for (int i = 0; i < 4; i++) | |
446 | { | |
5bf92d6f | 447 | fRecHitBlockCount[i] = 0; |
b92524d0 | 448 | } |
449 | } | |
450 | ||
451 | ||
a6b16447 | 452 | void AliHLTMUONMansoTrackerFSMComponent::FreeMemory() |
453 | { | |
454 | /// Deletes any objects and arrays allocated by this component and releases | |
455 | /// the memory used. This is called as a helper routine by the init and deinit | |
456 | /// methods. If some or all of the object pointers are already NULL then | |
457 | /// nothing is done for those. This method guarantees that all the relevant | |
458 | /// pointers will be NULL after returning from this method. | |
459 | ||
460 | if (fTracker != NULL) | |
461 | { | |
462 | delete fTracker; | |
463 | fTracker = NULL; | |
464 | } | |
465 | ||
466 | // Remember that only fRecHitBlock[0] stores the pointer to the allocated memory. | |
467 | // The other pointers are just reletive to this. | |
468 | if (fRecHitBlock[0] != NULL) | |
469 | delete [] fRecHitBlock[0]; | |
470 | ||
471 | fRecHitBlockArraySize = 0; | |
472 | for (Int_t i = 0; i < 4; i++) | |
473 | { | |
474 | fRecHitBlockCount[i] = 0; | |
475 | fRecHitBlock[i] = NULL; | |
476 | } | |
477 | } | |
478 | ||
479 | ||
b92524d0 | 480 | void AliHLTMUONMansoTrackerFSMComponent::AddRecHits( |
6253e09b | 481 | AliHLTUInt32_t specification, |
b92524d0 | 482 | const AliHLTMUONRecHitStruct* recHits, |
483 | AliHLTUInt32_t count | |
484 | ) | |
485 | { | |
6253e09b | 486 | /// |
487 | /// Adds a new reconstructed hit data block to the internal list of blocks | |
488 | /// for the tracker to process. | |
489 | /// These lists will later be used when the tracker requests them through | |
490 | /// the callback method 'RequestClusters'. | |
491 | /// | |
492 | ||
b92524d0 | 493 | DebugTrace("AliHLTMUONMansoTrackerFSMComponent::AddRecHits called with specification = 0x" |
494 | << std::hex << specification << std::dec << " and count = " | |
495 | << count << " rec hits." | |
496 | ); | |
497 | ||
498 | AliHLTUInt8_t chamberMap[20] = { | |
499 | 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10 | |
500 | }; | |
501 | ||
502 | // Identify the chamber the rec hits came from using the specifications field. | |
503 | bool gotDataFromDDL[22]; | |
504 | AliHLTMUONUtils::UnpackSpecBits(specification, gotDataFromDDL); | |
505 | ||
506 | AliHLTInt8_t chamber = -1; | |
507 | for (int i = 0; i < 20; i++) | |
508 | { | |
509 | if (not gotDataFromDDL[i]) continue; | |
510 | if (7 <= chamberMap[i] and chamberMap[i] <= 10) | |
511 | { | |
512 | if (chamber != -1 and chamber != chamberMap[i]) | |
513 | { | |
514 | Logging(kHLTLogError, | |
515 | "AliHLTMUONMansoTrackerFSMComponent::AddRecHits", | |
516 | "Invalid block", | |
517 | "Received a data block with data from multiple chambers." | |
518 | " This component cannot handle such a case." | |
519 | ); | |
520 | return; | |
521 | } | |
522 | else | |
523 | chamber = chamberMap[i]; | |
524 | } | |
525 | else | |
526 | { | |
527 | Logging(kHLTLogError, | |
528 | "AliHLTMUONMansoTrackerFSMComponent::AddRecHits", | |
529 | "Invalid chamber", | |
530 | "Received a data block with data from chamber %d" | |
531 | " which is outside the expected range: [7..10].", | |
532 | chamberMap[i] | |
533 | ); | |
534 | return; | |
535 | } | |
536 | } | |
537 | ||
538 | // Make sure we got one chamber number. | |
539 | if (chamber < 7 or 10 < chamber) | |
540 | { | |
541 | Logging(kHLTLogError, | |
542 | "AliHLTMUONMansoTrackerFSMComponent::AddRecHits", | |
543 | "Invalid block", | |
544 | "Received a reconstructed hit data block with a null specification." | |
545 | " Cannot know which chamber the data comes from." | |
546 | ); | |
547 | return; | |
548 | } | |
549 | ||
550 | DebugTrace("Added " << count << " reconstructed hits from chamber " | |
d42549e3 | 551 | << (int)chamber << " to the internal arrays." |
552 | ); | |
b92524d0 | 553 | |
5bf92d6f | 554 | assert( fRecHitBlockCount[chamber-7] < fRecHitBlockArraySize ); |
555 | AliRecHitBlockInfo info(count, recHits); | |
556 | fRecHitBlock[chamber-7][fRecHitBlockCount[chamber-7]] = info; | |
557 | fRecHitBlockCount[chamber-7]++; | |
b92524d0 | 558 | } |
559 | ||
560 | ||
561 | void AliHLTMUONMansoTrackerFSMComponent::RequestClusters( | |
562 | AliHLTMUONMansoTrackerFSM* tracker, | |
f1169efa | 563 | AliHLTFloat32_t left, AliHLTFloat32_t right, |
564 | AliHLTFloat32_t bottom, AliHLTFloat32_t top, | |
b92524d0 | 565 | AliHLTMUONChamberName chamber, const void* tag |
566 | ) | |
567 | { | |
6253e09b | 568 | /// |
569 | /// Inherited from AliHLTMUONMansoTrackerFSMCallback. | |
570 | /// This is the call back method used by the tracker algorithm to request | |
571 | /// clusters on a certain chamber. | |
572 | /// | |
573 | ||
b92524d0 | 574 | DebugTrace("AliHLTMUONMansoTracker::RequestClusters(chamber = " << chamber << ")"); |
575 | void* ctag = const_cast<void*>(tag); | |
576 | int chNo = -1; | |
5bf92d6f | 577 | AliHLTUInt32_t recHitsCount = 0; |
578 | AliRecHitBlockInfo* recHitsBlock = NULL; | |
b92524d0 | 579 | switch (chamber) |
580 | { | |
581 | case kChamber7: | |
5bf92d6f | 582 | recHitsCount = fRecHitBlockCount[0]; |
583 | recHitsBlock = fRecHitBlock[0]; | |
b92524d0 | 584 | chNo = 7; |
585 | break; | |
586 | ||
587 | case kChamber8: | |
5bf92d6f | 588 | recHitsCount = fRecHitBlockCount[1]; |
589 | recHitsBlock = fRecHitBlock[1]; | |
b92524d0 | 590 | chNo = 8; |
591 | break; | |
592 | ||
593 | case kChamber9: | |
5bf92d6f | 594 | recHitsCount = fRecHitBlockCount[2]; |
595 | recHitsBlock = fRecHitBlock[2]; | |
b92524d0 | 596 | chNo = 9; |
597 | break; | |
598 | ||
599 | case kChamber10: | |
5bf92d6f | 600 | recHitsCount = fRecHitBlockCount[3]; |
601 | recHitsBlock = fRecHitBlock[3]; | |
b92524d0 | 602 | chNo = 10; |
603 | break; | |
604 | ||
605 | default: return; | |
606 | } | |
607 | ||
608 | DebugTrace("Returning requested hits for chamber " << chNo << ":"); | |
5bf92d6f | 609 | for (AliHLTUInt32_t i = 0; i < recHitsCount; i++) |
610 | for (AliHLTUInt32_t j = 0; j < recHitsBlock[i].Count(); j++) | |
b92524d0 | 611 | { |
5bf92d6f | 612 | const AliHLTMUONRecHitStruct* hit = &(recHitsBlock[i].Data()[j]); |
f1169efa | 613 | if (left < hit->fX and hit->fX < right and bottom < hit->fY and hit->fY < top) |
614 | tracker->ReturnClusters(ctag, hit, 1); | |
b92524d0 | 615 | } |
616 | DebugTrace("Done returning hits from chamber " << chNo << "."); | |
617 | tracker->EndOfClusters(ctag); | |
618 | } | |
619 | ||
620 | ||
621 | void AliHLTMUONMansoTrackerFSMComponent::EndOfClusterRequests( | |
5def1693 | 622 | AliHLTMUONMansoTrackerFSM* /*tracker*/ |
b92524d0 | 623 | ) |
624 | { | |
6253e09b | 625 | /// |
626 | /// Inherited from AliHLTMUONMansoTrackerFSMCallback. | |
627 | /// Nothing special to do here. | |
628 | /// | |
629 | ||
b92524d0 | 630 | DebugTrace("End of cluster requests."); |
631 | } | |
632 | ||
633 | ||
634 | void AliHLTMUONMansoTrackerFSMComponent::FoundTrack(AliHLTMUONMansoTrackerFSM* tracker) | |
635 | { | |
6253e09b | 636 | /// |
637 | /// Inherited from AliHLTMUONMansoTrackerFSMCallback. | |
638 | /// This is the call back method used by the tracker algorithm to declare | |
639 | /// that a new track has been found. | |
640 | /// | |
641 | ||
b92524d0 | 642 | DebugTrace("AliHLTMUONMansoTrackerFSMComponent::FoundTrack()"); |
643 | ||
644 | AliHLTMUONMansoTracksBlockWriter* block = | |
645 | reinterpret_cast<AliHLTMUONMansoTracksBlockWriter*>(fBlock); | |
646 | ||
647 | AliHLTMUONMansoTrackStruct* track = block->AddEntry(); | |
648 | if (track == NULL) | |
649 | { | |
650 | Logging(kHLTLogError, | |
651 | "AliHLTMUONMansoTrackerFSMComponent::FoundTrack", | |
652 | "Buffer overflow", | |
653 | "We have overflowed the output buffer for Manso track data." | |
654 | " The output buffer size is only %d bytes.", | |
655 | block->BufferSize() | |
656 | ); | |
657 | return; | |
658 | } | |
659 | ||
660 | fTrackCount++; | |
661 | tracker->FillTrackData(*track); | |
662 | DebugTrace("\tTrack data = " << *track); | |
663 | } | |
664 | ||
665 | ||
5def1693 | 666 | void AliHLTMUONMansoTrackerFSMComponent::NoTrackFound(AliHLTMUONMansoTrackerFSM* /*tracker*/) |
b92524d0 | 667 | { |
6253e09b | 668 | /// |
669 | /// Inherited from AliHLTMUONMansoTrackerFSMCallback. | |
670 | /// Nothing special to do here. | |
671 | /// | |
672 | ||
b92524d0 | 673 | DebugTrace("No track found."); |
674 | } | |
6253e09b | 675 |