]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliAltroDecoder.h
Runing the online reconstruction in the Amore framework (Cvetan)
[u/mrichter/AliRoot.git] / RAW / AliAltroDecoder.h
CommitLineData
31a920d3 1//#-*- Mode: c++ -*-
86525f0f 2// $Id$
31a920d3 3
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 */
8
86525f0f 9/**
10 @file AliAltroDocoder.h
11 @author Per Thomas Hille, Oystein Djuvsland
12 @date
13 @brief High performance decoder class for the RCU/Altro data format
14*/
15
ac672c4c 16///////////////////////////////////////////////////////////////////////////////
17///
86525f0f 18/// This is the class for fast decoding of TPC/PHOS/EMCAL raw data
ac672c4c 19// see .cxx file for more detailed comments.
20///
21///////////////////////////////////////////////////////////////////////////////
22
23
44443c72 24#define DECODERERROR -3
25
31a920d3 26#include <TObject.h>
ac672c4c 27
28#include <iostream>
29using namespace std;
31a920d3 30
31#define DDL_32BLOCK_SIZE 5
32#define MAX_BRANCHES 2
33#define MAX_FEE_PER_BRANCH 16
34#define MAX_ALTROS_PER_FEE 8
35#define CHANNELS_PER_ALTRO 16
36#define MAX_SAMPLES_PER_CHANNEL 1024
37#define ALTRO_TRAILER_SIZE 4
38#define MAX_TRAILER_WORDS 3
39
40class AliAltroData;
41
42class AliAltroDecoder: public TObject {
43 public:
31a920d3 44 AliAltroDecoder();
31a920d3 45 virtual ~AliAltroDecoder();
31a920d3 46 Bool_t Decode();
31a920d3 47 Bool_t NextChannel(AliAltroData *altroDataPtr);
48
86525f0f 49 /**
50 * Copy the original 10/40 bit encecoded data of the current channel.
51 * The funtions copies the data to the end of the provided buffer.
52 * @param pBuffer target buffer
53 * @param bufferSize size of target buffer
54 * @return number of copied bytes, neg. error code if failed
55 */
56 Int_t CopyBackward(Byte_t* pBuffer, Int_t bufferSize);
57
31a920d3 58 /*
59 * DONT use !
60 * For debugging purphoses only, will be removed in near future
61 **/
62 template<typename T>
63 void DumpData(T *array, Int_t N, Int_t nPerLine)
64 {
65 cout << "DumpData N= " << N <<endl;
ac672c4c 66
31a920d3 67 for(Int_t i= 0; i< N; i++)
68 {
69 if((i%nPerLine == 0) && (i != 0))
70 {
71 printf("\n");
72 }
73
74 cout << array[i]<< "\t";
75
76 }
77 }
78
ebf7cafe 79 int SetMemory(UChar_t *dtaPtr, UInt_t size);
31a920d3 80 void PrintInfo(AliAltroData &altrodata, Int_t n = 0, Int_t nPerLine = 4);
31a920d3 81 Float_t GetFailureRate();
82
86525f0f 83 /**
84 * Provide a pointer to RCU trailer.
85 * The type of the parameter might not be optimal, but the function has
86 * been chosen that way to be similar to the counterpart in
87 * AliAltroRawStream.
88 * @return kTRUE if trailer available;
89 */
90 Bool_t GetRCUTrailerData(UChar_t*& data) const;
86525f0f 91 Int_t GetRCUTrailerSize() const;
92
31a920d3 93 private:
94
95 AliAltroDecoder& operator = (const AliAltroDecoder& decoder);
96 AliAltroDecoder(const AliAltroDecoder& decoder);
ac672c4c 97 Bool_t CheckPayloadTrailer() const;
31a920d3 98 void DecodeDDLBlock();
31a920d3 99 void DecodeLastDDLBlock();
ac672c4c 100 Int_t CountAAApaddings() const;
31a920d3 101 UInt_t *f32DtaPtr; // Pointer to dat of the input buffer in entities of 32 bit words (the RCU/DDL block)
102 UChar_t *f8DtaPtr; // Pointer to dat of the input buffer in entities of 8 bit words (the RCU/DDL block)
ac672c4c 103 const Long_t fkN32HeaderWords; // Number of 32 bit words in the common data header
31a920d3 104 Int_t fN40AltroWords; // Number of 40 bit altro words contained in the RCU payload as calculated form the payload size
105 Int_t fN40RcuAltroWords; // Number of 40 bit altro words contained in the RCU payload as given by the RCU trailer
106 Int_t fNDDLBlocks; // Number of DDL blocks in the payload (the last blocj might/ight not be 160 bits )
107 Int_t f32LastDDLBlockSize; // Size of the last DDL block
108 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
86525f0f 109 UInt_t f8PayloadSize; // The size of the payload in bytes (after subtraction of the RCU header and the RCU trailer words)
31a920d3 110 Long_t fOutBufferIndex; // current buffer position of the buffer for the decoded data (10 bit words represnted as int's)
111 UInt_t fSize; // The size of the input RCU/DDL payload in entities of bytes, inluding the RCU header and trailer
112 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
113 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)
114 Int_t fComplete; // Number of altro channels that is only partially read out (0x2aaa pattern missing in trailer)
115 Int_t fInComplete; // Number of altro channels that is read out properly
116 Bool_t fDecodeIfCorruptedTrailer; // Wether or not to try to decode the data if the RCU trailer is incorrect (will succseed in most cases)
117 Bool_t fIsDecoded; // Wether or not the buffer set last by the "SetMemory()" function has been decoded
44443c72 118 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.
119
120 // Bool_t fIsFirstChannelOfPayload;
121
ebf7cafe 122
31a920d3 123 ClassDef(AliAltroDecoder, 0) // class for decoding Altro payload
124};
125
126#endif