]>
Commit | Line | Data |
---|---|---|
48265b32 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
fb3305d1 | 18 | Revision 1.2 2007/10/12 13:36:27 cvetan |
19 | Coding convention fixes from Stefan | |
20 | ||
ca7b8371 | 21 | Revision 1.1 2007/09/17 10:23:31 cvetan |
22 | New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder. | |
23 | ||
48265b32 | 24 | */ |
25 | ||
ca7b8371 | 26 | //////////////////////////////////////////////////////////////////////// |
27 | //// | |
28 | //// AliTPCMonitorAltro class | |
29 | //// | |
30 | //// Class for decoding raw TPC data in the ALTRO format. | |
31 | //// Data are transformed from 32 bit words to 10 bit or 40 bit respectively. | |
32 | //// The whole payload is transformed at once and written to an array. | |
33 | //// The single channels are decoded starting from the trailer word which is | |
34 | //// decoded by DecodeTrailer(Int_t pos) | |
35 | //// | |
36 | //// Authors: Roland Bramm, | |
37 | //// Stefan Kniege, IKF, Frankfurt | |
38 | //// | |
39 | ///////////////////////////////////////////////////////////////////////// | |
40 | ||
48265b32 | 41 | |
42 | #include "AliTPCMonitorAltro.h" | |
ca7b8371 | 43 | #include "AliLog.h" |
44 | #include <Riostream.h> | |
fb3305d1 | 45 | using namespace std; |
ca7b8371 | 46 | ClassImp(AliTPCMonitorAltro) |
48265b32 | 47 | |
48 | //_____________________________________________________________________________________________ | |
ca7b8371 | 49 | AliTPCMonitorAltro::AliTPCMonitorAltro(UInt_t* memory, Int_t size, Int_t fformat) : |
50 | fverb(0), | |
51 | fmemory(memory), | |
52 | fsize(size), | |
53 | f40BitArray(0), | |
54 | f10BitArray(0), | |
55 | fdecoderPos(0), | |
56 | fallocate40BitArray(false), | |
57 | fallocate10BitArray(false), | |
58 | foffset(0), | |
59 | fwrite10bit(0), | |
60 | fTrailerNWords(0), | |
61 | fTrailerHwAddress(0), | |
62 | fTrailerDataPos(0), | |
63 | fTrailerBlockPos(0), | |
64 | fTrailerPos(0), | |
65 | fNextPos(0), | |
c60053f6 | 66 | ffilename() |
48265b32 | 67 | { |
ca7b8371 | 68 | // Constructor: Set different CDH offsets for ROOT (0) and date format |
69 | // Data offset can be changed via SetDataOffset(Int_t val) | |
70 | ||
48265b32 | 71 | if( fformat==0) foffset=7; // old CHD Format |
ca7b8371 | 72 | else if(fformat==1) foffset=8; // memory pointer from DATE (start CDH) |
73 | else if(fformat==2) foffset=0; // memory pointer from ROOT (after CDH) | |
48265b32 | 74 | } |
75 | ||
ca7b8371 | 76 | |
77 | //_____________________________________________________________________________________________ | |
78 | AliTPCMonitorAltro::AliTPCMonitorAltro(const AliTPCMonitorAltro &altro) : | |
79 | TNamed(altro), | |
80 | fverb(altro.fverb), | |
81 | fmemory(altro.fmemory), | |
82 | fsize(altro.fsize), | |
83 | f40BitArray(altro.f40BitArray), | |
84 | f10BitArray(altro.f10BitArray), | |
85 | fdecoderPos(altro.fdecoderPos), | |
86 | fallocate40BitArray(altro.fallocate40BitArray), | |
87 | fallocate10BitArray(altro.fallocate10BitArray), | |
88 | foffset(altro.foffset), | |
89 | fwrite10bit(altro.fwrite10bit), | |
90 | fTrailerNWords(altro.fTrailerNWords), | |
91 | fTrailerHwAddress(altro.fTrailerHwAddress), | |
92 | fTrailerDataPos(altro.fTrailerDataPos), | |
93 | fTrailerBlockPos(altro.fTrailerBlockPos), | |
94 | fTrailerPos(altro.fTrailerPos), | |
95 | fNextPos(altro.fNextPos), | |
c60053f6 | 96 | ffilename(altro.ffilename) |
ca7b8371 | 97 | { |
98 | // copy constructor | |
ca7b8371 | 99 | |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________________________ | |
103 | AliTPCMonitorAltro &AliTPCMonitorAltro::operator =(const AliTPCMonitorAltro& altro) | |
104 | { | |
105 | // assignement operator | |
106 | ||
107 | if(this!=&altro){ | |
108 | ((TNamed *)this)->operator=(altro); | |
109 | fverb=altro.fverb; | |
110 | fmemory=altro.fmemory; | |
111 | fsize=altro.fsize; | |
112 | f40BitArray=altro.f40BitArray; | |
113 | f10BitArray=altro.f10BitArray; | |
114 | fdecoderPos=altro.fdecoderPos; | |
115 | fallocate40BitArray=altro.fallocate40BitArray; | |
116 | fallocate10BitArray=altro.fallocate10BitArray; | |
117 | foffset=altro.foffset; | |
118 | fwrite10bit=altro.fwrite10bit; | |
119 | fTrailerNWords=altro.fTrailerNWords; | |
120 | fTrailerHwAddress=altro.fTrailerHwAddress; | |
121 | fTrailerDataPos=altro.fTrailerDataPos; | |
122 | fTrailerBlockPos=altro.fTrailerBlockPos; | |
123 | fTrailerPos=altro.fTrailerPos; | |
124 | fNextPos=altro.fNextPos; | |
c60053f6 | 125 | ffilename = altro.ffilename; |
ca7b8371 | 126 | } |
127 | return *this; | |
128 | } | |
129 | ||
130 | ||
48265b32 | 131 | //_____________________________________________________________________________________________ |
132 | AliTPCMonitorAltro::~AliTPCMonitorAltro() { | |
133 | // Destructor | |
134 | if(fallocate40BitArray == true) delete[] f40BitArray; | |
135 | if(fallocate10BitArray == true) delete[] f10BitArray; | |
48265b32 | 136 | } |
137 | ||
138 | //_____________________________________________________________________________________________ | |
139 | void AliTPCMonitorAltro::Allocate40BitArray() | |
140 | { | |
141 | // create array for 40 bit decoded data | |
142 | fallocate40BitArray = true; | |
143 | f40BitArray = new long long[Get40BitArraySize()]; | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________________________ | |
147 | void AliTPCMonitorAltro::Allocate10BitArray() | |
148 | { | |
149 | // Create array for 10 bit decoded data | |
150 | fallocate10BitArray = true; | |
151 | f10BitArray = new Short_t[Get10BitArraySize()]; | |
fb3305d1 | 152 | } |
48265b32 | 153 | |
154 | //_____________________________________________________________________________________________ | |
155 | long long *AliTPCMonitorAltro::Get40BitArray() | |
156 | { | |
157 | // Return pointer to array for 40 bit decoded data | |
158 | return f40BitArray; | |
159 | } | |
160 | ||
161 | //_____________________________________________________________________________________________ | |
162 | Short_t *AliTPCMonitorAltro::Get10BitArray() | |
163 | { | |
164 | // Return pointer to array for 10 bit decoded data | |
165 | return f10BitArray; | |
166 | } | |
167 | ||
fb3305d1 | 168 | // //_____________________________________________________________________________________________ |
169 | // Int_t AliTPCMonitorAltro::Get40BitArraySize() | |
170 | // { | |
171 | // // Return number of 40 bit words in payload | |
172 | // return fmemory[fsize-1]; | |
173 | // } | |
174 | ||
175 | // //_____________________________________________________________________________________________ | |
176 | // Int_t AliTPCMonitorAltro::Get10BitArraySize() | |
177 | // { | |
178 | // // Return number of 10 bit words in payload | |
179 | // return fmemory[fsize-1]*4; | |
180 | // } | |
48265b32 | 181 | |
182 | //_____________________________________________________________________________________________ | |
183 | void AliTPCMonitorAltro::Decodeto40Bit() | |
184 | { | |
185 | // Decode 32 bit words in fmemory to 40 bit words | |
186 | Long64_t blackbox = 0; | |
187 | Int_t rest; | |
188 | ||
189 | for(Int_t i = 0; i < Get40BitArraySize(); i++) | |
190 | { | |
191 | rest = i%4; | |
192 | switch(rest) { | |
193 | case 0: | |
ca7b8371 | 194 | blackbox = (fmemory[foffset]) + (((Long64_t)(fmemory[foffset+1]&fgk08BitOn))<<32); |
48265b32 | 195 | foffset +=1; |
196 | break; | |
197 | case 1: | |
ca7b8371 | 198 | blackbox = (fmemory[foffset]>>8 ) + (((Long64_t)(fmemory[foffset+1]&fgk16BitOn))<<24); |
48265b32 | 199 | foffset +=1; |
200 | break; | |
201 | case 2: | |
ca7b8371 | 202 | blackbox = (fmemory[foffset]>>16) + (((Long64_t)(fmemory[foffset+1]&fgk24BitOn))<<16); |
48265b32 | 203 | foffset +=1; |
204 | break; | |
205 | case 3: | |
206 | blackbox = (fmemory[foffset]>>24) + (((Long64_t)(fmemory[foffset+1] ))<< 8); | |
207 | foffset +=2; | |
208 | break; | |
209 | default: | |
210 | blackbox = 0; | |
211 | break; | |
212 | } | |
213 | f40BitArray[i] = blackbox; | |
214 | } | |
215 | } | |
216 | ||
217 | //_____________________________________________________________________________________________ | |
218 | void AliTPCMonitorAltro::Decodeto10Bit(Int_t equipment) | |
219 | { | |
220 | // Decode 32 bit words in fmemory to 10 bit words. | |
221 | // Write words to file if fwrite10bit ("Write 10 bit" in Monitor.C Gui ) is set | |
222 | ||
223 | Long64_t blackbox = 0; | |
224 | Int_t rest = 0; | |
225 | ||
226 | ofstream datout; | |
227 | if(fwrite10bit) | |
5312f439 | 228 | { |
c60053f6 | 229 | TString nameout=Form("%s_PayloadEquipmentId_%03i.txt",ffilename.Data(),equipment); |
230 | datout.open(nameout.Data()); | |
231 | AliInfo(Form("AliTPCMonitorAltro::decodeto10Bit : Write Data to %s",nameout.Data())); | |
5312f439 | 232 | if(foffset==0) datout << "Payload without CDH in 10bit words " << endl; |
233 | else datout << "CDH in 32 bit hex words words (" << foffset << " lines ) followed by payload in 10 bit words " << endl; | |
234 | for(Int_t ih = 0; ih< foffset ; ih++) | |
48265b32 | 235 | { |
5312f439 | 236 | datout << hex << fmemory[ih] << endl; |
48265b32 | 237 | } |
5312f439 | 238 | } |
48265b32 | 239 | |
5312f439 | 240 | for(Int_t ind = 0; ind < Get40BitArraySize(); ind++) |
241 | { | |
242 | rest = ind%4; | |
243 | switch(rest) | |
48265b32 | 244 | { |
5312f439 | 245 | case 0: |
246 | blackbox = (fmemory[foffset]) + (((Long64_t)(fmemory[foffset+1]&fgk08BitOn))<<32); | |
247 | foffset +=1; | |
248 | break; | |
249 | case 1: | |
250 | blackbox = (fmemory[foffset]>>8 ) + (((Long64_t)(fmemory[foffset+1]&fgk16BitOn))<<24); | |
251 | foffset +=1; | |
252 | break; | |
253 | case 2: | |
254 | blackbox = (fmemory[foffset]>>16) + (((Long64_t)(fmemory[foffset+1]&fgk24BitOn))<<16); | |
255 | foffset +=1; | |
256 | break; | |
257 | case 3: | |
258 | blackbox = (fmemory[foffset]>>24) + (((Long64_t)(fmemory[foffset+1] ))<< 8); | |
259 | foffset +=2; | |
260 | break; | |
261 | default: | |
262 | blackbox = 0; | |
263 | break; | |
48265b32 | 264 | } |
5312f439 | 265 | f10BitArray[ind*4+0] = (Short_t)( blackbox & fgkmask10 ) ; |
266 | f10BitArray[ind*4+1] = (Short_t)((blackbox & fgkmask20)>>10); | |
267 | f10BitArray[ind*4+2] = (Short_t)((blackbox & fgkmask30)>>20); | |
268 | f10BitArray[ind*4+3] = (Short_t)((blackbox & fgkmask40)>>30); | |
269 | } | |
48265b32 | 270 | if(fwrite10bit) |
5312f439 | 271 | { |
272 | for(Int_t ind = 0; ind < Get40BitArraySize(); ind++) | |
48265b32 | 273 | { |
5312f439 | 274 | datout << dec << f10BitArray[ind*4+0] << "\n"; |
275 | datout << dec << f10BitArray[ind*4+1] << "\n"; | |
276 | datout << dec << f10BitArray[ind*4+2] << "\n"; | |
277 | datout << dec << f10BitArray[ind*4+3] << "\n"; | |
48265b32 | 278 | } |
5312f439 | 279 | } |
48265b32 | 280 | |
281 | if(fwrite10bit) datout.close(); | |
282 | } | |
283 | ||
284 | //_____________________________________________________________________________________________ | |
285 | Int_t AliTPCMonitorAltro::DecodeTrailer(Int_t pos) | |
286 | { | |
287 | // Decode the trailer word starting at position pos in fmemory | |
288 | // Check if information leads to proper next trailer position | |
5312f439 | 289 | if (GetAltroVersion()==0xaabb) return DecodeTrailerVbb(pos); |
48265b32 | 290 | fTrailerPos = pos; |
291 | if(pos<=4) return 0; | |
292 | ||
293 | Long64_t words = 0; | |
294 | Long64_t tail = 0; | |
295 | Long64_t trailer = 0; | |
296 | Long64_t carry = 0; | |
297 | Long64_t rest = 0 ; | |
298 | ||
299 | for(Long64_t iter = 0 ; iter<4;iter++) | |
300 | { | |
301 | carry = f10BitArray[pos-iter] ; | |
302 | carry = ( carry << (30- ((iter)*10))); | |
303 | trailer += carry ; | |
304 | } | |
305 | ||
ca7b8371 | 306 | fTrailerHwAddress = (trailer & ((Long64_t )fgkTrailerMaskHardw) ); |
307 | words = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskNWords))>>16); | |
308 | tail = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskTail ))>>26 ); | |
48265b32 | 309 | |
310 | if(words%4!=0) rest = 4-(words%4); | |
311 | fTrailerNWords = words+rest ; | |
312 | fTrailerDataPos = pos -4 -rest ; | |
313 | fTrailerBlockPos = pos -4 ; | |
314 | fNextPos = (pos -fTrailerNWords -4); | |
315 | ||
ca7b8371 | 316 | if( tail!=fgkTrailerTail ) { AliError(Form("Could not read Trailer. \"Write 10bit\" for this event. Last Trailer line (2AA): %i. Supp.next Trailer line (2AA): %i ",pos,fNextPos)); return -1; } |
48265b32 | 317 | else if( fNextPos==-1 ) { /* was last channel */ return 0; } |
318 | else if( fNextPos <0 ) { AliError("Next Trailer position < 0 "); return -1; } | |
319 | else if((f10BitArray[fNextPos]!=682)) { AliError(Form("Could not find tail (2AA) at next supposed position %i",fNextPos)); return -1; } | |
320 | else { return fNextPos;} | |
321 | ||
322 | } | |
323 | ||
5312f439 | 324 | //_____________________________________________________________________________________________ |
325 | Int_t AliTPCMonitorAltro::DecodeTrailerVbb(Int_t pos) | |
326 | { | |
327 | // Decode the trailer word starting at position pos in fmemory | |
328 | // Check if information leads to proper next trailer position | |
329 | fTrailerPos = pos; | |
330 | if(pos>Get10BitArraySize()-4) return 0; | |
331 | ||
332 | Long64_t words = 0; | |
333 | Long64_t tail = 0; | |
334 | Long64_t trailer = 0; | |
335 | Long64_t carry = 0; | |
336 | Long64_t rest = 0 ; | |
337 | ||
338 | for(Long64_t iter = 0 ; iter<4;iter++) | |
339 | { | |
340 | carry = f10BitArray[pos-iter] ; | |
341 | carry = ( carry << (30- ((iter)*10))); | |
342 | trailer += carry ; | |
343 | } | |
344 | ||
345 | fTrailerHwAddress = (trailer & ((Long64_t )fgkTrailerMaskHardw) ); | |
346 | words = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskNWords))>>16); | |
347 | tail = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskTail ))>>26 ); | |
348 | ||
349 | //Decide on read direction (sign) from the RCU trailer information | |
350 | Int_t sign=-1; | |
351 | if (GetAltroVersion()==0xaabb) sign=1; | |
352 | ||
353 | if(words%4!=0) rest = 4-(words%4); | |
354 | fTrailerNWords = words+rest ; | |
355 | fTrailerDataPos = pos +sign*(4+rest) ; | |
356 | fTrailerBlockPos = pos +sign*4 ; | |
357 | fNextPos = (pos +sign*(fTrailerNWords+4)); | |
358 | ||
359 | if( tail==fgkTrailerTailErr ) { | |
7d85e147 | 360 | AliError(Form("Found Altro header with error marker (2AEE)[%0llx]: %i. Supp.next Trailer line (2AA)[%0x]: %i ", |
5312f439 | 361 | tail,pos,f10BitArray[fNextPos],fNextPos)); |
362 | return -fNextPos; | |
363 | } else if ( tail!=fgkTrailerTail ) { | |
7d85e147 | 364 | AliError(Form("Could not read Trailer. \"Write 10bit\" for this event. Last Trailer line (2AA)[%0llx]: %i. Supp.next Trailer line (2AA)[%0x]: %i ", |
5312f439 | 365 | tail,pos,f10BitArray[fNextPos],fNextPos)); return -1; |
366 | } else if( fNextPos==Get10BitArraySize()+3 ) { /* was last channel */ | |
367 | return 0; | |
368 | } else if( fNextPos >=Get10BitArraySize() ) { | |
369 | AliError(Form("Next Trailer position < 0 %i", fNextPos)); | |
370 | return -1; | |
371 | } else if((f10BitArray[fNextPos]!=682)&&(f10BitArray[fNextPos]!=686)) { | |
372 | AliError(Form("Could not find tail (2AA) at next supposed position %i",fNextPos)); | |
373 | return -1; | |
374 | } else { | |
375 | return fNextPos; | |
376 | } | |
377 | ||
378 | } | |
48265b32 | 379 | |
380 |