From 64c2397e2d714a7b28efda2f2c5c283f19e40a4e Mon Sep 17 00:00:00 2001 From: laphecet Date: Mon, 23 Nov 2009 17:33:40 +0000 Subject: [PATCH] Modifications to get summary plots about the readout errors for the tracker in the QA --- MUON/AliMUONLogger.cxx | 14 +- MUON/AliMUONLogger.h | 3 + MUON/AliMUONQAIndices.h | 5 + MUON/AliMUONRawStreamTrackerHP.cxx | 283 ++++++++++++++++++++------ MUON/AliMUONRawStreamTrackerHP.h | 92 ++++++--- MUON/AliMUONTrackerDataMaker.cxx | 27 ++- MUON/AliMUONTrackerDataMaker.h | 6 +- MUON/AliMUONTrackerQAChecker.cxx | 20 +- MUON/AliMUONTrackerQAChecker.h | 4 +- MUON/AliMUONTrackerQADataMakerRec.cxx | 143 ++++++++++++- MUON/AliMUONTrackerQADataMakerRec.h | 13 +- MUON/MUONRawStreamTracker.C | 7 +- 12 files changed, 501 insertions(+), 116 deletions(-) diff --git a/MUON/AliMUONLogger.cxx b/MUON/AliMUONLogger.cxx index cb7fa69167d..caa03a3885e 100644 --- a/MUON/AliMUONLogger.cxx +++ b/MUON/AliMUONLogger.cxx @@ -61,9 +61,11 @@ Int_t AliMUONLogger::Log(const char* message) { /// Log a message - if ( fLog->GetNofItems() >= fMaxNumberOfEntries ) + + if ( fMaxNumberOfEntries >0 && fLog->GetNofItems() >= fMaxNumberOfEntries ) { - AliWarning("Reached max number of entries. Printing and resetting."); + AliWarning(Form("Reached max number of entries (%d over %d). Printing and resetting.", + fLog->GetNofItems(),fMaxNumberOfEntries)); Print(); fLog->Clear(); } @@ -127,5 +129,11 @@ AliMUONLogger::Next(TString& msg, Int_t& occurance) } - +//_____________________________________________________________________________ +Int_t +AliMUONLogger::NumberOfEntries() const +{ + /// Get the number of logs we have so far + return fLog->GetNofItems(); +} diff --git a/MUON/AliMUONLogger.h b/MUON/AliMUONLogger.h index dfd87bb2f70..f9f1b39df3b 100644 --- a/MUON/AliMUONLogger.h +++ b/MUON/AliMUONLogger.h @@ -39,8 +39,11 @@ public: void Clear(Option_t* /*option*/ =""); Bool_t Next(TString& msg, Int_t& occurance); + void ResetItr(); + Int_t NumberOfEntries() const; + private: /// Not implemented AliMUONLogger(const AliMUONLogger& rhs); // not implemented diff --git a/MUON/AliMUONQAIndices.h b/MUON/AliMUONQAIndices.h index f7bf9085b5e..4a614cb0d0b 100644 --- a/MUON/AliMUONQAIndices.h +++ b/MUON/AliMUONQAIndices.h @@ -21,6 +21,11 @@ namespace AliMUONQAIndices kTrackerBusPatchNofPads = 5, ///< Number of pads per bus patch kTrackerBusPatchNofManus = 6, ///< Number of manus per bus patch kTrackerBusPatchConfig = 7, ///< Configuration of the tracker + kTrackerBusPatchParityErrors = 8, ///< Parity errors during readout of the tracker + kTrackerBusPatchTokenLostErrors = 9, ///< Token lost errors during readout of the tracker + kTrackerBusPatchPaddingErrors = 10, ///< Padding errors during readout of the tracker + kTrackerNofRawEventSeen = 11, ///< Number of events seen (and used) + kTrackerReadoutErrors = 12, ///< Integrated number of errors (and events for 1st bin) kTriggerScalersTime = 22, ///< Trigger scalers acquisition time index kTriggerScalers = 23, ///< Trigger scalers histogram per plane index kTriggerScalersDisplay = 31, ///< Trigger scalers display histogram per plane index diff --git a/MUON/AliMUONRawStreamTrackerHP.cxx b/MUON/AliMUONRawStreamTrackerHP.cxx index aa82a6ee576..16862c22768 100644 --- a/MUON/AliMUONRawStreamTrackerHP.cxx +++ b/MUON/AliMUONRawStreamTrackerHP.cxx @@ -49,8 +49,10 @@ #include "AliMUONBlockHeader.h" #include "AliMUONBusStruct.h" #include "AliMUONDDLTracker.h" +#include "AliMUONLogger.h" #include "AliRawReader.h" #include "AliLog.h" +#include "AliDAQ.h" #include #include using std::cout; @@ -66,7 +68,12 @@ const Int_t AliMUONRawStreamTrackerHP::fgkMaxDDL = 20; AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP() : TObject(), - fEnableErrorLogger(kFALSE), + fRawReader(NULL), + fLogger(NULL), + fDetailLevel(kMediumErrorDetail), + fEnableMUONErrorLogger(kFALSE), + fEnableRawReaderErrorLogger(kFALSE), + fWarnings(kTRUE), fDecoder(), fDDL(0), fBufferSize(8192), @@ -96,12 +103,19 @@ AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP() : fDecoder.MaxDSPs(), fDecoder.MaxBusPatches() ); + + fDecoder.GetHandler().SetRawStream(this); } AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP(AliRawReader* rawReader) : TObject(), - fEnableErrorLogger(kFALSE), + fRawReader(rawReader), + fLogger(NULL), + fDetailLevel(kMediumErrorDetail), + fEnableMUONErrorLogger(kFALSE), + fEnableRawReaderErrorLogger(kFALSE), + fWarnings(kTRUE), fDecoder(), fDDL(0), fBufferSize(8192), @@ -132,7 +146,7 @@ AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP(AliRawReader* rawReader) : fDecoder.MaxBusPatches() ); - fDecoder.GetHandler().SetReader(rawReader); + fDecoder.GetHandler().SetRawStream(this); } @@ -450,16 +464,6 @@ void AliMUONRawStreamTrackerHP::SetMaxBus(Int_t bus) ); } -AliRawReader* AliMUONRawStreamTrackerHP::GetReader() -{ - return fDecoder.GetHandler().GetReader(); -} - -void AliMUONRawStreamTrackerHP::SetReader(AliRawReader* reader) -{ - fDecoder.GetHandler().SetReader(reader); -} - /////////////////////////////////////////////////////////////////////////////// void AliMUONRawStreamTrackerHP::AliBlockHeader::Print() const @@ -530,7 +534,7 @@ void AliMUONRawStreamTrackerHP::AliBusPatch::Print(const Option_t* opt) const /////////////////////////////////////////////////////////////////////////////// AliMUONRawStreamTrackerHP::AliDecoderEventHandler::AliDecoderEventHandler() : - fRawReader(0x0), + fRawStream(NULL), fBufferStart(NULL), fBlockCount(0), fBlocks(NULL), @@ -547,7 +551,6 @@ AliMUONRawStreamTrackerHP::AliDecoderEventHandler::AliDecoderEventHandler() : fGlitchErrors(0), fPaddingErrors(0), fTokenLostErrors(0), - fWarnings(kTRUE), fMaxBlocks(), fMaxDsps(), fMaxBusPatches() @@ -653,6 +656,32 @@ void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewBuffer( } +void AliMUONRawStreamTrackerHP::Swap(UInt_t* buffer, Int_t size) const +{ + // swap from little to big endian + + typedef struct { + UInt_t b1:8; ///< first byte word + UInt_t b2:8; ///< second byte word + UInt_t b3:8; ///< third byte word + UInt_t b4:8; ///< fourth byte word + } RawWord; + + RawWord* word, temp; + word = (RawWord*) buffer; + + for (Int_t i = 0; i < size; i++) + { + temp = *(((RawWord*)buffer)+i); + word->b1 = temp.b4; + word->b2 = temp.b3; + word->b3 = temp.b2; + word->b4 = temp.b1; + word++; + } +} + + void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnError( ErrorCode error, const void* location ) @@ -660,81 +689,209 @@ void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnError( /// This is called by the high performance decoder when a error occurs /// when trying to decode the DDL payload. This indicates corruption in /// the data. This method converts the error code to a descriptive message - /// and logs this with the raw reader. + /// and logs this with the logger object. /// \param error The error code indicating the problem. /// \param location A pointer to the location within the DDL payload buffer /// being decoded where the problem with the data was found. - - assert( fRawReader != NULL ); - Char_t* message = NULL; + assert(fRawStream != NULL); + + const char* message = NULL; UInt_t word = 0; - + bool logAsMajorError = true; + + // Build the detailed part of the error message if high detail selected. + const char* detail = ""; + if (fRawStream->GetLoggingDetailLevel() == kHighErrorDetail) + { + bool blockPtrOk = fBlockCount > 0; + bool dspPtrOk = blockPtrOk ? fCurrentBlock->GetDspCount() > 0 : false; + bool buspatchPtrOk = dspPtrOk ? fCurrentDSP->GetBusPatchCount() > 0 : false; + // We subtract 1 from the current numbers of blocks, DSPs + // and bus patches to get the iBlock, iDsp and iBus indices. + detail = Form( + "At byte %d in DDL %d, event %d, iBlock %d, iDsp %d [DSP ID: %d (0x%X)]," + " iBus %d [bus patch ID: %d (0x%X)].", + (unsigned long)location - (unsigned long)fBufferStart + sizeof(AliRawDataHeader), + AliDAQ::DdlID("MUONTRK", fRawStream->GetDDL()), + fRawStream->GetReader()->GetEventIndex(), + int(fBlockCount)-1, + blockPtrOk ? int(fCurrentBlock->GetDspCount())-1 : -1, + blockPtrOk ? fCurrentBlock->GetDspId() : -1, + blockPtrOk ? fCurrentBlock->GetDspId() : -1, + dspPtrOk ? int(fCurrentDSP->GetBusPatchCount())-1 : -1, + buspatchPtrOk ? fCurrentBusPatch->GetBusPatchId() : -1, + buspatchPtrOk ? fCurrentBusPatch->GetBusPatchId() : -1 + ); + } + + // Build the log message. switch (error) { case kGlitchFound: fGlitchErrors++; - message = Form( - "Glitch error detected in DSP %d (0x%X), skipping event ", - fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId() - ); - fRawReader->AddMajorErrorLog(error, message); + switch (fRawStream->GetLoggingDetailLevel()) + { + case kLowErrorDetail: + message = "Glitch error detected."; + break; + case kMediumErrorDetail: + message = Form( + "Glitch error detected in DSP %d (0x%X), skipping event.", + fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId() + ); + break; + case kHighErrorDetail: + default: + message = Form("%s %s", ErrorCodeToMessage(error), detail); + break; + } + logAsMajorError = true; break; case kBadPaddingWord: fPaddingErrors++; - // We subtract 1 from the current numbers of blocks, DSPs - // and bus patches to get the indices. - message = Form( - "Padding word error for iBlock %d, iDsp %d, iBus %d\n", - fBlockCount-1, - fCurrentBlock->GetDspCount()-1, - fCurrentDSP->GetBusPatchCount()-1 - ); - fRawReader->AddMinorErrorLog(error, message); + switch (fRawStream->GetLoggingDetailLevel()) + { + case kLowErrorDetail: + message = "Padding word error detected."; + break; + case kMediumErrorDetail: + // We subtract 1 from the current numbers of blocks, DSPs + // and bus patches to get the indices. + message = Form( + "Padding word error for iBlock %d, iDsp %d, iBus %d.", + fBlockCount-1, + fCurrentBlock->GetDspCount()-1, + fCurrentDSP->GetBusPatchCount()-1 + ); + break; + case kHighErrorDetail: + default: + message = Form("%s %s", ErrorCodeToMessage(error), detail); + break; + } + logAsMajorError = false; break; case kParityError: fParityErrors++; - // location points to the incorrect data word and - // fCurrentBusPatch->GetData() returns a pointer to the start of - // bus patches data, so the difference divided by 4 gives the 32 - // bit word number. - word = ((unsigned long)location - (unsigned long)fCurrentBusPatch->GetData()) + switch (fRawStream->GetLoggingDetailLevel()) + { + case kLowErrorDetail: + message = "Parity error detected."; + break; + case kMediumErrorDetail: + message = Form( + "Parity error in buspatch %d (0x%X).", + fCurrentBusPatch->GetBusPatchId(), + fCurrentBusPatch->GetBusPatchId() + ); + break; + case kHighErrorDetail: + default: + // location points to the incorrect data word and + // fCurrentBusPatch->GetData() returns a pointer to the start of + // bus patches data, so the difference divided by 4 gives the 32 + // bit word number. + word = ((unsigned long)location - (unsigned long)fCurrentBusPatch->GetData()) / sizeof(UInt_t); - message = Form( - "Parity error in word %d for manuId %d and channel %d in buspatch %d\n", - word, - fCurrentBusPatch->GetManuId(word), - fCurrentBusPatch->GetChannelId(word), - fCurrentBusPatch->GetBusPatchId() - ); - fRawReader->AddMinorErrorLog(error, message); + message = Form( + "Parity error in word %d for manuId %d and channel %d in buspatch %d. %s", + word, + fCurrentBusPatch->GetManuId(word), + fCurrentBusPatch->GetChannelId(word), + fCurrentBusPatch->GetBusPatchId(), + detail + ); + break; + } + logAsMajorError = false; break; case kTokenLost: fTokenLostErrors++; - word = *reinterpret_cast(location); - message = Form( - "Lost token error detected in DSP %d (0x%X) with address 0x%X and code %d.", - fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId(), - ((word & 0xFFFF0000) >> 16), - (word & 0xF) - ); - fRawReader->AddMinorErrorLog(error, message); + switch (fRawStream->GetLoggingDetailLevel()) + { + case kLowErrorDetail: + message = "Lost token error detected."; + break; + case kMediumErrorDetail: + word = *reinterpret_cast(location); + message = Form( + "Lost token error detected in DSP 0x%X of DDL %d and code %d.", + ((word & 0xFFFF0000) >> 16), + fRawStream->GetDDL(), + (word & 0xF) + ); + break; + case kHighErrorDetail: + default: + word = *reinterpret_cast(location); + message = Form( + "Lost token error detected with address 0x%X and code %d. %s", + ((word & 0xFFFF0000) >> 16), + (word & 0xF), + detail + ); + message = Form("Lost token error detected. %s.", detail); + break; + } + logAsMajorError = false; break; default: - message = Form( - "%s (At byte %d in DDL.)", - ErrorCodeToMessage(error), - (unsigned long)location - (unsigned long)fBufferStart + sizeof(AliRawDataHeader) - ); - fRawReader->AddMajorErrorLog(error, message); + switch (fRawStream->GetLoggingDetailLevel()) + { + case kLowErrorDetail: + message = ErrorCodeToMessage(error); + break; + case kMediumErrorDetail: + message = Form( + "%s (At byte %d)", + ErrorCodeToMessage(error), + (unsigned long)location - (unsigned long)fBufferStart + sizeof(AliRawDataHeader) + ); + break; + case kHighErrorDetail: + default: + message = Form( + "%s Error code: %d (%s). %s", + ErrorCodeToMessage(error), + error, ErrorCodeToString(error), + detail + ); + break; + } + logAsMajorError = true; break; } - - if (fWarnings) + + // Now log the error message depending on the logging flags set. + if (fRawStream->IsRawReaderErrorLoggerEnabled()) + { + if (logAsMajorError) + fRawStream->GetReader()->AddMajorErrorLog(Int_t(error), message); + else + fRawStream->GetReader()->AddMinorErrorLog(Int_t(error), message); + } + if (fRawStream->IsMUONErrorLoggerEnabled()) + { + AliMUONLogger* logger = fRawStream->GetMUONErrorLogger(); + if (logger != NULL) + { + logger->Log(message); + } + else + { + AliErrorGeneral( + "AliMUONRawStreamTrackerHP::AliDecoderEventHandler", + "Enabled logging to AliMUONLogger, but the logger object" + " was not set with SetMUONErrorLogger()." + ); + } + } + if (fRawStream->IsWarningsEnabled()) { AliWarningGeneral( "AliMUONRawStreamTrackerHP::AliDecoderEventHandler", diff --git a/MUON/AliMUONRawStreamTrackerHP.h b/MUON/AliMUONRawStreamTrackerHP.h index 4b1ae774012..d7176f9c2d3 100644 --- a/MUON/AliMUONRawStreamTrackerHP.h +++ b/MUON/AliMUONRawStreamTrackerHP.h @@ -22,12 +22,21 @@ class AliMUONDDLTracker; class AliRawReader; +class AliMUONLogger; class AliMUONRawStreamTrackerHP : public TObject { public: class AliDspHeader; class AliBusPatch; + + /// Values indicating the logging detail level to use for error messages. + enum EDetailLevel + { + kLowErrorDetail, /// Logs minimal information in the error messages. + kMediumErrorDetail, /// Logs a medium level of detail in the error messages. + kHighErrorDetail /// Logs maximum information in the error messages. + }; /// Default constructor. AliMUONRawStreamTrackerHP(); @@ -39,7 +48,10 @@ public: virtual ~AliMUONRawStreamTrackerHP(); /// Get object for reading the raw data - virtual AliRawReader* GetReader(); + virtual AliRawReader* GetReader() { return fRawReader; } + + /// Set the raw reader + void SetReader(AliRawReader* reader) { fRawReader = reader; } /// Initialize iterator virtual void First(); @@ -49,10 +61,6 @@ public: /// Whether the iteration is finished or not virtual Bool_t IsDone() const; - - /// Nothing is actually done in the AddErrorMessage method because we log - /// the error messages as we find them in AliDecoderEventHandler::OnError(). - virtual void AddErrorMessage() { }; /// Advance one step in the iteration. Returns false if finished. virtual Bool_t Next(Int_t& busPatchId, @@ -117,9 +125,11 @@ public: } /// Set warnings flag to disable warnings on data errors. - void DisableWarnings() { fDecoder.GetHandler().Warnings(kFALSE); } + void DisableWarnings() { fWarnings = kFALSE; } /// Set warnings flag to enable warnings on data errors. - void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); } + void EnableWarnings() { fWarnings = kTRUE; } + + Bool_t IsWarningsEnabled() const { return fWarnings; } /// Returns the "try to recover from errors" flag. Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); } @@ -515,14 +525,41 @@ public: return (dsp != NULL) ? dsp->GetBlockHeader() : NULL; } - /// Set the raw reader - void SetReader(AliRawReader* reader); + /// Enable error logging to the raw reader. \note Kept for backward compatibility. + virtual void EnabbleErrorLogger() { EnableRawReaderErrorLogger(); } + + /// Enable error info logging to AliMUONLogger. + void EnableMUONErrorLogger() { fEnableMUONErrorLogger = kTRUE; } + + /// Disable logging to AliMUONLogger. + void DisableMUONErrorLogger() { fEnableMUONErrorLogger = kFALSE; } + + /// Enable error info logging to raw reader. + void EnableRawReaderErrorLogger() { fEnableRawReaderErrorLogger = kTRUE; } + + /// Disable logging to the raw reader. + void DisableRawReaderErrorLogger() { fEnableRawReaderErrorLogger = kFALSE; } - /// Enable error info logger - virtual void EnabbleErrorLogger() { fEnableErrorLogger = kTRUE; } + /// Check if the AliMUONLogger is enabled for error logging. + Bool_t IsMUONErrorLoggerEnabled() const { return fEnableMUONErrorLogger; } - /// Check if error info logger enable - virtual Bool_t IsErrorLogger() const {return fEnableErrorLogger; } + /// Check if the AliMUONLogger is enabled for error logging. + Bool_t IsRawReaderErrorLoggerEnabled() const { return fEnableRawReaderErrorLogger; } + + /// Returns the logger object. (constant version) + const AliMUONLogger* GetMUONErrorLogger() const { return fLogger; } + + /// Returns the logger object. + AliMUONLogger* GetMUONErrorLogger() { return fLogger; } + + /// Sets the logger object to use. Ownership of the logger object remains with the caller. + void SetMUONErrorLogger(AliMUONLogger* logger) { fLogger = logger; } + + /// Returns the level of detail used in the error messages. + EDetailLevel GetLoggingDetailLevel() const { return fDetailLevel; } + + /// Sets the level of detail used in the error messages. + void SetLoggingDetailLevel(EDetailLevel level) { fDetailLevel = level; } /// Number of glitch errors since First() was called UInt_t NumberOfGlitchErrors() const { return fTotalNumberOfGlitchErrors; } @@ -558,7 +595,10 @@ private: /// Return max number of tracker DDLs Int_t GetMaxDDL() const { return fgkMaxDDL; } - + + /// swap method for Power PC + virtual void Swap(UInt_t* buffer, Int_t size) const; + /// This is the custom event handler (callback interface) class which /// unpacks raw data words and fills an internal buffer with decoded digits /// as they are decoded by the high performance decoder. @@ -574,6 +614,9 @@ private: /// Sets the internal arrays based on the maximum number of structures allowed. void SetMaxStructs(UInt_t maxBlocks, UInt_t maxDsps, UInt_t maxBusPatches); + /// Sets the raw stream object which should be the parent of this class. + void SetRawStream(AliMUONRawStreamTrackerHP* rawStream) { fRawStream = rawStream; } + /// Return the number of blocks found in the payload. UInt_t BlockCount() const { return fBlockCount; }; @@ -597,11 +640,6 @@ private: UInt_t PaddingErrorCount() const { return fPaddingErrors; } /// Returns the number of token lost errors found in the DDL. UInt_t TokenLostCount() const { return fTokenLostErrors; } - - /// Returns the warnings flag. - Bool_t Warnings() const { return fWarnings; } - /// Sets the warnings flag. - void Warnings(Bool_t value) { fWarnings = value; } // The following methods are inherited from AliMUONTrackerDDLDecoderEventHandler: @@ -639,12 +677,6 @@ private: /// Error handler. void OnError(ErrorCode error, const void* location); - /// Set reader - void SetReader(AliRawReader* reader) { fRawReader = reader; } - - /// Get reader - AliRawReader* GetReader() const { return fRawReader; } - private: // Do not allow copying of this class. @@ -653,7 +685,7 @@ private: /// Not implemented AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/); - AliRawReader* fRawReader; //!< Pointer to the raw reader + AliMUONRawStreamTrackerHP* fRawStream; //!< Pointer to the parent raw stream object. const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer. UInt_t fBlockCount; //!< Number of blocks filled in fBlocks. AliBlockHeader* fBlocks; //!< Array of blocks. [0..fMaxBlocks-1] @@ -670,13 +702,17 @@ private: UInt_t fGlitchErrors; //!< Number of glitch errors found in DDL. UInt_t fPaddingErrors; //!< Number of padding errors found in DDL. UInt_t fTokenLostErrors; //!< Number of token lost errors found in DDL. - Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors. UInt_t fMaxBlocks; //!< max number of blocks UInt_t fMaxDsps; //!< max number of dsps per block UInt_t fMaxBusPatches; //!< max number of buspatches per dsp }; - Bool_t fEnableErrorLogger; //!< whether or not we log errors + AliRawReader* fRawReader; //!< Pointer to the raw reader + AliMUONLogger* fLogger; //!< Logger object to store error messages. + EDetailLevel fDetailLevel; //!< The logging detail level used in the error messages generated in OnError. + Bool_t fEnableMUONErrorLogger; //!< whether or not we log errors to AliMUONLogger + Bool_t fEnableRawReaderErrorLogger; //!< whether or not we log errors to the raw reader. + Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors. AliMUONTrackerDDLDecoder fDecoder; //!< The decoder for the DDL payload. Int_t fDDL; //!< The current DDL number being handled. Int_t fBufferSize; //!< This is the buffer size in bytes of fBuffer. diff --git a/MUON/AliMUONTrackerDataMaker.cxx b/MUON/AliMUONTrackerDataMaker.cxx index 26ec1a5e850..239d7c0d6c7 100644 --- a/MUON/AliMUONTrackerDataMaker.cxx +++ b/MUON/AliMUONTrackerDataMaker.cxx @@ -33,6 +33,7 @@ #include "AliMUONCalibParamND.h" #include "AliMUONCalibrationData.h" #include "AliMUONDigitCalibrator.h" +#include "AliMUONLogger.h" #include "AliMUONRawStreamTrackerHP.h" #include "AliMUONTrackerData.h" #include "AliMpDDLStore.h" @@ -61,7 +62,8 @@ fNumberOfEvents(0), fRunNumber(0), fIsRunning(kFALSE), fIsOwnerOfRawReader(kFALSE), -fIsEventByEvent(kFALSE) +fIsEventByEvent(kFALSE), +fLogger(0x0) { /// Root IO ctor } @@ -88,7 +90,8 @@ fNumberOfEvents(0), fRunNumber(runNumber), fIsRunning(kFALSE), fIsOwnerOfRawReader(kFALSE), -fIsEventByEvent(kFALSE) +fIsEventByEvent(kFALSE), +fLogger(0x0) { /// Ctor in which this object will NOT be the owner of the reader /// and can NOT apply rewind to it, nor use Next on it. @@ -117,7 +120,8 @@ fNumberOfEvents(0), fRunNumber(0), fIsRunning(kFALSE), fIsOwnerOfRawReader(kTRUE), -fIsEventByEvent(kFALSE) +fIsEventByEvent(kFALSE), +fLogger(0x0) { /// Ctor in which we take the ownership of the rawReader, so we can rewind /// and advance it as we wish @@ -147,7 +151,8 @@ fNumberOfEvents(0), fRunNumber(0), fIsRunning(kFALSE), fIsOwnerOfRawReader(kTRUE), -fIsEventByEvent(kFALSE) +fIsEventByEvent(kFALSE), +fLogger(0x0) { /// Ctor from raw data reader if (fRawReader) @@ -345,9 +350,17 @@ Bool_t AliMUONTrackerDataMaker::ProcessEvent() AliCodeTimerAuto("",0); AliMUONRawStreamTrackerHP stream(fRawReader); - + stream.DisableWarnings(); - stream.EnabbleErrorLogger(); + stream.DisableRawReaderErrorLogger(); + stream.DisableMUONErrorLogger(); + + if (fLogger) + { + stream.EnableMUONErrorLogger(); + stream.SetMUONErrorLogger(fLogger); + stream.SetLoggingDetailLevel(AliMUONRawStreamTrackerHP::kMediumErrorDetail); + } const Int_t nddls = AliDAQ::NumberOfDdls("MUONTRK"); TArrayI nevents(nddls); @@ -408,7 +421,7 @@ Bool_t AliMUONTrackerDataMaker::ProcessEvent() { fAccumulatedData->Add(*fOneEventData,&nevents); } - + return !badEvent; } diff --git a/MUON/AliMUONTrackerDataMaker.h b/MUON/AliMUONTrackerDataMaker.h index 06edd9d4990..2a07df9e1d2 100644 --- a/MUON/AliMUONTrackerDataMaker.h +++ b/MUON/AliMUONTrackerDataMaker.h @@ -25,6 +25,7 @@ class AliMUONDigitCalibrator; class AliMUONVStore; class AliMUONVTrackerData; class AliRawReader; +class AliMUONLogger; class AliMUONTrackerDataMaker : public AliMUONVTrackerDataMaker { @@ -96,6 +97,8 @@ public: void SetRawReader(AliRawReader* rawReader); + void EnableErrorLogger(AliMUONLogger* logger) { fLogger = logger; } + private: /// not implemented AliMUONTrackerDataMaker(const AliMUONTrackerDataMaker& rhs); @@ -123,8 +126,9 @@ private: Bool_t fIsOwnerOfRawReader; ///< whether we must delete rawReader or not Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation) static Int_t fgkCounter; ///< to count the number of instances + AliMUONLogger* fLogger; ///< error logger (not owner) - ClassDef(AliMUONTrackerDataMaker,1) // Producer of AliMUONVTrackerData from raw + ClassDef(AliMUONTrackerDataMaker,2) // Producer of AliMUONVTrackerData from raw }; #endif diff --git a/MUON/AliMUONTrackerQAChecker.cxx b/MUON/AliMUONTrackerQAChecker.cxx index 2d3cfe16511..686de7a1e32 100644 --- a/MUON/AliMUONTrackerQAChecker.cxx +++ b/MUON/AliMUONTrackerQAChecker.cxx @@ -250,12 +250,16 @@ AliMUONTrackerQAChecker::CheckRaws(TObjArray ** list, AliMUONRecoParam* recoPara TH1* hbpconfig = AliQAv1::GetData(list,AliMUONQAIndices::kTrackerBusPatchConfig,AliRecoParam::ConvertIndex(specie)); - if (!hbp || !hnpads ) + TH1* hnevents = AliQAv1::GetData(list,AliMUONQAIndices::kTrackerNofRawEventSeen,AliRecoParam::ConvertIndex(specie)); + + if ( !hbp || !hnpads || !hnevents ) { continue; } - rv[specie] = BeautifyTrackerBusPatchOccupancy(*hbp,hbpconfig,*hnpads,*recoParam); + Int_t nevents = TMath::Nint(hnevents->GetBinContent(1)); + + rv[specie] = BeautifyTrackerBusPatchOccupancy(*hbp,hbpconfig,*hnpads,nevents,*recoParam); } return rv; @@ -266,6 +270,7 @@ AliMUONVQAChecker::ECheckCode AliMUONTrackerQAChecker::BeautifyTrackerBusPatchOccupancy(TH1& hbp, const TH1* hbuspatchconfig, const TH1& hnpads, + Int_t nevents, AliMUONRecoParam& recoParam) { /// Put labels, limits and so on on the TrackerBusPatchOccupancy histogram @@ -385,15 +390,19 @@ AliMUONTrackerQAChecker::BeautifyTrackerBusPatchOccupancy(TH1& hbp, hbp.SetMaximum(ymax*1.4); - TPaveText* text = new TPaveText(0.50,0.80,0.99,0.99,"NDC"); + TPaveText* text = new TPaveText(0.50,0.60,0.99,0.99,"NDC"); - if (ok < 0 ) + text->AddText(Form("MCH RUN %d - %d events",AliCDBManager::Instance()->GetRun(),nevents)); + + if ( ok < 0 ) { text->AddText("Could not compute truncated mean. Not enough events ?"); + text->AddText(Form("nBusPatches=%d n=%d",nBusPatches,n)); } else if (!nPads || !nBusPatches) { - text->AddText("Could not get the total number of pads. ERROR !!!"); + text->AddText(Form("Could not get the total number of pads (%d) or total number of buspatches (%d). ERROR !!!", + nPads,nBusPatches)); } else { @@ -402,7 +411,6 @@ AliMUONTrackerQAChecker::BeautifyTrackerBusPatchOccupancy(TH1& hbp, Float_t aboveLimitFraction = nBusPatchesAboveLimit*100.0/nBusPatches; Float_t belowLimitFraction = nBusPatchesBelowLimit*100.0/nBusPatches; - text->AddText(Form("MCH RUN %d",AliCDBManager::Instance()->GetRun())); text->AddText(Form("%5.2f %% of missing buspatches (%d out of %d)",missingBusPatchFraction,nMissingBusPatches,nBusPatches)); text->AddText(Form("%5.2f %% of missing pads (%d out of %d)",missingPadFraction,nMissingPads,nPads)); text->AddText(Form("%5.2f %% bus patches above the %5.2f %% limit",aboveLimitFraction,maxToleratedOccupancy)); diff --git a/MUON/AliMUONTrackerQAChecker.h b/MUON/AliMUONTrackerQAChecker.h index 6560774004b..dec0dc338f5 100644 --- a/MUON/AliMUONTrackerQAChecker.h +++ b/MUON/AliMUONTrackerQAChecker.h @@ -32,7 +32,9 @@ private: AliMUONVQAChecker::ECheckCode BeautifyTrackerBusPatchOccupancy(TH1& hbp, const TH1* hbuspatchconfig, - const TH1& hnpads, AliMUONRecoParam& recoParam); + const TH1& hnpads, + Int_t nevents, + AliMUONRecoParam& recoParam); ClassDef(AliMUONTrackerQAChecker,1) // MUON quality assurance checker diff --git a/MUON/AliMUONTrackerQADataMakerRec.cxx b/MUON/AliMUONTrackerQADataMakerRec.cxx index b330c0bbedf..f38f0516c7f 100644 --- a/MUON/AliMUONTrackerQADataMakerRec.cxx +++ b/MUON/AliMUONTrackerQADataMakerRec.cxx @@ -23,6 +23,7 @@ #include "AliMUONDigitMaker.h" #include "AliMUONQAIndices.h" #include "AliMUONQAMappingCheck.h" +#include "AliMUONLogger.h" #include "AliMUONTrackerDataMaker.h" #include "AliMUONVCluster.h" #include "AliMUONVClusterStore.h" @@ -55,6 +56,7 @@ #include #include #include +#include //----------------------------------------------------------------------------- /// \class AliMUONTrackerQADataMakerRec @@ -67,6 +69,11 @@ ClassImp(AliMUONTrackerQADataMakerRec) /// \endcond +Double_t AliMUONTrackerQADataMakerRec::fgkRawNofGlitchErrors(0.0); +Double_t AliMUONTrackerQADataMakerRec::fgkRawNofTokenLostErrors(1.0); +Double_t AliMUONTrackerQADataMakerRec::fgkRawNofParityErrors(2.0); +Double_t AliMUONTrackerQADataMakerRec::fgkRawNofPaddingErrors(3.0); + //____________________________________________________________________________ AliMUONTrackerQADataMakerRec::AliMUONTrackerQADataMakerRec(AliQADataMakerRec* master) : AliMUONVQADataMakerRec(master), @@ -75,7 +82,8 @@ fDigitMaker(new AliMUONDigitMaker(kTRUE)), fClusterStore(0x0), fTrackerDataMaker(0x0), fMappingCheckRecPoints(0x0), -fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())) +fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())), +fLogger(0x0) { /// ctor } @@ -90,6 +98,14 @@ AliMUONTrackerQADataMakerRec::~AliMUONTrackerQADataMakerRec() delete fTrackerDataMaker; delete fCalibrationData; delete fMappingCheckRecPoints; + if (fLogger) + { + if ( fLogger->NumberOfEntries() != 0 ) + { + AliError("Some unprocessed logged errors are still there... Please check"); + } + delete fLogger; + } } //____________________________________________________________________________ @@ -381,9 +397,93 @@ void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArra Int_t bin = hbp->FindBin(busPatchId); hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent } + + TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofRawEventSeen); + hnevents->Reset(); + hnevents->Fill(0.0,fTrackerDataMaker->Data()->NumberOfEvents(-1)); + + if ( fLogger->NumberOfEntries() > 0 ) + { + // readout errors + FillErrors(*fLogger); + fLogger->Clear(); + } + } +} + +//____________________________________________________________________________ +void AliMUONTrackerQADataMakerRec::FillErrors(AliMUONLogger& log) +{ + log.ResetItr(); + + TString msg; + Int_t occurence; + + TH1* hparity = GetRawsData(AliMUONQAIndices::kTrackerBusPatchParityErrors); + + TH1* htoken = GetRawsData(AliMUONQAIndices::kTrackerBusPatchTokenLostErrors); + + TH1* hpadding = GetRawsData(AliMUONQAIndices::kTrackerBusPatchPaddingErrors); + + TH1* hroe = GetRawsData(AliMUONQAIndices::kTrackerReadoutErrors); + + TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofRawEventSeen); + + Int_t nevents = TMath::Nint(hnevents->GetBinContent(1)); + + if ( !nevents ) + { + TPaveText* text = new TPaveText(0,0,0.99,0.99,"NDC"); + text->AddText("FATAL : 0 event seen ? That's NOT normal..."); + text->SetFillColor(2); // red = FATAL + hroe->GetListOfFunctions()->Add(text); + return; + } + + while ( log.Next(msg,occurence) ) + { + AliDebug(1,Form("msg=%s occurence=%d",msg.Data(),occurence)); + + if ( msg.Contains("token") ) + { + Int_t dsp(-1),ddl(-1),ecode(-1); + + sscanf(msg.Data(),"Lost token error detected in DSP 0x%X of DDL %d and code %d.", + &dsp,&ddl,&ecode); + Int_t localBP = ((dsp >> 16)- 4)*5 + 1; + Int_t buspatch = localBP + ddl*100; + htoken->Fill(buspatch,occurence); + hroe->Fill(fgkRawNofTokenLostErrors,occurence); + AliDebug(1,Form("DDL %d DSP %d busPatch %d",ddl,dsp,buspatch)); + } + + if ( msg.Contains("Parity") ) + { + Int_t buspatch; + sscanf(msg.Data(),"Parity error in buspatch %d (0x%X).",&buspatch,&buspatch); + hparity->Fill(buspatch,occurence); + hroe->Fill(fgkRawNofParityErrors,occurence); + } + + if ( msg.Contains("Glitch") ) + { + hroe->Fill(fgkRawNofGlitchErrors,occurence); + } + + if ( msg.Contains("Padding") ) + { + Int_t block, dsp, buspatch; + sscanf(msg.Data(),"Padding word error for iBlock %d, iDsp %d, iBus %d.",&block,&dsp,&buspatch); + hpadding->Fill(buspatch,occurence); + hroe->Fill(fgkRawNofPaddingErrors,occurence); + } } + + /// Finally we normalize to the number of events, for the shifter plot only + hroe->Scale(100.0/nevents); } + //____________________________________________________________________________ void AliMUONTrackerQADataMakerRec::InitRaws() { @@ -395,7 +495,7 @@ void AliMUONTrackerQADataMakerRec::InitRaws() const Bool_t saveCorr = kTRUE ; const Bool_t image = kTRUE ; - Int_t bpmin(999999); + Int_t bpmin(999999); Int_t bpmax(0); TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator()); @@ -412,7 +512,6 @@ void AliMUONTrackerQADataMakerRec::InitRaws() TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",nbins,xmin,xmax); - TH1* hbpnpads = new TH1F("hTrackerBusPatchNofPads","Number of pads per bus patch",nbins,xmin,xmax); TH1* hbpnmanus = new TH1F("hTrackerBusPatchNofManus","Number of manus per bus patch",nbins,xmin,xmax); @@ -421,17 +520,51 @@ void AliMUONTrackerQADataMakerRec::InitRaws() Add2RawsList(hbpnpads,AliMUONQAIndices::kTrackerBusPatchNofPads, expert, !image, !saveCorr); Add2RawsList(hbpnmanus,AliMUONQAIndices::kTrackerBusPatchNofManus, expert, !image, !saveCorr); + Add2RawsList(new TH1F("hTrackerBusPatchParityErrors","Number of parity errors per bus patch",nbins,xmin,xmax), + AliMUONQAIndices::kTrackerBusPatchParityErrors,expert,!image,!saveCorr); + + Add2RawsList(new TH1F("hTrackerBusPatchTokenLostErrors","Number of token lost errors per bus patch",nbins,xmin,xmax), + AliMUONQAIndices::kTrackerBusPatchTokenLostErrors,expert,!image,!saveCorr); + + Add2RawsList(new TH1F("hTrackerBusPatchPaddingErrors","Number of padding errors per bus patch",nbins,xmin,xmax), + AliMUONQAIndices::kTrackerBusPatchPaddingErrors,expert,!image,!saveCorr); + + TH1* h = new TH1F("hTrackerReadoutErrors","Number of readout errors per event;;Error rate in %",4,-0.5,3.5); + h->SetStats(kFALSE); + + // The QA shifter will only see the summary plot below + TAxis* a = h->GetXaxis(); + + a->SetBinLabel(h->FindBin(fgkRawNofGlitchErrors),"Glitch errors"); + a->SetBinLabel(h->FindBin(fgkRawNofTokenLostErrors),"Token lost errors"); + a->SetBinLabel(h->FindBin(fgkRawNofParityErrors),"Parity errors"); + a->SetBinLabel(h->FindBin(fgkRawNofPaddingErrors),"Padding errors"); + + Add2RawsList(h,AliMUONQAIndices::kTrackerReadoutErrors,!expert,image,!saveCorr); + + TH1* hnevents = new TH1F("hTrackerNofRawEventSeen","Number of events seen",1,-0.5,0.5); + a = hnevents->GetXaxis(); + a->SetBinLabel(1,"Nevents"); + hnevents->SetStats(kFALSE); + + Add2RawsList(hnevents,AliMUONQAIndices::kTrackerNofRawEventSeen,expert,!image,!saveCorr); + const Bool_t histogram(kFALSE); if(!fTrackerDataMaker) { - fTrackerDataMaker = new AliMUONTrackerDataMaker(GetRecoParam(), + + AliMUONTrackerDataMaker* dm = new AliMUONTrackerDataMaker(GetRecoParam(), AliCDBManager::Instance()->GetRun(), 0x0, "", "NOGAIN", histogram, 0.0,0.0); + + fLogger = new AliMUONLogger(-1); + dm->EnableErrorLogger(fLogger); + fTrackerDataMaker = dm; } fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level @@ -833,6 +966,8 @@ void AliMUONTrackerQADataMakerRec::MakeRaws(AliRawReader* rawReader) ((AliMUONTrackerDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader); fTrackerDataMaker->ProcessEvent(); + + } //__________________________________________________________________ diff --git a/MUON/AliMUONTrackerQADataMakerRec.h b/MUON/AliMUONTrackerQADataMakerRec.h index 9d163def6a5..dd0764adfe6 100644 --- a/MUON/AliMUONTrackerQADataMakerRec.h +++ b/MUON/AliMUONTrackerQADataMakerRec.h @@ -22,6 +22,7 @@ class AliMUONVTrackerData; class AliMUONVTrackerDataMaker; class AliMUONCalibrationData; class AliMUONQAMappingCheck; +class AliMUONLogger; class AliMUONTrackerQADataMakerRec: public AliMUONVQADataMakerRec { @@ -53,6 +54,8 @@ private: void InsertTrackerData(Int_t specie, TObjArray** list, TObject* object, Int_t indexNumber, Bool_t replace=kFALSE); + void FillErrors(AliMUONLogger& log); + private: /// Not implemented AliMUONTrackerQADataMakerRec(const AliMUONTrackerQADataMakerRec& rhs); @@ -69,7 +72,15 @@ private: AliMUONCalibrationData* fCalibrationData; //!< Used to load Local, Regional and Global masks - ClassDef(AliMUONTrackerQADataMakerRec,1) // MUON Quality assurance data maker + AliMUONLogger* fLogger; //!< (readout) error logger + + static Double_t fgkRawNofEvents; //!< x-position to fill kTrackerReadoutErrors with nof events + static Double_t fgkRawNofGlitchErrors; //!< x-position to fill kTrackerReadoutErrors with nof glitch errors + static Double_t fgkRawNofTokenLostErrors; //!< x-position to fill kTrackerReadoutErrors with nof token lost errors + static Double_t fgkRawNofParityErrors; //!< x-position to fill kTrackerReadoutErrors with nof parity errors + static Double_t fgkRawNofPaddingErrors; //!< x-position to fill kTrackerReadoutErrors with nof padding errors + + ClassDef(AliMUONTrackerQADataMakerRec,2) // MUON Quality assurance data maker }; #endif diff --git a/MUON/MUONRawStreamTracker.C b/MUON/MUONRawStreamTracker.C index 1dc0b2bcb12..995f4b73379 100644 --- a/MUON/MUONRawStreamTracker.C +++ b/MUON/MUONRawStreamTracker.C @@ -358,7 +358,8 @@ void MUONRawStreamTrackerSimple2(TString fileName = "./", Int_t maxEvent = 1000) AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); // raw stream - AliMUONRawStreamTrackerHP rawStream(rawReader); + AliMUONRawStreamTrackerHP rawStream(rawReader); + rawStream.EnableRawReaderErrorLogger(); // Loop over events Int_t iEvent = 0; @@ -402,7 +403,9 @@ void MUONRawStreamTrackerErrorCount(TString fileName = "collection://filelist", AliRawReader* rawReader = AliRawReader::Create(fileName.Data()); // raw stream - AliMUONRawStreamTrackerHP rawStream(rawReader); + AliMUONRawStreamTrackerHP rawStream(rawReader); + rawStream.EnableRawReaderErrorLogger(); + rawStream.DisableWarnings(); // Loop over events Int_t iEvent = 0; -- 2.39.3