Optional input event handler.
[u/mrichter/AliRoot.git] / RAW / AliAltroDecoder.h
CommitLineData
31a920d3 1//#-*- Mode: c++ -*-
2
3#ifndef ALIALTRODECODER_H
4#define ALIALTRODECODER_H
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
7
8#include <TObject.h>
9
10#define DDL_32BLOCK_SIZE 5
11#define MAX_BRANCHES 2
12#define MAX_FEE_PER_BRANCH 16
13#define MAX_ALTROS_PER_FEE 8
14#define CHANNELS_PER_ALTRO 16
15#define MAX_SAMPLES_PER_CHANNEL 1024
16#define ALTRO_TRAILER_SIZE 4
17#define MAX_TRAILER_WORDS 3
18
19class AliAltroData;
20
21class AliAltroDecoder: public TObject {
22 public:
23
24 /*
25 *Default constructor
26 **/
27 AliAltroDecoder();
28
29 /*
30 *Default destructor
31 **/
32 virtual ~AliAltroDecoder();
33
34 /*
35 *Decode the RCU/DDL payload
36 **/
37 Bool_t Decode();
38
39 /*
40 *Reads the next altro channels
41 **/
42 Bool_t NextChannel(AliAltroData *altroDataPtr);
43
44 /*
45 * DONT use !
46 * For debugging purphoses only, will be removed in near future
47 **/
48 template<typename T>
49 void DumpData(T *array, Int_t N, Int_t nPerLine)
50 {
51 cout << "DumpData N= " << N <<endl;
52 for(Int_t i= 0; i< N; i++)
53 {
54 if((i%nPerLine == 0) && (i != 0))
55 {
56 printf("\n");
57 }
58
59 cout << array[i]<< "\t";
60
61 }
62 }
63
64 void SetMemory(UChar_t *dtaPtr, UInt_t size);
65
66 void PrintInfo(AliAltroData &altrodata, Int_t n = 0, Int_t nPerLine = 4);
67
68 /*
69 *Prints to stdout the percent of altroblocks that
70 *is missing the 2aaa trailer.
71 **/
72 Float_t GetFailureRate();
73
74 private:
75
76 AliAltroDecoder& operator = (const AliAltroDecoder& decoder);
77 AliAltroDecoder(const AliAltroDecoder& decoder);
78
79 /*
80 *Check wether or not there is consistency between the number of 40 bit altro words given by
81 *the RCU payload and the number of 40 bit words calculated from the size of the RCU payload.
82 **/
83 Bool_t CheckPayloadTrailer();
84
85 /*
86 *Decode one 160 bit DDL block into 16 x 16 bit integers (only least significant 10 bits are filled)
87 **/
88 void DecodeDDLBlock();
89
90 /*
91 *Decode one 160 bit DDL block into 16 integers.
92 *In order to use the same decoding function (DecodeDDLBlock())
93 *a copy of the the last DDL block is made and
94 *if the las block does not align with 160 bits then it is padded with zeroes
95 **/
96 void DecodeLastDDLBlock();
97
98 /*
99 *Use for simulated data only.
100 *Patch for incorrectly simulated data. Counts the number of
101 *2aaa word in the trailer of the payload and tries to figure out
102 *the correct number of 40 bit altro words in the RCU pauload
103 **/
104 Int_t countAAApaddings();
105
106 UInt_t *f32DtaPtr; // Pointer to dat of the input buffer in entities of 32 bit words (the RCU/DDL block)
107 UChar_t *f8DtaPtr; // Pointer to dat of the input buffer in entities of 8 bit words (the RCU/DDL block)
108 const Long_t fN32HeaderWords; // Number of 32 bit words in the common data header
109 Int_t fN40AltroWords; // Number of 40 bit altro words contained in the RCU payload as calculated form the payload size
110 Int_t fN40RcuAltroWords; // Number of 40 bit altro words contained in the RCU payload as given by the RCU trailer
111 Int_t fNDDLBlocks; // Number of DDL blocks in the payload (the last blocj might/ight not be 160 bits )
112 Int_t f32LastDDLBlockSize; // Size of the last DDL block
113 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
114 UInt_t f32PayloadSize; // The size of the payload in entities of 32 bit words (after subtraction of the RCU header and the RCU trailer words)
115 Long_t fOutBufferIndex; // current buffer position of the buffer for the decoded data (10 bit words represnted as int's)
116 UInt_t fSize; // The size of the input RCU/DDL payload in entities of bytes, inluding the RCU header and trailer
117 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
118 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)
119 Int_t fComplete; // Number of altro channels that is only partially read out (0x2aaa pattern missing in trailer)
120 Int_t fInComplete; // Number of altro channels that is read out properly
121 Bool_t fDecodeIfCorruptedTrailer; // Wether or not to try to decode the data if the RCU trailer is incorrect (will succseed in most cases)
122 Bool_t fIsDecoded; // Wether or not the buffer set last by the "SetMemory()" function has been decoded
123
124 ClassDef(AliAltroDecoder, 0) // class for decoding Altro payload
125};
126
127#endif