]>
Commit | Line | Data |
---|---|---|
8d17cebb | 1 | #include "AliHLTDDLDecoder.h" |
2 | #include "AliHLTAltroData.h" | |
3 | ||
b60bd496 | 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 | * 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 * | |
12 | * * | |
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 | **************************************************************************/ | |
21 | ||
22 | AliHLTDDLDecoder::AliHLTDDLDecoder() : f32DtaPtr(0), f8DtaPtr(0),fN32HeaderWords(8), fN32RcuTrailerWords(1), fNDDLBlocks(0), | |
6f5d0920 | 23 | fBufferPos(0), fN40AltroWords(0), fN40RcuAltroWords(0), fSize(0), fSegmentation(0), |
0d7c9b63 | 24 | f32LastDDLBlockSize(5), f32PayloadSize(0),fBufferIndex(0), fN10bitWords(0), fBad(0),fGood(0) |
8d17cebb | 25 | { |
8d17cebb | 26 | |
6f5d0920 | 27 | } |
8d17cebb | 28 | |
92aff66b | 29 | |
8d17cebb | 30 | AliHLTDDLDecoder::~AliHLTDDLDecoder() |
31 | { | |
32 | ||
33 | } | |
34 | ||
8d17cebb | 35 | bool |
36 | AliHLTDDLDecoder::CheckPayload() | |
37 | { | |
8d17cebb | 38 | if(fN40AltroWords != fN40RcuAltroWords) |
39 | { | |
40 | return false; | |
8d17cebb | 41 | } |
42 | else | |
43 | { | |
44 | ||
45 | return true; | |
46 | ||
47 | } | |
8d17cebb | 48 | } |
49 | ||
92aff66b | 50 | |
8d17cebb | 51 | bool |
52 | AliHLTDDLDecoder::Decode() | |
53 | { | |
92aff66b | 54 | // int naaa; |
55 | fComplete = 0; | |
56 | fInComplete = 0; | |
137c6c26 | 57 | |
8d17cebb | 58 | if((CheckPayload() == true) && (fSize > 32) ) |
59 | { | |
60 | fDDLBlockCnt = 0; | |
8d17cebb | 61 | fBufferIndex = 0; |
62 | fN10bitWords = 0; | |
6f5d0920 | 63 | |
92aff66b | 64 | // for(fI=0; fI < fNDDLBlocks; fI++) |
d2b84453 | 65 | for(int i = 0; i < fNDDLBlocks; i++) |
8d17cebb | 66 | { |
67 | DecodeDDLBlock(); | |
68 | } | |
69 | ||
0d7c9b63 | 70 | |
8d17cebb | 71 | DecodeLastDDLBlock(); |
0d7c9b63 | 72 | fGood ++; |
73 | ||
74 | /* | |
75 | printf("\n"); | |
76 | DumpData(fBuffer, 1000, 4); | |
77 | printf("\n"); | |
78 | */ | |
79 | ||
80 | return true; | |
6f5d0920 | 81 | } |
8d17cebb | 82 | |
6f5d0920 | 83 | else |
84 | { | |
0d7c9b63 | 85 | cout <<"WARNING: data integrity check failed, discarding data" << endl; |
6f5d0920 | 86 | cout << "Size of datablock is " << fSize << endl; |
87 | cout << "fN40AltroWords = " << fN40AltroWords << endl; | |
88 | cout << "fN40RcuAltroWords = " << fN40RcuAltroWords << endl; | |
0d7c9b63 | 89 | fBad ++; |
90 | float badPercent = (100*(float)fBad)/((float)fBad + (float)fGood); | |
91 | ||
92 | cout << "there are" << badPercent <<" % corrupted DDL corrupted blocks" << endl; | |
93 | ||
94 | fDDLBlockCnt = 0; | |
95 | fBufferIndex = 0; | |
96 | fN10bitWords = 0; | |
97 | ||
98 | // for(fI=0; fI < fNDDLBlocks; fI++) | |
99 | for(int i = 0; i < fNDDLBlocks; i++) | |
100 | { | |
101 | DecodeDDLBlock(); | |
102 | } | |
103 | ||
104 | ||
105 | DecodeLastDDLBlock(); | |
106 | ||
107 | /* | |
108 | printf("\n"); | |
109 | DumpData(fBuffer, 1000, 4); | |
110 | printf("\n"); | |
111 | */ | |
112 | ||
113 | return true; | |
114 | ||
115 | // return false; | |
8d17cebb | 116 | } |
8d17cebb | 117 | } |
118 | ||
8d17cebb | 119 | bool |
120 | AliHLTDDLDecoder::NextChannel(AliHLTAltroData *altroDataPtr) | |
121 | { | |
137c6c26 | 122 | |
8d17cebb | 123 | if(fBufferPos > fN32HeaderWords) |
124 | { | |
6e709a0d | 125 | if((fBuffer[fBufferPos] << 4 ) | ((fBuffer[fBufferPos-1] & 0x3c0) >> 6) == 0x2aaa) |
126 | { | |
127 | altroDataPtr->fIsComplete = true; | |
0d7c9b63 | 128 | // printf("\nAliHLTDDLDecoder::NextChannel data is complete 0x2aaa endmarker present\n"); |
6e709a0d | 129 | fComplete ++; |
130 | } | |
131 | else | |
132 | { | |
0d7c9b63 | 133 | // printf("\nAliHLTDDLDecoder::NextChannel ERROR, data is incomplete 0x2aaa endmarker missing\n"); |
6e709a0d | 134 | altroDataPtr->fIsComplete = false; |
135 | fInComplete ++; | |
6e709a0d | 136 | } |
137 | ||
8d17cebb | 138 | fBufferPos --; |
139 | fNAltro10bitWords = ( (fBuffer[fBufferPos] & 0x3f) << 4 ) | ((fBuffer[fBufferPos -1] & (0xF << 6)) >> 6) ; | |
140 | fBufferPos --; | |
141 | fHadd = ((fBuffer[fBufferPos] & 0x3)) << 10 | ( fBuffer[fBufferPos-1] ); | |
142 | fBufferPos --; | |
143 | ||
144 | if(fNAltro10bitWords%4 == 0) | |
145 | { | |
146 | fBufferPos = fBufferPos - fNAltro10bitWords; | |
147 | } | |
148 | else | |
149 | { | |
150 | fBufferPos = fBufferPos - fNAltro10bitWords -(4 - fNAltro10bitWords%4); | |
151 | } | |
152 | ||
153 | altroDataPtr->fData = &fBuffer[fBufferPos]; | |
154 | fBufferPos --; | |
8d17cebb | 155 | altroDataPtr->fDataSize = fNAltro10bitWords ; |
156 | altroDataPtr->fHadd = fHadd; | |
137c6c26 | 157 | |
b60bd496 | 158 | |
8d17cebb | 159 | return true; |
8d17cebb | 160 | } |
8d17cebb | 161 | else |
162 | { | |
163 | return false; | |
164 | } | |
165 | } | |
166 | ||
137c6c26 | 167 | |
92aff66b | 168 | int |
169 | AliHLTDDLDecoder::countAAApaddings() | |
170 | { | |
171 | ||
172 | ||
173 | } | |
174 | ||
175 | ||
137c6c26 | 176 | float |
177 | AliHLTDDLDecoder::GetFailureRate() | |
178 | { | |
179 | float tmp = 0; | |
180 | cout << "Number of Complete channles = " << fComplete <<endl; | |
181 | cout << "Number of InComplete channles = " << fInComplete <<endl; | |
f094c951 | 182 | tmp = (100*(float)fInComplete)/((float)fComplete + (float)fInComplete); |
137c6c26 | 183 | cout <<"There are "<< tmp <<"% incomplete channels"<<endl; |
137c6c26 | 184 | return tmp; |
185 | } | |
186 | ||
b60bd496 | 187 | |
8d17cebb | 188 | int |
189 | AliHLTDDLDecoder::GetMarker(UInt_t *buffer, int index) | |
190 | { | |
191 | int tmpMarker = 0; | |
192 | int tmpMask = 0x3c0; | |
8d17cebb | 193 | tmpMarker = (buffer[index] << 4 ) | ((buffer[index-1] & tmpMask) >> 6); |
8d17cebb | 194 | return tmpMarker; |
8d17cebb | 195 | } |
196 | ||
197 | void | |
198 | AliHLTDDLDecoder::PrintInfo(AliHLTAltroData &altrodata, int n, int nPerLine) | |
199 | { | |
200 | cout << "altrodata.fDataSize = " << altrodata.fDataSize << endl; | |
201 | cout << "altrodata.fHadd = " << altrodata.fHadd <<endl; | |
202 | for(int i= 0; i< n; i++) | |
203 | { | |
204 | if( (i%nPerLine == 0) && (i != 0) ) | |
205 | { | |
206 | printf("\n"); | |
207 | } | |
8d17cebb | 208 | printf("%d\t", altrodata.fData[i]); |
8d17cebb | 209 | } |
8d17cebb | 210 | printf("\n"); |
211 | } | |
212 | ||
b60bd496 | 213 | |
6f5d0920 | 214 | void |
8d17cebb | 215 | AliHLTDDLDecoder::SetMemory(UChar_t *dtaPtr, UInt_t size) |
216 | { | |
217 | f8DtaPtr =dtaPtr; | |
218 | fSize = size; | |
219 | f32PayloadSize = fSize/4 - (fN32HeaderWords + fN32RcuTrailerWords); | |
220 | fN40AltroWords = (32*f32PayloadSize)/40; | |
0d7c9b63 | 221 | |
222 | // cout << "AliHLTDDLDecoder::SetMemory f32PayloadSize =" << f32PayloadSize <<endl; | |
223 | // cout << "AliHLTDDLDecoder::SetMemory 32*f32PayloadSize =" << 32*f32PayloadSize <<endl; | |
224 | // cout << "AliHLTDDLDecoder::SetMemory (32*f32PayloadSize)/40 =" << (32*f32PayloadSize)/40 <<endl; | |
225 | ||
8d17cebb | 226 | f32LastDDLBlockSize = f32PayloadSize%DDL_32BLOCK_SIZE; |
8d17cebb | 227 | fNDDLBlocks = f32PayloadSize/5; |
8d17cebb | 228 | f8DtaPtr =f8DtaPtr + fSize; |
229 | f32DtaPtr = (UInt_t *) f8DtaPtr; | |
230 | f32DtaPtr = f32DtaPtr - fN32RcuTrailerWords; | |
231 | fN40RcuAltroWords = *f32DtaPtr; | |
8d17cebb | 232 | f32DtaPtr = (UInt_t *)dtaPtr + fN32HeaderWords; |
6f5d0920 | 233 | fBufferPos = fN40AltroWords*4 - 1; |
92aff66b | 234 | |
d2b84453 | 235 | // UShort_t *tmpBufferPos = fBufferPos; |
236 | ||
237 | // tmpBufferPos = tmpBufferPos - 2*fN32RcuTrailerWords; | |
92aff66b | 238 | |
239 | for(int i=0; i<4; i++) | |
240 | { | |
d2b84453 | 241 | // printf("\nAliHLTDDLDecoder::SetMemory i= %d, content = 0x%x\n", i, *tmpBufferPos); |
92aff66b | 242 | } |
8d17cebb | 243 | } |
244 | ||
6f5d0920 | 245 | void |
8d17cebb | 246 | AliHLTDDLDecoder::DecodeDDLBlock() |
247 | { | |
248 | fBuffer[fBufferIndex] = *f32DtaPtr & 0x3ff; //s0 | |
249 | fBufferIndex ++; | |
250 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc00) >> 10; //s1 | |
251 | fBufferIndex ++; | |
252 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff00000) >> 20; //s2 | |
253 | fBufferIndex ++; | |
254 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xc0000000) >> 30; //s3_1 | |
255 | f32DtaPtr ++; | |
256 | fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0xff) << 2); //s3_2 | |
257 | fBufferIndex ++; | |
258 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff00) >> 8; //s4 | |
259 | fBufferIndex ++; | |
260 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc0000) >> 18; //s5 | |
261 | fBufferIndex ++; | |
262 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xf0000000) >> 28; //s6_1 | |
263 | f32DtaPtr ++; | |
264 | fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0x3f) << 4); //s6_2 | |
265 | fBufferIndex ++; | |
266 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc0) >> 6; //s7 | |
267 | fBufferIndex ++; | |
268 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff0000) >> 16; //s8 | |
269 | fBufferIndex ++; | |
270 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xFC000000) >> 26; //s9_1 | |
271 | f32DtaPtr ++; | |
272 | fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0xf) << 6); //s9_2 | |
273 | fBufferIndex ++; | |
274 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff0) >> 4; //s10 | |
275 | fBufferIndex ++; | |
276 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc000) >> 14; //s11 | |
277 | fBufferIndex ++; | |
278 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xff000000) >> 24; //s12_1 | |
279 | f32DtaPtr ++; | |
280 | fBuffer[fBufferIndex] = fBuffer[fBufferIndex] | ((*f32DtaPtr & 0x3) << 8); //s12_2 | |
281 | fBufferIndex ++; | |
282 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc) >> 2; //s13 | |
283 | fBufferIndex ++; | |
284 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0x3ff000) >> 12; //s14 | |
285 | fBufferIndex ++; | |
286 | fBuffer[fBufferIndex] = (*f32DtaPtr & 0xffc00000) >> 22; //s15 | |
287 | fN10bitWords =fN10bitWords + 16 ; | |
288 | f32DtaPtr ++; | |
289 | fBufferIndex ++; | |
290 | fDDLBlockCnt ++; | |
291 | } | |
292 | ||
6f5d0920 | 293 | void |
8d17cebb | 294 | AliHLTDDLDecoder::DecodeLastDDLBlock() |
295 | { | |
6f5d0920 | 296 | for(unsigned fI=0; fI < f32LastDDLBlockSize; fI++) |
8d17cebb | 297 | { |
6f5d0920 | 298 | fDDLBlockDummy[fI] = *f32DtaPtr; |
8d17cebb | 299 | f32DtaPtr ++; |
300 | } | |
301 | ||
302 | f32DtaPtr = fDDLBlockDummy; | |
303 | f32DtaPtr ++; | |
304 | DecodeDDLBlock(); | |
305 | } | |
306 | ||
0d7c9b63 | 307 | /* |
8d17cebb | 308 | void |
309 | AliHLTDDLDecoder::SetNTrailerWords(int n) | |
310 | { | |
311 | fN32RcuTrailerWords = n; | |
312 | } | |
0d7c9b63 | 313 | */ |
8d17cebb | 314 |