]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCMonitorAltro.cxx
- The default value of useFastDecoder in ctor changed to kFALSE,
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorAltro.cxx
CommitLineData
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 18Revision 1.2 2007/10/12 13:36:27 cvetan
19Coding convention fixes from Stefan
20
ca7b8371 21Revision 1.1 2007/09/17 10:23:31 cvetan
22New 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 45using namespace std;
ca7b8371 46ClassImp(AliTPCMonitorAltro)
48265b32 47
48//_____________________________________________________________________________________________
ca7b8371 49AliTPCMonitorAltro::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),
66 ffilename(new Char_t[256])
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//_____________________________________________________________________________________________
78AliTPCMonitorAltro::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),
96 ffilename(new Char_t[strlen(altro.ffilename)+1])
97{
98 // copy constructor
99 strcpy(ffilename,altro.ffilename);
100
101}
102
103//_____________________________________________________________________________________________
104AliTPCMonitorAltro &AliTPCMonitorAltro::operator =(const AliTPCMonitorAltro& altro)
105{
106 // assignement operator
107
108 if(this!=&altro){
109 ((TNamed *)this)->operator=(altro);
110 fverb=altro.fverb;
111 fmemory=altro.fmemory;
112 fsize=altro.fsize;
113 f40BitArray=altro.f40BitArray;
114 f10BitArray=altro.f10BitArray;
115 fdecoderPos=altro.fdecoderPos;
116 fallocate40BitArray=altro.fallocate40BitArray;
117 fallocate10BitArray=altro.fallocate10BitArray;
118 foffset=altro.foffset;
119 fwrite10bit=altro.fwrite10bit;
120 fTrailerNWords=altro.fTrailerNWords;
121 fTrailerHwAddress=altro.fTrailerHwAddress;
122 fTrailerDataPos=altro.fTrailerDataPos;
123 fTrailerBlockPos=altro.fTrailerBlockPos;
124 fTrailerPos=altro.fTrailerPos;
125 fNextPos=altro.fNextPos;
126 ffilename = new Char_t[strlen(altro.ffilename)+1];
127 strcpy(ffilename,altro.ffilename);
128 }
129 return *this;
130}
131
132
48265b32 133//_____________________________________________________________________________________________
134AliTPCMonitorAltro::~AliTPCMonitorAltro() {
135 // Destructor
136 if(fallocate40BitArray == true) delete[] f40BitArray;
137 if(fallocate10BitArray == true) delete[] f10BitArray;
138 delete[] ffilename;
139 }
140
141//_____________________________________________________________________________________________
142void AliTPCMonitorAltro::Allocate40BitArray()
143{
144 // create array for 40 bit decoded data
145 fallocate40BitArray = true;
146 f40BitArray = new long long[Get40BitArraySize()];
147}
148
149//_____________________________________________________________________________________________
150void AliTPCMonitorAltro::Allocate10BitArray()
151{
152 // Create array for 10 bit decoded data
153 fallocate10BitArray = true;
154 f10BitArray = new Short_t[Get10BitArraySize()];
fb3305d1 155}
48265b32 156
157//_____________________________________________________________________________________________
158long long *AliTPCMonitorAltro::Get40BitArray()
159{
160 // Return pointer to array for 40 bit decoded data
161 return f40BitArray;
162}
163
164//_____________________________________________________________________________________________
165Short_t *AliTPCMonitorAltro::Get10BitArray()
166{
167 // Return pointer to array for 10 bit decoded data
168 return f10BitArray;
169}
170
fb3305d1 171// //_____________________________________________________________________________________________
172// Int_t AliTPCMonitorAltro::Get40BitArraySize()
173// {
174// // Return number of 40 bit words in payload
175// return fmemory[fsize-1];
176// }
177
178// //_____________________________________________________________________________________________
179// Int_t AliTPCMonitorAltro::Get10BitArraySize()
180// {
181// // Return number of 10 bit words in payload
182// return fmemory[fsize-1]*4;
183// }
48265b32 184
185//_____________________________________________________________________________________________
186void AliTPCMonitorAltro::Decodeto40Bit()
187{
188 // Decode 32 bit words in fmemory to 40 bit words
189 Long64_t blackbox = 0;
190 Int_t rest;
191
192 for(Int_t i = 0; i < Get40BitArraySize(); i++)
193 {
194 rest = i%4;
195 switch(rest) {
196 case 0:
ca7b8371 197 blackbox = (fmemory[foffset]) + (((Long64_t)(fmemory[foffset+1]&fgk08BitOn))<<32);
48265b32 198 foffset +=1;
199 break;
200 case 1:
ca7b8371 201 blackbox = (fmemory[foffset]>>8 ) + (((Long64_t)(fmemory[foffset+1]&fgk16BitOn))<<24);
48265b32 202 foffset +=1;
203 break;
204 case 2:
ca7b8371 205 blackbox = (fmemory[foffset]>>16) + (((Long64_t)(fmemory[foffset+1]&fgk24BitOn))<<16);
48265b32 206 foffset +=1;
207 break;
208 case 3:
209 blackbox = (fmemory[foffset]>>24) + (((Long64_t)(fmemory[foffset+1] ))<< 8);
210 foffset +=2;
211 break;
212 default:
213 blackbox = 0;
214 break;
215 }
216 f40BitArray[i] = blackbox;
217 }
218}
219
220//_____________________________________________________________________________________________
221void AliTPCMonitorAltro::Decodeto10Bit(Int_t equipment)
222{
223 // Decode 32 bit words in fmemory to 10 bit words.
224 // Write words to file if fwrite10bit ("Write 10 bit" in Monitor.C Gui ) is set
225
226 Long64_t blackbox = 0;
227 Int_t rest = 0;
228
229 ofstream datout;
230 if(fwrite10bit)
231 {
232 Char_t nameout[256] ; sprintf(nameout,"%s_PayloadEquipmentId_%03i.txt",ffilename,equipment);
233 datout.open(nameout);
234 AliInfo(Form("AliTPCMonitorAltro::decodeto10Bit : Write Data to %s",nameout));
235 if(foffset==0) datout << "Payload without CDH in 10bit words " << endl;
236 else datout << "CDH in 32 bit hex words words (" << foffset << " lines ) followed by payload in 10 bit words " << endl;
237 for(Int_t ih = 0; ih< foffset ; ih++)
238 {
239 datout << hex << fmemory[ih] << endl;
240 }
241 }
242
243 for(Int_t ind = 0; ind < Get40BitArraySize(); ind++)
244 {
245 rest = ind%4;
246 switch(rest)
247 {
248 case 0:
ca7b8371 249 blackbox = (fmemory[foffset]) + (((Long64_t)(fmemory[foffset+1]&fgk08BitOn))<<32);
48265b32 250 foffset +=1;
251 break;
252 case 1:
ca7b8371 253 blackbox = (fmemory[foffset]>>8 ) + (((Long64_t)(fmemory[foffset+1]&fgk16BitOn))<<24);
48265b32 254 foffset +=1;
255 break;
256 case 2:
ca7b8371 257 blackbox = (fmemory[foffset]>>16) + (((Long64_t)(fmemory[foffset+1]&fgk24BitOn))<<16);
48265b32 258 foffset +=1;
259 break;
260 case 3:
261 blackbox = (fmemory[foffset]>>24) + (((Long64_t)(fmemory[foffset+1] ))<< 8);
262 foffset +=2;
263 break;
264 default:
265 blackbox = 0;
266 break;
267 }
ca7b8371 268 f10BitArray[ind*4+0] = (Short_t)( blackbox & fgkmask10 ) ;
269 f10BitArray[ind*4+1] = (Short_t)((blackbox & fgkmask20)>>10);
270 f10BitArray[ind*4+2] = (Short_t)((blackbox & fgkmask30)>>20);
271 f10BitArray[ind*4+3] = (Short_t)((blackbox & fgkmask40)>>30);
48265b32 272 }
273 if(fwrite10bit)
274 {
275 for(Int_t ind = 0; ind < Get40BitArraySize(); ind++)
276 {
277 datout << dec << f10BitArray[ind*4+0] << "\n";
278 datout << dec << f10BitArray[ind*4+1] << "\n";
279 datout << dec << f10BitArray[ind*4+2] << "\n";
280 datout << dec << f10BitArray[ind*4+3] << "\n";
281 }
282 }
283
284 if(fwrite10bit) datout.close();
285}
286
287//_____________________________________________________________________________________________
288Int_t AliTPCMonitorAltro::DecodeTrailer(Int_t pos)
289{
290 // Decode the trailer word starting at position pos in fmemory
291 // Check if information leads to proper next trailer position
292
293 fTrailerPos = pos;
294 if(pos<=4) return 0;
295
296 Long64_t words = 0;
297 Long64_t tail = 0;
298 Long64_t trailer = 0;
299 Long64_t carry = 0;
300 Long64_t rest = 0 ;
301
302 for(Long64_t iter = 0 ; iter<4;iter++)
303 {
304 carry = f10BitArray[pos-iter] ;
305 carry = ( carry << (30- ((iter)*10)));
306 trailer += carry ;
307 }
308
ca7b8371 309 fTrailerHwAddress = (trailer & ((Long64_t )fgkTrailerMaskHardw) );
310 words = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskNWords))>>16);
311 tail = (Long64_t )( (trailer & ((Long64_t )fgkTrailerMaskTail ))>>26 );
48265b32 312
313 if(words%4!=0) rest = 4-(words%4);
314 fTrailerNWords = words+rest ;
315 fTrailerDataPos = pos -4 -rest ;
316 fTrailerBlockPos = pos -4 ;
317 fNextPos = (pos -fTrailerNWords -4);
318
ca7b8371 319 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 320 else if( fNextPos==-1 ) { /* was last channel */ return 0; }
321 else if( fNextPos <0 ) { AliError("Next Trailer position < 0 "); return -1; }
322 else if((f10BitArray[fNextPos]!=682)) { AliError(Form("Could not find tail (2AA) at next supposed position %i",fNextPos)); return -1; }
323 else { return fNextPos;}
324
325}
326
327
328