X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FMUON%2Futils%2FdHLTdumpraw.cxx;h=0936ff7e8dfff376b48726e95798ce283528cd71;hb=7090a07a18b0f379069a3a2cd379e4958ff2f105;hp=39874a1a74692897d9be561fcd87194edd644ec9;hpb=887a669cf6736588a41a9f08334f2e41276fef2c;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/MUON/utils/dHLTdumpraw.cxx b/HLT/MUON/utils/dHLTdumpraw.cxx index 39874a1a746..0936ff7e8df 100644 --- a/HLT/MUON/utils/dHLTdumpraw.cxx +++ b/HLT/MUON/utils/dHLTdumpraw.cxx @@ -13,7 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* $Id$ */ +// $Id$ /** * @file dHLTdumpraw.cxx @@ -104,6 +104,20 @@ void PrintRubbishData(AliHLTUInt32_t offset, const char* padByte, AliHLTUInt32_t } +void PrintBitPattern(AliHLTUInt32_t value, int bitcount = 32) +{ + // Prints a bit pattern to cout. + + for (int i = bitcount-1; i >= 0; i--) + { + if ( ((value >> i) & 0x1) == 1 ) + cout << "1"; + else + cout << "0"; + } +} + + template int CheckHeaderField( FieldType& field, const char* buffer, unsigned long bufferSize, @@ -238,67 +252,76 @@ namespace void HandleError( const char* errorMessage, int errorCode, const char* errorCodeString, const void* location - ) - { - unsigned long offset = (unsigned long)location - (unsigned long)fBufferStart - + sizeof(AliRawDataHeader); - - cerr << "ERROR: " << errorMessage - << " [Error code = " << errorCode << " (" - << errorCodeString << "), at byte " - << offset << " (" << noshowbase << hex << "0x" - << offset << dec << ")]" << endl; - - if (fDumpStart == NULL) fDumpStart = location; - fDumpData = true; - } + ); - void TryDumpCorruptData(const void* dumpEnd) - { - if (dumpEnd < fDumpStart) return; - if (not fDumpData) return; - - unsigned long startOffset = (unsigned long)fDumpStart - (unsigned long)fBufferStart - + sizeof(AliRawDataHeader); - unsigned long endOffset = (unsigned long)dumpEnd - (unsigned long)fBufferStart - + sizeof(AliRawDataHeader); - if (endOffset - startOffset > 264) - { - endOffset = startOffset + 264; - dumpEnd = reinterpret_cast(fBufferStart) + endOffset; - } - cerr << "Dumping corrupt data words from byte " << startOffset - << " (" << noshowbase << hex << "0x" << startOffset - << dec << "), to byte " << endOffset << " (" << noshowbase - << hex << "0x" << endOffset << dec << "):" << endl; - const UInt_t* start = reinterpret_cast(fDumpStart); - const UInt_t* end = reinterpret_cast(dumpEnd); - cerr << " Start byte | Data words" << endl; - for (const UInt_t* current = start; current < end; current++) - { - unsigned long currentByte = (unsigned long)current - - (unsigned long)fBufferStart + sizeof(AliRawDataHeader); - cerr << right << setw(9) << dec << currentByte << setw(0) - << " 0x" << left << setw(7) << noshowbase << hex - << currentByte << setw(0) << right << " | "; - char fillChar = cerr.fill(); - cerr.fill('0'); - for (int i = 0; i < 4 and current < end; i++, current++) - { - cerr << noshowbase << hex << "0x" << setw(8) - << (*current) << setw(0) << dec << " "; - } - cerr.fill(fillChar); - cerr << endl; - } - fDumpStart = NULL; - fDumpData = false; - } + void TryDumpCorruptData(const void* dumpEnd); const void* fBufferStart; ///< Start location of buffer. const void* fDumpStart; ///< Start location of corrupt data to dump. bool fDumpData; ///< Flag indicating if fDumpStart points to corrupt data and should be dumped. }; + + + void AliDecoderHandler::HandleError( + const char* errorMessage, int errorCode, + const char* errorCodeString, const void* location + ) + { + unsigned long offset = (unsigned long)location - (unsigned long)fBufferStart + + sizeof(AliRawDataHeader); + + cerr << "ERROR: " << errorMessage + << " [Error code = " << errorCode << " (" + << errorCodeString << "), at byte " + << offset << " (" << noshowbase << hex << "0x" + << offset << dec << ")]" << endl; + + if (fDumpStart == NULL) fDumpStart = location; + fDumpData = true; + } + + + void AliDecoderHandler::TryDumpCorruptData(const void* dumpEnd) + { + if (dumpEnd < fDumpStart) return; + if (not fDumpData) return; + + unsigned long startOffset = (unsigned long)fDumpStart - (unsigned long)fBufferStart + + sizeof(AliRawDataHeader); + unsigned long endOffset = (unsigned long)dumpEnd - (unsigned long)fBufferStart + + sizeof(AliRawDataHeader); + if (endOffset - startOffset > 264) + { + endOffset = startOffset + 264; + dumpEnd = reinterpret_cast(fBufferStart) + endOffset; + } + cerr << "Dumping corrupt data words from byte " << startOffset + << " (" << noshowbase << hex << "0x" << startOffset + << dec << "), to byte " << endOffset << " (" << noshowbase + << hex << "0x" << endOffset << dec << "):" << endl; + const UInt_t* start = reinterpret_cast(fDumpStart); + const UInt_t* end = reinterpret_cast(dumpEnd); + cerr << " Start byte | Data words" << endl; + for (const UInt_t* current = start; current < end; current++) + { + unsigned long currentByte = (unsigned long)current + - (unsigned long)fBufferStart + sizeof(AliRawDataHeader); + cerr << right << setw(9) << dec << currentByte << setw(0) + << " 0x" << left << setw(7) << noshowbase << hex + << currentByte << setw(0) << right << " | "; + char fillChar = cerr.fill(); + cerr.fill('0'); + for (int i = 0; i < 4 and current < end; i++, current++) + { + cerr << noshowbase << hex << "0x" << setw(8) + << (*current) << setw(0) << dec << " "; + } + cerr.fill(fillChar); + cerr << endl; + } + fDumpStart = NULL; + fDumpData = false; + } /** * Event handler for the tracker DDL decoder. @@ -310,7 +333,10 @@ namespace public: AliTrackerDecoderHandler() : AliMUONTrackerDDLDecoderEventHandler(), - AliDecoderHandler() + AliDecoderHandler(), + fBlockNum(0), + fDSPNum(0), + fBusPatchNum(0) {} virtual ~AliTrackerDecoderHandler() {} @@ -318,6 +344,7 @@ namespace void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/) { fBufferStart = buffer; + fBlockNum = fDSPNum = fBusPatchNum = 0; } void OnEndOfBuffer(const void* buffer, UInt_t bufferSize) @@ -327,53 +354,140 @@ namespace TryDumpCorruptData(bufferEnd); } - void OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/) - { - TryDumpCorruptData(header); - - //TODO print nicely. - cout << "block: " << header << endl; - } + void OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/); - void OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/) - { - TryDumpCorruptData(header); - - //TODO print nicely. - cout << "DSP: " << header << endl; - } + void OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/); + + void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/); - void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/) + void OnData(UInt_t data, bool parityError); + + void OnError(ErrorCode error, const void* location); + + private: + + UInt_t fBlockNum; ///< Number of block being processed [1..maxBlock]. + UInt_t fDSPNum; ///< Number of DSP being processed [1..maxDSP]. + UInt_t fBusPatchNum; ///< Number of bus patch being processed [1..maxBusPatch]. + }; + + + void AliTrackerDecoderHandler::OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/) + { + TryDumpCorruptData(header); + fBlockNum++; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << "================================ Block header " + << setw(3) << fBlockNum << setw(0) + << " ================================" << endl; + cout << " Data key word for block : 0x" << noshowbase << setw(8) << setfill('0') + << hex << header->fDataKey << dec << setfill(fillChar) << setw(0) << endl; + cout << " Total Length of block : " << header->fTotalLength << endl; + cout << " Length of raw data : " << header->fLength << endl; + cout << " DSP ID : " << header->fDSPId << endl; + cout << " L0 trigger word : " << header->fL0Trigger << " (0x" + << noshowbase << setw(8) << setfill('0') << hex << header->fL0Trigger + << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << " Mini event ID : " << header->fMiniEventId << " (0x" + << noshowbase << setw(8) << setfill('0') << hex << header->fMiniEventId + << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << "Event ID In Bunch Crossing : " << header->fEventId1 << " (0x" + << noshowbase << setw(8) << setfill('0') << hex << header->fEventId1 + << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << " Event ID In Orbit Number : " << header->fEventId2 << " (0x" + << noshowbase << setw(8) << setfill('0') << hex << header->fEventId2 + << dec << setw(0) << setfill(fillChar) << ")" << endl; + } + + + void AliTrackerDecoderHandler::OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/) + { + TryDumpCorruptData(header); + fDSPNum++; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << "================================= DSP header " + << setw(3) << fDSPNum << setw(0) + << " =================================" << endl; + cout << " Data key word for FRT : 0x" << noshowbase + << setw(8) << setfill('0') << hex << header->fDataKey << dec + << setfill(fillChar) << setw(0) << endl; + cout << " Total length of structure : " << header->fTotalLength << endl; + cout << " Length of raw data : " << header->fLength << endl; + cout << " DSP ID : " << header->fDSPId << endl; + cout << " L1 accept in block Structure (CRT) : " << header->fBlkL1ATrigger + << " (0x" << noshowbase << setw(8) << setfill('0') << hex + << header->fBlkL1ATrigger << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << " Mini event ID in bunch crossing : " << header->fMiniEventId + << " (0x" << noshowbase << setw(8) << setfill('0') << hex + << header->fMiniEventId << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << "Number of L1 accept in DSP Structure (FRT) : " << header->fL1ATrigger << endl; + cout << "Number of L1 reject in DSP Structure (FRT) : " << header->fL1RTrigger << endl; + const char* paddingWordValue = ") (INVALID)"; + if (header->fPaddingWord == 0) paddingWordValue = ") (false)"; + if (header->fPaddingWord == 1) paddingWordValue = ") (true)"; + cout << " Padding word set for 64 bits transfer : " << header->fPaddingWord + << " (0x" << noshowbase << setw(8) << setfill('0') << hex + << header->fPaddingWord << setw(0) << setfill(fillChar) << dec + << paddingWordValue << endl; + cout << " Error word : " << header->fErrorWord + << " (" << noshowbase << setw(8) << setfill('0') << hex + << header->fErrorWord << setw(0) << setfill(fillChar) + << dec << ")" << endl; + } + + + void AliTrackerDecoderHandler::OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* /*data*/) + { + TryDumpCorruptData(header); + fBusPatchNum++; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << "============================== Bus patch header " + << setw(3) << fBusPatchNum << setw(0) + << " ==============================" << endl; + cout << "Data key word for bus patch : 0x" << noshowbase << setw(8) + << setfill('0') << hex << header->fDataKey << dec + << setfill(fillChar) << setw(0) << endl; + cout << " Total length of structure : " << header->fTotalLength << endl; + cout << " Length of raw data : " << header->fLength << endl; + cout << " Bus patch ID : " << header->fBusPatchId << endl; + if (header->fLength > 0) { - TryDumpCorruptData(header); - - //TODO print nicely. - cout << "buspatch: " << header << endl; + cout << " Raw bits | Manu ID | Manu channel | ADC Signal" << endl; + cout << "----------------------------------------------------------" << endl; } - - void OnData(UInt_t data, bool parityError) + } + + + void AliTrackerDecoderHandler::OnData(UInt_t data, bool parityError) + { + UShort_t manuId, adc; + UChar_t manuChannel; + UnpackADC(data, manuId, manuChannel, adc); + char fillChar = cout.fill(); // store current fill char to restore it. + cout << noshowbase << " 0x" << setfill('0') << hex << setw(8) << data + << setw(0) << dec << setfill(fillChar) << " " + << setw(12) << manuId << setw(0) << " " + << setw(12) << (UInt_t)manuChannel << setw(0) << " " + << setw(12) << adc << setw(0); + if (parityError) { - if (parityError) - { - // TODO complete - cerr << "Raw data word with parity error" << data << endl; - } - else - { - //TODO print nicely. - cout << "data word: 0x" << hex << data << dec << endl; - } + cout << " <= WARNING: Raw data word with parity error!" << endl; } - - void OnError(ErrorCode error, const void* location) + else { - TryDumpCorruptData(location); - HandleError( - ErrorCodeToMessage(error), error, - ErrorCodeToString(error), location - ); + cout << endl; } - }; + } + + + void AliTrackerDecoderHandler::OnError(ErrorCode error, const void* location) + { + TryDumpCorruptData(location); + HandleError( + ErrorCodeToMessage(error), error, + ErrorCodeToString(error), location + ); + } /** * Event handler for the trigger DDL decoder. @@ -385,7 +499,9 @@ namespace public: AliTriggerDecoderHandler() : AliMUONTriggerDDLDecoderEventHandler(), - AliDecoderHandler() + AliDecoderHandler(), + fRegNum(0), + fLocNum(0) {} virtual ~AliTriggerDecoderHandler() {} @@ -393,6 +509,7 @@ namespace void OnNewBuffer(const void* buffer, UInt_t /*bufferSize*/) { fBufferStart = buffer; + fRegNum = fLocNum = 0; } void OnEndOfBuffer(const void* buffer, UInt_t bufferSize) @@ -402,84 +519,673 @@ namespace TryDumpCorruptData(bufferEnd); } + const char* EventTypeToString(UInt_t type); + + const char* DarcTypeToString(UInt_t type); + void OnDarcHeader( UInt_t header, const AliMUONDarcScalarsStruct* scalars, const void* data - ) - { - if (scalars != NULL) - TryDumpCorruptData(scalars); - else - TryDumpCorruptData(data); - - //TODO print nicely. - cout << "DARC header: " << header << endl; - } + ); void OnGlobalHeader( const AliMUONGlobalHeaderStruct* header, - const AliMUONGlobalScalarsStruct* /*scalars*/, + const AliMUONGlobalScalarsStruct* scalars, const void* /*data*/ - ) - { - TryDumpCorruptData(header); - - //TODO print nicely. - cout << "global header: " << header << endl; - } + ); void OnNewRegionalStruct( const AliMUONRegionalHeaderStruct* regionalStruct, - const AliMUONRegionalScalarsStruct* /*scalars*/, + const AliMUONRegionalScalarsStruct* scalars, const void* /*data*/ - ) - { - TryDumpCorruptData(regionalStruct); - - //TODO print nicely. - cout << "regional struct: " << regionalStruct << endl; - } + ); void OnLocalStruct( const AliMUONLocalInfoStruct* localStruct, - const AliMUONLocalScalarsStruct* /*scalars*/ - ) + const AliMUONLocalScalarsStruct* scalars + ); + + void OnError(ErrorCode error, const void* location); + + private: + + UInt_t fRegNum; ///< Number of block being processed [1..maxReg]. + UInt_t fLocNum; ///< Number of DSP being processed [1..maxLoc]. + }; + + + const char* AliTriggerDecoderHandler::EventTypeToString(UInt_t type) + { + switch (type) { - TryDumpCorruptData(localStruct); - - //TODO print nicely. - cout << "local struct: " << localStruct << endl; + case 0: return "Other software trigger"; + case 1: return "Physics"; + case 2: return "Start of run"; + case 3: return "End of run"; + default: return "UNKNOWN"; } + } + + + const char* AliTriggerDecoderHandler::DarcTypeToString(UInt_t type) + { + typedef AliMUONTriggerDDLDecoder AliDec; + if (type == AliDec::DarcDefaultType()) return "Default"; + if (type == AliDec::DarcVadorhType()) return "Vadorh"; + return "UNKNOWN"; + } + + + void AliTriggerDecoderHandler::OnDarcHeader( + UInt_t header, + const AliMUONDarcScalarsStruct* scalars, + const void* data + ) + { + if (scalars != NULL) + TryDumpCorruptData(scalars); + else + TryDumpCorruptData(data); + + cout << "================================ DARC header =====================================" << endl; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << noshowbase << " Header bit pattern : 0x" << setfill('0') << hex << setw(8) + << header << setw(0) << dec << setfill(fillChar) << endl; + UInt_t eventType = GetDarcEventType(header); + cout << " Event type : " << eventType << " (" + << EventTypeToString(eventType) << ")" << endl; + cout << " Application type : " << ((header >> 27) & 0x7) << endl; + UInt_t darcType = GetDarcType(header); + cout << " DARC type : " << darcType << " (" + << DarcTypeToString(darcType) << ")" << endl; + cout << " Serial number : " << (UInt_t)GetDarcSerialNb(header) << endl; + cout << " Version : " << (UInt_t)GetDarcVersion(header) << endl; + cout << " VME trigger used : " << boolalpha << GetDarcVMETrig(header) << endl; + cout << "Global card data occurrence : " << boolalpha << GetDarcGlobalFlag(header) << endl; + cout << " CTP or LTU interfaced : " << boolalpha << GetDarcCTPTrig(header) << endl; + cout << " DAQ interfaced : " << boolalpha << GetDarcDAQFlag(header) << endl; + cout << " Regional cards occurrence : 0x" << noshowbase << hex << setw(2) << setfill('0') + << (UInt_t)GetDarcRegPattern(header) << dec << setfill(fillChar) << setw(0) + << " [bits: "; + PrintBitPattern(((UInt_t)GetDarcRegPattern(header) >> 4) & 0xF, 4); cout << " "; + PrintBitPattern(((UInt_t)GetDarcRegPattern(header) >> 0) & 0xF, 4); + cout << "]" << endl; - void OnError(ErrorCode error, const void* location) + cout << "================================ DARC scalars ====================================" << endl; + if (scalars != NULL) { - TryDumpCorruptData(location); - HandleError( - ErrorCodeToMessage(error), error, - ErrorCodeToString(error), location - ); + cout << " Trigger | Received | Used" << endl; + cout << "----------------------------------" << endl; + cout << " L0 " << setw(8) << ((scalars->fL0R >> 16) & 0xFFFF) << setw(0) + << " " << setw(8) << ((scalars->fL0R >> 0) & 0xFFFF) << setw(0) << endl; + cout << " L1 physics " << setw(8) << ((scalars->fL1P >> 16) & 0xFFFF) << setw(0) + << " " << setw(8) << ((scalars->fL1P >> 0) & 0xFFFF) << setw(0) << endl; + cout << "L1 software " << setw(8) << ((scalars->fL1S >> 16) & 0xFFFF) << setw(0) + << " " << setw(8) << ((scalars->fL1S >> 0) & 0xFFFF) << setw(0) << endl; + cout << " L2 accept " << setw(8) << ((scalars->fL2A >> 16) & 0xFFFF) << setw(0) + << " " << setw(8) << ((scalars->fL2A >> 0) & 0xFFFF) << setw(0) << endl; + cout << " L2 reject " << setw(8) << ((scalars->fL2R >> 16) & 0xFFFF) << setw(0) + << " " << setw(8) << ((scalars->fL2R >> 0) & 0xFFFF) << setw(0) << endl; + cout << " Clock : " << scalars->fClk << endl; + cout << "Hold (dead time) : " << scalars->fHold << endl; + cout << " Spare word : " << scalars->fSpare << " (0x" + << setw(8) << setfill('0') << hex << scalars->fSpare << + setw(0) << setfill(fillChar) << dec << ")" << endl; } - }; + else + { + cout << "(None found)" << endl; + } + } + + + void AliTriggerDecoderHandler::OnGlobalHeader( + const AliMUONGlobalHeaderStruct* header, + const AliMUONGlobalScalarsStruct* scalars, + const void* /*data*/ + ) + { + TryDumpCorruptData(header); + + cout << "=============================== Global header ====================================" << endl; + cout << "Global input from regional controllers:" << endl; + cout << " | | High pT | Low pT " << endl; + cout << " | Bit pattern | Single mu | mu pair | Single mu | mu pair " << endl; + cout << "Input | Hex | Binary | -ve | +ve | unlike | like | -ve | +ve | unlike | like" << endl; + cout << "--------------------------------------------------------------------------------" << endl; + char fillChar = cout.fill(); // store current fill char to restore it. + for (int i = 0; i < 4; i++) + { + union + { + UInt_t fWord; + UChar_t fByte[4]; + } input; + input.fWord = header->fInput[i]; + for (int j = 0; j < 4; j++) + { + cout << setw(5) << (i*4+j) << " 0x" << noshowbase << setw(2) + << setfill('0') << hex << (UInt_t)input.fByte[j] << setw(0) + << setfill(fillChar) << dec << " "; + PrintBitPattern(input.fByte[j], 8); + cout << ((((input.fByte[j] >> 7) & 0x1) == 1) ? " yes" : " no"); + cout << ((((input.fByte[j] >> 6) & 0x1) == 1) ? " yes" : " no"); + cout << ((((input.fByte[j] >> 5) & 0x1) == 1) ? " yes " : " no "); + cout << ((((input.fByte[j] >> 4) & 0x1) == 1) ? " yes" : " no"); + cout << ((((input.fByte[j] >> 3) & 0x1) == 1) ? " yes" : " no"); + cout << ((((input.fByte[j] >> 2) & 0x1) == 1) ? " yes" : " no"); + cout << ((((input.fByte[j] >> 1) & 0x1) == 1) ? " yes " : " no "); + cout << ((((input.fByte[j] >> 0) & 0x1) == 1) ? " yes" : " no"); + cout << endl; + } + } + cout << " Global ouput : 0x" << noshowbase << setw(2) << setfill('0') << hex + << (UInt_t)GetGlobalOutput(header) << setw(0) << setfill(fillChar) << dec << " [Bits: "; + PrintBitPattern(((UInt_t)GetGlobalOutput(header) >> 4) & 0xF, 4); cout << " "; + PrintBitPattern(((UInt_t)GetGlobalOutput(header) >> 0) & 0xF, 4); + cout << "]" << endl; + cout << " [ unlike sign | like sign | single muon ]" << endl; + cout << " [ high | low | high | low | high | low ]" << endl; + cout << " [-----------------------------------------]" << endl; + cout << " [ "; + cout << ((((GetGlobalOutput(header) >> 5) & 0x1) == 1) ? " yes" : " no"); + cout << ((((GetGlobalOutput(header) >> 4) & 0x1) == 1) ? " yes" : " no"); + cout << ((((GetGlobalOutput(header) >> 3) & 0x1) == 1) ? " yes" : " no"); + cout << ((((GetGlobalOutput(header) >> 2) & 0x1) == 1) ? " yes" : " no"); + cout << ((((GetGlobalOutput(header) >> 1) & 0x1) == 1) ? " yes" : " no"); + cout << ((((GetGlobalOutput(header) >> 0) & 0x1) == 1) ? " yes" : " no"); + cout << " ]" << endl; + cout << "Global configuration : 0x" << noshowbase << setw(4) << setfill('0') << hex + << GetGlobalConfig(header) << setw(0) << setfill(fillChar) << dec << " [Bits: "; + PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 12) & 0xF, 4); cout << " "; + PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 8) & 0xF, 4); cout << " "; + PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 4) & 0xF, 4); cout << " "; + PrintBitPattern(((UInt_t)GetGlobalConfig(header) >> 0) & 0xF, 4); + cout << "]" << endl; + + cout << "=============================== Global scalars ===================================" << endl; + if (scalars != NULL) + { + cout << " Number of L0 triggers : " << scalars->fL0 << endl; + cout << " Number of clock cycles : " << scalars->fClk << endl; + cout << " Number of unlike mu pair low pT : " << scalars->fScaler[0] << endl; + cout << "Number of unlike mu pair high pT : " << scalars->fScaler[1] << endl; + cout << " Number of like mu pair low pT : " << scalars->fScaler[2] << endl; + cout << " Number of like mu pair high pT : " << scalars->fScaler[3] << endl; + cout << " Number of single mu low pT : " << scalars->fScaler[4] << endl; + cout << " Number of single mu high pT : " << scalars->fScaler[5] << endl; + cout << " Hold (dead time) : " << scalars->fHold << endl; + cout << " Spare word : " << scalars->fSpare << " (0x" + << setw(8) << setfill('0') << hex << scalars->fSpare << + setw(0) << setfill(fillChar) << dec << ")" << endl; + } + else + { + cout << "(None found)" << endl; + } + } + + + void AliTriggerDecoderHandler::OnNewRegionalStruct( + const AliMUONRegionalHeaderStruct* regionalStruct, + const AliMUONRegionalScalarsStruct* scalars, + const void* /*data*/ + ) + { + TryDumpCorruptData(regionalStruct); + + fRegNum++; + cout << "========================= Regional structure header " + << setw(3) << fRegNum << setw(0) + << " ==========================" << endl; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << "Darc word bit pattern : 0x" << noshowbase << setw(8) << setfill('0') + << hex << regionalStruct->fDarcWord << setw(0) + << setfill(fillChar) << dec << endl; + UShort_t errBits = GetRegionalErrorBits(regionalStruct); + cout << " [ Error type : " + << (((errBits >> 7) & 0x1) == 1 ? "1 (Physics) " : "0 (Software)") + << " ]" << endl; + cout << " [ Regional error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ Full error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ Empty error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ DARC L2 reject error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ DARC L2 error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ DARC L1 error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + cout << " [ DARC L0 error : " << ((errBits >> 6) & 0x1) << " ]" << endl; + + cout << " [ FPGA number in card : " + << (UInt_t)GetRegionalFPGANumber(regionalStruct) << " ("; + PrintBitPattern((UInt_t)GetRegionalFPGANumber(regionalStruct), 3); + cout << "b) ]" << endl; + + cout << " [ Physics trigger : " << setw(13) << boolalpha << left + << GetRegionalDarcPhysFlag(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ Regional present : " << setw(13) << boolalpha << left + << GetRegionalPresentFlag(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ RAM not full : " << setw(13) << boolalpha << left + << GetRegionalRamNotFullFlag(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ RAM not empty : " << setw(13) << boolalpha << left + << GetRegionalRamNotEmptyFlag(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ L2 rejected : " << setw(13) << boolalpha << left + << GetRegionalL2RejStatus(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ L2 accepted : " << setw(13) << boolalpha << left + << GetRegionalL2AccStatus(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ L1 found : " << setw(13) << boolalpha << left + << GetRegionalL1Status(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ L0 found : " << setw(13) << boolalpha << left + << GetRegionalL0Status(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ No. of events in RAM : " << setw(13) << left + << (UInt_t)GetRegionalEventInRam(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ Busy word : 0x" + << (UInt_t)GetRegionalBusy(regionalStruct) << " ("; + PrintBitPattern((UInt_t)GetRegionalBusy(regionalStruct), 4); + cout << "b) ]" << endl; + + cout << "Regional word bit pattern : 0x" << noshowbase << setw(8) << setfill('0') + << hex << regionalStruct->fWord << setw(0) + << setfill(fillChar) << dec << endl; + cout << " [ Physics trigger occurred : " << setw(27) << boolalpha << left + << (UInt_t)GetRegionalPhysFlag(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ Number of resets : " << setw(27) << left + << (UInt_t)GetRegionalResetNb(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ Controller Serial number : " << setw(27) << left + << (UInt_t)GetRegionalSerialNb(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ Regional crate ID : " << setw(27) << left + << (UInt_t)GetRegionalId(regionalStruct) << setw(0) + << right << "]" << endl; + cout << " [ FPGA software version : " << setw(27) << left + << (UInt_t)GetRegionalVersion(regionalStruct) << setw(0) + << right << "]" << endl; + UInt_t output = GetRegionalOutput(regionalStruct); + cout << " [ Regional output : 0x" << setw(2) << setfill('0') << hex + << output << dec << setw(0) << setfill(fillChar) << setw(0) << right << " ("; + PrintBitPattern(output, 8); + cout << "b) ]" << endl; + + cout << " [ High pT | Low pT ]" << endl; + cout << " [ Single mu | mu pair | Single mu | mu pair ]" << endl; + cout << " [ -ve | +ve | unlike | like | -ve | +ve | unlike | like ]" << endl; + cout << " [-------------------------------------------------------]" << endl; + cout << ((((output >> 7) & 0x1) == 1) ? " [ yes" : " [ no"); + cout << ((((output >> 6) & 0x1) == 1) ? " yes" : " no"); + cout << ((((output >> 5) & 0x1) == 1) ? " yes " : " no "); + cout << ((((output >> 4) & 0x1) == 1) ? " yes" : " no"); + cout << ((((output >> 3) & 0x1) == 1) ? " yes" : " no"); + cout << ((((output >> 2) & 0x1) == 1) ? " yes" : " no"); + cout << ((((output >> 1) & 0x1) == 1) ? " yes " : " no "); + cout << ((((output >> 0) & 0x1) == 1) ? " yes ]" : " no ]"); + cout << endl; + + cout << "Regional input (low pT) bit pattern : 0x" << noshowbase << setw(8) + << setfill('0') << hex << regionalStruct->fInput[0] + << setw(0) << setfill(fillChar) << dec << endl; + cout << "Regional input (high pT) bit pattern : 0x" << noshowbase << setw(8) + << setfill('0') << hex << regionalStruct->fInput[1] + << setw(0) << setfill(fillChar) << dec << endl; + cout << "Regional input logical dump: " << endl; + cout << " Local | Local | low pT mu | high pT mu" << endl; + cout << "structure no. | board | -ve | +ve | -ve | +ve" << endl; + cout << "-----------------------------------------------" << endl; + for (int i = 15; i >= 0 ; i--) + { + cout << setw(13) << (fLocNum + 16 - i) << setw(0) << " "; + cout << setw(5) << (15 - i) << setw(0) << " "; + cout << ((((regionalStruct->fInput[0] >> (i*2+1)) & 0x1) == 1) ? "yes" : " no"); + cout << ((((regionalStruct->fInput[0] >> (i*2+0)) & 0x1) == 1) ? " yes" : " no"); + cout << ((((regionalStruct->fInput[1] >> (i*2+1)) & 0x1) == 1) ? " yes" : " no"); + cout << ((((regionalStruct->fInput[1] >> (i*2+0)) & 0x1) == 1) ? " yes" : " no"); + cout << endl; + } + + UInt_t mask = GetRegionalMask(regionalStruct); + cout << "Local mask : 0x" << noshowbase << setw(4) << setfill('0') << hex + << mask << dec << setw(0) << setfill(fillChar) << " [Bits: "; + PrintBitPattern(mask >> 12, 4); cout << " "; + PrintBitPattern(mask >> 8, 4); cout << " "; + PrintBitPattern(mask >> 4, 4); cout << " "; + PrintBitPattern(mask >> 0, 4); cout << "]" << endl; + + cout << "L0 counter : " << GetRegionalL0(regionalStruct) << endl; + + cout << "========================= Regional structure scalars " + << setw(3) << fRegNum << setw(0) + << " =========================" << endl; + if (scalars != NULL) + { + cout << " Number of clock cycles : " << scalars->fClk << endl; + cout << " Number of high pT +ve single mu : " << scalars->fScaler[0] << endl; + cout << " Number of high pT -ve single mu : " << scalars->fScaler[1] << endl; + cout << "Number of high pT unlike sign pair : " << scalars->fScaler[2] << endl; + cout << " Number of high pT like sign pair : " << scalars->fScaler[3] << endl; + cout << " Number of low pT +ve single mu : " << scalars->fScaler[4] << endl; + cout << " Number of low pT -ve single mu : " << scalars->fScaler[5] << endl; + cout << " Number of low pT unlike sign pair : " << scalars->fScaler[6] << endl; + cout << " Number of low pT like sign pair : " << scalars->fScaler[7] << endl; + cout << " Hold (dead time) : " << scalars->fHold << endl; + } + else + { + cout << "(None found)" << endl; + } + } + + + void AliTriggerDecoderHandler::OnLocalStruct( + const AliMUONLocalInfoStruct* localStruct, + const AliMUONLocalScalarsStruct* scalars + ) + { + TryDumpCorruptData(localStruct); + + fLocNum++; + cout << "=========================== Local structure header " + << setw(3) << fLocNum << setw(0) + << " ===========================" << endl; + char fillChar = cout.fill(); // store current fill char to restore it. + cout << "L0 strip patterns:" << endl; + cout << "Chamber | X | Y " << endl; + cout << "----------------------------------------------" << endl; + cout << " 11 "; + PrintBitPattern(GetLocalX1(localStruct), 16); + cout << " "; + PrintBitPattern(GetLocalY1(localStruct), 16); + cout << endl; + cout << " 12 "; + PrintBitPattern(GetLocalX2(localStruct), 16); + cout << " "; + PrintBitPattern(GetLocalY2(localStruct), 16); + cout << endl; + cout << " 13 "; + PrintBitPattern(GetLocalX3(localStruct), 16); + cout << " "; + PrintBitPattern(GetLocalY3(localStruct), 16); + cout << endl; + cout << " 14 "; + PrintBitPattern(GetLocalX4(localStruct), 16); + cout << " "; + PrintBitPattern(GetLocalY4(localStruct), 16); + cout << endl; + + cout << "L0 trigger bits: (word = "; + cout << showbase << hex << localStruct->fTriggerBits + << noshowbase << dec << ")" << endl; + cout << " ID | Dec | TrigY | YPos | Sign XDev | XDev | XPos " << endl; + cout << "----------------------------------------------------------------" << endl; + cout << "Decimal : " << setw(4) << (UInt_t)GetLocalId(localStruct) << setw(0) << " "; + cout << setw(4) << (UInt_t)GetLocalDec(localStruct) << setw(0) << " "; + cout << setw(3) << (UInt_t)GetLocalTrigY(localStruct) << setw(0) << " "; + cout << setw(4) << (UInt_t)GetLocalYPos(localStruct) << setw(0) << " "; + cout << setw(5) << (UInt_t)GetLocalSXDev(localStruct) << setw(0) << " "; + cout << setw(4) << (UInt_t)GetLocalXDev(localStruct) << setw(0) << " "; + cout << setw(4) << (UInt_t)GetLocalXPos(localStruct) << setw(0) << endl; + cout << " Binary : "; + PrintBitPattern(AliHLTUInt32_t(GetLocalId(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalDec(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalTrigY(localStruct)), 1); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalYPos(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalSXDev(localStruct)), 1); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalXDev(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(GetLocalXPos(localStruct)), 5); + cout << endl; + + cout << "L0 decision (Dec): [high pT: "; + PrintBitPattern((UInt_t)GetLocalHpt(localStruct), 2); + cout << "b ("; + switch ((UInt_t)GetLocalHpt(localStruct)) + { + case 0: cout << "No trigger"; break; + case 1: cout << "-ve particle"; break; + case 2: cout << "+ve particle"; break; + case 3: cout << "No deviation trigger"; break; + default: cout << "UNKNOWN"; break; + } + cout << "), low pT: "; + PrintBitPattern((UInt_t)GetLocalLpt(localStruct), 2); + cout << "b ("; + switch ((UInt_t)GetLocalLpt(localStruct)) + { + case 0: cout << "No trigger"; break; + case 1: cout << "-ve particle"; break; + case 2: cout << "+ve particle"; break; + case 3: cout << "No deviation trigger"; break; + default: cout << "UNKNOWN"; break; + } + cout << ")]" << endl; + + cout << "=========================== Local structure scalars " + << setw(3) << fLocNum << setw(0) + << " ==========================" << endl; + if (scalars != NULL) + { + cout << " Number of L0 triggers : " << scalars->fL0 << endl; + cout << " Hold (dead time) : " << scalars->fHold << endl; + cout << " Number of clock cycles : " << scalars->fClk << endl; + cout << " Number of low pT no triggers : " << scalars->fLPtNTrig << endl; + cout << " Number of high pT no triggers : " << scalars->fHPtNTrig << endl; + cout << " Number of low pT right triggers : " << scalars->fLPtRTrig << endl; + cout << " Number of high pT right triggers : " << scalars->fHPtRTrig << endl; + cout << " Number of low pT left triggers : " << scalars->fLPtLTrig << endl; + cout << " Number of high pT left triggers : " << scalars->fHPtLTrig << endl; + cout << " Number of low pT straight triggers : " << scalars->fLPtSTrig << endl; + cout << "Number of high pT straight triggers : " << scalars->fHPtSTrig << endl; + + UInt_t xoryflag = GetLocalComptXY(scalars); + if (xoryflag == 1) + { + cout << "Y strip counts:" << endl; + } + else + { + cout << "X strip counts:" << endl; + } + cout << " | Chamber " << endl; + cout << "Strip | 11 | 12 | 13 | 14" << endl; + cout << "------------------------------------------" << endl; + for (int i = 0; i < 16; i++) + { + cout << setw(5) << i << setw(0) << " " + << setw(6) << (UInt_t)GetLocalXY1(scalars, i) << setw(0) << " " + << setw(6) << (UInt_t)GetLocalXY2(scalars, i) << setw(0) << " " + << setw(6) << (UInt_t)GetLocalXY3(scalars, i) << setw(0) << " " + << setw(6) << (UInt_t)GetLocalXY4(scalars, i) << setw(0) << endl; + } + + cout << " EOS word : 0x" << setw(8) << setfill('0') + << hex << scalars->fEOS << setw(0) << setfill(fillChar) << dec << endl; + cout << " [ Switches : 0x" << setw(3) + << setfill('0') << hex << (UInt_t)GetLocalSwitch(scalars) + << setw(0) << setfill(fillChar) << dec << " ("; + PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 8, 2); cout << " "; + PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 4, 4); cout << " "; + PrintBitPattern((UInt_t)GetLocalSwitch(scalars) >> 0, 4); + cout << "b) ]" << endl; + cout << " [ X or Y : " << xoryflag + << ((xoryflag == 1) ? " (scalars for Y strips) ]" : " (scalars for X strips) ]") + << endl; + + cout << "Reset signal : " << scalars->fReset << endl; + } + else + { + cout << "(None found)" << endl; + } + } + + + void AliTriggerDecoderHandler::OnError(ErrorCode error, const void* location) + { + TryDumpCorruptData(location); + HandleError( + ErrorCodeToMessage(error), error, + ErrorCodeToString(error), location + ); + } } // end of namespace -int DumpTrackerDDLRawStream( - const char* buffer, unsigned long bufferSize, +int DumpRawDataHeader( + const char* buffer, unsigned long bufferSize, const AliRawDataHeader* header, bool continueParse ) { - // TODO dump the CDH header. + // Dumps the common DDL raw data block header. + + cout << "*************************** Common DDL data header *******************************" << endl; + char fillChar = cout.fill(); // remember fill char to set back to original later. + int result = CheckHeaderField(header->fSize, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Size of the raw data in bytes : "; + if (header->fSize != 0xFFFFFFFF) + cout << header->fSize; + else + cout << "0xFFFFFFFF (unknown)"; + cout << endl; + + result = CheckHeaderField(header->fWord2, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " Format version : " << UInt_t(header->GetVersion()) << endl; + UInt_t l1msg = header->GetL1TriggerMessage(); + cout << " L1 trigger message : 0x" + << noshowbase << hex << setfill('0') << setw(2) << l1msg + << setw(0) << setfill(fillChar) << dec + << " [Spare: " << ((l1msg >> 7) & 0x1) + << ", ClT: " << ((l1msg >> 6) & 0x1) + << ", RoC: 0x" << noshowbase << hex << ((l1msg >> 2) & 0x4) << dec + << ", ESR: " << ((l1msg >> 1) & 0x1) + << ", L1SwC: " << ((l1msg >> 0) & 0x1) << "]" << endl; + cout << " Bunch crossing (Event ID1) : " << header->GetEventID1() << " (0x" + << noshowbase << hex << setfill('0') << setw(3) << header->GetEventID1() + << dec << setw(0) << setfill(fillChar) << ")" << endl; + + result = CheckHeaderField(header->fEventID2, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " Orbit number (Event ID2) : " << header->fEventID2 << " (0x" + << noshowbase << hex << setfill('0') << setw(6) << header->fEventID2 + << dec << setw(0) << setfill(fillChar) << ")" << endl; + + result = CheckHeaderField(header->fAttributesSubDetectors, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " Block attributes : " << UInt_t(header->GetAttributes()) << " (0x" + << noshowbase << hex << setfill('0') << setw(2) << UInt_t(header->GetAttributes()) + << dec << setw(0) << setfill(fillChar) << ")" << endl; + cout << " Participating sub-detectors : 0x" << noshowbase << hex + << setfill('0') << setw(6) << header->GetSubDetectors() << dec + << setw(0) << setfill(fillChar) << " [Bits: "; + for (int i = 5; i >= 0; i--) + { + PrintBitPattern(header->GetSubDetectors() >> (i*4), 4); + if (i != 0) + cout << " "; + else + cout << "]" << endl; + } + + result = CheckHeaderField(header->fStatusMiniEventID, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + UInt_t statusBits = header->GetStatus(); + cout << " Status & error bits : 0x" << noshowbase << hex + << setfill('0') << setw(4) << statusBits << setw(0) << setfill(fillChar) + << dec << endl; + cout << " [ Original data bit : " << ((statusBits >> 15) & 0x1) << " ]" << endl; + cout << " [ Multi-event buffer error : " << ((statusBits >> 14) & 0x1) << " ]" << endl; + cout << " [ Trigger L1 missing error : " << ((statusBits >> 13) & 0x1) << " ]" << endl; + cout << " [ Trigger error (other) : " << ((statusBits >> 12) & 0x1) << " ]" << endl; + cout << " [ Pre-pulse error : " << ((statusBits >> 11) & 0x1) << " ]" << endl; + cout << " [ Trigger L2 time violation : " << ((statusBits >> 10) & 0x1) << " ]" << endl; + cout << " [ Trigger L1 time violation : " << ((statusBits >> 9) & 0x1) << " ]" << endl; + cout << " [ DDG payload flag : " << ((statusBits >> 8) & 0x1) << " ]" << endl; + cout << " [ HLT payload flag : " << ((statusBits >> 7) & 0x1) << " ]" << endl; + cout << " [ HLT decision flag : " << ((statusBits >> 6) & 0x1) << " ]" << endl; + cout << " [ FEE error : " << ((statusBits >> 5) & 0x1) << " ]" << endl; + cout << " [ Trigger information unavailable : " << ((statusBits >> 4) & 0x1) << " ]" << endl; + cout << " [ Control parity error : " << ((statusBits >> 3) & 0x1) << " ]" << endl; + cout << " [ Data parity error : " << ((statusBits >> 2) & 0x1) << " ]" << endl; + cout << " [ Trigger missing error : " << ((statusBits >> 1) & 0x1) << " ]" << endl; + cout << " [ Trigger overlap error : " << ((statusBits >> 0) & 0x1) << " ]" << endl; + cout << " Mini event ID : " << header->GetMiniEventID() << " (0x" + << noshowbase << hex << setfill('0') << setw(3) << header->GetMiniEventID() + << dec << setw(0) << setfill(fillChar) << ")" << endl; + + result = CheckHeaderField(header->fTriggerClassLow, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + result = CheckHeaderField(header->fROILowTriggerClassHigh, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + ULong64_t triggerClasses = header->GetTriggerClasses(); + cout << " Trigger classes : 0x" << noshowbase << hex << setw(13) + << setfill('0') << triggerClasses << setw(0) << setfill(fillChar) + << dec << endl; + cout << " [Bits: "; + PrintBitPattern(triggerClasses >> (12*4), 2); + cout << " "; + for (int i = 11; i >= 0; i--) + { + PrintBitPattern(triggerClasses >> (i*4), 4); + if (i != 0) + cout << " "; + else + cout << "]" << endl; + } + + result = CheckHeaderField(header->fROIHigh, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + ULong64_t roiBits = header->GetROI(); + cout << " Region of interest : 0x" << noshowbase << hex << setw(9) + << setfill('0') << roiBits << setw(0) << setfill(fillChar) + << dec << endl; + cout << " [Bits: "; + for (int i = 8; i >= 0; i--) + { + PrintBitPattern(roiBits >> (i*4), 4); + if (i != 0) + cout << " "; + else + cout << "]" << endl; + } + cout << "**********************************************************************************" <(buffer); + int result = DumpRawDataHeader(buffer, bufferSize, header, continueParse); + if (result != EXIT_SUCCESS) return result; // Setup the decoder for the DDL payload. AliMUONTrackerDDLDecoder decoder; decoder.ExitOnError(not continueParse); - decoder.SendDataOnParityError(false); - decoder.TryRecover(false); + decoder.SendDataOnParityError(true); + decoder.TryRecover(tryrecover); decoder.AutoDetectTrailer(true); decoder.CheckForTrailer(true); - const char* payload = buffer + sizeof(AliRawDataHeader); + char* payload = buffer + sizeof(AliRawDataHeader); UInt_t payloadSize = bufferSize - sizeof(AliRawDataHeader); if (decoder.Decode(payload, payloadSize)) { @@ -494,18 +1200,20 @@ int DumpTrackerDDLRawStream( int DumpTriggerDDLRawStream( const char* buffer, unsigned long bufferSize, - bool continueParse + bool continueParse, bool tryrecover ) { - // TODO dump the CDH header. + // Dumps a trigger DDL raw stream data. const AliRawDataHeader* header = reinterpret_cast(buffer); - bool scalarEvent = header->GetL1TriggerMessage() == 0x1; + int result = DumpRawDataHeader(buffer, bufferSize, header, continueParse); + if(result != EXIT_SUCCESS) return result; + bool scalarEvent = ((header->GetL1TriggerMessage() & 0x1) == 0x1); AliMUONTriggerDDLDecoder decoder; decoder.ExitOnError(not continueParse); - decoder.TryRecover(false); + decoder.TryRecover(tryrecover); decoder.AutoDetectScalars(false); const char* payload = buffer + sizeof(AliRawDataHeader); UInt_t payloadSize = bufferSize - sizeof(AliRawDataHeader); @@ -530,7 +1238,24 @@ int DumpRecHitStruct( // At each step check if we have not overflowed the buffer. If we have // not, then we can print the field, otherwise we print the left over // bytes assumed to be corrupted rubbish. - int result = CheckField(hit->fX, buffer, bufferSize, continueParse); + + int result = CheckField(hit->fFlags, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + AliHLTUInt8_t chamber = 0xFF; + AliHLTUInt16_t detElemId = 0xFFFF; + AliHLTMUONUtils::UnpackRecHitFlags(hit->fFlags, chamber, detElemId); + if (chamber == 0 and detElemId == 0) + { + cout << setw(10) << left << (int)(chamber) << setw(0); + cout << setw(12) << left << (int)detElemId << setw(0); + } + else + { + cout << setw(10) << left << (int)(chamber+1) << setw(0); + cout << setw(12) << left << (int)detElemId << setw(0); + } + + result = CheckField(hit->fX, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; cout << setw(13) << left << hit->fX << setw(0); @@ -551,6 +1276,8 @@ int DumpRecHitsBlock( bool continueParse ) { + // Dumps a reconstructed hits data block. + int result = EXIT_SUCCESS; AliHLTMUONRecHitsBlockReader block(buffer, bufferSize); @@ -560,8 +1287,8 @@ int DumpRecHitsBlock( AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize); // Print the data block record entries. - cout << " X (cm) | Y (cm) | Z (cm)" << endl; - cout << "---------------------------------------" << endl; + cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl; + cout << "-----------------------------------------------------------" << endl; const AliHLTMUONRecHitStruct* entry = block.GetArray(); for(AliHLTUInt32_t i = 0; i < nentries; i++) { @@ -589,7 +1316,9 @@ int DumpTriggerRecordStruct( result = CheckField(record->fFlags, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << "Flags: " << showbase << hex << record->fFlags << dec; + cout.flags(oldflags); // Print the individual trigger bits. AliHLTMUONParticleSign sign; @@ -619,13 +1348,12 @@ int DumpTriggerRecordStruct( if (result != EXIT_SUCCESS) return result; cout << "pz = " << record->fPz << ") GeV/c"<fHit[0]; for(AliHLTUInt32_t ch = 0; ch < 4; ch++) { - cout << setw(10) << left << ch + 11 << setw(0); result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse); if (result != EXIT_SUCCESS) return result; } @@ -640,6 +1368,8 @@ int DumpTriggerRecordsBlock( bool continueParse ) { + // Dumps a trigger records data block. + AliHLTMUONTriggerRecordsBlockReader block(buffer, bufferSize); int result = CheckCommonHeader(block, buffer, bufferSize, continueParse); @@ -661,6 +1391,76 @@ int DumpTriggerRecordsBlock( } +int DumpLocalStruct( + const char* buffer, unsigned long bufferSize, + const AliMUONLocalInfoStruct* localStruct, + bool continueParse, + const char* title = "" + ) +{ + // Prints the fields of a L0 local structure as found in the buffer. + + typedef AliMUONTriggerDDLDecoderEventHandler AliH; + + cout << "L0 strip patterns" << title << ":" << endl; + cout << "Chamber | X | Y " << endl; + cout << "----------------------------------------------" << endl; + int result = CheckField(localStruct->fX2X1, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " 11 "; + PrintBitPattern(AliH::GetLocalX1(localStruct), 16); + result = CheckField(localStruct->fY2Y1, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " "; + PrintBitPattern(AliH::GetLocalY1(localStruct), 16); + cout << endl; + cout << " 12 "; + PrintBitPattern(AliH::GetLocalX2(localStruct), 16); + cout << " "; + PrintBitPattern(AliH::GetLocalY2(localStruct), 16); + cout << endl; + + result = CheckField(localStruct->fX4X3, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " 13 "; + PrintBitPattern(AliH::GetLocalX3(localStruct), 16); + result = CheckField(localStruct->fY4Y3, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << " "; + PrintBitPattern(AliH::GetLocalY3(localStruct), 16); + cout << endl; + cout << " 12 "; + PrintBitPattern(AliH::GetLocalX4(localStruct), 16); + cout << " "; + PrintBitPattern(AliH::GetLocalY4(localStruct), 16); + cout << endl; + + cout << "L0 trigger bits" << title << ": (word = "; + result = CheckField(localStruct->fTriggerBits, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << showbase << hex << localStruct->fTriggerBits + << noshowbase << dec << ")" << endl; + cout << " ID | Dec | TrigY | YPos | Sign XDev | XDev | XPos " << endl; + cout << "------------------------------------------------------" << endl; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalId(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalDec(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalTrigY(localStruct)), 1); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalYPos(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalSXDev(localStruct)), 1); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalXDev(localStruct)), 4); + cout << " "; + PrintBitPattern(AliHLTUInt32_t(AliH::GetLocalXPos(localStruct)), 5); + cout << endl; + + return result; +} + + int DumpTrigRecInfoStruct( const char* buffer, unsigned long bufferSize, const AliHLTMUONTrigRecInfoStruct* debuginfo, @@ -671,22 +1471,43 @@ int DumpTrigRecInfoStruct( // At each step check if we have not overflowed the buffer. If we have // not, then we can print the field, otherwise we print the left over // bytes assumed to be corrupted rubbish. + int result = CheckField(debuginfo->fTrigRecId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << setw(22) << left << debuginfo->fTrigRecId << setw(0); + cout << "Trigger Record ID: " << debuginfo->fTrigRecId << endl; - result = CheckField(debuginfo->fDetElemId, buffer, bufferSize, continueParse); - if (result != EXIT_SUCCESS) return result; - cout << setw(20) << left << debuginfo->fDetElemId << setw(0); - + cout << "Detector element IDs:" << endl; + cout << " Chamber : 11 | 12 | 13 | 14" << endl; + cout << " ID : "; + for (int i = 0; i < 4; i++) + { + result = CheckField(debuginfo->fDetElemId[i], buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); + cout << setw(12) << right << debuginfo->fDetElemId[i] << setw(0); + cout.flags(oldflags); + if (i != 3) cout << " | "; + } + cout << endl; + + cout << "Momentum estimation parameters:" << endl; + cout << " Parameter : Z_middle coordinate (cm) | Integrated magnetic field (T.m)" << endl; + cout << " Value : "; result = CheckField(debuginfo->fZmiddle, buffer, bufferSize, continueParse); if(result != EXIT_SUCCESS) return result; - cout << setw(30) << left << debuginfo->fZmiddle << setw(0); - + cout << setw(24) << right << debuginfo->fZmiddle << setw(0) << " | "; + result = CheckField(debuginfo->fBl, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout <fBl << setw(0) << endl; - + cout << setw(31) << right << debuginfo->fBl << setw(0) << endl; + + result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0Struct, continueParse, " for central local structure"); + if (result != EXIT_SUCCESS) return result; + result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0StructPrev, continueParse, " for previous local structure"); + if (result != EXIT_SUCCESS) return result; + result = DumpLocalStruct(buffer, bufferSize, &debuginfo->fL0StructNext, continueParse, " for next local structure"); + if (result != EXIT_SUCCESS) return result; + return result; } @@ -696,6 +1517,8 @@ int DumpTrigRecsDebugBlock( bool continueParse ) { + // Dumps the debugging information for trigger records. + AliHLTMUONTrigRecsDebugBlockReader block(buffer, bufferSize); int result = CheckCommonHeader(block, buffer, bufferSize, continueParse); @@ -704,11 +1527,11 @@ int DumpTrigRecsDebugBlock( AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize); // Print the data block record entries. - cout << "Trigger Record ID | Detector ID | Momentum X Component (Gev/c) | Integrated Magnetic Field (T.m)" << endl; - cout << "--------------------------------------------------------------------------------------------------" << endl; const AliHLTMUONTrigRecInfoStruct* entry = block.GetArray(); for(AliHLTUInt32_t i = 0; i < nentries; i++) { + cout << "======================= Trigger Record debug data " << i+1 + << " of " << nentries << " =======================" << endl; int subResult = DumpTrigRecInfoStruct(buffer, bufferSize, entry++, continueParse); if (subResult != EXIT_SUCCESS) return subResult; } @@ -717,9 +1540,9 @@ int DumpTrigRecsDebugBlock( } -int DumpTriggerChannelStruct( +int DumpClusterStruct( const char* buffer, unsigned long bufferSize, - const AliHLTMUONTriggerChannelStruct* triggerchannel, + const AliHLTMUONClusterStruct* cluster, bool continueParse ) { @@ -727,79 +1550,34 @@ int DumpTriggerChannelStruct( // At each step check if we have not overflowed the buffer. If we have // not, then we can print the field, otherwise we print the left over // bytes assumed to be corrupted rubbish. - int result = CheckField(triggerchannel->fTrigRecId, buffer, bufferSize, continueParse); + int result = CheckField(cluster->fId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << setw(25) << left << triggerchannel->fTrigRecId << setw(0); + cout << " Cluster ID: " << cluster->fId << endl; - result = CheckField(triggerchannel->fChamber, buffer, bufferSize, continueParse); + result = CheckField(cluster->fDetElemId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << setw(13) << left << triggerchannel->fChamber << setw(0); + cout << " Detector Element ID: " << cluster->fDetElemId << endl; - result = CheckField(triggerchannel->fSignal, buffer, bufferSize, continueParse); + result = CheckField(cluster->fNchannelsB, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << setw(10) << left << triggerchannel->fSignal << setw(0); - - result = CheckField(triggerchannel->fRawDataWord, buffer, bufferSize, continueParse); - if(result != EXIT_SUCCESS) return result; - cout << showbase << hex << triggerchannel->fRawDataWord << dec << setw(0) << endl; - return result; -} + cout << " Number of channels in bending plane: " << cluster->fNchannelsB << endl; - -int DumpTriggerChannelsBlock( - const char* buffer, unsigned long bufferSize, - bool continueParse - ) -{ - int result = EXIT_SUCCESS; - AliHLTMUONTriggerChannelsBlockReader block(buffer, bufferSize); - - result = CheckCommonHeader(block, buffer, bufferSize, continueParse); - if (result != EXIT_SUCCESS and not continueParse) return result; - - AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize); + result = CheckField(cluster->fNchannelsNB, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Number of channels in non-bending plane: " << cluster->fNchannelsNB << endl; - // Print the data block record entries. - cout << " Trigger Record ID | Chamber | Signal | Raw Data Word " << endl; - cout << "--------------------------------------------------------------" << endl; - const AliHLTMUONTriggerChannelStruct* entry = block.GetArray(); - for(AliHLTUInt32_t i = 0; i < nentries; i++) - { - int subResult = DumpTriggerChannelStruct(buffer, bufferSize, entry++, continueParse); - if (subResult != EXIT_SUCCESS) return subResult; - } - - return result; -} - - -int DumpClusterStruct( - const char* buffer, unsigned long bufferSize, - const AliHLTMUONClusterStruct* cluster, - bool continueParse - ) -{ - // Step through the fields trying to print them. - // At each step check if we have not overflowed the buffer. If we have - // not, then we can print the field, otherwise we print the left over - // bytes assumed to be corrupted rubbish. - int result = CheckField(cluster->fId, buffer, bufferSize, continueParse); + result = CheckField(cluster->fChargeB, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << "cluster->fId: " << cluster->fId << "\t"; + cout << " Charge on bending plane: " << cluster->fChargeB << endl; - result = CheckField(cluster->fDetElemId, buffer, bufferSize, continueParse); + result = CheckField(cluster->fChargeNB, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; - cout << "cluster->fDetElemId: " << cluster->fDetElemId << "\t"; - - result = CheckField(cluster->fNchannels, buffer, bufferSize, continueParse); - if(result != EXIT_SUCCESS) return result; - cout << "cluster->fNchannels: " << cluster->fNchannels <fChargeNB << endl; - cout << " Corresponding Hit: "<< endl; - cout << " X (cm) | Y (cm) | Z (cm)" << endl; - cout << "---------------------------------------" << endl; - const AliHLTMUONRecHitStruct * hit = & cluster->fHit; - result = DumpRecHitStruct(buffer, bufferSize, hit, continueParse); + cout << "Corresponding Hit: "<< endl; + cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl; + cout << "-----------------------------------------------------------" << endl; + result = DumpRecHitStruct(buffer, bufferSize, &cluster->fHit, continueParse); return result; } @@ -810,6 +1588,8 @@ int DumpClustersBlock( bool continueParse ) { + // Dumps a clusters block structure. + int result = EXIT_SUCCESS; AliHLTMUONClustersBlockReader block(buffer, bufferSize); @@ -822,8 +1602,8 @@ int DumpClustersBlock( const AliHLTMUONClusterStruct* entry = block.GetArray(); for(AliHLTUInt32_t i = 0; i < nentries; i++) { - cout << " ===================================================== Cluster Number " - << i+1 << "==================================================" << endl; + cout << "======================= Cluster Number " + << i+1 << " =======================" << endl; int subResult = DumpClusterStruct(buffer, bufferSize, entry++, continueParse); if (subResult != EXIT_SUCCESS) return subResult; } @@ -844,27 +1624,39 @@ int DumpChannelStruct( // bytes assumed to be corrupted rubbish. int result = CheckField(channel->fClusterId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << setw(16) << left << channel->fClusterId << setw(0); + cout.flags(oldflags); result = CheckField(channel->fBusPatch, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(16) << left << channel->fBusPatch << setw(0); + cout.flags(oldflags); result = CheckField(channel->fManu, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(16) << left << channel->fManu << setw(0); + cout.flags(oldflags); result = CheckField(channel->fChannelAddress, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(16) << left << channel->fChannelAddress << setw(0); + cout.flags(oldflags); result = CheckField(channel->fSignal, buffer, bufferSize, continueParse); if(result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(16) << left << channel->fSignal << setw(0); + cout.flags(oldflags); result = CheckField(channel->fRawDataWord, buffer, bufferSize, continueParse); if(result != EXIT_SUCCESS) return result; - cout << showbase << hex << channel->fRawDataWord << dec << setw(0) <fRawDataWord << dec << setw(0) << endl; + cout.flags(oldflags); return result; } @@ -875,6 +1667,8 @@ int DumpChannelsBlock( bool continueParse ) { + // Dumps a channels block structure. + int result = EXIT_SUCCESS; AliHLTMUONChannelsBlockReader block(buffer, bufferSize); @@ -884,7 +1678,7 @@ int DumpChannelsBlock( AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize); // Print the data block record entries. - cout << "Cluster Id | Bus Patch | Manu Address | Channel Addr | Signal Value | Raw Data Word " << endl; + cout << "Cluster ID | Bus Patch | Manu Address | Channel Addr | Signal Value | Raw Data Word " << endl; cout << "----------------------------------------------------------------------------------------------" << endl; const AliHLTMUONChannelStruct* entry = block.GetArray(); for(AliHLTUInt32_t i = 0; i < nentries; i++) @@ -916,7 +1710,9 @@ int DumpMansoTrackStruct( result = CheckField(track->fFlags, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << "Flags: " << showbase << hex << track->fFlags << dec; + cout.flags(oldflags); // Print the individual trigger bits. AliHLTMUONParticleSign sign; @@ -951,12 +1747,11 @@ int DumpMansoTrackStruct( cout << "Chi squared fit: " << track->fChi2 << endl; cout << "Track hits:" << endl; - cout << "Chamber | X (cm) | Y (cm) | Z (cm)" << endl; - cout << "------------------------------------------------" << endl; + cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl; + cout << "-----------------------------------------------------------" << endl; const AliHLTMUONRecHitStruct* hit = &track->fHit[0]; for(AliHLTUInt32_t ch = 0; ch < 4; ch++) { - cout << setw(10) << left << ch + 7 << setw(0); result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse); if (result != EXIT_SUCCESS) return result; } @@ -970,6 +1765,8 @@ int DumpMansoTracksBlock( bool continueParse ) { + // Dumps the Manso tracks block structure. + int result = EXIT_SUCCESS; AliHLTMUONMansoTracksBlockReader block(buffer, bufferSize); @@ -1004,19 +1801,27 @@ int DumpMansoRoIStruct( // bytes assumed to be corrupted rubbish. int result = CheckField(roi->fX, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << setw(13) << left << roi->fX << setw(0); + cout.flags(oldflags); result = CheckField(roi->fY, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(13) << left << roi->fY << setw(0); + cout.flags(oldflags); result = CheckField(roi->fZ, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(13) << left << roi->fZ << setw(0); + cout.flags(oldflags); result = CheckField(roi->fRadius, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << roi->fRadius << setw(0) << endl; + cout.flags(oldflags); return result; } @@ -1028,6 +1833,8 @@ int DumpMansoCandidateStruct( bool continueParse ) { + // Dumps the manso candidate structure. + int result = DumpMansoTrackStruct(buffer, bufferSize, &candidate->fTrack, continueParse); if (result != EXIT_SUCCESS) return result; @@ -1041,6 +1848,22 @@ int DumpMansoCandidateStruct( result = DumpMansoRoIStruct(buffer, bufferSize, roi++, continueParse); if (result != EXIT_SUCCESS) return result; } + + cout << "Momentum estimation parameters:" << endl; + cout << " Parameter : Z_middle coordinate (cm) | Integrated magnetic field (T.m)" << endl; + cout << " Value : "; + result = CheckField(candidate->fZmiddle, buffer, bufferSize, continueParse); + if(result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); + cout << setw(24) << right << candidate->fZmiddle << setw(0) << " | "; + cout.flags(oldflags); + + result = CheckField(candidate->fBl, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); + cout << setw(31) << right << candidate->fBl << setw(0) << endl; + cout.flags(oldflags); + return result; } @@ -1050,6 +1873,8 @@ int DumpMansoCandidatesBlock( bool continueParse ) { + // Dumps the manso candidates block structure. + int result = EXIT_SUCCESS; AliHLTMUONMansoCandidatesBlockReader block(buffer, bufferSize); @@ -1072,6 +1897,129 @@ int DumpMansoCandidatesBlock( } +int DumpTrackStruct( + const char* buffer, unsigned long bufferSize, + const AliHLTMUONTrackStruct* track, + bool continueParse + ) +{ + // Step through the fields trying to print them. + // At each step check if we have not overflowed the buffer. If we have + // not, then we can print the field, otherwise we print the left over + // bytes assumed to be corrupted rubbish. + int result = CheckField(track->fId, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Track ID: " << track->fId << "\t"; + + result = CheckField(track->fTrigRec, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Trigger Record ID: " << track->fTrigRec << endl; + + result = CheckField(track->fFlags, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); + cout << "Flags: " << showbase << hex << track->fFlags << dec; + cout.flags(oldflags); + + // Print the individual trigger bits. + AliHLTMUONParticleSign sign; + bool hitset[16]; + AliHLTMUONUtils::UnpackTrackFlags(track->fFlags, sign, hitset); + cout << " [Sign: " << sign << ", Hits set: "; + bool first = true; + for (AliHLTUInt32_t i = 0; i < 16; i++) + { + if (hitset[i]) + { + cout << (first ? "" : ", ") << i; + first = false; + } + } + cout << (first ? "none]" : "]") << endl; + + result = CheckField(track->fPx, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Momentum: (px = " << track->fPx << ", "; + + result = CheckField(track->fPy, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "py = " << track->fPy << ", "; + + result = CheckField(track->fPz, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "pz = " << track->fPz << ") GeV/c" << endl; + + result = CheckField(track->fInverseBendingMomentum, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Inverse bending momentum: " << track->fInverseBendingMomentum << " c/GeV" << endl; + + result = CheckField(track->fThetaX, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Slope: (non-bending plane = " << track->fThetaX << ", "; + + result = CheckField(track->fThetaY, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "bending plane = " << track->fThetaY << ")" << endl; + + result = CheckField(track->fX, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "DCA vertex: (x = " << track->fX << ", "; + + result = CheckField(track->fY, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "y = " << track->fY << ", "; + + result = CheckField(track->fZ, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "z = " << track->fZ << ") cm" << endl; + + result = CheckField(track->fChi2, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS) return result; + cout << "Chi squared fit: " << track->fChi2 << endl; + + cout << "Track hits:" << endl; + cout << "Chamber | DetElemID | X (cm) | Y (cm) | Z (cm)" << endl; + cout << "-----------------------------------------------------------" << endl; + const AliHLTMUONRecHitStruct* hit = &track->fHit[0]; + for(AliHLTUInt32_t ch = 0; ch < 16; ch++) + { + result = DumpRecHitStruct(buffer, bufferSize, hit++, continueParse); + if (result != EXIT_SUCCESS) return result; + } + + return result; +} + + +int DumpTracksBlock( + const char* buffer, unsigned long bufferSize, + bool continueParse + ) +{ + // Dumps the full tracks block structure. + + int result = EXIT_SUCCESS; + AliHLTMUONTracksBlockReader block(buffer, bufferSize); + + result = CheckCommonHeader(block, buffer, bufferSize, continueParse); + if (result != EXIT_SUCCESS and not continueParse) return result; + + AliHLTUInt32_t nentries = CalculateNEntries(block, bufferSize); + + // Print the data block record entries. + const AliHLTMUONTrackStruct* entry = block.GetArray(); + for(AliHLTUInt32_t i = 0; i < nentries; i++) + { + cout << "================================ track number " << i+1 + << " of " << nentries << " ================================" << endl; + int subResult = DumpTrackStruct(buffer, bufferSize, entry++, continueParse); + if (subResult != EXIT_SUCCESS) return subResult; + } + + return result; +} + + int DumpSinglesDecisionBlockHeader( const char* buffer, unsigned long bufferSize, const AliHLTMUONSinglesDecisionBlockStruct* header, @@ -1106,10 +2054,13 @@ int DumpTrackDecisionStruct( // bytes assumed to be corrupted rubbish. int result = CheckField(decision->fTrackId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << setw(13) << left << decision->fTrackId << setw(0); + cout.flags(oldflags); result = CheckField(decision->fTriggerBits, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(12) << left << showbase << hex << decision->fTriggerBits << setw(0) << dec; @@ -1118,6 +2069,7 @@ int DumpTrackDecisionStruct( AliHLTMUONUtils::UnpackTrackDecisionBits(decision->fTriggerBits, highPt, lowPt); cout << setw(7) << left << (highPt ? "yes" : "no"); cout << setw(8) << left << (lowPt ? "yes" : "no"); + cout.flags(oldflags); result = CheckField(decision->fPt, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; @@ -1222,16 +2174,22 @@ int DumpPairDecisionStruct( // bytes assumed to be corrupted rubbish. int result = CheckField(decision->fTrackAId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + ios::fmtflags oldflags = cout.flags(); cout << setw(13) << left << decision->fTrackAId << setw(0); + cout.flags(oldflags); result = CheckField(decision->fTrackBId, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(13) << left << decision->fTrackBId << setw(0); + cout.flags(oldflags); result = CheckField(decision->fTriggerBits, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; + oldflags = cout.flags(); cout << setw(12) << left << showbase << hex << decision->fTriggerBits << setw(0) << dec; + cout.flags(oldflags); // Print the individual trigger bits. bool highMass, lowMass, unlike; @@ -1240,12 +2198,14 @@ int DumpPairDecisionStruct( decision->fTriggerBits, highMass, lowMass, unlike, highPtCount, lowPtCount ); + oldflags = cout.flags(); cout << setw(7) << left << (highMass ? "yes" : "no"); cout << setw(7) << left << (lowMass ? "yes" : "no"); cout << setw(7) << left << (unlike ? "yes" : "no"); cout << setw(6) << left << AliHLTUInt16_t(highPtCount); cout << setw(8) << left << AliHLTUInt16_t(lowPtCount); cout << setw(0); + cout.flags(oldflags); result = CheckField(decision->fInvMass, buffer, bufferSize, continueParse); if (result != EXIT_SUCCESS) return result; @@ -1427,11 +2387,13 @@ int CheckIfDDLStream(const char* buffer, unsigned long bufferSize) /** * Parses the buffer and prints the contents to screen. - * [in] \param buffer The pointer to the buffer to parse. - * [in] \param bufferSize The size of the buffer in bytes. - * [in] \param continueParse If specified then the we try to continue parsing the + * \param [in] buffer The pointer to the buffer to parse. + * \param [in] bufferSize The size of the buffer in bytes. + * \param [in] continueParse If specified then the we try to continue parsing the * buffer as much as possible. - * [in/out] \param type Initialy this should indicate the type of the data block + * \param [in] tryrecover Indicates if the DDL decoders should have special + * recovery logic enabled. + * \param [in,out] type Initialy this should indicate the type of the data block * or kUnknownDataBlock if not known. On exit it will be filled with * the type of the data block as discovered by this routine if type * initially contained kUnknownDataBlock. @@ -1439,8 +2401,8 @@ int CheckIfDDLStream(const char* buffer, unsigned long bufferSize) * on success. */ int ParseBuffer( - const char* buffer, unsigned long bufferSize, - bool continueParse, int& type + char* buffer, unsigned long bufferSize, + bool continueParse, bool tryrecover, int& type ) { assert( buffer != NULL ); @@ -1516,11 +2478,11 @@ int ParseBuffer( switch (type) { case kTrackerDDLRawData: - subResult = DumpTrackerDDLRawStream(buffer, bufferSize, continueParse); + subResult = DumpTrackerDDLRawStream(buffer, bufferSize, continueParse, tryrecover); if (subResult != EXIT_SUCCESS) result = subResult; break; case kTriggerDDLRawData: - subResult = DumpTriggerDDLRawStream(buffer, bufferSize, continueParse); + subResult = DumpTriggerDDLRawStream(buffer, bufferSize, continueParse, tryrecover); if (subResult != EXIT_SUCCESS) result = subResult; break; case kTriggerRecordsDataBlock: @@ -1531,10 +2493,6 @@ int ParseBuffer( subResult = DumpTrigRecsDebugBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; break; - case kTriggerChannelsDataBlock: - subResult = DumpTriggerChannelsBlock(buffer, bufferSize, continueParse); - if (subResult != EXIT_SUCCESS) result = subResult; - break; case kRecHitsDataBlock: subResult = DumpRecHitsBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; @@ -1544,7 +2502,7 @@ int ParseBuffer( if (subResult != EXIT_SUCCESS) result = subResult; break; case kChannelsDataBlock: - return DumpChannelsBlock(buffer, bufferSize, continueParse); + subResult = DumpChannelsBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; break; case kMansoTracksDataBlock: @@ -1555,17 +2513,21 @@ int ParseBuffer( subResult = DumpMansoCandidatesBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; break; + case kTracksDataBlock: + subResult = DumpTracksBlock(buffer, bufferSize, continueParse); + if (subResult != EXIT_SUCCESS) result = subResult; + break; case kSinglesDecisionDataBlock: subResult = DumpSinglesDecisionBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; break; case kPairsDecisionDataBlock: - return DumpPairsDecisionBlock(buffer, bufferSize, continueParse); + subResult = DumpPairsDecisionBlock(buffer, bufferSize, continueParse); if (subResult != EXIT_SUCCESS) result = subResult; break; default : cout << "ERROR: Unknown data block type. Found a type number of " - << showbase << hex << int(type) << dec + << showbase << hex << int(type) << noshowbase << dec << " (" << int(type) << ")." << endl; result = PARSE_ERROR; } @@ -1638,14 +2600,21 @@ const char* TryDecodeDataSpec(const char* filename) return NULL; } +namespace +{ + // CDB path and run number to use. + const char* gCDBPath = "local://$ALICE_ROOT/OCDB"; + Int_t gRunNumber = 0; +} + /** * Performs basic data integrity checks of the data block using the * AliHLTMUONDataCheckerComponent. - * [in] \param sys The HLT system framework. - * [in] \param filename The name of the file containing the data block to check. - * [in] \param type Must indicate the type of the data block. - * [in] \param dataspec The data specification of the data block. NULL if none. - * [in] \param maxLogging If set to true then full logging is turned on for AliHLTSystem. + * \param [in] sys The HLT system framework. + * \param [in] filename The name of the file containing the data block to check. + * \param [in] type Must indicate the type of the data block. + * \param [in] dataspec The data specification of the data block. NULL if none. + * \param [in] maxLogging If set to true then full logging is turned on for AliHLTSystem. * \returns The error code indicating the problem. EXIT_SUCCESS is returned * on success. */ @@ -1666,18 +2635,14 @@ int CheckDataIntegrity( sys.SetGlobalLoggingLevel(AliHLTComponentLogSeverity(level)); } - // Check if required libraries are there and load them if not. - if (gClassTable->GetID("AliHLTAgentUtil") < 0) - { - sys.LoadComponentLibraries("libAliHLTUtil.so"); - } - if (gClassTable->GetID("AliHLTMUONAgent") < 0) - { - sys.LoadComponentLibraries("libAliHLTMUON.so"); - } + sys.LoadComponentLibraries("libAliHLTUtil.so"); + sys.LoadComponentLibraries("libAliHLTMUON.so"); // Setup the component parameter lists and then the components. - TString dcparams = "-return_error -warn_on_unexpected_block -no_global_check"; + TString dcparams = "-return_error -warn_on_unexpected_block -no_global_check -cdbpath "; + dcparams += gCDBPath; + dcparams += " -run "; + dcparams += gRunNumber; TString fpparams = "-datatype '"; fpparams += TypeToString(type); fpparams += "' 'MUON'"; @@ -1811,7 +2776,8 @@ void PrintUsage(bool asError = true) { std::ostream& os = asError ? cerr : cout; os << "Usage: dHLTdumpraw [-help|-h] [-continue|-c] [-type|-t ] [-check|-k]" << endl; - os << " [-debug|-d] [-dataspec|-s ] [ ...]" << endl; + os << " [-debug|-d] [-dataspec|-s ] [-cdbpath|-p ] [-run|-r ]" << endl; + os << " [ ...]" << endl; os << "Where is the name of a file containing a raw data block." << endl; os << "Options:" << endl; os << " -help | -h" << endl; @@ -1819,6 +2785,9 @@ void PrintUsage(bool asError = true) os << " -continue | -c" << endl; os << " If specified, the program will try to continue parsing the data block" << endl; os << " as much as possible rather than stopping at the first error." << endl; + os << " -recover | -e" << endl; + os << " If specified, special DDL decoder recovery logic is enabled to handle" << endl; + os << " corrupt DDL data." << endl; os << " -type | -t " << endl; os << " Forces the contents of the subsequent files specified on the command" << endl; os << " line to be interpreted as a specific type of data block." << endl; @@ -1827,12 +2796,12 @@ void PrintUsage(bool asError = true) os << " rawtrigger - raw DDL stream from trigger chambers." << endl; os << " trigrecs - trigger records data." << endl; os << " trigrecsdebug - debugging information about trigger records." << endl; - os << " trigchannels - channel debugging in." << endl; os << " rechits - reconstructed hits data." << endl; os << " channels - channel debugging information from hit reconstruction." << endl; os << " clusters - cluster debugging information from hit reconstruction." << endl; os << " mansotracks - partial tracks from Manso algorithm." << endl; os << " mansocandidates - track candidates considered in the Manso algorithm." << endl; + os << " tracks - tracks from full tracker component." << endl; os << " singlesdecision - trigger decisions for single tracks." << endl; os << " pairsdecision - trigger decisions for track pairs." << endl; os << " autodetect - the type of the data block will be automatically" << endl; @@ -1847,6 +2816,10 @@ void PrintUsage(bool asError = true) os << " -dataspec | -s " << endl; os << " When specified, then is used as the data specification for the" << endl; os << " data file that follows. This option is only useful with the -check|-k option." << endl; + os << " -cdbpath | -p " << endl; + os << " The path to the CDB to use when running with the -check | -k option." << endl; + os << " -run | -r " << endl; + os << " The run number to use when running with the -check | -k option." << endl; } /** @@ -1861,6 +2834,7 @@ void PrintUsage(bool asError = true) * and added to 'filenames'. * @param continueParse Set to true if the user requested to continue to parse * after errors. + * @param tryrecover Set to true if the user wants DDL decoder recovery logic enabled. * @param checkData Set to true if data integrity checking was requested. * @param maxLogging Set to true if maximal logging was requested. * @return A status flag suitable for returning from main(), containing either @@ -1868,22 +2842,26 @@ void PrintUsage(bool asError = true) */ int ParseCommandLine( int argc, - const char** argv, + char** argv, const char** filenames, int* filetypes, const char** dataspecs, int& numOfFiles, bool& continueParse, + bool& tryrecover, bool& checkData, bool& maxLogging ) { numOfFiles = 0; continueParse = false; + tryrecover = false; maxLogging = false; checkData = false; int currentType = kUnknownDataBlock; const char* currentDataSpec = NULL; + bool pathSet = false; + bool runSet = false; // Parse the command line. for (int i = 1; i < argc; i++) @@ -1897,6 +2875,10 @@ int ParseCommandLine( { continueParse = true; } + else if (strcmp(argv[i], "-recover") == 0 or strcmp(argv[i], "-e") == 0) + { + tryrecover = true; + } else if (strcmp(argv[i], "-type") == 0 or strcmp(argv[i], "-t") == 0) { if (++i >= argc) @@ -1964,6 +2946,50 @@ int ParseCommandLine( } currentDataSpec = argv[i]; } + else if (strcmp(argv[i], "-cdbpath") == 0 or strcmp(argv[i], "-p") == 0) + { + if (pathSet) + { + cerr << "WARNING: Already used -cdbpath|-p with '" << gCDBPath + << "' before. Will override it with the last value specified with -cdbpath|-p." + << endl; + } + if (++i >= argc) + { + cerr << "ERROR: Missing the URL for the CDB path." << endl << endl; + PrintUsage(); + return CMDLINE_ERROR; + } + gCDBPath = argv[i]; + pathSet = true; + } + else if (strcmp(argv[i], "-run") == 0 or strcmp(argv[i], "-r") == 0) + { + if (runSet) + { + cerr << "WARNING: Already used -run|-r with " << gRunNumber + << " before. Will override it with the last value specified with -run|-r." + << endl; + } + if (++i >= argc) + { + cerr << "ERROR: Missing the run number." << endl << endl; + PrintUsage(); + return CMDLINE_ERROR; + } + + char* cpErr = NULL; + Int_t run = Int_t( strtol(argv[i], &cpErr, 0) ); + if (cpErr == NULL or *cpErr != '\0' or run < 0) + { + cerr << "ERROR: Cannot convert '" << argv[i] << "' to a valid run number." + " Expected a positive integer value." << endl; + return CMDLINE_ERROR; + } + + gRunNumber = run; + runSet = true; + } else { assert( numOfFiles < argc ); @@ -1988,7 +3014,7 @@ int ParseCommandLine( } -int main(int argc, const char** argv) +int main(int argc, char** argv) { // Test endianess of this machine during runtime and print warning if it is not // little endian. @@ -2016,6 +3042,7 @@ int main(int argc, const char** argv) int numOfFiles = 0; bool continueParse = false; + bool tryrecover = false; bool checkData = false; bool maxLogging = false; int returnCode = EXIT_SUCCESS; @@ -2038,7 +3065,7 @@ int main(int argc, const char** argv) returnCode = ParseCommandLine( argc, argv, filename, filetype, dataspec, numOfFiles, - continueParse, checkData, maxLogging + continueParse, tryrecover, checkData, maxLogging ); if (returnCode == EXIT_SUCCESS) @@ -2053,7 +3080,7 @@ int main(int argc, const char** argv) cout << "########## Start of dump for file: " << filename[i] << " ##########" << endl; } - int result = ParseBuffer(buffer, bufferSize, continueParse, filetype[i]); + int result = ParseBuffer(buffer, bufferSize, continueParse, tryrecover, filetype[i]); if (buffer != NULL) delete [] buffer; if (result != EXIT_SUCCESS) {