]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/utils/dHLTdumpraw.cxx
Bug fix; not handling the return statement properly.
[u/mrichter/AliRoot.git] / HLT / MUON / utils / dHLTdumpraw.cxx
CommitLineData
3dad52b0 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
1d8ae082 16// $Id$
3dad52b0 17
18/**
19 * @file dHLTdumpraw.cxx
20 * @author Artur Szostak <artursz@iafrica.com>,
21 * Seforo Mohlalisi <seforomohlalisi@yahoo.co.uk>
887a669c 22 * @date 1 July 2007
3dad52b0 23 * @brief Command line utility to dump dHLT's internal raw data blocks.
24 */
25
26// We define NDEBUG for the AliHLTMUONDataBlockReader.h header file since this
27// program by definition handles corrupt data. So we do not need the assertions
28// in the AliHLTMUONDataBlockReader class to be checked.
9c234d7b 29#ifndef NDEBUG
3dad52b0 30#define NDEBUG
9c234d7b 31#endif
3dad52b0 32#include "AliHLTMUONDataBlockReader.h"
9c234d7b 33#if defined(DEBUG) && defined(NDEBUG)
3dad52b0 34#undef NDEBUG
9c234d7b 35#endif
36
3dad52b0 37#include "AliHLTMUONUtils.h"
887a669c 38#include "AliHLTMUONConstants.h"
39#include "Rtypes.h"
40#include "AliRawDataHeader.h"
41#include "AliMUONTrackerDDLDecoder.h"
42#include "AliMUONTriggerDDLDecoder.h"
43#include "AliHLTSystem.h"
44#include "AliHLTConfiguration.h"
45#include "AliLog.h"
46#include "TClassTable.h"
47#include "TString.h"
48#include "TRegexp.h"
3dad52b0 49
b09247a2 50#include <cstring>
fdee2dad 51#include <cstdlib>
887a669c 52#include <cstdio>
3dad52b0 53#include <cassert>
54#include <new>
55#include <fstream>
56
57#include <iostream>
58using std::cout;
59using std::cerr;
60using std::endl;
61using std::showbase;
62using std::noshowbase;
63using std::hex;
64using std::dec;
65
66#include <iomanip>
67using std::setw;
68using std::left;
887a669c 69using std::right;
3dad52b0 70using std::internal;
71
72
73#define CMDLINE_ERROR 1
74#define PARSE_ERROR 2
75#define SYSTEM_ERROR 3
76#define FATAL_ERROR 4
887a669c 77#define HLTSYSTEM_ERROR 5
78
79
80// Adding enum types for extending AliHLTMUONDataBlockType with the
81// raw DDL data types.
82enum AliHLTMUONDDLRawDataType
83{
84 kTrackerDDLRawData = 10,
85 kTriggerDDLRawData = 11
86};
3dad52b0 87
88
89void PrintRubbishData(AliHLTUInt32_t offset, const char* padByte, AliHLTUInt32_t padCount)
90{
91 if (padCount == 0) return;
92
93 cerr << "ERROR: Found the following unexpected rubbish data at the"
94 " end of the data block:" << endl;
95 cerr << "Byte #\tValue\tCharacter" << endl;
96 for (AliHLTUInt32_t i = 0; i < padCount; i++)
97 {
98 short value = short(padByte[i]) & 0xFF;
99 char character = padByte[i];
100 cerr << offset + i + 1 << "\t"
101 << noshowbase << hex << "0x" << value << dec << "\t"
102 << character << endl;
103 }
104}
105
106
a090ff22 107void PrintBitPattern(AliHLTUInt32_t value, int bitcount = 32)
108{
109 // Prints a bit pattern to cout.
110
111 for (int i = bitcount-1; i >= 0; i--)
112 {
113 if ( ((value >> i) & 0x1) == 1 )
114 cout << "1";
115 else
116 cout << "0";
117 }
118}
119
120
3dad52b0 121template <typename FieldType>
122int CheckHeaderField(
123 FieldType& field, const char* buffer, unsigned long bufferSize,
124 bool continueParse
125 )
126{
127 const char* fieldptr = reinterpret_cast<const char*>(&field);
128 const char* endptr = buffer + bufferSize;
129 AliHLTUInt32_t bufferRemaining = endptr > fieldptr ? endptr - fieldptr : 0;
130
131 if (bufferRemaining < sizeof(field))
132 {
133 cout << "..." << endl; // We may be half way through printing a line so end it.
134 cerr << "ERROR: The data block is too short. The header is corrupt." << endl;
135 if (continueParse)
136 {
137 AliHLTUInt32_t offset = fieldptr - buffer;
138 PrintRubbishData(offset, fieldptr, bufferRemaining);
139 }
140 return PARSE_ERROR;
141 }
142 return EXIT_SUCCESS;
143}
144
145
146template <typename FieldType>
147int CheckField(
148 FieldType& field, const char* buffer, unsigned long bufferSize,
149 bool continueParse
150 )
151{
152 const char* fieldptr = reinterpret_cast<const char*>(&field);
153 const char* endptr = buffer + bufferSize;
154 AliHLTUInt32_t bufferRemaining = endptr > fieldptr ? endptr - fieldptr : 0;
155
156 if (bufferRemaining < sizeof(field))
157 {
158 cout << "..." << endl; // We may be half way through printing a line so end it.
159 cerr << "ERROR: The data block is too short. The data is corrupt." << endl;
160 if (continueParse)
161 {
162 AliHLTUInt32_t offset = fieldptr - buffer;
163 PrintRubbishData(offset, fieldptr, bufferRemaining);
164 }
165 return PARSE_ERROR;
166 }
167 return EXIT_SUCCESS;
168}
169
170
171template <typename BlockType>
172int CheckCommonHeader(
63ae97e0 173 BlockType& block, const char* /*buffer*/, unsigned long bufferSize,
3dad52b0 174 bool continueParse
175 )
176{
177 int result = EXIT_SUCCESS;
178
179 // Check the fRecordWidth field in the common header.
180 if (block.CommonBlockHeader().fRecordWidth !=
181 sizeof(typename BlockType::ElementType))
182 {
183 cerr << "ERROR: The record width found in the header is incorrect."
184 " Found a record width of "
185 << block.CommonBlockHeader().fRecordWidth << " bytes, but expected"
186 " a value of " << sizeof(typename BlockType::ElementType)
187 << " bytes." << endl;
188 result = PARSE_ERROR;
189 if (not continueParse) return result;
190 }
191
192 if (not block.BufferSizeOk())
193 {
194 cerr << "ERROR: The size of the file is incorrect. It is "
195 << bufferSize << " bytes big, but according"
196 " to the data block header it should be " << block.BytesUsed()
197 << " bytes." << endl;
198 result = PARSE_ERROR;
199 if (not continueParse) return result;
200 }
201
202 return result;
203}
204
205
206template <typename BlockType>
207AliHLTUInt32_t CalculateNEntries(BlockType& block, unsigned long bufferSize)
208{
209 // Calculate how many entries we can display. If the buffer size is correct
210 // we just use the number of entries the block specifies. Otherwise we need
211 // to calculate it from the buffer size.
212 AliHLTUInt32_t nentries;
213 if (block.BytesUsed() == bufferSize)
214 {
215 nentries = block.Nentries();
216 }
217 else
218 {
219 AliHLTInt32_t dataSize = bufferSize
220 - sizeof(typename BlockType::HeaderType);
221 nentries = dataSize / sizeof(typename BlockType::ElementType);
222 if (dataSize % sizeof(typename BlockType::ElementType) > 0)
223 nentries++;
224 }
225 return nentries;
226}
227
228
887a669c 229namespace
230{
231 /**
232 * Common methods for DDL decoder event handlers.
233 */
234 class AliDecoderHandler
235 {
236 public:
237 AliDecoderHandler() :
238 fBufferStart(NULL),
239 fDumpStart(NULL),
240 fDumpData(false)
241 {
242 }
243
244 virtual ~AliDecoderHandler() {}
245
246 protected:
247
248 // Do not allow copying of this class.
249 AliDecoderHandler(const AliDecoderHandler& obj);
250 AliDecoderHandler& operator = (const AliDecoderHandler& obj);
251
252 void HandleError(
253 const char* errorMessage, int errorCode,
254 const char* errorCodeString, const void* location
a090ff22 255 );
887a669c 256
a090ff22 257 void TryDumpCorruptData(const void* dumpEnd);
887a669c 258
259 const void* fBufferStart; ///< Start location of buffer.
260 const void* fDumpStart; ///< Start location of corrupt data to dump.
261 bool fDumpData; ///< Flag indicating if fDumpStart points to corrupt data and should be dumped.
262 };
a090ff22 263
264
265 void AliDecoderHandler::HandleError(
266 const char* errorMessage, int errorCode,
267 const char* errorCodeString, const void* location
268 )
269 {
270 unsigned long offset = (unsigned long)location - (unsigned long)fBufferStart
271 + sizeof(AliRawDataHeader);
272
273 cerr << "ERROR: " << errorMessage
274 << " [Error code = " << errorCode << " ("
275 << errorCodeString << "), at byte "
276 << offset << " (" << noshowbase << hex << "0x"
277 << offset << dec << ")]" << endl;
278
279 if (fDumpStart == NULL) fDumpStart = location;
280 fDumpData = true;
281 }
282
283
284 void AliDecoderHandler::TryDumpCorruptData(const void* dumpEnd)
285 {
286 if (dumpEnd < fDumpStart) return;
287 if (not fDumpData) return;
288
289 unsigned long startOffset = (unsigned long)fDumpStart - (unsigned long)fBufferStart
290 + sizeof(AliRawDataHeader);
291 unsigned long endOffset = (unsigned long)dumpEnd - (unsigned long)fBufferStart
292 + sizeof(AliRawDataHeader);
293 if (endOffset - startOffset > 264)
294 {
295 endOffset = startOffset + 264;
296 dumpEnd = reinterpret_cast<const char*>(fBufferStart) + endOffset;
297 }
298 cerr << "Dumping corrupt data words from byte " << startOffset
299 << " (" << noshowbase << hex << "0x" << startOffset
300 << dec << "), to byte " << endOffset << " (" << noshowbase
301 << hex << "0x" << endOffset << dec << "):" << endl;
302 const UInt_t* start = reinterpret_cast<const UInt_t*>(fDumpStart);
303 const UInt_t* end = reinterpret_cast<const UInt_t*>(dumpEnd);
304 cerr << " Start byte | Data words" << endl;
305 for (const UInt_t* current = start; current < end; current++)
306 {
307 unsigned long currentByte = (unsigned long)current
308 - (unsigned long)fBufferStart + sizeof(AliRawDataHeader);
309 cerr << right << setw(9) << dec << currentByte << setw(0)
310 << " 0x" << left << setw(7) << noshowbase << hex
311 << currentByte << setw(0) << right << " | ";
312 char fillChar = cerr.fill();
313 cerr.fill('0');
314 for (int i = 0; i < 4 and current < end; i++, current++)
315 {
316 cerr << noshowbase << hex << "0x" << setw(8)
317 << (*current) << setw(0) << dec << " ";
318 }
319 cerr.fill(fillChar);
320 cerr << endl;
321 }
322 fDumpStart = NULL;
323 fDumpData = false;
324 }
887a669c 325
326 /**
327 * Event handler for the tracker DDL decoder.
328 * It simply prints the structure to standard output.
329 */
330 class AliTrackerDecoderHandler :
331 public AliMUONTrackerDDLDecoderEventHandler, public AliDecoderHandler
332 {
333 public:
334 AliTrackerDecoderHandler() :
335 AliMUONTrackerDDLDecoderEventHandler(),
a090ff22 336 AliDecoderHandler(),
337 fBlockNum(0),
338 fDSPNum(0),
339 fBusPatchNum(0)
887a669c 340 {}
341
342 virtual ~AliTrackerDecoderHandler() {}
343
344 void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/)
345 {
346 fBufferStart = buffer;
a090ff22 347 fBlockNum = fDSPNum = fBusPatchNum = 0;
887a669c 348 }
349
350 void OnEndOfBuffer(const void* buffer, UInt_t bufferSize)
351 {
352 const char* bufferEnd =
353 reinterpret_cast<const char*>(buffer) + bufferSize;
354 TryDumpCorruptData(bufferEnd);
355 }
356
a090ff22 357 void OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/);
887a669c 358
a090ff22 359 void OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/);
360
361 void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/);
362
363 void OnData(UInt_t data, bool parityError);
364
365 void OnError(ErrorCode error, const void* location);
887a669c 366
a090ff22 367 private:
368
369 UInt_t fBlockNum; ///< Number of block being processed [1..maxBlock].
370 UInt_t fDSPNum; ///< Number of DSP being processed [1..maxDSP].
371 UInt_t fBusPatchNum; ///< Number of bus patch being processed [1..maxBusPatch].
372 };
373
374
375 void AliTrackerDecoderHandler::OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/)
376 {
377 TryDumpCorruptData(header);
378 fBlockNum++;
379 char fillChar = cout.fill(); // store current fill char to restore it.
380 cout << "================================ Block header "
381 << setw(3) << fBlockNum << setw(0)
382 << " ================================" << endl;
383 cout << " Data key word for block : 0x" << noshowbase << setw(8) << setfill('0')
384 << hex << header->fDataKey << dec << setfill(fillChar) << setw(0) << endl;
385 cout << " Total Length of block : " << header->fTotalLength << endl;
386 cout << " Length of raw data : " << header->fLength << endl;
387 cout << " DSP ID : " << header->fDSPId << endl;
388 cout << " L0 trigger word : " << header->fL0Trigger << " (0x"
389 << noshowbase << setw(8) << setfill('0') << hex << header->fL0Trigger
390 << dec << setw(0) << setfill(fillChar) << ")" << endl;
391 cout << " Mini event ID : " << header->fMiniEventId << " (0x"
392 << noshowbase << setw(8) << setfill('0') << hex << header->fMiniEventId
393 << dec << setw(0) << setfill(fillChar) << ")" << endl;
394 cout << "Event ID In Bunch Crossing : " << header->fEventId1 << " (0x"
395 << noshowbase << setw(8) << setfill('0') << hex << header->fEventId1
396 << dec << setw(0) << setfill(fillChar) << ")" << endl;
397 cout << " Event ID In Orbit Number : " << header->fEventId2 << " (0x"
398 << noshowbase << setw(8) << setfill('0') << hex << header->fEventId2
399 << dec << setw(0) << setfill(fillChar) << ")" << endl;
400 }
401
402
403 void AliTrackerDecoderHandler::OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/)
404 {
405 TryDumpCorruptData(header);
406 fDSPNum++;
407 char fillChar = cout.fill(); // store current fill char to restore it.
408 cout << "================================= DSP header "
409 << setw(3) << fDSPNum << setw(0)
410 << " =================================" << endl;
411 cout << " Data key word for FRT : 0x" << noshowbase
412 << setw(8) << setfill('0') << hex << header->fDataKey << dec
413 << setfill(fillChar) << setw(0) << endl;
414 cout << " Total length of structure : " << header->fTotalLength << endl;
415 cout << " Length of raw data : " << header->fLength << endl;
416 cout << " DSP ID : " << header->fDSPId << endl;
417 cout << " L1 accept in block Structure (CRT) : " << header->fBlkL1ATrigger
418 << " (0x" << noshowbase << setw(8) << setfill('0') << hex
419 << header->fBlkL1ATrigger << dec << setw(0) << setfill(fillChar) << ")" << endl;
420 cout << " Mini event ID in bunch crossing : " << header->fMiniEventId
421 << " (0x" << noshowbase << setw(8) << setfill('0') << hex
422 << header->fMiniEventId << dec << setw(0) << setfill(fillChar) << ")" << endl;
423 cout << "Number of L1 accept in DSP Structure (FRT) : " << header->fL1ATrigger << endl;
424 cout << "Number of L1 reject in DSP Structure (FRT) : " << header->fL1RTrigger << endl;
425 const char* paddingWordValue = ") (INVALID)";
426 if (header->fPaddingWord == 0) paddingWordValue = ") (false)";
427 if (header->fPaddingWord == 1) paddingWordValue = ") (true)";
428 cout << " Padding word set for 64 bits transfer : " << header->fPaddingWord
429 << " (0x" << noshowbase << setw(8) << setfill('0') << hex
430 << header->fPaddingWord << setw(0) << setfill(fillChar) << dec
431 << paddingWordValue << endl;
432 cout << " Error word : " << header->fErrorWord
433 << " (" << noshowbase << setw(8) << setfill('0') << hex
434 << header->fErrorWord << setw(0) << setfill(fillChar)
435 << dec << ")" << endl;
436 }
437
438
439 void AliTrackerDecoderHandler::OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/)
440 {
441 TryDumpCorruptData(header);
442 fBusPatchNum++;
443 char fillChar = cout.fill(); // store current fill char to restore it.
444 cout << "============================== Bus patch header "
445 << setw(3) << fBusPatchNum << setw(0)
446 << " ==============================" << endl;
447 cout << "Data key word for bus patch : 0x" << noshowbase << setw(8)
448 << setfill('0') << hex << header->fDataKey << dec
449 << setfill(fillChar) << setw(0) << endl;
450 cout << " Total length of structure : " << header->fTotalLength << endl;
451 cout << " Length of raw data : " << header->fLength << endl;
452 cout << " Bus patch ID : " << header->fBusPatchId << endl;
453 if (header->fLength > 0)
887a669c 454 {
a090ff22 455 cout << " Raw bits | Manu ID | Manu channel | ADC Signal" << endl;
456 cout << "----------------------------------------------------------" << endl;
887a669c 457 }
a090ff22 458 }
459
460
461 void AliTrackerDecoderHandler::OnData(UInt_t data, bool parityError)
462 {
463 UShort_t manuId, adc;
464 UChar_t manuChannel;
465 UnpackADC(data, manuId, manuChannel, adc);
466 char fillChar = cout.fill(); // store current fill char to restore it.
467 cout << noshowbase << " 0x" << setfill('0') << hex << setw(8) << data
468 << setw(0) << dec << setfill(fillChar) << " "
469 << setw(12) << manuId << setw(0) << " "
470 << setw(12) << (UInt_t)manuChannel << setw(0) << " "
471 << setw(12) << adc << setw(0);
472 if (parityError)
887a669c 473 {
a090ff22 474 cout << " <= WARNING: Raw data word with parity error!" << endl;
887a669c 475 }
a090ff22 476 else
887a669c 477 {
a090ff22 478 cout << endl;
887a669c 479 }
a090ff22 480 }
481
482
483 void AliTrackerDecoderHandler::OnError(ErrorCode error, const void* location)
484 {
485 TryDumpCorruptData(location);
486 HandleError(
487 ErrorCodeToMessage(error), error,
488 ErrorCodeToString(error), location
489 );
490 }
887a669c 491
492 /**
493 * Event handler for the trigger DDL decoder.
494 * It simply prints the structure to standard output.
495 */
496 class AliTriggerDecoderHandler :
497 public AliMUONTriggerDDLDecoderEventHandler, public AliDecoderHandler
498 {
499 public:
500 AliTriggerDecoderHandler() :
501 AliMUONTriggerDDLDecoderEventHandler(),
a090ff22 502 AliDecoderHandler(),
503 fRegNum(0),
504 fLocNum(0)
887a669c 505 {}
506
507 virtual ~AliTriggerDecoderHandler() {}
508
509 void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/)
510 {
511 fBufferStart = buffer;
a090ff22 512 fRegNum = fLocNum = 0;
887a669c 513 }
514
515 void OnEndOfBuffer(const void* buffer, UInt_t bufferSize)
516 {
517 const char* bufferEnd =
518 reinterpret_cast<const char*>(buffer) + bufferSize;
519 TryDumpCorruptData(bufferEnd);
520 }
521
a090ff22 522 const char* EventTypeToString(UInt_t type);
523
524 const char* DarcTypeToString(UInt_t type);
525
887a669c 526 void OnDarcHeader(
527 UInt_t header,
528 const AliMUONDarcScalarsStruct* scalars,
529 const void* data
a090ff22 530 );
887a669c 531
532 void OnGlobalHeader(
533 const AliMUONGlobalHeaderStruct* header,
a090ff22 534 const AliMUONGlobalScalarsStruct* scalars,
887a669c 535 const void* /*data*/
a090ff22 536 );
887a669c 537
538 void OnNewRegionalStruct(
539 const AliMUONRegionalHeaderStruct* regionalStruct,
a090ff22 540 const AliMUONRegionalScalarsStruct* scalars,
887a669c 541 const void* /*data*/
a090ff22 542 );
887a669c 543
544 void OnLocalStruct(
545 const AliMUONLocalInfoStruct* localStruct,
a090ff22 546 const AliMUONLocalScalarsStruct* scalars
547 );
548
549 void OnError(ErrorCode error, const void* location);
550
551 private:
552
553 UInt_t fRegNum; ///< Number of block being processed [1..maxReg].
554 UInt_t fLocNum; ///< Number of DSP being processed [1..maxLoc].
555 };
556
557
558 const char* AliTriggerDecoderHandler::EventTypeToString(UInt_t type)
559 {
560 switch (type)
887a669c 561 {
a090ff22 562 case 0: return "Other software trigger";
563 case 1: return "Physics";
564 case 2: return "Start of run";
565 case 3: return "End of run";
566 default: return "UNKNOWN";
887a669c 567 }
a090ff22 568 }
569
570
571 const char* AliTriggerDecoderHandler::DarcTypeToString(UInt_t type)
572 {
573 typedef AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler> AliDec;
574 if (type == AliDec::DarcDefaultType()) return "Default";
575 if (type == AliDec::DarcVadorhType()) return "Vadorh";
576 return "UNKNOWN";
577 }
578
579
580 void AliTriggerDecoderHandler::OnDarcHeader(
581 UInt_t header,
582 const AliMUONDarcScalarsStruct* scalars,
583 const void* data
584 )
585 {
586 if (scalars != NULL)
587 TryDumpCorruptData(scalars);
588 else
589 TryDumpCorruptData(data);
887a669c 590
a090ff22 591 cout << "================================ DARC header =====================================" << endl;
592 char fillChar = cout.fill(); // store current fill char to restore it.
593 cout << noshowbase << " Header bit pattern : 0x" << setfill('0') << hex << setw(8)
594 << header << setw(0) << dec << setfill(fillChar) << endl;
595 UInt_t eventType = GetDarcEventType(header);
596 cout << " Event type : " << eventType << " ("
597 << EventTypeToString(eventType) << ")" << endl;
598 cout << " Application type : " << ((header >> 27) & 0x7) << endl;
599 UInt_t darcType = GetDarcType(header);
600 cout << " DARC type : " << darcType << " ("
601 << DarcTypeToString(darcType) << ")" << endl;
602 cout << " Serial number : " << (UInt_t)GetDarcSerialNb(header) << endl;
603 cout << " Version : " << (UInt_t)GetDarcVersion(header) << endl;
604 cout << " VME trigger used : " << boolalpha << GetDarcVMETrig(header) << endl;
605 cout << "Global card data occurrence : " << boolalpha << GetDarcGlobalFlag(header) << endl;
606 cout << " CTP or LTU interfaced : " << boolalpha << GetDarcCTPTrig(header) << endl;
607 cout << " DAQ interfaced : " << boolalpha << GetDarcDAQFlag(header) << endl;
608 cout << " Regional cards occurrence : 0x" << noshowbase << hex << setw(2) << setfill('0')
609 << (UInt_t)GetDarcRegPattern(header) << dec << setfill(fillChar) << setw(0)
610 << " [bits: ";
611 PrintBitPattern(((UInt_t)GetDarcRegPattern(header) >> 4) & 0xF, 4); cout << " ";
612 PrintBitPattern(((UInt_t)GetDarcRegPattern(header) >> 0) & 0xF, 4);
613 cout << "]" << endl;
614
615 cout << "================================ DARC scalars ====================================" << endl;
616 if (scalars != NULL)
887a669c 617 {
a090ff22 618 cout << " Trigger | Received | Used" << endl;
619 cout << "----------------------------------" << endl;
620 cout << " L0 " << setw(8) << ((scalars->fL0R >> 16) & 0xFFFF) << setw(0)
621 << " " << setw(8) << ((scalars->fL0R >> 0) & 0xFFFF) << setw(0) << endl;
622 cout << " L1 physics " << setw(8) << ((scalars->fL1P >> 16) & 0xFFFF) << setw(0)
623 << " " << setw(8) << ((scalars->fL1P >> 0) & 0xFFFF) << setw(0) << endl;
624 cout << "L1 software " << setw(8) << ((scalars->fL1S >> 16) & 0xFFFF) << setw(0)
625 << " " << setw(8) << ((scalars->fL1S >> 0) & 0xFFFF) << setw(0) << endl;
626 cout << " L2 accept " << setw(8) << ((scalars->fL2A >> 16) & 0xFFFF) << setw(0)
627 << " " << setw(8) << ((scalars->fL2A >> 0) & 0xFFFF) << setw(0) << endl;
628 cout << " L2 reject " << setw(8) << ((scalars->fL2R >> 16) & 0xFFFF) << setw(0)
629 << " " << setw(8) << ((scalars->fL2R >> 0) & 0xFFFF) << setw(0) << endl;
630 cout << " Clock : " << scalars->fClk << endl;
631 cout << "Hold (dead time) : " << scalars->fHold << endl;
632 cout << " Spare word : " << scalars->fSpare << " (0x"
633 << setw(8) << setfill('0') << hex << scalars->fSpare <<
634 setw(0) << setfill(fillChar) << dec << ")" << endl;
887a669c 635 }
a090ff22 636 else
637 {
638 cout << "(None found)" << endl;
639 }
640 }
641
642
643 void AliTriggerDecoderHandler::OnGlobalHeader(
644 const AliMUONGlobalHeaderStruct* header,
645 const AliMUONGlobalScalarsStruct* scalars,
646 const void* /*data*/
647 )
648 {
649 TryDumpCorruptData(header);
650
651 cout << "=============================== Global header ====================================" << endl;
652 cout << "Global input from regional controllers:" << endl;
653 cout << " | | High pT | Low pT " << endl;
654 cout << " | Bit pattern | Single mu | mu pair | Single mu | mu pair " << endl;
655 cout << "Input | Hex | Binary | -ve | +ve | unlike | like | -ve | +ve | unlike | like" << endl;
656 cout << "--------------------------------------------------------------------------------" << endl;
657 char fillChar = cout.fill(); // store current fill char to restore it.
658 for (int i = 0; i < 4; i++)
659 {
660 union
661 {
662 UInt_t fWord;
663 UChar_t fByte[4];
664 } input;
665 input.fWord = header->fInput[i];
666 for (int j = 0; j < 4; j++)
667 {
668 cout << setw(5) << (i*4+j) << " 0x" << noshowbase << setw(2)
669 << setfill('0') << hex << (UInt_t)input.fByte[j] << setw(0)
670 << setfill(fillChar) << dec << " ";
671 PrintBitPattern(input.fByte[j], 8);
672 cout << ((((input.fByte[j] >> 7) & 0x1) == 1) ? " yes" : " no");
673 cout << ((((input.fByte[j] >> 6) & 0x1) == 1) ? " yes" : " no");
674 cout << ((((input.fByte[j] >> 5) & 0x1) == 1) ? " yes " : " no ");
675 cout << ((((input.fByte[j] >> 4) & 0x1) == 1) ? " yes" : " no");
676 cout << ((((input.fByte[j] >> 3) & 0x1) == 1) ? " yes" : " no");
677 cout << ((((input.fByte[j] >> 2) & 0x1) == 1) ? " yes" : " no");
678 cout << ((((input.fByte[j] >> 1) & 0x1) == 1) ? " yes " : " no ");
679 cout << ((((input.fByte[j] >> 0) & 0x1) == 1) ? " yes" : " no");
680 cout << endl;
681 }
682 }
683 cout << " Global ouput : 0x" << noshowbase << setw(2) << setfill('0') << hex
684 << (UInt_t)GetGlobalOutput(header) << setw(0) << setfill(fillChar) << dec << " [Bits: ";
685 PrintBitPattern(((UInt_t)GetGlobalOutput(header) >> 4) & 0xF, 4); cout << " ";
686 PrintBitPattern(((UInt_t)GetGlobalOutput(header) >> 0) & 0xF, 4);
687 cout << "]" << endl;
688 cout << " [ unlike sign | like sign | single muon ]" << endl;
689 cout << " [ high | low | high | low | high | low ]" << endl;
690 cout << " [-----------------------------------------]" << endl;
691 cout << " [ ";
692 cout << ((((GetGlobalOutput(header) >> 5) & 0x1) == 1) ? " yes" : " no");
693 cout << ((((GetGlobalOutput(header) >> 4) & 0x1) == 1) ? " yes" : " no");
694 cout << ((((GetGlobalOutput(header) >> 3) & 0x1) == 1) ? " yes" : " no");
695 cout << ((((GetGlobalOutput(header) >> 2) & 0x1) == 1) ? " yes" : " no");
696 cout << ((((GetGlobalOutput(header) >> 1) & 0x1) == 1) ? " yes" : " no");
697 cout << ((((GetGlobalOutput(header) >> 0) & 0x1) == 1) ? " yes" : " no");
698 cout << " ]" << endl;
699 cout << "Global configuration : 0x" << noshowbase << setw(4) << setfill('0') << hex
700 << GetGlobalConfig(header) << setw(0) << setfill(fillChar) << dec << " [Bits: ";
701 PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 12) & 0xF, 4); cout << " ";
702 PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 8) & 0xF, 4); cout << " ";
703 PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 4) & 0xF, 4); cout << " ";
704 PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 0) & 0xF, 4);
705 cout << "]" << endl;
706
707 cout << "=============================== Global scalars ===================================" << endl;
708 if (scalars != NULL)
709 {
710 cout << " Number of L0 triggers : " << scalars->fL0 << endl;
711 cout << " Number of clock cycles : " << scalars->fClk << endl;
712 cout << " Number of unlike mu pair low pT : " << scalars->fScaler[0] << endl;
713 cout << "Number of unlike mu pair high pT : " << scalars->fScaler[1] << endl;
714 cout << " Number of like mu pair low pT : " << scalars->fScaler[2] << endl;
715 cout << " Number of like mu pair high pT : " << scalars->fScaler[3] << endl;
716 cout << " Number of single mu low pT : " << scalars->fScaler[4] << endl;
717 cout << " Number of single mu high pT : " << scalars->fScaler[5] << endl;
718 cout << " Hold (dead time) : " << scalars->fHold << endl;
719 cout << " Spare word : " << scalars->fSpare << " (0x"
720 << setw(8) << setfill('0') << hex << scalars->fSpare <<
721 setw(0) << setfill(fillChar) << dec << ")" << endl;
722 }
723 else
724 {
725 cout << "(None found)" << endl;
726 }
727 }
728
729
730 void AliTriggerDecoderHandler::OnNewRegionalStruct(
731 const AliMUONRegionalHeaderStruct* regionalStruct,
732 const AliMUONRegionalScalarsStruct* scalars,
733 const void* /*data*/
734 )
735 {
736 TryDumpCorruptData(regionalStruct);
737
738 fRegNum++;
739 cout << "========================= Regional structure header "
740 << setw(3) << fRegNum << setw(0)
741 << " ==========================" << endl;
742 char fillChar = cout.fill(); // store current fill char to restore it.
743 cout << "Darc word bit pattern : 0x" << noshowbase << setw(8) << setfill('0')
744 << hex << regionalStruct->fDarcWord << setw(0)
745 << setfill(fillChar) << dec << endl;
746 UShort_t errBits = GetRegionalErrorBits(regionalStruct);
747 cout << " [ Error type : "
748 << (((errBits >> 7) & 0x1) == 1 ? "1 (Physics) " : "0 (Software)")
749 << " ]" << endl;
750 cout << " [ Regional error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
751 cout << " [ Full error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
752 cout << " [ Empty error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
753 cout << " [ DARC L2 reject error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
754 cout << " [ DARC L2 error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
755 cout << " [ DARC L1 error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
756 cout << " [ DARC L0 error : " << ((errBits >> 6) & 0x1) << " ]" << endl;
757
758 cout << " [ FPGA number in card : "
759 << (UInt_t)GetRegionalFPGANumber(regionalStruct) << " (";
760 PrintBitPattern((UInt_t)GetRegionalFPGANumber(regionalStruct), 3);
761 cout << "b) ]" << endl;
762
763 cout << " [ Physics trigger : " << setw(13) << boolalpha << left
764 << GetRegionalDarcPhysFlag(regionalStruct) << setw(0)
765 << right << "]" << endl;
766 cout << " [ Regional present : " << setw(13) << boolalpha << left
767 << GetRegionalPresentFlag(regionalStruct) << setw(0)
768 << right << "]" << endl;
769 cout << " [ RAM not full : " << setw(13) << boolalpha << left
770 << GetRegionalRamNotFullFlag(regionalStruct) << setw(0)
771 << right << "]" << endl;
772 cout << " [ RAM not empty : " << setw(13) << boolalpha << left
773 << GetRegionalRamNotEmptyFlag(regionalStruct) << setw(0)
774 << right << "]" << endl;
775 cout << " [ L2 rejected : " << setw(13) << boolalpha << left
776 << GetRegionalL2RejStatus(regionalStruct) << setw(0)
777 << right << "]" << endl;
778 cout << " [ L2 accepted : " << setw(13) << boolalpha << left
779 << GetRegionalL2AccStatus(regionalStruct) << setw(0)
780 << right << "]" << endl;
781 cout << " [ L1 found : " << setw(13) << boolalpha << left
782 << GetRegionalL1Status(regionalStruct) << setw(0)
783 << right << "]" << endl;
784 cout << " [ L0 found : " << setw(13) << boolalpha << left
785 << GetRegionalL0Status(regionalStruct) << setw(0)
786 << right << "]" << endl;
787 cout << " [ No. of events in RAM : " << setw(13) << left
788 << (UInt_t)GetRegionalEventInRam(regionalStruct) << setw(0)
789 << right << "]" << endl;
790 cout << " [ Busy word : 0x"
791 << (UInt_t)GetRegionalBusy(regionalStruct) << " (";
792 PrintBitPattern((UInt_t)GetRegionalBusy(regionalStruct), 4);
793 cout << "b) ]" << endl;
794
795 cout << "Regional word bit pattern : 0x" << noshowbase << setw(8) << setfill('0')
796 << hex << regionalStruct->fWord << setw(0)
797 << setfill(fillChar) << dec << endl;
798 cout << " [ Physics trigger occurred : " << setw(27) << boolalpha << left
799 << (UInt_t)GetRegionalPhysFlag(regionalStruct) << setw(0)
800 << right << "]" << endl;
801 cout << " [ Number of resets : " << setw(27) << left
802 << (UInt_t)GetRegionalResetNb(regionalStruct) << setw(0)
803 << right << "]" << endl;
804 cout << " [ Controller Serial number : " << setw(27) << left
805 << (UInt_t)GetRegionalSerialNb(regionalStruct) << setw(0)
806 << right << "]" << endl;
807 cout << " [ Regional crate ID : " << setw(27) << left
808 << (UInt_t)GetRegionalId(regionalStruct) << setw(0)
809 << right << "]" << endl;
810 cout << " [ FPGA software version : " << setw(27) << left
811 << (UInt_t)GetRegionalVersion(regionalStruct) << setw(0)
812 << right << "]" << endl;
813 UInt_t output = GetRegionalOutput(regionalStruct);
814 cout << " [ Regional output : 0x" << setw(2) << setfill('0') << hex
815 << output << dec << setw(0) << setfill(fillChar) << setw(0) << right << " (";
816 PrintBitPattern(output, 8);
817 cout << "b) ]" << endl;
818
819 cout << " [ High pT | Low pT ]" << endl;
820 cout << " [ Single mu | mu pair | Single mu | mu pair ]" << endl;
821 cout << " [ -ve | +ve | unlike | like | -ve | +ve | unlike | like ]" << endl;
822 cout << " [-------------------------------------------------------]" << endl;
823 cout << ((((output >> 7) & 0x1) == 1) ? " [ yes" : " [ no");
824 cout << ((((output >> 6) & 0x1) == 1) ? " yes" : " no");
825 cout << ((((output >> 5) & 0x1) == 1) ? " yes " : " no ");
826 cout << ((((output >> 4) & 0x1) == 1) ? " yes" : " no");
827 cout << ((((output >> 3) & 0x1) == 1) ? " yes" : " no");
828 cout << ((((output >> 2) & 0x1) == 1) ? " yes" : " no");
829 cout << ((((output >> 1) & 0x1) == 1) ? " yes " : " no ");
830 cout << ((((output >> 0) & 0x1) == 1) ? " yes ]" : " no ]");
831 cout << endl;
832
833 cout << "Regional input (low pT) bit pattern : 0x" << noshowbase << setw(8)
834 << setfill('0') << hex << regionalStruct->fInput[0]
835 << setw(0) << setfill(fillChar) << dec << endl;
836 cout << "Regional input (high pT) bit pattern : 0x" << noshowbase << setw(8)
837 << setfill('0') << hex << regionalStruct->fInput[1]
838 << setw(0) << setfill(fillChar) << dec << endl;
839 cout << "Regional input logical dump: " << endl;
840 cout << " Local | Local | low pT mu | high pT mu" << endl;
841 cout << "structure no. | board | -ve | +ve | -ve | +ve" << endl;
842 cout << "-----------------------------------------------" << endl;
843 for (int i = 15; i >= 0 ; i--)
844 {
845 cout << setw(13) << (fLocNum + 16 - i) << setw(0) << " ";
846 cout << setw(5) << (15 - i) << setw(0) << " ";
847 cout << ((((regionalStruct->fInput[0] >> (i*2+1)) & 0x1) == 1) ? "yes" : " no");
848 cout << ((((regionalStruct->fInput[0] >> (i*2+0)) & 0x1) == 1) ? " yes" : " no");
849 cout << ((((regionalStruct->fInput[1] >> (i*2+1)) & 0x1) == 1) ? " yes" : " no");
850 cout << ((((regionalStruct->fInput[1] >> (i*2+0)) & 0x1) == 1) ? " yes" : " no");
851 cout << endl;
852 }
853
854 UInt_t mask = GetRegionalMask(regionalStruct);
855 cout << "Local mask : 0x" << noshowbase << setw(4) << setfill('0') << hex
856 << mask << dec << setw(0) << setfill(fillChar) << " [Bits: ";
857 PrintBitPattern(mask >> 12, 4); cout << " ";
858 PrintBitPattern(mask >> 8, 4); cout << " ";
859 PrintBitPattern(mask >> 4, 4); cout << " ";
860 PrintBitPattern(mask >> 0, 4); cout << "]" << endl;
861
862 cout << "L0 counter : " << GetRegionalL0(regionalStruct) << endl;
863
864 cout << "========================= Regional structure scalars "
865 << setw(3) << fRegNum << setw(0)
866 << " =========================" << endl;
867 if (scalars != NULL)
868 {
869 cout << " Number of clock cycles : " << scalars->fClk << endl;
870 cout << " Number of high pT +ve single mu : " << scalars->fScaler[0] << endl;
871 cout << " Number of high pT -ve single mu : " << scalars->fScaler[1] << endl;
872 cout << "Number of high pT unlike sign pair : " << scalars->fScaler[2] << endl;
873 cout << " Number of high pT like sign pair : " << scalars->fScaler[3] << endl;
874 cout << " Number of low pT +ve single mu : " << scalars->fScaler[4] << endl;
875 cout << " Number of low pT -ve single mu : " << scalars->fScaler[5] << endl;
876 cout << " Number of low pT unlike sign pair : " << scalars->fScaler[6] << endl;
877 cout << " Number of low pT like sign pair : " << scalars->fScaler[7] << endl;
878 cout << " Hold (dead time) : " << scalars->fHold << endl;
879 }
880 else
881 {
882 cout << "(None found)" << endl;
883 }
884 }
885
886
887 void AliTriggerDecoderHandler::OnLocalStruct(
888 const AliMUONLocalInfoStruct* localStruct,
889 const AliMUONLocalScalarsStruct* scalars
890 )
891 {
892 TryDumpCorruptData(localStruct);
893
894 fLocNum++;
895 cout << "=========================== Local structure header "
896 << setw(3) << fLocNum << setw(0)
897 << " ===========================" << endl;
898 char fillChar = cout.fill(); // store current fill char to restore it.
899 cout << "L0 strip patterns:" << endl;
900 cout << "Chamber | X | Y " << endl;
901 cout << "----------------------------------------------" << endl;
902 cout << " 11 ";
903 PrintBitPattern(GetLocalX1(localStruct), 16);
904 cout << " ";
905 PrintBitPattern(GetLocalY1(localStruct), 16);
906 cout << endl;
907 cout << " 12 ";
908 PrintBitPattern(GetLocalX2(localStruct), 16);
909 cout << " ";
910 PrintBitPattern(GetLocalY2(localStruct), 16);
911 cout << endl;
912 cout << " 13 ";
913 PrintBitPattern(GetLocalX3(localStruct), 16);
914 cout << " ";
915 PrintBitPattern(GetLocalY3(localStruct), 16);
916 cout << endl;
7f62a2ea 917 cout << " 14 ";
a090ff22 918 PrintBitPattern(GetLocalX4(localStruct), 16);
919 cout << " ";
920 PrintBitPattern(GetLocalY4(localStruct), 16);
921 cout << endl;
922
923 cout << "L0 trigger bits: (word = ";
924 cout << showbase << hex << localStruct->fTriggerBits
925 << noshowbase << dec << ")" << endl;
926 cout << " ID | Dec | TrigY | YPos | Sign XDev | XDev | XPos " << endl;
927 cout << "----------------------------------------------------------------" << endl;
928 cout << "Decimal : " << setw(4) << (UInt_t)GetLocalId(localStruct) << setw(0) << " ";
929 cout << setw(4) << (UInt_t)GetLocalDec(localStruct) << setw(0) << " ";
930 cout << setw(3) << (UInt_t)GetLocalTrigY(localStruct) << setw(0) << " ";
931 cout << setw(4) << (UInt_t)GetLocalYPos(localStruct) << setw(0) << " ";
932 cout << setw(5) << (UInt_t)GetLocalSXDev(localStruct) << setw(0) << " ";
933 cout << setw(4) << (UInt_t)GetLocalXDev(localStruct) << setw(0) << " ";
934 cout << setw(4) << (UInt_t)GetLocalXPos(localStruct) << setw(0) << endl;
935 cout << " Binary : ";
936 PrintBitPattern(AliHLTUInt32_t(GetLocalId(localStruct)), 4);
937 cout << " ";
938 PrintBitPattern(AliHLTUInt32_t(GetLocalDec(localStruct)), 4);
939 cout << " ";
940 PrintBitPattern(AliHLTUInt32_t(GetLocalTrigY(localStruct)), 1);
941 cout << " ";
942 PrintBitPattern(AliHLTUInt32_t(GetLocalYPos(localStruct)), 4);
943 cout << " ";
944 PrintBitPattern(AliHLTUInt32_t(GetLocalSXDev(localStruct)), 1);
945 cout << " ";
946 PrintBitPattern(AliHLTUInt32_t(GetLocalXDev(localStruct)), 4);
947 cout << " ";
948 PrintBitPattern(AliHLTUInt32_t(GetLocalXPos(localStruct)), 5);
949 cout << endl;
950
951 cout << "L0 decision (Dec): [high pT: ";
952 PrintBitPattern((UInt_t)GetLocalHpt(localStruct), 2);
953 cout << "b (";
954 switch ((UInt_t)GetLocalHpt(localStruct))
955 {
956 case 0: cout << "No trigger"; break;
957 case 1: cout << "-ve particle"; break;
958 case 2: cout << "+ve particle"; break;
959 case 3: cout << "No deviation trigger"; break;
960 default: cout << "UNKNOWN"; break;
961 }
962 cout << "), low pT: ";
963 PrintBitPattern((UInt_t)GetLocalLpt(localStruct), 2);
964 cout << "b (";
965 switch ((UInt_t)GetLocalLpt(localStruct))
966 {
967 case 0: cout << "No trigger"; break;
968 case 1: cout << "-ve particle"; break;
969 case 2: cout << "+ve particle"; break;
970 case 3: cout << "No deviation trigger"; break;
971 default: cout << "UNKNOWN"; break;
972 }
973 cout << ")]" << endl;
974
975 cout << "=========================== Local structure scalars "
976 << setw(3) << fLocNum << setw(0)
977 << " ==========================" << endl;
978 if (scalars != NULL)
979 {
980 cout << " Number of L0 triggers : " << scalars->fL0 << endl;
981 cout << " Hold (dead time) : " << scalars->fHold << endl;
982 cout << " Number of clock cycles : " << scalars->fClk << endl;
983 cout << " Number of low pT no triggers : " << scalars->fLPtNTrig << endl;
984 cout << " Number of high pT no triggers : " << scalars->fHPtNTrig << endl;
985 cout << " Number of low pT right triggers : " << scalars->fLPtRTrig << endl;
986 cout << " Number of high pT right triggers : " << scalars->fHPtRTrig << endl;
987 cout << " Number of low pT left triggers : " << scalars->fLPtLTrig << endl;
988 cout << " Number of high pT left triggers : " << scalars->fHPtLTrig << endl;
989 cout << " Number of low pT straight triggers : " << scalars->fLPtSTrig << endl;
990 cout << "Number of high pT straight triggers : " << scalars->fHPtSTrig << endl;
991
992 UInt_t xoryflag = GetLocalComptXY(scalars);
993 if (xoryflag == 1)
994 {
995 cout << "Y strip counts:" << endl;
996 }
997 else
998 {
999 cout << "X strip counts:" << endl;
1000 }
1001 cout << " | Chamber " << endl;
1002 cout << "Strip | 11 | 12 | 13 | 14" << endl;
1003 cout << "------------------------------------------" << endl;
1004 for (int i = 0; i < 16; i++)
1005 {
1006 cout << setw(5) << i << setw(0) << " "
1007 << setw(6) << (UInt_t)GetLocalXY1(scalars, i) << setw(0) << " "
1008 << setw(6) << (UInt_t)GetLocalXY2(scalars, i) << setw(0) << " "
1009 << setw(6) << (UInt_t)GetLocalXY3(scalars, i) << setw(0) << " "
1010 << setw(6) << (UInt_t)GetLocalXY4(scalars, i) << setw(0) << endl;
1011 }
1012
1013 cout << " EOS word : 0x" << setw(8) << setfill('0')
1014 << hex << scalars->fEOS << setw(0) << setfill(fillChar) << dec << endl;
1015 cout << " [ Switches : 0x" << setw(3)
1016 << setfill('0') << hex << (UInt_t)GetLocalSwitch(scalars)
1017 << setw(0) << setfill(fillChar) << dec << " (";
1018 PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 8, 2); cout << " ";
1019 PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 4, 4); cout << " ";
1020 PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 0, 4);
1021 cout << "b) ]" << endl;
1022 cout << " [ X or Y : " << xoryflag
1023 << ((xoryflag == 1) ? " (scalars for Y strips) ]" : " (scalars for X strips) ]")
1024 << endl;
1025
1026 cout << "Reset signal : " << scalars->fReset << endl;
1027 }
1028 else
1029 {
1030 cout << "(None found)" << endl;
1031 }
1032 }
1033
1034
1035 void AliTriggerDecoderHandler::OnError(ErrorCode error, const void* location)
1036 {
1037 TryDumpCorruptData(location);
1038 HandleError(
1039 ErrorCodeToMessage(error), error,
1040 ErrorCodeToString(error), location
1041 );
1042 }
887a669c 1043
1044} // end of namespace
1045
1046
a090ff22 1047int DumpRawDataHeader(
1048 const char* buffer, unsigned long bufferSize, const AliRawDataHeader* header,
1049 bool continueParse
1050 )
1051{
a8982f78 1052 // Dumps the common DDL raw data block header.
1053
a090ff22 1054 cout << "*************************** Common DDL data header *******************************" << endl;
1055 char fillChar = cout.fill(); // remember fill char to set back to original later.
1056 int result = CheckHeaderField(header->fSize, buffer, bufferSize, continueParse);
1057 if (result != EXIT_SUCCESS) return result;
1058 cout << "Size of the raw data in bytes : ";
1059 if (header->fSize != 0xFFFFFFFF)
1060 cout << header->fSize;
1061 else
1062 cout << "0xFFFFFFFF (unknown)";
1063 cout << endl;
1064
1065 result = CheckHeaderField(header->fWord2, buffer, bufferSize, continueParse);
1066 if (result != EXIT_SUCCESS) return result;
1067 cout << " Format version : " << UInt_t(header->GetVersion()) << endl;
1068 UInt_t l1msg = header->GetL1TriggerMessage();
1069 cout << " L1 trigger message : 0x"
1070 << noshowbase << hex << setfill('0') << setw(2) << l1msg
1071 << setw(0) << setfill(fillChar) << dec
1072 << " [Spare: " << ((l1msg >> 7) & 0x1)
1073 << ", ClT: " << ((l1msg >> 6) & 0x1)
1074 << ", RoC: 0x" << noshowbase << hex << ((l1msg >> 2) & 0x4) << dec
1075 << ", ESR: " << ((l1msg >> 1) & 0x1)
1076 << ", L1SwC: " << ((l1msg >> 0) & 0x1) << "]" << endl;
1077 cout << " Bunch crossing (Event ID1) : " << header->GetEventID1() << " (0x"
1078 << noshowbase << hex << setfill('0') << setw(3) << header->GetEventID1()
1079 << dec << setw(0) << setfill(fillChar) << ")" << endl;
1080
1081 result = CheckHeaderField(header->fEventID2, buffer, bufferSize, continueParse);
1082 if (result != EXIT_SUCCESS) return result;
1083 cout << " Orbit number (Event ID2) : " << header->fEventID2 << " (0x"
1084 << noshowbase << hex << setfill('0') << setw(6) << header->fEventID2
1085 << dec << setw(0) << setfill(fillChar) << ")" << endl;
1086
1087 result = CheckHeaderField(header->fAttributesSubDetectors, buffer, bufferSize, continueParse);
1088 if (result != EXIT_SUCCESS) return result;
1089 cout << " Block attributes : " << UInt_t(header->GetAttributes()) << " (0x"
1090 << noshowbase << hex << setfill('0') << setw(2) << UInt_t(header->GetAttributes())
1091 << dec << setw(0) << setfill(fillChar) << ")" << endl;
1092 cout << " Participating sub-detectors : 0x" << noshowbase << hex
1093 << setfill('0') << setw(6) << header->GetSubDetectors() << dec
1094 << setw(0) << setfill(fillChar) << " [Bits: ";
1095 for (int i = 5; i >= 0; i--)
1096 {
1097 PrintBitPattern(header->GetSubDetectors() >> (i*4), 4);
1098 if (i != 0)
1099 cout << " ";
1100 else
1101 cout << "]" << endl;
1102 }
1103
1104 result = CheckHeaderField(header->fStatusMiniEventID, buffer, bufferSize, continueParse);
1105 if (result != EXIT_SUCCESS) return result;
1106 UInt_t statusBits = header->GetStatus();
1107 cout << " Status & error bits : 0x" << noshowbase << hex
1108 << setfill('0') << setw(4) << statusBits << setw(0) << setfill(fillChar)
1109 << dec << endl;
1110 cout << " [ Reserved : " << ((statusBits >> 15) & 0x1) << " ]" << endl;
1111 cout << " [ Multi-event buffer error : " << ((statusBits >> 14) & 0x1) << " ]" << endl;
1112 cout << " [ Trigger L1 missing error : " << ((statusBits >> 13) & 0x1) << " ]" << endl;
1113 cout << " [ Trigger error (other) : " << ((statusBits >> 12) & 0x1) << " ]" << endl;
1114 cout << " [ Pre-pulse error : " << ((statusBits >> 11) & 0x1) << " ]" << endl;
1115 cout << " [ Trigger L2 time violation : " << ((statusBits >> 10) & 0x1) << " ]" << endl;
1116 cout << " [ Trigger L1 time violation : " << ((statusBits >> 9) & 0x1) << " ]" << endl;
1117 cout << " [ DDG payload flag : " << ((statusBits >> 8) & 0x1) << " ]" << endl;
1118 cout << " [ HLT payload flag : " << ((statusBits >> 7) & 0x1) << " ]" << endl;
1119 cout << " [ HLT decision flag : " << ((statusBits >> 6) & 0x1) << " ]" << endl;
1120 cout << " [ FEE error : " << ((statusBits >> 5) & 0x1) << " ]" << endl;
1121 cout << " [ Trigger information unavailable : " << ((statusBits >> 4) & 0x1) << " ]" << endl;
1122 cout << " [ Control parity error : " << ((statusBits >> 3) & 0x1) << " ]" << endl;
1123 cout << " [ Data parity error : " << ((statusBits >> 2) & 0x1) << " ]" << endl;
1124 cout << " [ Trigger missing error : " << ((statusBits >> 1) & 0x1) << " ]" << endl;
1125 cout << " [ Trigger overlap error : " << ((statusBits >> 0) & 0x1) << " ]" << endl;
1126 cout << " Mini event ID : " << header->GetMiniEventID() << " (0x"
1127 << noshowbase << hex << setfill('0') << setw(3) << header->GetMiniEventID()
1128 << dec << setw(0) << setfill(fillChar) << ")" << endl;
1129
1130 result = CheckHeaderField(header->fTriggerClassLow, buffer, bufferSize, continueParse);
1131 if (result != EXIT_SUCCESS) return result;
1132 result = CheckHeaderField(header->fROILowTriggerClassHigh, buffer, bufferSize, continueParse);
1133 if (result != EXIT_SUCCESS) return result;
1134 ULong64_t triggerClasses = header->GetTriggerClasses();
1135 cout << " Trigger classes : 0x" << noshowbase << hex << setw(13)
1136 << setfill('0') << triggerClasses << setw(0) << setfill(fillChar)
1137 << dec << endl;
1138 cout << " [Bits: ";
1139 PrintBitPattern(triggerClasses >> (12*4), 2);
1140 cout << " ";
1141 for (int i = 11; i >= 0; i--)
1142 {
1143 PrintBitPattern(triggerClasses >> (i*4), 4);
1144 if (i != 0)
1145 cout << " ";
1146 else
1147 cout << "]" << endl;
1148 }
1149
1150 result = CheckHeaderField(header->fROIHigh, buffer, bufferSize, continueParse);
1151 if (result != EXIT_SUCCESS) return result;
1152 ULong64_t roiBits = header->GetROI();
1153 cout << " Region of interest : 0x" << noshowbase << hex << setw(9)
1154 << setfill('0') << roiBits << setw(0) << setfill(fillChar)
1155 << dec << endl;
1156 cout << " [Bits: ";
1157 for (int i = 8; i >= 0; i--)
1158 {
1159 PrintBitPattern(roiBits >> (i*4), 4);
1160 if (i != 0)
1161 cout << " ";
1162 else
1163 cout << "]" << endl;
1164 }
1165 cout << "**********************************************************************************" <<endl;
1166 return EXIT_SUCCESS;
1167}
1168
1169
887a669c 1170int DumpTrackerDDLRawStream(
daab896b 1171 char* buffer, unsigned long bufferSize,
1172 bool continueParse, bool tryrecover
887a669c 1173 )
1174{
a8982f78 1175 // Dumps a tracker DDL raw stream data.
1176
daab896b 1177 AliRawDataHeader* header = reinterpret_cast<AliRawDataHeader*>(buffer);
a090ff22 1178 int result = DumpRawDataHeader(buffer, bufferSize, header, continueParse);
1179 if (result != EXIT_SUCCESS) return result;
887a669c 1180
1181 // Setup the decoder for the DDL payload.
1182 AliMUONTrackerDDLDecoder<AliTrackerDecoderHandler> decoder;
1183 decoder.ExitOnError(not continueParse);
a090ff22 1184 decoder.SendDataOnParityError(true);
daab896b 1185 decoder.TryRecover(tryrecover);
887a669c 1186 decoder.AutoDetectTrailer(true);
1187 decoder.CheckForTrailer(true);
daab896b 1188 char* payload = buffer + sizeof(AliRawDataHeader);
887a669c 1189 UInt_t payloadSize = bufferSize - sizeof(AliRawDataHeader);
1190 if (decoder.Decode(payload, payloadSize))
1191 {
1192 return EXIT_SUCCESS;
1193 }
1194 else
1195 {
1196 return PARSE_ERROR;
1197 }
1198}
1199
1200
1201int DumpTriggerDDLRawStream(
1202 const char* buffer, unsigned long bufferSize,
daab896b 1203 bool continueParse, bool tryrecover
887a669c 1204 )
1205{
a8982f78 1206 // Dumps a trigger DDL raw stream data.
1207
887a669c 1208 const AliRawDataHeader* header =
1209 reinterpret_cast<const AliRawDataHeader*>(buffer);
a090ff22 1210 int result = DumpRawDataHeader(buffer, bufferSize, header, continueParse);
1211 if(result != EXIT_SUCCESS) return result;
1212 bool scalarEvent = ((header->GetL1TriggerMessage() & 0x1) == 0x1);
887a669c 1213
1214 AliMUONTriggerDDLDecoder<AliTriggerDecoderHandler> decoder;
1215 decoder.ExitOnError(not continueParse);
daab896b 1216 decoder.TryRecover(tryrecover);
887a669c 1217 decoder.AutoDetectScalars(false);
1218 const char* payload = buffer + sizeof(AliRawDataHeader);
1219 UInt_t payloadSize = bufferSize - sizeof(AliRawDataHeader);
1220 if (decoder.Decode(payload, payloadSize, scalarEvent))
1221 {
1222 return EXIT_SUCCESS;
1223 }
1224 else
1225 {
1226 return PARSE_ERROR;
1227 }
1228}
1229
1230
a68bc1e6 1231int DumpRecHitStruct(
3dad52b0 1232 const char* buffer, unsigned long bufferSize,
a68bc1e6 1233 const AliHLTMUONRecHitStruct* hit,
3dad52b0 1234 bool continueParse
1235 )
1236{
a68bc1e6 1237 // Step through the fields trying to print them.
1238 // At each step check if we have not overflowed the buffer. If we have
1239 // not, then we can print the field, otherwise we print the left over
1240 // bytes assumed to be corrupted rubbish.
a090ff22 1241
1242 int result = CheckField(hit->fFlags, buffer, bufferSize, continueParse);
1243 if (result != EXIT_SUCCESS) return result;
1244 AliHLTUInt8_t chamber = 0xFF;
1245 AliHLTUInt16_t detElemId = 0xFFFF;
1246 AliHLTMUONUtils::UnpackRecHitFlags(hit->fFlags, chamber, detElemId);
1247 if (chamber == 0 and detElemId == 0)
1248 {
1249 cout << setw(10) << left << (int)(chamber) << setw(0);
1250 cout << setw(12) << left << (int)detElemId << setw(0);
1251 }
1252 else
1253 {
1254 cout << setw(10) << left << (int)(chamber+1) << setw(0);
1255 cout << setw(12) << left << (int)detElemId << setw(0);
1256 }
1257
1258 result = CheckField(hit->fX, buffer, bufferSize, continueParse);
a68bc1e6 1259 if (result != EXIT_SUCCESS) return result;
1260 cout << setw(13) << left << hit->fX << setw(0);
1261
1262 result = CheckField(hit->fY, buffer, bufferSize, continueParse);
1263 if (result != EXIT_SUCCESS) return result;
1264 cout << setw(13) << left << hit->fY << setw(0);
1265
1266 result = CheckField(hit->fZ, buffer, bufferSize, continueParse);
1267 if (result != EXIT_SUCCESS) return result;
1268 cout << hit->fZ << setw(0) << endl;
1269
1270 return result;
3dad52b0 1271}
1272
1273
a68bc1e6 1274int DumpRecHitsBlock(
3dad52b0 1275 const char* buffer, unsigned long bufferSize,
1276 bool continueParse
1277 )
1278{
a8982f78 1279 // Dumps a reconstructed hits data block.
1280
a68bc1e6 1281 int result = EXIT_SUCCESS;
1282 AliHLTMUONRecHitsBlockReader block(buffer, bufferSize);
1283
1284 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1285 if (result != EXIT_SUCCESS and not continueParse) return result;
1286
1287 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1288
1289 // Print the data block record entries.
a090ff22 1290 cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl;
1291 cout << "-----------------------------------------------------------" << endl;
a68bc1e6 1292 const AliHLTMUONRecHitStruct* entry = block.GetArray();
1293 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1294 {
1295 int subResult = DumpRecHitStruct(buffer, bufferSize, entry++, continueParse);
1296 if (subResult != EXIT_SUCCESS) return subResult;
1297 }
1298
1299 return result;
3dad52b0 1300}
1301
1302
a68bc1e6 1303int DumpTriggerRecordStruct(
dba14d7d 1304 const char* buffer, unsigned long bufferSize,
1305 const AliHLTMUONTriggerRecordStruct* record,
1306 bool continueParse
1307 )
a68bc1e6 1308{
1309 // Step through the fields trying to print them.
1310 // At each step check if we have not overflowed the buffer. If we have
1311 // not, then we can print the field, otherwise we print the left over
1312 // bytes assumed to be corrupted rubbish.
1313 int result = CheckField(record->fId, buffer, bufferSize, continueParse);
1314 if (result != EXIT_SUCCESS) return result;
1315 cout << "Trigger Record ID: " << record->fId <<endl;
1316
1317 result = CheckField(record->fFlags, buffer, bufferSize, continueParse);
1318 if (result != EXIT_SUCCESS) return result;
1319 cout << "Flags: " << showbase << hex << record->fFlags << dec;
1320
1321 // Print the individual trigger bits.
1322 AliHLTMUONParticleSign sign;
1323 bool hitset[4];
1324 AliHLTMUONUtils::UnpackTriggerRecordFlags(record->fFlags, sign, hitset);
1325 cout << " [Sign: " << sign << ", Hits set on chambers: ";
1326 bool first = true;
1327 for (AliHLTUInt32_t i = 0; i < 4; i++)
1328 {
1329 if (hitset[i])
1330 {
1331 cout << (first ? "" : ", ") << i+11;
1332 first = false;
1333 }
1334 }
1335 cout << (first ? "none]" : "]") << endl;
1336
1337 result = CheckField(record->fPx, buffer, bufferSize, continueParse);
1338 if (result != EXIT_SUCCESS) return result;
1339 cout << "Momentum: (px = " << record->fPx << ", ";
1340
1341 result = CheckField(record->fPy, buffer, bufferSize, continueParse);
1342 if (result != EXIT_SUCCESS) return result;
1343 cout << "py = " << record->fPy << ", ";
1344
1345 result = CheckField(record->fPz, buffer, bufferSize, continueParse);
1346 if (result != EXIT_SUCCESS) return result;
1347 cout << "pz = " << record->fPz << ") GeV/c"<<endl;
1348
a090ff22 1349 cout << "Hits on chambers:" << endl;
1350 cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl;
1351 cout << "-----------------------------------------------------------" << endl;
a68bc1e6 1352 const AliHLTMUONRecHitStruct* hit = &record->fHit[0];
1353 for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
1354 {
a68bc1e6 1355 result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse);
1356 if (result != EXIT_SUCCESS) return result;
1357 }
1358
1359 return result;
1360
1361}
1362
1363
1364int DumpTriggerRecordsBlock(
3dad52b0 1365 const char* buffer, unsigned long bufferSize,
1366 bool continueParse
1367 )
1368{
a8982f78 1369 // Dumps a trigger records data block.
1370
a68bc1e6 1371 AliHLTMUONTriggerRecordsBlockReader block(buffer, bufferSize);
1372
1373 int result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1374 if (result != EXIT_SUCCESS and not continueParse) return result;
1375
1376 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1377
1378 // Print the data block record entries.
1379 const AliHLTMUONTriggerRecordStruct* entry = block.GetArray();
1380 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1381 {
1382 cout << "============================== Trigger Record number " << i+1
1383 << " of " << nentries << " ==============================" << endl;
1384 int subResult = DumpTriggerRecordStruct(buffer, bufferSize, entry++, continueParse);
1385 if (subResult != EXIT_SUCCESS) return subResult;
1386 }
1387
3dad52b0 1388 return EXIT_SUCCESS;
1389}
1390
1391
462e3880 1392int DumpLocalStruct(
1393 const char* buffer, unsigned long bufferSize,
1394 const AliMUONLocalInfoStruct* localStruct,
1395 bool continueParse,
1396 const char* title = ""
1397 )
1398{
1399 // Prints the fields of a L0 local structure as found in the buffer.
1400
1401 typedef AliMUONTriggerDDLDecoderEventHandler AliH;
1402
1403 cout << "L0 strip patterns" << title << ":" << endl;
1404 cout << "Chamber | X | Y " << endl;
1405 cout << "----------------------------------------------" << endl;
1406 int result = CheckField(localStruct->fX2X1, buffer, bufferSize, continueParse);
1407 if (result != EXIT_SUCCESS) return result;
1408 cout << " 11 ";
1409 PrintBitPattern(AliH::GetLocalX1(localStruct), 16);
1410 result = CheckField(localStruct->fY2Y1, buffer, bufferSize, continueParse);
1411 if (result != EXIT_SUCCESS) return result;
1412 cout << " ";
1413 PrintBitPattern(AliH::GetLocalY1(localStruct), 16);
1414 cout << endl;
1415 cout << " 12 ";
1416 PrintBitPattern(AliH::GetLocalX2(localStruct), 16);
1417 cout << " ";
1418 PrintBitPattern(AliH::GetLocalY2(localStruct), 16);
1419 cout << endl;
1420
1421 result = CheckField(localStruct->fX4X3, buffer, bufferSize, continueParse);
1422 if (result != EXIT_SUCCESS) return result;
1423 cout << " 13 ";
1424 PrintBitPattern(AliH::GetLocalX3(localStruct), 16);
1425 result = CheckField(localStruct->fY4Y3, buffer, bufferSize, continueParse);
1426 if (result != EXIT_SUCCESS) return result;
1427 cout << " ";
1428 PrintBitPattern(AliH::GetLocalY3(localStruct), 16);
1429 cout << endl;
1430 cout << " 12 ";
1431 PrintBitPattern(AliH::GetLocalX4(localStruct), 16);
1432 cout << " ";
1433 PrintBitPattern(AliH::GetLocalY4(localStruct), 16);
1434 cout << endl;
1435
1436 cout << "L0 trigger bits" << title << ": (word = ";
1437 result = CheckField(localStruct->fTriggerBits, buffer, bufferSize, continueParse);
1438 if (result != EXIT_SUCCESS) return result;
1439 cout << showbase << hex << localStruct->fTriggerBits
1440 << noshowbase << dec << ")" << endl;
1441 cout << " ID | Dec | TrigY | YPos | Sign XDev | XDev | XPos " << endl;
1442 cout << "------------------------------------------------------" << endl;
1443 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalId(localStruct)), 4);
1444 cout << " ";
1445 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalDec(localStruct)), 4);
1446 cout << " ";
1447 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalTrigY(localStruct)), 1);
1448 cout << " ";
1449 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalYPos(localStruct)), 4);
1450 cout << " ";
1451 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalSXDev(localStruct)), 1);
1452 cout << " ";
1453 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalXDev(localStruct)), 4);
1454 cout << " ";
1455 PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalXPos(localStruct)), 5);
1456 cout << endl;
1457
1458 return result;
1459}
1460
1461
dba14d7d 1462int DumpTrigRecInfoStruct(
1463 const char* buffer, unsigned long bufferSize,
1464 const AliHLTMUONTrigRecInfoStruct* debuginfo,
1465 bool continueParse
1466 )
a68bc1e6 1467{
1468 // Step through the fields trying to print them.
1469 // At each step check if we have not overflowed the buffer. If we have
1470 // not, then we can print the field, otherwise we print the left over
1471 // bytes assumed to be corrupted rubbish.
a090ff22 1472
a68bc1e6 1473 int result = CheckField(debuginfo->fTrigRecId, buffer, bufferSize, continueParse);
1474 if (result != EXIT_SUCCESS) return result;
a090ff22 1475 cout << "Trigger Record ID: " << debuginfo->fTrigRecId << endl;
a68bc1e6 1476
a090ff22 1477 cout << "Detector element IDs:" << endl;
1478 cout << " Chamber : 11 | 12 | 13 | 14" << endl;
1479 cout << " ID : ";
1480 for (int i = 0; i < 4; i++)
1481 {
1482 result = CheckField(debuginfo->fDetElemId[i], buffer, bufferSize, continueParse);
1483 if (result != EXIT_SUCCESS) return result;
1484 cout << setw(12) << right << debuginfo->fDetElemId[i] << setw(0);
1485 if (i != 3) cout << " | ";
1486 }
1487 cout << endl;
1488
1489 cout << "Momentum estimation parameters:" << endl;
1490 cout << " Parameter : Z_middle coordinate (cm) | Integrated magnetic field (T.m)" << endl;
1491 cout << " Value : ";
a68bc1e6 1492 result = CheckField(debuginfo->fZmiddle, buffer, bufferSize, continueParse);
1493 if(result != EXIT_SUCCESS) return result;
a090ff22 1494 cout << setw(24) << right << debuginfo->fZmiddle << setw(0) << " | ";
1495
a68bc1e6 1496 result = CheckField(debuginfo->fBl, buffer, bufferSize, continueParse);
1497 if (result != EXIT_SUCCESS) return result;
a090ff22 1498 cout << setw(31) << right << debuginfo->fBl << setw(0) << endl;
1499
462e3880 1500 result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0Struct, continueParse, " for central local structure");
a090ff22 1501 if (result != EXIT_SUCCESS) return result;
462e3880 1502 result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0StructPrev, continueParse, " for previous local structure");
a090ff22 1503 if (result != EXIT_SUCCESS) return result;
462e3880 1504 result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0StructNext, continueParse, " for next local structure");
a090ff22 1505 if (result != EXIT_SUCCESS) return result;
a090ff22 1506
a68bc1e6 1507 return result;
1508}
1509
1510
1511int DumpTrigRecsDebugBlock(
3dad52b0 1512 const char* buffer, unsigned long bufferSize,
3dad52b0 1513 bool continueParse
1514 )
a68bc1e6 1515{
a8982f78 1516 // Dumps the debugging information for trigger records.
1517
a68bc1e6 1518 AliHLTMUONTrigRecsDebugBlockReader block(buffer, bufferSize);
1519
1520 int result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1521 if (result != EXIT_SUCCESS and not continueParse) return result;
1522
1523 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1524
1525 // Print the data block record entries.
a68bc1e6 1526 const AliHLTMUONTrigRecInfoStruct* entry = block.GetArray();
1527 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1528 {
3d3c03a0 1529 cout << "======================= Trigger Record debug data " << i+1
1530 << " of " << nentries << " =======================" << endl;
a68bc1e6 1531 int subResult = DumpTrigRecInfoStruct(buffer, bufferSize, entry++, continueParse);
1532 if (subResult != EXIT_SUCCESS) return subResult;
1533 }
1534
1535 return EXIT_SUCCESS;
1536}
1537
1538
a68bc1e6 1539int DumpClusterStruct(
dba14d7d 1540 const char* buffer, unsigned long bufferSize,
1541 const AliHLTMUONClusterStruct* cluster,
1542 bool continueParse
1543 )
a68bc1e6 1544{
1545 // Step through the fields trying to print them.
1546 // At each step check if we have not overflowed the buffer. If we have
1547 // not, then we can print the field, otherwise we print the left over
1548 // bytes assumed to be corrupted rubbish.
1549 int result = CheckField(cluster->fId, buffer, bufferSize, continueParse);
1550 if (result != EXIT_SUCCESS) return result;
66622a82 1551 cout << " Cluster ID: " << cluster->fId << endl;
a68bc1e6 1552
1553 result = CheckField(cluster->fDetElemId, buffer, bufferSize, continueParse);
1554 if (result != EXIT_SUCCESS) return result;
66622a82 1555 cout << " Detector Element ID: " << cluster->fDetElemId << endl;
a68bc1e6 1556
66622a82 1557 result = CheckField(cluster->fNchannelsB, buffer, bufferSize, continueParse);
83d66053 1558 if (result != EXIT_SUCCESS) return result;
66622a82 1559 cout << " Number of channels in bending plane: " << cluster->fNchannelsB << endl;
1560
1561 result = CheckField(cluster->fNchannelsNB, buffer, bufferSize, continueParse);
1562 if (result != EXIT_SUCCESS) return result;
1563 cout << "Number of channels in non-bending plane: " << cluster->fNchannelsNB << endl;
83d66053 1564
66622a82 1565 result = CheckField(cluster->fChargeB, buffer, bufferSize, continueParse);
1566 if (result != EXIT_SUCCESS) return result;
1567 cout << " Charge on bending plane: " << cluster->fChargeB << endl;
1568
1569 result = CheckField(cluster->fChargeNB, buffer, bufferSize, continueParse);
83d66053 1570 if (result != EXIT_SUCCESS) return result;
66622a82 1571 cout << " Charge on non bending plane: " << cluster->fChargeNB << endl;
a68bc1e6 1572
a090ff22 1573 cout << "Corresponding Hit: "<< endl;
1574 cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl;
1575 cout << "-----------------------------------------------------------" << endl;
1576 result = DumpRecHitStruct(buffer, bufferSize, &cluster->fHit, continueParse);
a68bc1e6 1577
3dad52b0 1578 return result;
1579}
1580
1581
1582int DumpClustersBlock(
1583 const char* buffer, unsigned long bufferSize,
1584 bool continueParse
1585 )
1586{
a8982f78 1587 // Dumps a clusters block structure.
1588
a68bc1e6 1589 int result = EXIT_SUCCESS;
3dad52b0 1590 AliHLTMUONClustersBlockReader block(buffer, bufferSize);
a68bc1e6 1591
1592 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1593 if (result != EXIT_SUCCESS and not continueParse) return result;
1594
1595 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1596
1597 // Print the data block record entries.
1598 const AliHLTMUONClusterStruct* entry = block.GetArray();
1599 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1600 {
3d3c03a0 1601 cout << "======================= Cluster Number "
1602 << i+1 << " =======================" << endl;
a68bc1e6 1603 int subResult = DumpClusterStruct(buffer, bufferSize, entry++, continueParse);
1604 if (subResult != EXIT_SUCCESS) return subResult;
1605 }
1606
1607 return result;
1608}
1609
1610
1611int DumpChannelStruct(
dba14d7d 1612 const char* buffer, unsigned long bufferSize,
1613 const AliHLTMUONChannelStruct* channel,
1614 bool continueParse
1615 )
a68bc1e6 1616{
1617 // Step through the fields trying to print them.
1618 // At each step check if we have not overflowed the buffer. If we have
1619 // not, then we can print the field, otherwise we print the left over
1620 // bytes assumed to be corrupted rubbish.
1621 int result = CheckField(channel->fClusterId, buffer, bufferSize, continueParse);
1622 if (result != EXIT_SUCCESS) return result;
1623 cout << setw(16) << left << channel->fClusterId << setw(0);
1624
dba14d7d 1625 result = CheckField(channel->fBusPatch, buffer, bufferSize, continueParse);
1626 if (result != EXIT_SUCCESS) return result;
1627 cout << setw(16) << left << channel->fBusPatch << setw(0);
1628
a68bc1e6 1629 result = CheckField(channel->fManu, buffer, bufferSize, continueParse);
1630 if (result != EXIT_SUCCESS) return result;
1631 cout << setw(16) << left << channel->fManu << setw(0);
1632
1633 result = CheckField(channel->fChannelAddress, buffer, bufferSize, continueParse);
1634 if (result != EXIT_SUCCESS) return result;
dba14d7d 1635 cout << setw(16) << left << channel->fChannelAddress << setw(0);
a68bc1e6 1636
1637 result = CheckField(channel->fSignal, buffer, bufferSize, continueParse);
1638 if(result != EXIT_SUCCESS) return result;
1639 cout << setw(16) << left << channel->fSignal << setw(0);
1640
1641 result = CheckField(channel->fRawDataWord, buffer, bufferSize, continueParse);
1642 if(result != EXIT_SUCCESS) return result;
1643 cout << showbase << hex << channel->fRawDataWord << dec << setw(0) <<endl;
1644
1645 return result;
3dad52b0 1646}
1647
1648
1649int DumpChannelsBlock(
1650 const char* buffer, unsigned long bufferSize,
1651 bool continueParse
1652 )
1653{
a8982f78 1654 // Dumps a channels block structure.
1655
a68bc1e6 1656 int result = EXIT_SUCCESS;
3dad52b0 1657 AliHLTMUONChannelsBlockReader block(buffer, bufferSize);
a68bc1e6 1658
1659 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1660 if (result != EXIT_SUCCESS and not continueParse) return result;
1661
1662 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1663
1664 // Print the data block record entries.
a090ff22 1665 cout << "Cluster ID | Bus Patch | Manu Address | Channel Addr | Signal Value | Raw Data Word " << endl;
dba14d7d 1666 cout << "----------------------------------------------------------------------------------------------" << endl;
a68bc1e6 1667 const AliHLTMUONChannelStruct* entry = block.GetArray();
1668 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1669 {
1670 int subResult = DumpChannelStruct(buffer, bufferSize, entry++, continueParse);
1671 if (subResult != EXIT_SUCCESS) return subResult;
1672 }
3dad52b0 1673 return EXIT_SUCCESS;
1674}
1675
1676
1677int DumpMansoTrackStruct(
1678 const char* buffer, unsigned long bufferSize,
1679 const AliHLTMUONMansoTrackStruct* track,
1680 bool continueParse
1681 )
1682{
1683 // Step through the fields trying to print them.
1684 // At each step check if we have not overflowed the buffer. If we have
1685 // not, then we can print the field, otherwise we print the left over
1686 // bytes assumed to be corrupted rubbish.
1687 int result = CheckField(track->fId, buffer, bufferSize, continueParse);
1688 if (result != EXIT_SUCCESS) return result;
1689 cout << "Track ID: " << track->fId << "\t";
1690
1691 result = CheckField(track->fTrigRec, buffer, bufferSize, continueParse);
1692 if (result != EXIT_SUCCESS) return result;
1693 cout << "Trigger Record ID: " << track->fTrigRec << endl;
1694
1695 result = CheckField(track->fFlags, buffer, bufferSize, continueParse);
1696 if (result != EXIT_SUCCESS) return result;
1697 cout << "Flags: " << showbase << hex << track->fFlags << dec;
a68bc1e6 1698
3dad52b0 1699 // Print the individual trigger bits.
1700 AliHLTMUONParticleSign sign;
1701 bool hitset[4];
1702 AliHLTMUONUtils::UnpackMansoTrackFlags(track->fFlags, sign, hitset);
1703 cout << " [Sign: " << sign << ", Hits set on chambers: ";
1704 bool first = true;
1705 for (AliHLTUInt32_t i = 0; i < 4; i++)
1706 {
1707 if (hitset[i])
1708 {
1709 cout << (first ? "" : ", ") << i+7;
1710 first = false;
1711 }
1712 }
1713 cout << (first ? "none]" : "]") << endl;
1714
1715 result = CheckField(track->fPx, buffer, bufferSize, continueParse);
1716 if (result != EXIT_SUCCESS) return result;
1717 cout << "Momentum: (px = " << track->fPx << ", ";
1718
1719 result = CheckField(track->fPy, buffer, bufferSize, continueParse);
1720 if (result != EXIT_SUCCESS) return result;
1721 cout << "py = " << track->fPy << ", ";
1722
1723 result = CheckField(track->fPz, buffer, bufferSize, continueParse);
1724 if (result != EXIT_SUCCESS) return result;
1725 cout << "pz = " << track->fPz << ") GeV/c\t";
1726
1727 result = CheckField(track->fChi2, buffer, bufferSize, continueParse);
1728 if (result != EXIT_SUCCESS) return result;
1729 cout << "Chi squared fit: " << track->fChi2 << endl;
1730
1731 cout << "Track hits:" << endl;
a090ff22 1732 cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl;
1733 cout << "-----------------------------------------------------------" << endl;
3dad52b0 1734 const AliHLTMUONRecHitStruct* hit = &track->fHit[0];
1735 for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
1736 {
3dad52b0 1737 result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse);
1738 if (result != EXIT_SUCCESS) return result;
1739 }
1740
1741 return result;
1742}
1743
1744
1745int DumpMansoTracksBlock(
1746 const char* buffer, unsigned long bufferSize,
1747 bool continueParse
1748 )
1749{
a8982f78 1750 // Dumps the Manso tracks block structure.
1751
3dad52b0 1752 int result = EXIT_SUCCESS;
1753 AliHLTMUONMansoTracksBlockReader block(buffer, bufferSize);
1754
1755 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1756 if (result != EXIT_SUCCESS and not continueParse) return result;
1757
1758 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1759
1760 // Print the data block record entries.
1761 const AliHLTMUONMansoTrackStruct* entry = block.GetArray();
1762 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1763 {
1764 cout << "============================== Manso track number " << i+1
1765 << " of " << nentries << " ==============================" << endl;
1766 int subResult = DumpMansoTrackStruct(buffer, bufferSize, entry++, continueParse);
1767 if (subResult != EXIT_SUCCESS) return subResult;
1768 }
1769
1770 return result;
1771}
1772
1773
1774int DumpMansoRoIStruct(
1775 const char* buffer, unsigned long bufferSize,
1776 const AliHLTMUONMansoRoIStruct* roi,
1777 bool continueParse
1778 )
1779{
1780 // Step through the fields trying to print them.
1781 // At each step check if we have not overflowed the buffer. If we have
1782 // not, then we can print the field, otherwise we print the left over
1783 // bytes assumed to be corrupted rubbish.
1784 int result = CheckField(roi->fX, buffer, bufferSize, continueParse);
1785 if (result != EXIT_SUCCESS) return result;
1786 cout << setw(13) << left << roi->fX << setw(0);
1787
1788 result = CheckField(roi->fY, buffer, bufferSize, continueParse);
1789 if (result != EXIT_SUCCESS) return result;
1790 cout << setw(13) << left << roi->fY << setw(0);
1791
1792 result = CheckField(roi->fZ, buffer, bufferSize, continueParse);
1793 if (result != EXIT_SUCCESS) return result;
1794 cout << setw(13) << left << roi->fZ << setw(0);
1795
1796 result = CheckField(roi->fRadius, buffer, bufferSize, continueParse);
1797 if (result != EXIT_SUCCESS) return result;
1798 cout << roi->fRadius << setw(0) << endl;
1799
1800 return result;
1801}
1802
1803
1804int DumpMansoCandidateStruct(
1805 const char* buffer, unsigned long bufferSize,
1806 const AliHLTMUONMansoCandidateStruct* candidate,
1807 bool continueParse
1808 )
1809{
a8982f78 1810 // Dumps the manso candidate structure.
1811
3dad52b0 1812 int result = DumpMansoTrackStruct(buffer, bufferSize, &candidate->fTrack, continueParse);
1813 if (result != EXIT_SUCCESS) return result;
1814
1815 cout << "Regions of interest:" << endl;
1816 cout << "Chamber | X (cm) | Y (cm) | Z (cm) | Radius (cm)" << endl;
1817 cout << "-------------------------------------------------------------" << endl;
1818 const AliHLTMUONMansoRoIStruct* roi = &candidate->fRoI[0];
1819 for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
1820 {
1821 cout << setw(10) << ch + 7;
1822 result = DumpMansoRoIStruct(buffer, bufferSize, roi++, continueParse);
1823 if (result != EXIT_SUCCESS) return result;
1824 }
a090ff22 1825
1826 cout << "Momentum estimation parameters:" << endl;
1827 cout << " Parameter : Z_middle coordinate (cm) | Integrated magnetic field (T.m)" << endl;
1828 cout << " Value : ";
1829 result = CheckField(candidate->fZmiddle, buffer, bufferSize, continueParse);
1830 if(result != EXIT_SUCCESS) return result;
1831 cout << setw(24) << right << candidate->fZmiddle << setw(0) << " | ";
1832
1833 result = CheckField(candidate->fBl, buffer, bufferSize, continueParse);
1834 if (result != EXIT_SUCCESS) return result;
1835 cout << setw(31) << right << candidate->fBl << setw(0) << endl;
1836
3dad52b0 1837 return result;
1838}
1839
1840
1841int DumpMansoCandidatesBlock(
1842 const char* buffer, unsigned long bufferSize,
1843 bool continueParse
1844 )
1845{
a8982f78 1846 // Dumps the manso candidates block structure.
1847
3dad52b0 1848 int result = EXIT_SUCCESS;
1849 AliHLTMUONMansoCandidatesBlockReader block(buffer, bufferSize);
1850
1851 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1852 if (result != EXIT_SUCCESS and not continueParse) return result;
1853
1854 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1855
1856 // Print the data block record entries.
1857 const AliHLTMUONMansoCandidateStruct* entry = block.GetArray();
1858 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1859 {
1860 cout << "=========================== Manso track candidate number " << i+1
1861 << " of " << nentries << " ===========================" << endl;
1862 int subResult = DumpMansoCandidateStruct(buffer, bufferSize, entry++, continueParse);
1863 if (subResult != EXIT_SUCCESS) return subResult;
1864 }
1865
1866 return result;
1867}
1868
1869
a8982f78 1870int DumpTrackStruct(
1871 const char* buffer, unsigned long bufferSize,
1872 const AliHLTMUONTrackStruct* track,
1873 bool continueParse
1874 )
1875{
1876 // Step through the fields trying to print them.
1877 // At each step check if we have not overflowed the buffer. If we have
1878 // not, then we can print the field, otherwise we print the left over
1879 // bytes assumed to be corrupted rubbish.
1880 int result = CheckField(track->fId, buffer, bufferSize, continueParse);
1881 if (result != EXIT_SUCCESS) return result;
1882 cout << "Track ID: " << track->fId << "\t";
1883
1884 result = CheckField(track->fTrigRec, buffer, bufferSize, continueParse);
1885 if (result != EXIT_SUCCESS) return result;
1886 cout << "Trigger Record ID: " << track->fTrigRec << endl;
1887
1888 result = CheckField(track->fFlags, buffer, bufferSize, continueParse);
1889 if (result != EXIT_SUCCESS) return result;
1890 cout << "Flags: " << showbase << hex << track->fFlags << dec;
1891
1892 // Print the individual trigger bits.
1893 AliHLTMUONParticleSign sign;
1894 bool hitset[16];
1895 AliHLTMUONUtils::UnpackTrackFlags(track->fFlags, sign, hitset);
1896 cout << " [Sign: " << sign << ", Hits set: ";
1897 bool first = true;
1898 for (AliHLTUInt32_t i = 0; i < 16; i++)
1899 {
1900 if (hitset[i])
1901 {
1902 cout << (first ? "" : ", ") << i;
1903 first = false;
1904 }
1905 }
1906 cout << (first ? "none]" : "]") << endl;
1907
1908 result = CheckField(track->fPx, buffer, bufferSize, continueParse);
1909 if (result != EXIT_SUCCESS) return result;
1910 cout << "Momentum: (px = " << track->fPx << ", ";
1911
1912 result = CheckField(track->fPy, buffer, bufferSize, continueParse);
1913 if (result != EXIT_SUCCESS) return result;
1914 cout << "py = " << track->fPy << ", ";
1915
1916 result = CheckField(track->fPz, buffer, bufferSize, continueParse);
1917 if (result != EXIT_SUCCESS) return result;
1918 cout << "pz = " << track->fPz << ") GeV/c" << endl;
1919
1920 result = CheckField(track->fInverseBendingMomentum, buffer, bufferSize, continueParse);
1921 if (result != EXIT_SUCCESS) return result;
1922 cout << "Inverse bending momentum: " << track->fInverseBendingMomentum << " c/GeV" << endl;
1923
1924 result = CheckField(track->fThetaX, buffer, bufferSize, continueParse);
1925 if (result != EXIT_SUCCESS) return result;
1926 cout << "Slope: (non-bending plane = " << track->fThetaX << ", ";
1927
1928 result = CheckField(track->fThetaY, buffer, bufferSize, continueParse);
1929 if (result != EXIT_SUCCESS) return result;
1930 cout << "bending plane = " << track->fThetaY << ")" << endl;
1931
1932 result = CheckField(track->fX, buffer, bufferSize, continueParse);
1933 if (result != EXIT_SUCCESS) return result;
1934 cout << "DCA vertex: (x = " << track->fX << ", ";
1935
1936 result = CheckField(track->fY, buffer, bufferSize, continueParse);
1937 if (result != EXIT_SUCCESS) return result;
1938 cout << "y = " << track->fY << ", ";
1939
1940 result = CheckField(track->fZ, buffer, bufferSize, continueParse);
1941 if (result != EXIT_SUCCESS) return result;
1942 cout << "z = " << track->fZ << ") cm" << endl;
1943
1944 result = CheckField(track->fChi2, buffer, bufferSize, continueParse);
1945 if (result != EXIT_SUCCESS) return result;
1946 cout << "Chi squared fit: " << track->fChi2 << endl;
1947
1948 cout << "Track hits:" << endl;
1949 cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl;
1950 cout << "-----------------------------------------------------------" << endl;
1951 const AliHLTMUONRecHitStruct* hit = &track->fHit[0];
1952 for(AliHLTUInt32_t ch = 0; ch < 16; ch++)
1953 {
1954 result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse);
1955 if (result != EXIT_SUCCESS) return result;
1956 }
1957
1958 return result;
1959}
1960
1961
1962int DumpTracksBlock(
1963 const char* buffer, unsigned long bufferSize,
1964 bool continueParse
1965 )
1966{
1967 // Dumps the full tracks block structure.
1968
1969 int result = EXIT_SUCCESS;
1970 AliHLTMUONTracksBlockReader block(buffer, bufferSize);
1971
1972 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
1973 if (result != EXIT_SUCCESS and not continueParse) return result;
1974
1975 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
1976
1977 // Print the data block record entries.
1978 const AliHLTMUONTrackStruct* entry = block.GetArray();
1979 for(AliHLTUInt32_t i = 0; i < nentries; i++)
1980 {
1981 cout << "================================ track number " << i+1
1982 << " of " << nentries << " ================================" << endl;
1983 int subResult = DumpTrackStruct(buffer, bufferSize, entry++, continueParse);
1984 if (subResult != EXIT_SUCCESS) return subResult;
1985 }
1986
1987 return result;
1988}
1989
1990
3dad52b0 1991int DumpSinglesDecisionBlockHeader(
1992 const char* buffer, unsigned long bufferSize,
1993 const AliHLTMUONSinglesDecisionBlockStruct* header,
1994 bool continueParse
1995 )
1996{
1997 // Step through the header fields trying to print them.
1998 // At each step check if we have not overflowed the buffer, if we have
1999 // not then we can print the field, otherwise we print the left over
2000 // bytes assumed to be corrupted rubbish.
2001 int result = CheckHeaderField(header->fNlowPt, buffer, bufferSize, continueParse);
2002 if (result != EXIT_SUCCESS) return result;
2003 cout << " Number of low pt triggers: " << header->fNlowPt << endl;
2004
2005 result = CheckHeaderField(header->fNhighPt, buffer, bufferSize, continueParse);
2006 if (result != EXIT_SUCCESS) return result;
2007 cout << "Number of high pt triggers: " << header->fNhighPt << endl;
2008
2009 return result;
2010}
2011
2012
2013int DumpTrackDecisionStruct(
2014 const char* buffer, unsigned long bufferSize,
2015 const AliHLTMUONTrackDecisionStruct* decision,
2016 bool continueParse
2017 )
2018{
2019 // Step through the fields trying to print them.
2020 // At each step check if we have not overflowed the buffer. If we have
2021 // not, then we can print the field, otherwise we print the left over
2022 // bytes assumed to be corrupted rubbish.
2023 int result = CheckField(decision->fTrackId, buffer, bufferSize, continueParse);
2024 if (result != EXIT_SUCCESS) return result;
2025 cout << setw(13) << left << decision->fTrackId << setw(0);
2026
2027 result = CheckField(decision->fTriggerBits, buffer, bufferSize, continueParse);
2028 if (result != EXIT_SUCCESS) return result;
2029 cout << setw(12) << left << showbase << hex << decision->fTriggerBits
2030 << setw(0) << dec;
2031
2032 // Print the individual trigger bits.
2033 bool highPt, lowPt;
2034 AliHLTMUONUtils::UnpackTrackDecisionBits(decision->fTriggerBits, highPt, lowPt);
2035 cout << setw(7) << left << (highPt ? "yes" : "no");
2036 cout << setw(8) << left << (lowPt ? "yes" : "no");
c9537879 2037
2038 result = CheckField(decision->fPt, buffer, bufferSize, continueParse);
2039 if (result != EXIT_SUCCESS) return result;
2040 cout << setw(0) << decision->fPt << endl;
3dad52b0 2041
2042 return result;
2043}
2044
2045
2046int DumpSinglesDecisionBlock(
2047 const char* buffer, unsigned long bufferSize,
2048 bool continueParse
2049 )
2050{
2051 int result = EXIT_SUCCESS;
2052 AliHLTMUONSinglesDecisionBlockReader block(buffer, bufferSize);
2053
2054 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
2055 if (result != EXIT_SUCCESS and not continueParse) return result;
2056
2057 // Dump the rest of the block header.
2058 const AliHLTMUONSinglesDecisionBlockStruct* header = &block.BlockHeader();
2059 int subResult = DumpSinglesDecisionBlockHeader(buffer, bufferSize, header, continueParse);
2060 if (subResult != EXIT_SUCCESS) return subResult;
2061
2062 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
2063
2064 // Print the data block record entries.
c9537879 2065 cout << " | Trigger Bits |" << endl;
2066 cout << "Track ID | Raw HighPt LowPt | pT" << endl;
2067 cout << "----------------------------------------------------" << endl;
3dad52b0 2068 const AliHLTMUONTrackDecisionStruct* entry = block.GetArray();
2069 for(AliHLTUInt32_t i = 0; i < nentries; i++)
2070 {
2071 subResult = DumpTrackDecisionStruct(buffer, bufferSize, entry++, continueParse);
2072 if (subResult != EXIT_SUCCESS) return subResult;
2073 }
2074
2075 return result;
2076}
2077
2078
2079int DumpPairsDecisionBlockHeader(
2080 const char* buffer, unsigned long bufferSize,
2081 const AliHLTMUONPairsDecisionBlockStruct* header,
2082 bool continueParse
2083 )
2084{
2085 // Step through the header fields trying to print them.
2086 // At each step check if we have not overflowed the buffer, if we have
2087 // not then we can print the field, otherwise we print the left over
2088 // bytes assumed to be corrupted rubbish.
2089 int result = CheckHeaderField(header->fNunlikeAnyPt, buffer, bufferSize, continueParse);
2090 if (result != EXIT_SUCCESS) return result;
2091 cout << " Number of unlike all pt triggers: " << header->fNunlikeAnyPt << endl;
2092
2093 result = CheckHeaderField(header->fNunlikeLowPt, buffer, bufferSize, continueParse);
2094 if (result != EXIT_SUCCESS) return result;
2095 cout << " Number of unlike low pt triggers: " << header->fNunlikeLowPt << endl;
2096
2097 result = CheckHeaderField(header->fNunlikeHighPt, buffer, bufferSize, continueParse);
2098 if (result != EXIT_SUCCESS) return result;
2099 cout << " Number of unlike high pt triggers: " << header->fNunlikeHighPt << endl;
2100
2101 result = CheckHeaderField(header->fNlikeAnyPt, buffer, bufferSize, continueParse);
2102 if (result != EXIT_SUCCESS) return result;
2103 cout << " Number of like any pt triggers: " << header->fNlikeAnyPt << endl;
2104
2105 result = CheckHeaderField(header->fNlikeLowPt, buffer, bufferSize, continueParse);
2106 if (result != EXIT_SUCCESS) return result;
2107 cout << " Number of like low pt triggers: " << header->fNlikeLowPt << endl;
2108
2109 result = CheckHeaderField(header->fNlikeHighPt, buffer, bufferSize, continueParse);
2110 if (result != EXIT_SUCCESS) return result;
2111 cout << " Number of like high pt triggers: " << header->fNlikeHighPt << endl;
2112
2113 result = CheckHeaderField(header->fNmassAny, buffer, bufferSize, continueParse);
2114 if (result != EXIT_SUCCESS) return result;
2115 cout << " Number of all invariant mass triggers: " << header->fNmassAny << endl;
2116
2117 result = CheckHeaderField(header->fNmassLow, buffer, bufferSize, continueParse);
2118 if (result != EXIT_SUCCESS) return result;
2119 cout << " Number of low invariant mass triggers: " << header->fNmassLow << endl;
2120
2121 result = CheckHeaderField(header->fNmassHigh, buffer, bufferSize, continueParse);
2122 if (result != EXIT_SUCCESS) return result;
2123 cout << "Number of high invariant mass triggers: " << header->fNmassHigh << endl;
2124
2125 return result;
2126}
2127
2128
2129int DumpPairDecisionStruct(
2130 const char* buffer, unsigned long bufferSize,
2131 const AliHLTMUONPairDecisionStruct* decision,
2132 bool continueParse
2133 )
2134{
2135 // Step through the fields trying to print them.
2136 // At each step check if we have not overflowed the buffer. If we have
2137 // not, then we can print the field, otherwise we print the left over
2138 // bytes assumed to be corrupted rubbish.
2139 int result = CheckField(decision->fTrackAId, buffer, bufferSize, continueParse);
2140 if (result != EXIT_SUCCESS) return result;
2141 cout << setw(13) << left << decision->fTrackAId << setw(0);
2142
2143 result = CheckField(decision->fTrackBId, buffer, bufferSize, continueParse);
2144 if (result != EXIT_SUCCESS) return result;
2145 cout << setw(13) << left << decision->fTrackBId << setw(0);
2146
2147 result = CheckField(decision->fTriggerBits, buffer, bufferSize, continueParse);
2148 if (result != EXIT_SUCCESS) return result;
2149 cout << setw(12) << left << showbase << hex << decision->fTriggerBits
2150 << setw(0) << dec;
2151
2152 // Print the individual trigger bits.
2153 bool highMass, lowMass, unlike;
2154 AliHLTUInt8_t highPtCount, lowPtCount;
2155 AliHLTMUONUtils::UnpackPairDecisionBits(
2156 decision->fTriggerBits,
2157 highMass, lowMass, unlike, highPtCount, lowPtCount
2158 );
2159 cout << setw(7) << left << (highMass ? "yes" : "no");
2160 cout << setw(7) << left << (lowMass ? "yes" : "no");
2161 cout << setw(7) << left << (unlike ? "yes" : "no");
2162 cout << setw(6) << left << AliHLTUInt16_t(highPtCount);
2163 cout << setw(8) << left << AliHLTUInt16_t(lowPtCount);
2164 cout << setw(0);
2165
2166 result = CheckField(decision->fInvMass, buffer, bufferSize, continueParse);
2167 if (result != EXIT_SUCCESS) return result;
2168 cout << decision->fInvMass << endl;
2169
2170 return EXIT_SUCCESS;
2171}
2172
2173
2174int DumpPairsDecisionBlock(
2175 const char* buffer, unsigned long bufferSize,
2176 bool continueParse
2177 )
2178{
2179 int result = EXIT_SUCCESS;
2180 AliHLTMUONPairsDecisionBlockReader block(buffer, bufferSize);
2181
2182 result = CheckCommonHeader(block, buffer, bufferSize, continueParse);
2183 if (result != EXIT_SUCCESS and not continueParse) return result;
2184
2185 // Dump the rest of the block header.
2186 const AliHLTMUONPairsDecisionBlockStruct* header = &block.BlockHeader();
2187 int subResult = DumpPairsDecisionBlockHeader(buffer, bufferSize, header, continueParse);
2188 if (subResult != EXIT_SUCCESS) return subResult;
2189
2190 AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize);
2191
2192 // Print the data block record entries.
2193 cout << " | | Trigger Bits |" << endl;
2194 cout << "Track A ID | Track B ID | Raw HiMass LoMass Unlike HiPt# LoPt# | Invariant mass" << endl;
2195 cout << "----------------------------------------------------------------------------------------" << endl;
2196 const AliHLTMUONPairDecisionStruct* entry = block.GetArray();
2197 for(AliHLTUInt32_t i = 0; i < nentries; i++)
2198 {
2199 subResult = DumpPairDecisionStruct(buffer, bufferSize, entry++, continueParse);
2200 if (subResult != EXIT_SUCCESS) return subResult;
2201 }
2202
2203 return result;
2204}
2205
2206
2207int DumpCommonHeader(
2208 const char* buffer, unsigned long bufferSize,
2209 const AliHLTMUONDataBlockHeader* header, bool continueParse
2210 )
2211{
2212 // Step through the header fields trying to print them.
2213 // At each step check if we have not overflowed the buffer, if we have
2214 // not then we can print the field, otherwise we print the left over
2215 // bytes assumed to be corrupted rubbish.
2216 int result = CheckHeaderField(header->fType, buffer, bufferSize, continueParse);
2217 if (result != EXIT_SUCCESS) return result;
2218 AliHLTMUONDataBlockType type = AliHLTMUONDataBlockType(header->fType);
2219 cout << " Block type: " << type << endl;
2220
2221 result = CheckHeaderField(header->fRecordWidth, buffer, bufferSize, continueParse);
2222 if (result != EXIT_SUCCESS) return result;
2223 cout << " Record width: " << header->fRecordWidth << endl;
2224
2225 result = CheckHeaderField(header->fNrecords, buffer, bufferSize, continueParse);
2226 if (result != EXIT_SUCCESS) return result;
2227 cout << "Number of entries: " << header->fNrecords << endl;
2228
2229 return result;
2230}
2231
887a669c 2232/**
2233 * Method to look for a certain data word key in the buffer.
2234 * \param buffer The start location in the buffer to search.
2235 * \param end The end of the buffer.
2236 * \returns the pointer position just past the word found or
2237 * NULL if the word was not found in the buffer.
2238 */
2239const char* FindDataWord(const char* buffer, const char* end, UInt_t word)
2240{
2241 for (const char* current = buffer; (current+1) <= end; current += sizeof(UInt_t))
2242 {
2243 const UInt_t* currentWord = reinterpret_cast<const UInt_t*>(current);
2244 if (*currentWord == word) return current + sizeof(UInt_t);
2245 }
2246 return NULL;
2247}
2248
2249/**
2250 * Method to check if the data buffer is really a raw DDL stream.
2251 * \returns kUnknownDataBlock if this does not look like a raw DDL stream.
2252 * kTrackerDDLRawData if this looks like a raw DDL stream from the tracker.
2253 * kTriggerDDLRawData if this looks like a raw DDL stream from the trigger.
2254 */
2255int CheckIfDDLStream(const char* buffer, unsigned long bufferSize)
2256{
2257 if (bufferSize < sizeof(AliRawDataHeader)) return kUnknownDataBlock;
2258
2259 const AliRawDataHeader* cdhHeader =
2260 reinterpret_cast<const AliRawDataHeader*>(buffer);
2261
2262 // Keep scores of indicators / tests that show this is a raw DDL stream
2263 // either from the trigger or tracker. We will decide if the stream is
2264 // indeed a raw DDL stream if the largest of the two scores is above a
2265 // minimum threshold.
2266 int trackerScore = 0;
2267 int triggerScore = 0;
2268
2269 if (cdhHeader->fSize == UInt_t(-1) or cdhHeader->fSize == bufferSize)
2270 {
2271 trackerScore++;
2272 triggerScore++;
2273 }
2274
2275 if (cdhHeader->GetVersion() == 2)
2276 {
2277 trackerScore++;
2278 triggerScore++;
2279 }
2280
2281 const char* payload = buffer + sizeof(AliRawDataHeader);
2282 const char* payloadEnd = buffer + bufferSize;
2283
2284 typedef AliMUONTrackerDDLDecoder<AliMUONTrackerDDLDecoderEventHandler> AliTrkDecoder;
2285 typedef AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler> AliTrgDecoder;
2286
2287 // See if the DDL data has a payload with data word keys as expected by
2288 // AliMUONTrackerDDLDecoder.
2289 const char* current = payload;
2290 while ( (current = FindDataWord(current, payloadEnd, AliTrkDecoder::BlockDataKeyWord())) != NULL )
2291 {
2292 trackerScore++;
2293 }
2294 current = payload;
2295 while ( (current = FindDataWord(current, payloadEnd, AliTrkDecoder::DspDataKeyWord())) != NULL )
2296 {
2297 trackerScore++;
2298 }
2299 current = payload;
2300 while ( (current = FindDataWord(current, payloadEnd, AliTrkDecoder::BusPatchDataKeyWord())) != NULL )
2301 {
2302 trackerScore++;
2303 }
2304 current = payload;
2305 while ( (current = FindDataWord(current, payloadEnd, AliTrkDecoder::EndOfDDLWord())) != NULL )
2306 {
2307 trackerScore++;
2308 }
2309
2310 // See if the DDL data has a payload with data word keys as expected by
2311 // AliMUONTriggerDDLDecoder.
2312 current = payload;
2313 while ( (current = FindDataWord(current, payloadEnd, AliTrgDecoder::EndOfDarcWord())) != NULL )
2314 {
2315 triggerScore++;
2316 }
2317 current = payload;
2318 while ( (current = FindDataWord(current, payloadEnd, AliTrgDecoder::EndOfGlobalWord())) != NULL )
2319 {
2320 triggerScore++;
2321 }
2322 current = payload;
2323 while ( (current = FindDataWord(current, payloadEnd, AliTrgDecoder::EndOfRegionalWord())) != NULL )
2324 {
2325 triggerScore++;
2326 }
2327 current = payload;
2328 while ( (current = FindDataWord(current, payloadEnd, AliTrgDecoder::EndOfLocalWord())) != NULL )
2329 {
2330 triggerScore++;
2331 }
2332
2333 if (triggerScore > trackerScore)
2334 {
2335 if (triggerScore >= 6) return kTriggerDDLRawData;
2336 }
2337 else
2338 {
2339 if (trackerScore >= 6) return kTrackerDDLRawData;
2340 }
2341 return kUnknownDataBlock;
2342}
3dad52b0 2343
887a669c 2344/**
2345 * Parses the buffer and prints the contents to screen.
2346 * [in] \param buffer The pointer to the buffer to parse.
2347 * [in] \param bufferSize The size of the buffer in bytes.
2348 * [in] \param continueParse If specified then the we try to continue parsing the
2349 * buffer as much as possible.
daab896b 2350 * [in] \param tryrecover Indicates if the DDL decoders should have special
2351 * recovery logic enabled.
887a669c 2352 * [in/out] \param type Initialy this should indicate the type of the data block
2353 * or kUnknownDataBlock if not known. On exit it will be filled with
2354 * the type of the data block as discovered by this routine if type
2355 * initially contained kUnknownDataBlock.
2356 * \returns The error code indicating the problem. EXIT_SUCCESS is returned
2357 * on success.
2358 */
3dad52b0 2359int ParseBuffer(
daab896b 2360 char* buffer, unsigned long bufferSize,
2361 bool continueParse, bool tryrecover, int& type
3dad52b0 2362 )
2363{
2364 assert( buffer != NULL );
2365 int result = EXIT_SUCCESS;
887a669c 2366 int subResult = EXIT_FAILURE;
3dad52b0 2367
887a669c 2368 // If the -type|-t option was not used in the command line then we need to
2369 // figure out what type of data block this is from the data itself.
2370 bool ddlStream = false;
2371 if (type == kUnknownDataBlock)
3dad52b0 2372 {
887a669c 2373 // First check if this is a raw DDL stream, if not then assume it is
2374 // some kind of internal dHLT raw data block.
2375 int streamType = CheckIfDDLStream(buffer, bufferSize);
2376 if (streamType == kTrackerDDLRawData or streamType == kTriggerDDLRawData)
2377 {
2378 type = streamType;
2379 ddlStream = true;
2380 }
3dad52b0 2381 }
887a669c 2382 else if (type == kTrackerDDLRawData or type == kTriggerDDLRawData)
3dad52b0 2383 {
887a669c 2384 ddlStream = true;
3dad52b0 2385 }
887a669c 2386
2387 if (not ddlStream)
3dad52b0 2388 {
887a669c 2389 if (bufferSize < sizeof(AliHLTMUONDataBlockHeader))
2390 {
2391 cerr << "ERROR: The size of the file is too small to contain a"
2392 " valid data block." << endl;
2393 result = PARSE_ERROR;
2394 if (not continueParse) return result;
2395 }
2396 const AliHLTMUONDataBlockHeader* header =
2397 reinterpret_cast<const AliHLTMUONDataBlockHeader*>(buffer);
2398
2399 subResult = DumpCommonHeader(buffer, bufferSize, header, continueParse);
2400 if (subResult != EXIT_SUCCESS) return subResult;
2401
2402
2403 // Check if the block type in the header corresponds to the type given
2404 // by the '-type' command line parameter. If they do not then print an
2405 // error or big fat warning message and force interpretation of the data
2406 // block with the type given by '-type'.
2407 AliHLTMUONDataBlockType headerType = AliHLTMUONDataBlockType(header->fType);
2408
2409 if (type == kUnknownDataBlock)
2410 {
2411 // -type not used in the command line so just use what is given
2412 // by the data block header.
2413 type = headerType;
2414 }
2415 else if (type != headerType)
2416 {
2417 cerr << "WARNING: The data block header indicates a type"
2418 " different from what was specified on the command line."
2419 " The data could be corrupt."
2420 << endl;
2421 cerr << "WARNING: The type value in the file is "
2422 << showbase << hex << header->fType
2423 << " (" << headerType << "), but on the command line it is "
2424 << showbase << hex << int(type) << dec
2425 << " (" << type << ")."
2426 << endl;
2427 cerr << "WARNING: Will force the interpretation of the data block"
2428 " with a type of " << type << "." << endl;
2429 }
3dad52b0 2430 }
2431
887a669c 2432 // Now we know what type the data block is supposed to be, so we can
3dad52b0 2433 // dump it to screen with the appropriate dump routine.
2434 switch (type)
2435 {
887a669c 2436 case kTrackerDDLRawData:
daab896b 2437 subResult = DumpTrackerDDLRawStream(buffer, bufferSize, continueParse, tryrecover);
887a669c 2438 if (subResult != EXIT_SUCCESS) result = subResult;
2439 break;
2440 case kTriggerDDLRawData:
daab896b 2441 subResult = DumpTriggerDDLRawStream(buffer, bufferSize, continueParse, tryrecover);
887a669c 2442 if (subResult != EXIT_SUCCESS) result = subResult;
2443 break;
3dad52b0 2444 case kTriggerRecordsDataBlock:
2445 subResult = DumpTriggerRecordsBlock(buffer, bufferSize, continueParse);
2446 if (subResult != EXIT_SUCCESS) result = subResult;
2447 break;
2448 case kTrigRecsDebugDataBlock:
2449 subResult = DumpTrigRecsDebugBlock(buffer, bufferSize, continueParse);
2450 if (subResult != EXIT_SUCCESS) result = subResult;
2451 break;
3dad52b0 2452 case kRecHitsDataBlock:
2453 subResult = DumpRecHitsBlock(buffer, bufferSize, continueParse);
2454 if (subResult != EXIT_SUCCESS) result = subResult;
2455 break;
2456 case kClustersDataBlock:
2457 subResult = DumpClustersBlock(buffer, bufferSize, continueParse);
2458 if (subResult != EXIT_SUCCESS) result = subResult;
2459 break;
2460 case kChannelsDataBlock:
329db59d 2461 subResult = DumpChannelsBlock(buffer, bufferSize, continueParse);
3dad52b0 2462 if (subResult != EXIT_SUCCESS) result = subResult;
2463 break;
2464 case kMansoTracksDataBlock:
2465 subResult = DumpMansoTracksBlock(buffer, bufferSize, continueParse);
2466 if (subResult != EXIT_SUCCESS) result = subResult;
2467 break;
2468 case kMansoCandidatesDataBlock:
2469 subResult = DumpMansoCandidatesBlock(buffer, bufferSize, continueParse);
2470 if (subResult != EXIT_SUCCESS) result = subResult;
2471 break;
a8982f78 2472 case kTracksDataBlock:
2473 subResult = DumpTracksBlock(buffer, bufferSize, continueParse);
2474 if (subResult != EXIT_SUCCESS) result = subResult;
2475 break;
3dad52b0 2476 case kSinglesDecisionDataBlock:
2477 subResult = DumpSinglesDecisionBlock(buffer, bufferSize, continueParse);
2478 if (subResult != EXIT_SUCCESS) result = subResult;
2479 break;
2480 case kPairsDecisionDataBlock:
2481 return DumpPairsDecisionBlock(buffer, bufferSize, continueParse);
2482 if (subResult != EXIT_SUCCESS) result = subResult;
2483 break;
2484 default :
2485 cout << "ERROR: Unknown data block type. Found a type number of "
2486 << showbase << hex << int(type) << dec
2487 << " (" << int(type) << ")." << endl;
2488 result = PARSE_ERROR;
2489 }
2490
2491 return result;
2492}
2493
887a669c 2494/**
2495 * Convert the type code to a string.
2496 */
2497const char* TypeToString(int type)
2498{
2499 if (type == kTrackerDDLRawData or type == kTriggerDDLRawData)
2500 {
2501 static char str[kAliHLTComponentDataTypefIDsize+1];
2502 AliHLTComponentDataType t = AliHLTMUONConstants::DDLRawDataType();
2503 memcpy(&str, &t.fID, kAliHLTComponentDataTypefIDsize);
2504 // Must insert the NULL character to make this an ANSI C string.
2505 str[kAliHLTComponentDataTypefIDsize] = '\0';
2506 return &str[0];
2507 }
2508 else
2509 {
2510 return AliHLTMUONUtils::DataBlockTypeToString(AliHLTMUONDataBlockType(type));
2511 }
2512}
2513
2514/**
2515 * Find the data specification from the filename and return it in string format.
2516 */
2517const char* TryDecodeDataSpec(const char* filename)
2518{
2519 TString name = filename;
2520
2521 TRegexp re1("MUONTR[GK]_[0123456789]+\\.ddl$");
2522 Ssiz_t length = 0;
2523 Ssiz_t pos = re1.Index(name, &length);
2524 if (pos != kNPOS)
2525 {
2526 TString substr;
2527 for (Ssiz_t i = 0; i < length; i++)
2528 substr += name[pos+i];
2529 TRegexp re("[0123456789]+");
2530 pos = re.Index(substr, &length);
2531 TString num;
2532 for (Ssiz_t i = 0; i < length; i++)
2533 num += substr[pos+i];
2534 AliHLTUInt32_t spec = AliHLTMUONUtils::EquipIdToSpec(num.Atoi());
2535 static char strbuf[32];
2536 sprintf(&strbuf[0], "0x%8.8X", spec);
2537 return &strbuf[0];
2538 }
2539
2540 TRegexp re2("_MUON\\:.+_0x[0123456789abscefABCDEF]+\\.dat$");
2541 pos = re2.Index(name, &length);
2542 if (pos != kNPOS)
2543 {
2544 TString substr;
2545 for (Ssiz_t i = 0; i < length; i++)
2546 substr += name[pos+i];
2547 TRegexp re("0x[0123456789abscefABCDEF]+");
2548 pos = re.Index(substr, &length);
2549 TString num;
2550 for (Ssiz_t i = 0; i < length; i++)
2551 num += substr[pos+i];
2552 static TString result = num;
2553 return result.Data();
2554 }
2555
2556 return NULL;
2557}
2558
ffb64d3e 2559namespace
2560{
2561 // CDB path and run number to use.
162637e4 2562 const char* gCDBPath = "local://$ALICE_ROOT/OCDB";
ffb64d3e 2563 Int_t gRunNumber = 0;
2564}
2565
887a669c 2566/**
2567 * Performs basic data integrity checks of the data block using the
2568 * AliHLTMUONDataCheckerComponent.
2569 * [in] \param sys The HLT system framework.
2570 * [in] \param filename The name of the file containing the data block to check.
2571 * [in] \param type Must indicate the type of the data block.
2572 * [in] \param dataspec The data specification of the data block. NULL if none.
2573 * [in] \param maxLogging If set to true then full logging is turned on for AliHLTSystem.
2574 * \returns The error code indicating the problem. EXIT_SUCCESS is returned
2575 * on success.
2576 */
2577int CheckDataIntegrity(
2578 AliHLTSystem& sys, const char* filename, int type,
2579 const char* dataspec, bool maxLogging
2580 )
2581{
2582 if (maxLogging)
2583 {
2584 AliLog::SetGlobalLogLevel(AliLog::kMaxType);
2585 sys.SetGlobalLoggingLevel(kHLTLogAll);
2586 }
2587 else
2588 {
2589 AliLog::SetGlobalLogLevel(AliLog::kWarning);
2590 int level = kHLTLogWarning | kHLTLogError | kHLTLogFatal;
2591 sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(level));
2592 }
2593
ffb64d3e 2594 sys.LoadComponentLibraries("libAliHLTUtil.so");
2595 sys.LoadComponentLibraries("libAliHLTMUON.so");
887a669c 2596
2597 // Setup the component parameter lists and then the components.
ffb64d3e 2598 TString dcparams = "-return_error -warn_on_unexpected_block -no_global_check -cdbpath ";
2599 dcparams += gCDBPath;
2600 dcparams += " -run ";
2601 dcparams += gRunNumber;
887a669c 2602 TString fpparams = "-datatype '";
2603 fpparams += TypeToString(type);
2604 fpparams += "' 'MUON'";
2605 if (dataspec != NULL)
2606 {
2607 fpparams += " -dataspec ";
2608 fpparams += dataspec;
2609 }
2610 else
2611 {
2612 const char* spec = TryDecodeDataSpec(filename);
2613 if (spec != NULL)
2614 {
2615 fpparams += " -dataspec ";
2616 fpparams += spec;
2617 }
2618 else
2619 {
2620 dcparams += " -ignorespec";
2621 }
2622 }
2623 fpparams += " -datafile ";
2624 fpparams += filename;
2625 TString fpname = "filePublisher_";
2626 fpname += filename;
2627 TString dcname = "checker_";
2628 dcname += filename;
2629
2630 if (maxLogging)
2631 {
2632 cout << "DEBUG: Using the following flags for FilePublisher: \""
2633 << fpparams.Data() << "\""<< endl;
2634 cout << "DEBUG: Using the following flags for "
2635 << AliHLTMUONConstants::DataCheckerComponentId()
2636 << ": \"" << dcparams.Data() << "\""<< endl;
2637 }
2638
2639 AliHLTConfiguration(fpname.Data(), "FilePublisher", NULL, fpparams.Data());
2640 AliHLTConfiguration checker(
2641 dcname.Data(), AliHLTMUONConstants::DataCheckerComponentId(),
2642 fpname.Data(), dcparams.Data()
2643 );
2644
2645 // Build and run the HLT tasks.
2646 if (sys.BuildTaskList(dcname.Data()) != 0) return HLTSYSTEM_ERROR;
2647 if (maxLogging) sys.PrintTaskList();
2648 if (sys.Run() != 1) return HLTSYSTEM_ERROR;
2649
2650 // Now clean up.
2651 if (sys.CleanTaskList() != 0) return HLTSYSTEM_ERROR;
2652
2653 return EXIT_SUCCESS;
2654}
2655
3dad52b0 2656
2657/**
2658 * The caller is responsible for freeing memory allocated for buffer with a call
2659 * to delete [] buffer.
2660 */
2661int ReadFile(const char* filename, char*& buffer, unsigned long& bufferSize)
2662{
2663 assert( filename != NULL );
2664
2665 // Open the file and find its size.
2666 fstream file;
2667 file.open(filename, ios::in);
2668 if (not file)
2669 {
2670 cerr << "ERROR: Could not open the file: " << filename << endl;
2671 return SYSTEM_ERROR;
2672 }
2673 file.seekg(0, ios::end);
2674 if (not file)
2675 {
2676 cerr << "ERROR: Could not seek in the file: " << filename << endl;
2677 return SYSTEM_ERROR;
2678 }
2679 bufferSize = file.tellg();
2680 if (not file)
2681 {
2682 cerr << "ERROR: Could not get file size for the file: " <<
2683 filename << endl;
2684 return SYSTEM_ERROR;
2685 }
2686 file.seekg(0, ios::beg);
2687 if (not file)
2688 {
2689 cerr << "ERROR: Could not seek in the file: " << filename << endl;
2690 return SYSTEM_ERROR;
2691 }
2692
2693 // Allocate the memory for the file.
2694 try
2695 {
2696 buffer = new char[bufferSize];
2697 }
2698 catch (const std::bad_alloc&)
2699 {
2700 cerr << "ERROR: Out of memory. Tried to allocate " << bufferSize
2701 << " bytes." << endl;
2702 return SYSTEM_ERROR;
2703 }
2704
2705 file.read(buffer, bufferSize);
2706 if (not file)
2707 {
2708 delete [] buffer;
2709 buffer = NULL;
2710 bufferSize = 0;
2711 cerr << "ERROR: Could not read from file: " << filename << endl;
2712 return SYSTEM_ERROR;
2713 }
2714
2715 file.close();
2716 if (not file)
2717 {
2718 delete [] buffer;
2719 buffer = NULL;
2720 bufferSize = 0;
2721 cerr << "ERROR: Could not close the file: " << filename << endl;
2722 return SYSTEM_ERROR;
2723 }
2724
2725 return EXIT_SUCCESS;
2726}
2727
2728/**
2729 * Prints the command line usage of this program to standard error.
2730 */
c9537879 2731void PrintUsage(bool asError = true)
3dad52b0 2732{
c9537879 2733 std::ostream& os = asError ? cerr : cout;
887a669c 2734 os << "Usage: dHLTdumpraw [-help|-h] [-continue|-c] [-type|-t <typename>] [-check|-k]" << endl;
ffb64d3e 2735 os << " [-debug|-d] [-dataspec|-s <number>] [-cdbpath|-p <url>] [-run|-r <number>]" << endl;
2736 os << " <filename> [<filename> ...]" << endl;
c9537879 2737 os << "Where <filename> is the name of a file containing a raw data block." << endl;
2738 os << "Options:" << endl;
2739 os << " -help | -h" << endl;
2740 os << " Displays this message." << endl;
f68b4e0e 2741 os << " -continue | -c" << endl;
c9537879 2742 os << " If specified, the program will try to continue parsing the data block" << endl;
2743 os << " as much as possible rather than stopping at the first error." << endl;
daab896b 2744 os << " -recover | -e" << endl;
2745 os << " If specified, special DDL decoder recovery logic is enabled to handle" << endl;
2746 os << " corrupt DDL data." << endl;
f68b4e0e 2747 os << " -type | -t <typename>" << endl;
c9537879 2748 os << " Forces the contents of the subsequent files specified on the command" << endl;
2749 os << " line to be interpreted as a specific type of data block." << endl;
2750 os << " Where <typename> can be one of:" << endl;
887a669c 2751 os << " rawtracker - raw DDL stream from tracker chambers." << endl;
2752 os << " rawtrigger - raw DDL stream from trigger chambers." << endl;
c9537879 2753 os << " trigrecs - trigger records data." << endl;
2754 os << " trigrecsdebug - debugging information about trigger records." << endl;
c9537879 2755 os << " rechits - reconstructed hits data." << endl;
2756 os << " channels - channel debugging information from hit reconstruction." << endl;
2757 os << " clusters - cluster debugging information from hit reconstruction." << endl;
2758 os << " mansotracks - partial tracks from Manso algorithm." << endl;
2759 os << " mansocandidates - track candidates considered in the Manso algorithm." << endl;
a8982f78 2760 os << " tracks - tracks from full tracker component." << endl;
c9537879 2761 os << " singlesdecision - trigger decisions for single tracks." << endl;
2762 os << " pairsdecision - trigger decisions for track pairs." << endl;
2763 os << " autodetect - the type of the data block will be automatically" << endl;
2764 os << " detected." << endl;
887a669c 2765 os << " -check | -k" << endl;
2766 os << " If specified then data integrity checks are performed on the raw data." << endl;
2767 os << " Warnings and errors are printed as problems are found with the data, but" << endl;
2768 os << " the data will still be converted into ROOT objects as best as possible." << endl;
2769 os << " -debug | -d" << endl;
2770 os << " If specified, then the all debug messages are printed by the AliHLTSystem." << endl;
2771 os << " This is only useful if experiencing problems with the -check|-k option." << endl;
2772 os << " -dataspec | -s <number>" << endl;
2773 os << " When specified, then <number> is used as the data specification for the" << endl;
2774 os << " data file that follows. This option is only useful with the -check|-k option." << endl;
ffb64d3e 2775 os << " -cdbpath | -p <url>" << endl;
2776 os << " The path to the CDB to use when running with the -check | -k option." << endl;
2777 os << " -run | -r <number>" << endl;
2778 os << " The run number to use when running with the -check | -k option." << endl;
3dad52b0 2779}
2780
3dad52b0 2781/**
2782 * Parses the command line.
2783 * @param argc Number of arguments as given in main().
2784 * @param argv Array of arguments as given in main().
c9537879 2785 * @param filenames Pointer to buffer storing file name strings.
c9537879 2786 * @param filetypes Array that receives the type of the data block expected, i.e.
2787 * the value of the -type flag for the corresponding file.
887a669c 2788 * @param dataspecs Data specifications to use for the data files.
2789 * @param numOfFiles Receives the number of file name strings that were found
2790 * and added to 'filenames'.
2791 * @param continueParse Set to true if the user requested to continue to parse
2792 * after errors.
daab896b 2793 * @param tryrecover Set to true if the user wants DDL decoder recovery logic enabled.
887a669c 2794 * @param checkData Set to true if data integrity checking was requested.
2795 * @param maxLogging Set to true if maximal logging was requested.
3dad52b0 2796 * @return A status flag suitable for returning from main(), containing either
2797 * EXIT_SUCCESS or CMDLINE_ERROR.
2798 */
2799int ParseCommandLine(
c9537879 2800 int argc,
5b882880 2801 char** argv,
c9537879 2802 const char** filenames,
887a669c 2803 int* filetypes,
2804 const char** dataspecs,
c9537879 2805 int& numOfFiles,
2806 bool& continueParse,
daab896b 2807 bool& tryrecover,
887a669c 2808 bool& checkData,
2809 bool& maxLogging
3dad52b0 2810 )
2811{
c9537879 2812 numOfFiles = 0;
3dad52b0 2813 continueParse = false;
daab896b 2814 tryrecover = false;
887a669c 2815 maxLogging = false;
2816 checkData = false;
2817 int currentType = kUnknownDataBlock;
2818 const char* currentDataSpec = NULL;
ffb64d3e 2819 bool pathSet = false;
2820 bool runSet = false;
3dad52b0 2821
2822 // Parse the command line.
2823 for (int i = 1; i < argc; i++)
2824 {
f68b4e0e 2825 if (strcmp(argv[i], "-help") == 0 or strcmp(argv[i], "-h") == 0)
3dad52b0 2826 {
c9537879 2827 PrintUsage(false);
3dad52b0 2828 return EXIT_SUCCESS;
2829 }
f68b4e0e 2830 else if (strcmp(argv[i], "-continue") == 0 or strcmp(argv[i], "-c") == 0)
3dad52b0 2831 {
2832 continueParse = true;
2833 }
daab896b 2834 else if (strcmp(argv[i], "-recover") == 0 or strcmp(argv[i], "-e") == 0)
2835 {
2836 tryrecover = true;
2837 }
f68b4e0e 2838 else if (strcmp(argv[i], "-type") == 0 or strcmp(argv[i], "-t") == 0)
3dad52b0 2839 {
c9537879 2840 if (++i >= argc)
3dad52b0 2841 {
887a669c 2842 cerr << "ERROR: Missing a type specifier." << endl << endl;
3dad52b0 2843 PrintUsage();
2844 return CMDLINE_ERROR;
2845 }
c9537879 2846 // Now we need to parse the typename in the command line.
2847 if (strcmp(argv[i], "autodetect") == 0)
2848 {
2849 currentType = kUnknownDataBlock;
2850 }
887a669c 2851 else if (strcmp(argv[i], "rawtracker") == 0)
2852 {
2853 currentType = kTrackerDDLRawData;
2854 }
2855 else if (strcmp(argv[i], "rawtrigger") == 0)
2856 {
2857 currentType = kTriggerDDLRawData;
2858 }
3dad52b0 2859 else
c9537879 2860 {
f68b4e0e 2861 currentType = AliHLTMUONUtils::ParseCommandLineTypeString(argv[i]);
2862 if (currentType == kUnknownDataBlock)
2863 {
2864 cerr << "ERROR: Invalid type name '" << argv[i]
2865 << "' specified for argument " << argv[i-1]
2866 << "." << endl << endl;
2867 PrintUsage();
2868 return CMDLINE_ERROR;
2869 }
c9537879 2870 }
2871 }
887a669c 2872 else if (strcmp(argv[i], "-debug") == 0 or strcmp(argv[i], "-d") == 0)
2873 {
2874 maxLogging = true;
2875 }
2876 else if (strcmp(argv[i], "-check") == 0 or strcmp(argv[i], "-k") == 0)
2877 {
2878 checkData = true;
2879 }
2880 else if (strcmp(argv[i], "-dataspec") == 0 or strcmp(argv[i], "-s") == 0)
2881 {
2882 if (++i >= argc)
2883 {
2884 cerr << "ERROR: Missing a specification number." << endl << endl;
2885 PrintUsage();
2886 return CMDLINE_ERROR;
2887 }
2888
2889 char* errPos = NULL;
2890 unsigned long num = strtoul(argv[i], &errPos, 0);
2891 if (errPos == NULL or *errPos != '\0')
2892 {
2893 cerr << "ERROR: Cannot convert '%s' to a data specification number."
2894 << argv[i] << endl;
2895 return CMDLINE_ERROR;
2896 }
2897 if (not AliHLTMUONUtils::IsSpecValid(num))
2898 {
2899 cerr << "ERROR: The data specification number is not a valid format."
2900 << endl;
2901 return CMDLINE_ERROR;
2902 }
2903 currentDataSpec = argv[i];
2904 }
ffb64d3e 2905 else if (strcmp(argv[i], "-cdbpath") == 0 or strcmp(argv[i], "-p") == 0)
2906 {
2907 if (pathSet)
2908 {
2909 cerr << "WARNING: Already used -cdbpath|-p with '" << gCDBPath
2910 << "' before. Will override it with the last value specified with -cdbpath|-p."
2911 << endl;
2912 }
2913 if (++i >= argc)
2914 {
2915 cerr << "ERROR: Missing the URL for the CDB path." << endl << endl;
2916 PrintUsage();
2917 return CMDLINE_ERROR;
2918 }
2919 gCDBPath = argv[i];
2920 pathSet = true;
2921 }
2922 else if (strcmp(argv[i], "-run") == 0 or strcmp(argv[i], "-r") == 0)
2923 {
2924 if (runSet)
2925 {
2926 cerr << "WARNING: Already used -run|-r with " << gRunNumber
2927 << " before. Will override it with the last value specified with -run|-r."
2928 << endl;
2929 }
2930 if (++i >= argc)
2931 {
2932 cerr << "ERROR: Missing the run number." << endl << endl;
2933 PrintUsage();
2934 return CMDLINE_ERROR;
2935 }
2936
2937 char* cpErr = NULL;
2938 Int_t run = Int_t( strtol(argv[i], &cpErr, 0) );
2939 if (cpErr == NULL or *cpErr != '\0' or run < 0)
2940 {
2941 cerr << "ERROR: Cannot convert '" << argv[i] << "' to a valid run number."
2942 " Expected a positive integer value." << endl;
2943 return CMDLINE_ERROR;
2944 }
2945
2946 gRunNumber = run;
2947 runSet = true;
2948 }
c9537879 2949 else
2950 {
2951 assert( numOfFiles < argc );
2952 filenames[numOfFiles] = argv[i];
2953 filetypes[numOfFiles] = currentType;
887a669c 2954 dataspecs[numOfFiles] = currentDataSpec;
2955 currentDataSpec = NULL; // Reset because '-dataspec' option is only valid for one file.
c9537879 2956 numOfFiles++;
3dad52b0 2957 }
2958 }
2959
c9537879 2960 // Now check that we have at least one filename and all the flags we need.
2961 if (numOfFiles == 0)
3dad52b0 2962 {
c9537879 2963 cerr << "ERROR: Missing a file name. You must specify at least one file to process."
3dad52b0 2964 << endl << endl;
2965 PrintUsage();
2966 return CMDLINE_ERROR;
2967 }
2968
2969 return EXIT_SUCCESS;
2970}
2971
2972
5b882880 2973int main(int argc, char** argv)
3dad52b0 2974{
1120d5de 2975 // Test endianess of this machine during runtime and print warning if it is not
2976 // little endian.
2977 union
2978 {
2979 int dword;
2980 char byte[4];
2981 } endianTest;
2982 endianTest.dword = 0x1;
2983 if (endianTest.byte[0] != 0x1)
2984 {
2985 cerr << "!!!! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!!!!" << endl;
2986 cerr << "!!!! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!!!!" << endl;
2987 cerr << "!! !!" << endl;
2988 cerr << "!! This is not a little endian machine, but dHLT raw data is normally !!" << endl;
2989 cerr << "!! generated in little endian format. Unless you are looking at localy !!" << endl;
2990 cerr << "!! created simulated data, then this program will not show you correct !!" << endl;
2991 cerr << "!! output. !!" << endl;
2992 cerr << "!! !!" << endl;
2993 cerr << "!!!! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!!!!" << endl;
2994 cerr << "!!!! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!!!!" << endl;
2995 cerr << endl;
2996 }
2997
2998
c9537879 2999 int numOfFiles = 0;
3dad52b0 3000 bool continueParse = false;
daab896b 3001 bool tryrecover = false;
887a669c 3002 bool checkData = false;
3003 bool maxLogging = false;
3dad52b0 3004 int returnCode = EXIT_SUCCESS;
3dad52b0 3005 char* buffer = NULL;
887a669c 3006 const char** filename = NULL;
3007 int* filetype = NULL;
3008 const char** dataspec = NULL;
3dad52b0 3009
3010 try
3011 {
887a669c 3012 // Reduce logging now to get rid of informationals from AliHLTSystem constructor.
3013 AliLog::SetGlobalLogLevel(AliLog::kWarning);
3014 AliHLTSystem sys;
3015
c9537879 3016 // There will be at least 'argc' number of filenames.
3017 typedef const char* AnsiString;
887a669c 3018 filename = new AnsiString[argc];
3019 filetype = new int[argc];
3020 dataspec = new AnsiString[argc];
c9537879 3021
887a669c 3022 returnCode = ParseCommandLine(
3023 argc, argv, filename, filetype, dataspec, numOfFiles,
daab896b 3024 continueParse, tryrecover, checkData, maxLogging
887a669c 3025 );
3dad52b0 3026
c9537879 3027 if (returnCode == EXIT_SUCCESS)
3dad52b0 3028 {
c9537879 3029 for (int i = 0; i < numOfFiles; i++)
3030 {
3031 unsigned long bufferSize = 0;
3032 returnCode = ReadFile(filename[i], buffer, bufferSize);
3033 if (returnCode != EXIT_SUCCESS) break;
a2be583d 3034 if (numOfFiles > 1)
3035 {
887a669c 3036 cout << "########## Start of dump for file: "
3037 << filename[i] << " ##########" << endl;
a2be583d 3038 }
daab896b 3039 int result = ParseBuffer(buffer, bufferSize, continueParse, tryrecover, filetype[i]);
c9537879 3040 if (buffer != NULL) delete [] buffer;
3041 if (result != EXIT_SUCCESS)
3042 {
3043 returnCode = result;
3044 if (not continueParse) break;
3045 }
887a669c 3046 if (checkData)
3047 {
3048 result = CheckDataIntegrity(
3049 sys, filename[i], filetype[i],
3050 dataspec[i], maxLogging
3051 );
3052 if (result != EXIT_SUCCESS)
3053 {
3054 returnCode = result;
3055 if (not continueParse) break;
3056 }
3057 }
a2be583d 3058 if (numOfFiles > 1)
3059 {
887a669c 3060 cout << "########## End of dump for file: " <<
3061 filename[i] << " ##########" << endl;
a2be583d 3062 }
c9537879 3063 }
3dad52b0 3064 }
3065
c9537879 3066 delete [] filename;
3067 delete [] filetype;
887a669c 3068 delete [] dataspec;
3dad52b0 3069 }
3070 catch (...)
3071 {
3072 cerr << "FATAL ERROR: An unknown exception occurred!" << endl << endl;
3073 returnCode = FATAL_ERROR;
3074 if (buffer != NULL) delete [] buffer;
887a669c 3075 if (filename != NULL) delete [] filename;
3076 if (filetype != NULL) delete [] filetype;
3077 if (dataspec != NULL) delete [] dataspec;
3dad52b0 3078 }
c9537879 3079
3dad52b0 3080 return returnCode;
3081}