1 #include "AliHLTDDLDecoder.h"
2 #include "AliHLTAltroData.h"
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 *
9 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
10 * Contributors are mentioned in the code where appropriate. *
11 * Please report bugs to perthi@fys.uio.no *
13 * Permission to use, copy, modify and distribute this software and its *
14 * documentation strictly for non-commercial purposes is hereby granted *
15 * without fee, provided that the above copyright notice appears in all *
16 * copies and that both the copyright notice and this permission notice *
17 * appear in the supporting documentation. The authors make no claims *
18 * about the suitability of this software for any purpose. It is *
19 * provided "as is" without express or implied warranty. *
20 **************************************************************************/
22 AliHLTDDLDecoder::AliHLTDDLDecoder() : f32DtaPtr(0), f8DtaPtr(0),fN32HeaderWords(8), fN32RcuTrailerWords(1), fNDDLBlocks(0),
23 fBufferPos(0), fN40AltroWords(0), fN40RcuAltroWords(0), fSize(0), fSegmentation(0),
24 f32LastDDLBlockSize(5), f32PayloadSize(0),fBufferIndex(0), fN10bitWords(0)
29 AliHLTDDLDecoder::~AliHLTDDLDecoder()
35 AliHLTDDLDecoder::CheckPayload()
37 if(fN40AltroWords != fN40RcuAltroWords)
51 AliHLTDDLDecoder::Decode()
56 if((CheckPayload() == true) && (fSize > 32) )
62 for(fI=0; fI < fNDDLBlocks; fI++)
74 cout <<"ERROR: data integrity check failed, discarding data" << endl;
75 cout << "Size of datablock is " << fSize << endl;
76 cout << "fN40AltroWords = " << fN40AltroWords << endl;
77 cout << "fN40RcuAltroWords = " << fN40RcuAltroWords << endl;
83 AliHLTDDLDecoder::NextChannel(AliHLTAltroData *altroDataPtr)
86 if(fBufferPos > fN32HeaderWords)
88 if((fBuffer[fBufferPos] << 4 ) | ((fBuffer[fBufferPos-1] & 0x3c0) >> 6) == 0x2aaa)
90 altroDataPtr->fIsComplete = true;
95 altroDataPtr->fIsComplete = false;
100 fNAltro10bitWords = ( (fBuffer[fBufferPos] & 0x3f) << 4 ) | ((fBuffer[fBufferPos -1] & (0xF << 6)) >> 6) ;
102 fHadd = ((fBuffer[fBufferPos] & 0x3)) << 10 | ( fBuffer[fBufferPos-1] );
105 if(fNAltro10bitWords%4 == 0)
107 fBufferPos = fBufferPos - fNAltro10bitWords;
111 fBufferPos = fBufferPos - fNAltro10bitWords -(4 - fNAltro10bitWords%4);
114 altroDataPtr->fData = &fBuffer[fBufferPos];
116 altroDataPtr->fDataSize = fNAltro10bitWords ;
117 altroDataPtr->fHadd = fHadd;
130 AliHLTDDLDecoder::GetFailureRate()
133 cout << "Number of Complete channles = " << fComplete <<endl;
134 cout << "Number of InComplete channles = " << fInComplete <<endl;
135 tmp = (100*(float)fInComplete)/((float)fComplete + (float)fInComplete);
136 cout <<"There are "<< tmp <<"% incomplete channels"<<endl;
142 AliHLTDDLDecoder::GetMarker(UInt_t *buffer, int index)
146 tmpMarker = (buffer[index] << 4 ) | ((buffer[index-1] & tmpMask) >> 6);
151 AliHLTDDLDecoder::PrintInfo(AliHLTAltroData &altrodata, int n, int nPerLine)
153 cout << "altrodata.fDataSize = " << altrodata.fDataSize << endl;
154 cout << "altrodata.fHadd = " << altrodata.fHadd <<endl;
155 for(int i= 0; i< n; i++)
157 if( (i%nPerLine == 0) && (i != 0) )
161 printf("%d\t", altrodata.fData[i]);
168 AliHLTDDLDecoder::SetMemory(UChar_t *dtaPtr, UInt_t size)
172 f32PayloadSize = fSize/4 - (fN32HeaderWords + fN32RcuTrailerWords);
173 fN40AltroWords = (32*f32PayloadSize)/40;
174 f32LastDDLBlockSize = f32PayloadSize%DDL_32BLOCK_SIZE;
175 fNDDLBlocks = f32PayloadSize/5;
176 f8DtaPtr =f8DtaPtr + fSize;
177 f32DtaPtr = (UInt_t *) f8DtaPtr;
178 f32DtaPtr = f32DtaPtr - fN32RcuTrailerWords;
179 fN40RcuAltroWords = *f32DtaPtr;
180 f32DtaPtr = (UInt_t *)dtaPtr + fN32HeaderWords;
181 fBufferPos = fN40AltroWords*4 - 1;
185 AliHLTDDLDecoder::DecodeDDLBlock()
187 fBuffer[fBufferIndex] = *f32DtaPtr & 0x3ff; //s0
189 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc00) >> 10; //s1
191 fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff00000) >> 20; //s2
193 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xc0000000) >> 30; //s3_1
195 fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0xff) << 2); //s3_2
197 fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff00) >> 8; //s4
199 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc0000) >> 18; //s5
201 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xf0000000) >> 28; //s6_1
203 fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0x3f) << 4); //s6_2
205 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc0) >> 6; //s7
207 fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff0000) >> 16; //s8
209 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xFC000000) >> 26; //s9_1
211 fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0xf) << 6); //s9_2
213 fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff0) >> 4; //s10
215 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc000) >> 14; //s11
217 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xff000000) >> 24; //s12_1
219 fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0x3) << 8); //s12_2
221 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc) >> 2; //s13
223 fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff000) >> 12; //s14
225 fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc00000) >> 22; //s15
226 fN10bitWords =fN10bitWords + 16 ;
233 AliHLTDDLDecoder::DecodeLastDDLBlock()
235 for(unsigned fI=0; fI < f32LastDDLBlockSize; fI++)
237 fDDLBlockDummy[fI] = *f32DtaPtr;
241 f32DtaPtr = fDDLBlockDummy;
247 AliHLTDDLDecoder::SetNTrailerWords(int n)
249 fN32RcuTrailerWords = n;