]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONRawStreamTrackerHP.h
ConsistencyCheck() rewritten.
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTrackerHP.h
index 2ede43711ac9d152c76373e724f0cc5ca2badaf0..53644150b813465e6c2e1f69431db062cf3cff22 100644 (file)
 /// \brief  Declaration of the high performance decoder for muon trigger chamber raw streams.
 ///
 
-#include "AliMUONVRawStreamTracker.h"
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
 #include "AliMUONTrackerDDLDecoder.h"
 
-class AliMUONRawStreamTrackerHP : public AliMUONVRawStreamTracker
+#include <cstring>
+
+class AliMUONDDLTracker;
+class AliRawReader;
+
+class AliMUONRawStreamTrackerHP : public TObject
 {
 public:
        class AliDspHeader;
@@ -31,8 +38,9 @@ public:
        /// Default destructor.
        virtual ~AliMUONRawStreamTrackerHP();
        
-       // The following public methods are all inherited from AliMUONVRawStreamTracker:
-       
+  /// Get object for reading the raw data
+  virtual AliRawReader* GetReader();
+
        /// Initialize iterator
        virtual void First();
        
@@ -45,11 +53,21 @@ public:
        /// 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,
+                           UShort_t& manuId, UChar_t& manuChannel,
+                           UShort_t& adc) { return Next(busPatchId,manuId,manuChannel,adc,kTRUE); }
        
        /// Advance one step in the iteration. Returns false if finished.
        virtual Bool_t Next(Int_t& busPatchId,
-                               UShort_t& manuId, UChar_t& manuChannel,
-                               UShort_t& adc);
+                      UShort_t& manuId,
+                      UChar_t& manuChannel,
+                      UShort_t& adc,
+                      Bool_t skipParityErrors);
+
+       /// Construct and return a pointer to the DDL payload object.
+       virtual AliMUONDDLTracker* GetDDLTracker() const;
        
        /// Returns the next batch of decoded channel data.
        const AliBusPatch* Next();
@@ -105,6 +123,24 @@ public:
        /// payload headers.
        void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
        
+       /// Returns the auto-detect trailer words flag.
+       Bool_t AutoDetectTrailer() const { return Bool_t(fDecoder.AutoDetectTrailer()); }
+       
+       /// Sets the auto-detect trailer words flag.
+       /// When set to true the decoder will try to detect if the end of DDL
+       /// keys are in the trailer words or not. These are generated by the
+       /// detector but not the older versions of AliRoot simulations.
+       void AutoDetectTrailer(Bool_t value) { fDecoder.AutoDetectTrailer(bool(value)); }
+
+       /// Returns the flag indicating if the data is expected to have the
+       /// end of DDL keys in the trailer. This flag is ignored if AutoDetectTrailer()
+       /// was set to true.
+       Bool_t CheckForTrailer() const { return Bool_t(fDecoder.CheckForTrailer()); }
+       
+       /// Sets the flag indicating if the trailer words should contain the
+       /// end of DDL key.
+       void CheckForTrailer(Bool_t value) { fDecoder.CheckForTrailer(bool(value)); }
+       
        /// Light weight interface class to the block header data.
        class AliBlockHeader
        {
@@ -455,8 +491,8 @@ public:
        /// Returns the current bus patch being decoded or NULL if none found.
        const AliBusPatch* CurrentBusPatch() const
        {
-               return (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch()) ?
-                       fCurrentBusPatch : NULL;
+               return (fkCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch()) ?
+                       fkCurrentBusPatch : NULL;
        }
 
        /// Returns the current DSP being decoded or NULL if none found.
@@ -473,6 +509,33 @@ public:
                return (dsp != NULL) ? dsp->GetBlockHeader() : NULL;
        }
 
+  /// Set the raw reader
+  void SetReader(AliRawReader* reader);
+  
+  /// Enable error info logger
+  virtual void EnabbleErrorLogger() { fEnableErrorLogger = kTRUE; }
+  
+  /// Check if error info logger enable
+  virtual Bool_t IsErrorLogger() const {return fEnableErrorLogger; }
+    
+  /// Number of glitch errors since First() was called
+  Int_t NumberOfGlitchErrors() const { return fTotalNumberOfGlitchErrors; }
+
+  /// Number of padding errors since First() was called
+  Int_t NumberOfPaddingErrors() const { return fTotalNumberOfPaddingErrors; }
+
+  /// Number of parity errors since First() was called
+  Int_t NumberOfParityErrors() const { return fTotalNumberOfParityErrors; }
+
+  /// Whether we got glitch errors or not
+  Bool_t HasGlitchError() const { return NumberOfGlitchErrors() > 0; }
+
+  /// Whether we got padding errors or not
+  Bool_t HasPaddingError() const { return NumberOfPaddingErrors() > 0; }
+
+  /// Whether we got parity errors or not
+  Bool_t HasParityError() const { return NumberOfParityErrors() > 0; }
+
 private:
 
        // Do not allow copying of this class.
