]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTDDLDecoder.h
Effective C++ & documentation, bug fix in Online display
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTDDLDecoder.h
1 #ifndef ALIHLTDDLDECODER_H
2 #define ALIHLTDDLDECODER_H
3
4 /**************************************************************************
5  * This file is property of and copyright by the Experimental Nuclear     *
6  * Physics Group, Dep. of Physics                                         *
7  * University of Oslo, Norway, 2007                                       *
8  *                                                                        *
9  * Authors: Ã˜ystein Djuvsland <oystein.djuvsland@gmail.com>               * 
10  *      &   Per Thomas Hille <perthi@fys.uio.no>                          *
11  * for the ALICE HLT Project.                                             *
12  * Contributors are mentioned in the code where appropriate.              *
13  * Please report bugs to perthi@fys.uio.no                                * 
14  *                                                                        *
15  * Permission to use, copy, modify and distribute this software and its   *
16  * documentation strictly for non-commercial purposes is hereby granted   *
17  * without fee, provided that the above copyright notice appears in all   *
18  * copies and that both the copyright notice and this permission notice   *
19  * appear in the supporting documentation. The authors make no claims     *
20  * about the suitability of this software for any purpose. It is          *
21  * provided "as is" without express or implied warranty.                  *
22  **************************************************************************/
23 #define DDL_32BLOCK_SIZE 5
24
25 #include "Rtypes.h"
26 #include <iostream>
27 #include "AliHLTPHOSConstants.h"
28
29 using  std::cout;
30 using  std::endl;
31 using namespace PhosHLTConst;
32
33
34 class AliHLTAltroData;
35
36
37 class AliHLTDDLDecoder
38 {
39  public:
40  
41   /*
42    *Default constructor
43    */
44   AliHLTDDLDecoder();
45
46   /*
47    *Default destructor
48    */
49   virtual ~AliHLTDDLDecoder();
50
51   /*
52    *Check wether or not there is consistency between the number of 40 bit altro words given by
53    *the RCU payload and the number of 40 bit words calculated from the size of the RCU payload.
54    */
55   bool CheckPayload();
56
57   /*
58    *Decode the RCU/DDL payload 
59    */
60   bool Decode();
61
62
63   bool NextChannel(AliHLTAltroData *altroDataPtr);
64
65   template<typename T> 
66   void  DumpData(T *array, int N, int nPerLine)
67   {
68     cout <<   "DumpData N=  " << N <<endl;
69     for(int i= 0; i< N; i++)
70       {
71         if((i%nPerLine == 0)  &&  (i != 0))
72           {
73             printf("\n");
74           }
75
76         cout << array[i]<< "\t";
77
78       }
79   }
80
81
82
83
84
85
86   void SetMemory(UChar_t  *dtaPtr, UInt_t size);
87   void PrintInfo(AliHLTAltroData &altrodata, int n = 0, int nPerLine = 4);
88
89   /*
90    *
91    */
92   float GetFailureRate();
93
94  private:
95   /*
96    *Decode one 160 bit DDL block into 16 x 16 bit integers (only least significant 10 bits are filled)
97    */
98   void DecodeDDLBlock();
99  
100   /*
101    *Decode one 160 bit DDL block into 16 integers, 
102    *if the las blaock does not align with 160 bits then first pad with zeroes 
103   */
104   void DecodeLastDDLBlock();
105
106   int countAAApaddings();
107
108   UInt_t  *f32DtaPtr;                     /**<Pointer to dat of the input buffer in entities of 32 bit words (the RCU/DDL block) */
109   UChar_t *f8DtaPtr;                      /**<Pointer to dat of the input buffer in entities of 8 bit words (the RCU/DDL block) */
110   const long int fN32HeaderWords;         /**<Number of 32 bit words in the common data header*/
111   const long int fN32RcuTrailerWords;     /**<Number of 32 bit words in the RCU trailer*/
112   int  fN40AltroWords;                    /**<Number of 40 bit altro words contained in the RCU payload as calculated form the payload size*/
113   int  fN40RcuAltroWords;                 /**<Number of 40 bit altro words contained in the RCU payload as given by the RCU trailer*/            
114   int fNDDLBlocks;                        /**<Number of DDL blocks in the payload (the last blocj might/ight not be 160 bits )*/
115   int  f32LastDDLBlockSize;               /**<Size of the last DDL block*/ 
116   UInt_t fDDLBlockDummy[DDL_BLOCK_SIZE];  /**<buffer to contain the las DDL block, if the block is not aligned with 160 bitm the remaining fileds are padded with zeroes*/
117   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)*/
118   long int fOutBufferIndex;               /**<current buffer position of the buffer for the decoded data (10 bit words represnted as int's)*/
119   UInt_t  fSize;                          /**<The size of the input RCU/DDL payload in entities of bytes, inluding the RCU header and trailer */  
120   UInt_t fOutBuffer[N_FEECS*N_BRANCHES*8*N_ALTROCHANNELS*(ALTRO_MAX_SAMPLES + ALTRO_MAX_TRALER_SIZE)];  /**<Buffer to hold the decoded data*/
121   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)*/
122   int fComplete;                          /**<Number of altro channels that is only partially read out  (0x2aaa pattern missing in trailer)*/
123   int fInComplete;                        /**<Number of altro channels that is read out properly*/       
124   bool fDecodeIfCorruptedTrailer;         /**<Wether or not to try to decode the data if the RCU trailer is incorrect (will succseed in most cases)*/ 
125   bool fIsDecoded;                        /**<Wether or not the buffer set last by the "SetMemory()" function has been decoded*/
126 };
127
128 #endif