4 #ifndef ALIALTRODECODER_H
5 #define ALIALTRODECODER_H
6 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
10 @file AliAltroDocoder.h
11 @author Per Thomas Hille, Oystein Djuvsland
13 @brief High performance decoder class for the RCU/Altro data format
16 ///////////////////////////////////////////////////////////////////////////////
18 /// This is the class for fast decoding of TPC/PHOS/EMCAL raw data
19 // see .cxx file for more detailed comments.
21 ///////////////////////////////////////////////////////////////////////////////
29 #define DDL_32BLOCK_SIZE 5
30 #define MAX_BRANCHES 2
31 #define MAX_FEE_PER_BRANCH 16
32 #define MAX_ALTROS_PER_FEE 8
33 #define CHANNELS_PER_ALTRO 16
34 #define MAX_SAMPLES_PER_CHANNEL 1024
35 #define ALTRO_TRAILER_SIZE 4
36 #define MAX_TRAILER_WORDS 3
40 class AliAltroDecoder: public TObject {
43 virtual ~AliAltroDecoder();
45 Bool_t NextChannel(AliAltroData *altroDataPtr);
48 * Copy the original 10/40 bit encecoded data of the current channel.
49 * The funtions copies the data to the end of the provided buffer.
50 * @param pBuffer target buffer
51 * @param bufferSize size of target buffer
52 * @return number of copied bytes, neg. error code if failed
54 Int_t CopyBackward(Byte_t* pBuffer, Int_t bufferSize);
58 * For debugging purphoses only, will be removed in near future
61 void DumpData(T *array, Int_t N, Int_t nPerLine)
63 cout << "DumpData N= " << N <<endl;
65 for(Int_t i= 0; i< N; i++)
67 if((i%nPerLine == 0) && (i != 0))
72 cout << array[i]<< "\t";
77 int SetMemory(UChar_t *dtaPtr, UInt_t size);
78 void PrintInfo(AliAltroData &altrodata, Int_t n = 0, Int_t nPerLine = 4);
79 Float_t GetFailureRate();
82 * Provide a pointer to RCU trailer.
83 * The type of the parameter might not be optimal, but the function has
84 * been chosen that way to be similar to the counterpart in
86 * @return kTRUE if trailer available;
88 Bool_t GetRCUTrailerData(UChar_t*& data) const;
91 * Provide size of RCU trailer.
93 Int_t GetRCUTrailerSize() const;
97 AliAltroDecoder& operator = (const AliAltroDecoder& decoder);
98 AliAltroDecoder(const AliAltroDecoder& decoder);
99 Bool_t CheckPayloadTrailer() const;
100 void DecodeDDLBlock();
101 void DecodeLastDDLBlock();
102 Int_t CountAAApaddings() const;
103 UInt_t *f32DtaPtr; // Pointer to dat of the input buffer in entities of 32 bit words (the RCU/DDL block)
104 UChar_t *f8DtaPtr; // Pointer to dat of the input buffer in entities of 8 bit words (the RCU/DDL block)
105 const Long_t fkN32HeaderWords; // Number of 32 bit words in the common data header
106 Int_t fN40AltroWords; // Number of 40 bit altro words contained in the RCU payload as calculated form the payload size
107 Int_t fN40RcuAltroWords; // Number of 40 bit altro words contained in the RCU payload as given by the RCU trailer
108 Int_t fNDDLBlocks; // Number of DDL blocks in the payload (the last blocj might/ight not be 160 bits )
109 Int_t f32LastDDLBlockSize; // Size of the last DDL block
110 UInt_t fDDLBlockDummy[DDL_32BLOCK_SIZE]; // buffer to contain the las DDL block, if the block is not aligned with 160 bitm the remaining fileds are padded with zeroes
111 UInt_t f8PayloadSize; // The size of the payload in bytes (after subtraction of the RCU header and the RCU trailer words)
112 Long_t fOutBufferIndex; // current buffer position of the buffer for the decoded data (10 bit words represnted as int's)
113 UInt_t fSize; // The size of the input RCU/DDL payload in entities of bytes, inluding the RCU header and trailer
114 UInt_t fOutBuffer[MAX_FEE_PER_BRANCH*MAX_BRANCHES*MAX_ALTROS_PER_FEE*CHANNELS_PER_ALTRO*(MAX_SAMPLES_PER_CHANNEL + ALTRO_TRAILER_SIZE)]; // Buffer to hold the decoded data
115 UInt_t fNAltro10bitWords; // The total number of 10 bit altro words in the RCU payload, including trailers (disregardin that the altro trialer is not aligned with 10 bit)
116 Int_t fComplete; // Number of altro channels that is only partially read out (0x2aaa pattern missing in trailer)
117 Int_t fInComplete; // Number of altro channels that is read out properly
118 Bool_t fDecodeIfCorruptedTrailer; // Wether or not to try to decode the data if the RCU trailer is incorrect (will succseed in most cases)
119 Bool_t fIsDecoded; // Wether or not the buffer set last by the "SetMemory()" function has been decoded
120 Bool_t fIsFatalCorruptedTrailer; // If trailer is fataly corrupted, not possible in any way to recover, then it is not allowed to decode the DDL payload.
122 ClassDef(AliAltroDecoder, 0) // class for decoding Altro payload