@@ -481,11 +544,12 @@ private:
         /// Not implemented
        AliMUONRawStreamTrackerHP& operator = (const AliMUONRawStreamTrackerHP& stream);
        
+       /// Return max number of tracker DDLs
+       Int_t GetMaxDDL() const { return fgkMaxDDL; }
+  
        /// 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.
-       /// Any errors are logged to the parent AliMUONVRawStreamTracker, so one
-       /// must set this pointer appropriately before decoding and DDL payload.
        class AliDecoderEventHandler : public AliMUONTrackerDDLDecoderEventHandler
        {
        public:
@@ -498,9 +562,6 @@ 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(AliMUONVRawStreamTracker* rawStream) { fRawStream = rawStream; }
-               
                /// Return the number of blocks found in the payload.
                UInt_t BlockCount() const { return fBlockCount; };
                
@@ -564,6 +625,12 @@ 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.
@@ -572,7 +639,7 @@ private:
                 /// Not implemented
                AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
 
-               AliMUONVRawStreamTracker* fRawStream; //!< Pointer to the parent raw stream object.
+    AliRawReader* fRawReader; //!< Pointer to the raw reader
                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]
@@ -589,17 +656,28 @@ private:
                UInt_t fGlitchErrors;   //!< Number of glitch errors found in DDL.
                UInt_t fPaddingErrors;  //!< Number of padding 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
        AliMUONTrackerDDLDecoder<AliDecoderEventHandler> 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.
        UChar_t* fBuffer;   //!< This is the buffer in which we store the DDL payload read from AliRawReader.
-       const AliBusPatch* fCurrentBusPatch;  //!< The current data word to return by Next().
-       const UInt_t* fCurrentData;  //!< The current data word to return by Next().
-       const UInt_t* fEndOfData;  //!< The last data word in the current bus patch.
+       const AliBusPatch* fkCurrentBusPatch;  //!< The current bus patch being handled by Next().
+       const UInt_t* fkCurrentData;  //!< The current data word to return by Next().
+       const UInt_t* fkEndOfData;  //!< The last data word in the current bus patch.
        Bool_t fHadError;   //!< Flag indicating if there was a decoding error or not.
        Bool_t fDone;       //!< Flag indicating if the iteration is done or not.
+       mutable AliMUONDDLTracker* fDDLObject; //!< Temporary DDL object used by GetDDLTracker() for caching.
+  Int_t fTotalNumberOfGlitchErrors; //!< number of glitch errors since First() was called
+  Int_t fTotalNumberOfParityErrors; //!< number of glitch errors since First() was called
+  Int_t fTotalNumberOfPaddingErrors; //!< number of glitch errors since First() was called
+  
+  static const Int_t fgkMaxDDL; //!< max number of tracker DDLs
 
        ClassDef(AliMUONRawStreamTrackerHP, 0) // High performance decoder for reading MUON raw digits from tracking chamber DDL data.
 };
@@ -609,9 +687,10 @@ private:
 inline const AliMUONRawStreamTrackerHP::AliBusPatch* AliMUONRawStreamTrackerHP::Next()
 {
        /// Returns the next batch of decoded channel data.
+       if (fkCurrentBusPatch == NULL) return NULL;
        do {
-               if (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
-                       return fCurrentBusPatch++;
+               if (fkCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
+                       return fkCurrentBusPatch++;
        } while (NextDDL());
        return NULL;
 }
@@ -625,7 +704,7 @@ inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewBlock(
        /// internal counter.
 
        assert( header != NULL );
-       assert( fBlockCount < (UInt_t)fRawStream->GetMaxBlock() );
+       assert( fBlockCount < fMaxBlocks );
        // Link the block unless it is the first one.
        if (fBlockCount > 0) fCurrentBlock->SetNext(fCurrentBlock+1);
        *(++fCurrentBlock) = AliBlockHeader(fCurrentDSP+1, header);
@@ -641,7 +720,7 @@ inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewDSP(
        /// appropriate counters.
        
        assert( header != NULL );
-       assert( fCurrentBlock->GetDspCount() < (UInt_t)fRawStream->GetMaxDsp() );
+       assert( fCurrentBlock->GetDspCount() < fMaxDsps );
        // Link the DSP unless it is the first one.
        if (fCurrentBlock->GetDspCount() > 0) fCurrentDSP->SetNext(fCurrentDSP+1);
        *(++fCurrentDSP) = AliDspHeader(fCurrentBlock, fCurrentBusPatch+1, header);
@@ -658,7 +737,7 @@ inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewBusPatch(
 
        assert( header != NULL );
        assert( data != NULL );
-       assert( fCurrentDSP->GetBusPatchCount() < (UInt_t)fRawStream->GetMaxBus() );
+       assert( fCurrentDSP->GetBusPatchCount() < fMaxBusPatches );
        // Link the bus patch unless it is the first one. 
        if (fCurrentDSP->GetBusPatchCount() > 0) fCurrentBusPatch->SetNext(fCurrentBusPatch+1);
        *(++fCurrentBusPatch) = AliBusPatch(