]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDRawStreamV2.cxx
Use debug stream only if requested
[u/mrichter/AliRoot.git] / TRD / AliTRDRawStreamV2.cxx
CommitLineData
ecf39416 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// This class provides access to TRD digits in raw data. //
21// //
22// It loops over all TRD digits in the raw data given by the AliRawReader. //
23// The Next method goes to the next digit. If there are no digits left //
24// it returns kFALSE. //
25// Several getters provide information about the current digit. //
26// //
27// Author: C. Lippmann (C.Lippmann@gsi.de) //
28// //
29///////////////////////////////////////////////////////////////////////////////
30
31#include "AliLog.h"
32#include "AliRawReader.h"
0c349049 33
ecf39416 34#include "AliTRDRawStreamV2.h"
35#include "AliTRDgeometry.h"
36#include "AliTRDcalibDB.h"
37#include "AliTRDfeeParam.h"
ecf39416 38#include "AliTRDdigitsManager.h"
39#include "AliTRDdataArrayI.h"
625f5260 40#include "AliTRDdataArrayS.h"
ecf39416 41#include "AliTRDSignalIndex.h"
42
ecf39416 43ClassImp(AliTRDRawStreamV2)
44
45//_____________________________________________________________________________
46AliTRDRawStreamV2::AliTRDRawStreamV2()
dfbb4bb9 47 :AliTRDrawStreamBase()
48// :TObject()
0c349049 49 ,fGeo(NULL)
ecf39416 50 ,fSig()
51 ,fADC(0)
52 ,fTB(0)
53 ,fEv(0)
54 ,fROB(0)
55 ,fMCM(0)
56 ,fSM(0)
57 ,fLAYER(0)
58 ,fSTACK(0)
59 ,fROC(0)
60 ,fSIDE(0)
61 ,fDCS(0)
62 ,fROW(0)
63 ,fCOL(0)
64 ,fDET(0)
65 ,fLastDET(-1)
66 ,fBCctr(0)
67 ,fPTctr(0)
68 ,fPTphase(0)
69 ,fRVmajor(0)
70 ,fRVminor(0)
71 ,fHCHWords(0)
72 ,fTBins(0)
73 ,fTCon(0)
74 ,fPEDon(0)
75 ,fGAINon(0)
76 ,fXTon(0)
77 ,fNonLinOn(0)
78 ,fBypass(0)
79 ,fCommonAdditive(0)
80 ,fZeroSuppressed(0)
81 ,fHCHctr1(0)
82 ,fHCHctr2(0)
83 ,fMCMHctr1(0)
84 ,fMCMHctr2(0)
85 ,fGTUctr1(0)
86 ,fGTUctr2(0)
87 ,fHCdataCtr(0)
88 ,fTracklPID(0.)
89 ,fTracklDefL(0.)
90 ,fTracklPadPos(0.)
91 ,fTracklPadRow(0)
92 ,fGTUlinkMask()
93 ,fMCMWordCrt(0)
94 ,fMCMWordsExpected(0)
95 ,fRawReader(NULL)
96 ,fRawVersion(2)
97 ,fRawDigitThreshold(0)
98 ,fNextStatus(0)
99 ,fLastStatus(0)
100 ,fTbSwitch(0)
101 ,fTbSwitchCtr(0)
102 ,fTimeWords(0)
103 ,fWordCtr(0)
104 ,fRowMax(0)
105 ,fColMax(0)
106 ,fADCmask()
107 ,fLastADCmask(0)
108 ,fChamberDone()
109 ,fRetVal(0)
110 ,fEqID(0)
111 ,fDataSize(0)
112 ,fSizeOK(kFALSE)
113 ,fCountBytes(0)
114 ,fBufSize(0)
115 ,fkBufferSet(kFALSE)
116 ,fPos(NULL)
117 ,fDataWord(NULL)
118 ,fTimeBinsCalib(0)
119 ,fADClookup()
120 ,fNActiveADCs(0)
121 ,fEndOfDataFlag(kFALSE)
ecf39416 122{
123 //
124 // Default constructor
125 //
126
127 for (Int_t i = 0; i < 540; i++) {
128 fChamberDone[i] = 0;
129 }
130
131}
132
133//_____________________________________________________________________________
134AliTRDRawStreamV2::AliTRDRawStreamV2(AliRawReader *rawReader)
dfbb4bb9 135 :AliTRDrawStreamBase(rawReader)
136// :TObject()
0c349049 137 ,fGeo(NULL)
ecf39416 138 ,fADC(0)
139 ,fTB(0)
140 ,fEv(0)
141 ,fROB(0)
142 ,fMCM(0)
143 ,fSM(0)
144 ,fLAYER(0)
145 ,fSTACK(0)
146 ,fROC(0)
147 ,fSIDE(0)
148 ,fDCS(0)
149 ,fROW(0)
150 ,fCOL(0)
151 ,fDET(0)
152 ,fLastDET(-1)
153 ,fBCctr(0)
154 ,fPTctr(0)
155 ,fPTphase(0)
156 ,fRVmajor(0)
157 ,fRVminor(0)
158 ,fHCHWords(0)
159 ,fTBins(0)
160 ,fTCon(0)
161 ,fPEDon(0)
162 ,fGAINon(0)
163 ,fXTon(0)
164 ,fNonLinOn(0)
165 ,fBypass(0)
166 ,fCommonAdditive(0)
167 ,fZeroSuppressed(0)
168 ,fHCHctr1(0)
169 ,fHCHctr2(0)
170 ,fMCMHctr1(0)
171 ,fMCMHctr2(0)
172 ,fGTUctr1(0)
173 ,fGTUctr2(0)
174 ,fHCdataCtr(0)
175 ,fTracklPID(0.)
176 ,fTracklDefL(0.)
177 ,fTracklPadPos(0.)
178 ,fTracklPadRow(0)
179 ,fGTUlinkMask()
180 ,fMCMWordCrt(0)
181 ,fMCMWordsExpected(0)
182 ,fRawReader(rawReader)
183 ,fRawVersion(2)
184 ,fRawDigitThreshold(0)
185 ,fNextStatus(0)
186 ,fLastStatus(0)
187 ,fTbSwitch(0)
188 ,fTbSwitchCtr(0)
189 ,fTimeWords(0)
190 ,fWordCtr(0)
191 ,fRowMax(0)
192 ,fColMax(0)
193 ,fADCmask()
194 ,fLastADCmask(0)
195 ,fChamberDone()
196 ,fRetVal(0)
197 ,fEqID(0)
198 ,fDataSize(0)
199 ,fSizeOK(kFALSE)
200 ,fCountBytes(0)
201 ,fBufSize(0)
202 ,fkBufferSet(kFALSE)
203 ,fPos(NULL)
204 ,fDataWord(NULL)
205 ,fTimeBinsCalib(0)
206 ,fADClookup()
207 ,fNActiveADCs(0)
208 ,fEndOfDataFlag(kFALSE)
ecf39416 209{
210 //
211 // Create an object to read TRD raw digits
212 //
213
214 fRawReader->Select("TRD");
215
216 for (Int_t i = 0; i < 540; i++) {
217 fChamberDone[i] = 0;
218 }
219
220}
221
222//_____________________________________________________________________________
223AliTRDRawStreamV2::AliTRDRawStreamV2(const AliTRDRawStreamV2& stream)
dfbb4bb9 224 :AliTRDrawStreamBase(stream)
225// :TObject()
0c349049 226 ,fGeo(NULL)
ecf39416 227 ,fSig()
228 ,fADC(-1)
229 ,fTB(-1)
230 ,fEv(-1)
231 ,fROB(-1)
232 ,fMCM(-1)
233 ,fSM(-1)
234 ,fLAYER(-1)
235 ,fSTACK(-1)
236 ,fROC(-1)
237 ,fSIDE(-1)
238 ,fDCS(-1)
239 ,fROW(-1)
240 ,fCOL(-1)
241 ,fDET(0)
242 ,fLastDET(-1)
243 ,fBCctr(-1)
244 ,fPTctr(-1)
245 ,fPTphase(-1)
246 ,fRVmajor(-1)
247 ,fRVminor(-1)
248 ,fHCHWords(-1)
249 ,fTBins(-1)
250 ,fTCon(0)
251 ,fPEDon(0)
252 ,fGAINon(0)
253 ,fXTon(0)
254 ,fNonLinOn(-1)
255 ,fBypass(-1)
256 ,fCommonAdditive(-1)
257 ,fZeroSuppressed(0)
258 ,fHCHctr1(-1)
259 ,fHCHctr2(-1)
260 ,fMCMHctr1(-1)
261 ,fMCMHctr2(-1)
262 ,fGTUctr1(-1)
263 ,fGTUctr2(-1)
264 ,fHCdataCtr(-1)
265 ,fTracklPID(-1.)
266 ,fTracklDefL(-1.)
267 ,fTracklPadPos(-1.)
268 ,fTracklPadRow(-1)
269 ,fGTUlinkMask()
270 ,fMCMWordCrt(0)
271 ,fMCMWordsExpected(0)
272 ,fRawReader(NULL)
273 ,fRawVersion(-1)
274 ,fRawDigitThreshold(0)
275 ,fNextStatus(0)
276 ,fLastStatus(0)
277 ,fTbSwitch(0)
278 ,fTbSwitchCtr(0)
279 ,fTimeWords(0)
280 ,fWordCtr(0)
281 ,fRowMax(-1)
282 ,fColMax(-1)
283 ,fADCmask()
284 ,fLastADCmask(0)
285 ,fChamberDone()
286 ,fRetVal(0)
287 ,fEqID(0)
288 ,fDataSize(0)
289 ,fSizeOK(kFALSE)
290 ,fCountBytes(0)
291 ,fBufSize(0)
292 ,fkBufferSet(kFALSE)
293 ,fPos(NULL)
294 ,fDataWord(NULL)
295 ,fTimeBinsCalib(0)
296 ,fADClookup()
297 ,fNActiveADCs(0)
298 ,fEndOfDataFlag(kFALSE)
ecf39416 299{
300 //
301 // Copy constructor
302 //
303
304 AliFatal("Copy constructor not implemented");
305
306}
307
308//_____________________________________________________________________________
309AliTRDRawStreamV2& AliTRDRawStreamV2::operator = (const AliTRDRawStreamV2&
310 /* stream */)
311{
312 //
313 // Assigment operator
314 //
315
316 Fatal("operator =", "assignment operator not implemented");
317 return *this;
318
319}
320
321//_____________________________________________________________________________
322AliTRDRawStreamV2::~AliTRDRawStreamV2()
323{
324 //
325 // Destructor
326 //
327
328 if (fGeo) {
329 delete fGeo;
330 }
331
332}
333
334//_____________________________________________________________________________
335void AliTRDRawStreamV2::SetRawReader(AliRawReader *rawReader)
336{
337 //
338 // Set the rawreader
339 //
340
341 if (rawReader)
342 {
343 fRawReader = rawReader;
344 }
345}
346
347//_____________________________________________________________________________
348Bool_t AliTRDRawStreamV2::SetRawVersion(Int_t rv)
349{
350 //
351 // Set the raw data version
352 //
353
354 if ( rv >= 0 && rv <= 3 ) {
355 fRawVersion = rv;
356 return kTRUE;
357 }
358
359 return kFALSE;
360
361}
362
ecf39416 363//____________________________________________________________________________
dfbb4bb9 364Bool_t AliTRDRawStreamV2::Init()
ecf39416 365{
366 //
367 // Initialization
368 //
369
370 if (!AliTRDcalibDB::Instance()) {
371 AliError("Could not get calibration object");
dfbb4bb9 372 return kFALSE;
ecf39416 373 }
374
375 if (!fGeo) {
376 fGeo = new AliTRDgeometry();
377 }
378
379 fTimeBinsCalib = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
380 //AliDebug(2, Form("Number of Timebins read from CDB: %d", fTimeBinsCalib));
381
382 // The number of data words needed for this number of time bins (there
383 // are 3 time bins in one word)
384 fTimeWords = (fTimeBinsCalib-1)/3 + 1;
385
386 fTbSwitch = 3;
387 fTbSwitchCtr = 0;
388
389 fHCHctr1 = fHCHctr2 = 0;
390 fGTUctr1 = fGTUctr2 = -1;
391
392 fHCdataCtr = 0;
393 fWordCtr = 0;
394
395 fDET = 0;
396 fLastDET = -1;
397 fRetVal = 0;
398 fEqID = 0;
399 fDataSize = 0;
400 fSizeOK = kFALSE;
401
0c349049 402 fLastStatus = kStart;
403 fNextStatus = kStart;
ecf39416 404
405 fCountBytes = 0;
406 fBufSize = 0;
407 fDataWord = NULL;
408 fPos = NULL;
409 fWordCtr = 0;
410 fkBufferSet = kFALSE;
411
412 fMCMWordCrt = 0;
413 fMCMWordsExpected = 0;
414
415 fEndOfDataFlag = kFALSE;
416 // set all ADC active
0c349049 417 // should be 1111 1111 1111 1111 1111 1 = 21 bits active (0-20)
418 fNActiveADCs = ChannelsToRead(0x1fffff);
ecf39416 419
420 fLastADCmask = 0;
421
422 return kTRUE;
423}
424
33dd2de9 425//____________________________________________________________________________
426void AliTRDRawStreamV2::SwapOnEndian()
427{
428 //
429 // Check the endian and swap if needed
430 //
431
432 int itemp = 1;
433 char* ptemp = (char*) &itemp;
434 if (ptemp[0] != 1)
435 {
436 // need to swap...
437 // assume we are at the begining of the buffer!
438 //AliDebug(5, "Swapping.");
439 UInt_t *pbegin = (UInt_t*)fPos;
440 UInt_t iutmp = 0;
441 for (UInt_t i = 0; i < fBufSize / fgkSizeWord; i++)
442 {
443 fDataWord = pbegin + i;
444 iutmp = (((*fDataWord & 0x000000ffU) << 24) | ((*fDataWord & 0x0000ff00U) << 8) |
445 ((*fDataWord & 0x00ff0000U) >> 8) | ((*fDataWord & 0xff000000U) >> 24));
446 // here we override the value in the buffer!
447 *fDataWord = iutmp;
448 }
449 fDataWord = pbegin;
450 }
451}
ecf39416 452//____________________________________________________________________________
453Int_t AliTRDRawStreamV2::NextData()
454{
455 //
456 // Updates the next data word pointer
457 //
458
0c349049 459 if (fCountBytes + fgkSizeWord >= fBufSize)
ecf39416 460 {
461 fkBufferSet = fRawReader->ReadNextData(fPos);
462 if (fkBufferSet == kTRUE)
463 {
464 fBufSize = fRawReader->GetDataSize();
465 fCountBytes = 0;
466 fDataWord = (UInt_t*)fPos;
33dd2de9 467 SwapOnEndian();
0c349049 468 ChangeStatus(kNextSM);
ecf39416 469 fWordCtr = 0;
0c349049 470 return kNextSM;
ecf39416 471 }
472 else
473 {
0c349049 474 ChangeStatus(kStop);
475 return kNoMoreData;
ecf39416 476 }
477 }
478 else
479 {
0c349049 480 fPos += fgkSizeWord;
481 fCountBytes += fgkSizeWord;
ecf39416 482 fDataWord = (UInt_t*)fPos;
483 fWordCtr++;
0c349049 484 return kWordOK;
ecf39416 485 }
486}
487
488//============================================================================
489// Decoding functions
490//============================================================================
491
ecf39416 492//____________________________________________________________________________
493void AliTRDRawStreamV2::DecodeHCheader(Int_t timeBins)
494{
495 //
496 // Decode the HC header (fRawVersion == 2, 3, 4, ???)
497 //
498
499 fRVmajor = (*fDataWord >> 24) & 0x7f;
500 fRVminor = (*fDataWord >> 17) & 0x7f;
501
502 if (fRVmajor < 2 || fRVmajor > 4)
503 AliError(Form(" Unsupported raw version: %d", fRawVersion))
504
505 if ( fRawVersion != fRVmajor ) {
506
507 AliWarning("===============================================================================");
508 AliWarning(Form("Mismatch between fRawVersion (%d) and fRVmajor from HC header (%d)"
509 ,fRawVersion,fRVmajor));
510 AliWarning(Form("Setting fRawVersion to %d", fRVmajor));
511 AliWarning("===============================================================================");
512 fRawVersion = fRVmajor;
513
514 }
515
516 //
517 // check for zero suppression
518 if ( fRawVersion >= 3 || fRawVersion <= 4 ) fZeroSuppressed = kTRUE;
519 else fZeroSuppressed = kFALSE;
520
521 // 1st word (h[0])
522 if ( (*fDataWord & 0x3) == 1 ) {
523
524 fHCHWords = (*fDataWord >> 14) & 0x7;
525 fSM = (*fDataWord >> 9) & 0x1f;
526 fLAYER = (*fDataWord >> 6) & 0x7;
527 fSTACK = (*fDataWord >> 3) & 0x7;
528 fSIDE = (*fDataWord >> 2) & 0x1;
529
530 fROC = fGeo->GetDetectorSec(fLAYER, fSTACK);
531
532 //AliDebug(3, Form("0x%08x: HC header: sm=%d; roc=%d; side=%x", *fDataWord, fSM, fROC, fSIDE+10));
533 //AliDebug(5, Form("0x%08x: HC header: expecting %d HC words", *fDataWord, fHCHWords));
534
535 if ((fSM < 0) ||
536 (fSM > 17) ||
537 (fLAYER < 0) ||
538 (fLAYER > 5) ||
539 (fSTACK < 0) ||
540 (fSTACK > 4) ||
541 (fSIDE < 0) ||
542 (fSIDE > 1))
543 {
544 AliWarning(Form("0x%08x: Strange HC header: dcs=%d; sm=%d; layer=%d; stack=%d.",
545 *fDataWord, fDCS, fSM, fLAYER, fSTACK));
546 fRawReader->AddMajorErrorLog(kHCHeaderCorrupt,Form("0x%08x:dcs=%d; sm=%d; layer=%d; stack=%d.",
547 *fDataWord, fDCS, fSM, fLAYER, fSTACK));
548 }
549 else
550 {
551 fHCHctr1++;
552 fHCHctr2++;
553 }
554 }
555 else
556 {
557 AliWarning(Form("0x%08x: No HC header when it was expected.", *fDataWord));
558 fRawReader->AddMajorErrorLog(kHCHeaderMissing,Form("0x%08x", *fDataWord));
559 }
560
561 // 2nd word (h[1])
562 if ( fHCHWords >= 1 )
563 {
564 // read one more word
0c349049 565 if (NextData() != kWordOK)
ecf39416 566 {
567 AliWarning("Next HC word missing");
568 fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word missing");
0c349049 569 fNextStatus = kNextHC;
ecf39416 570 return;
571 }
572
573 if ( (*fDataWord & 0x3) == 1 )
574 {
575
576 fBCctr = (*fDataWord >> 16);
577 fPTctr = (*fDataWord >> 12) & 0xf;
578 fPTphase = (*fDataWord >> 8) & 0xf;
579 fTBins = ((*fDataWord >> 2) & 0x3f) + 1;
580 fTimeWords = (fTBins - 1)/3 + 1;
581
582// AliDebug(3, Form("0x%08x: HC header 2: BCctr=%d PTctr=%d PTph=%d TB=%d"
583// , *fDataWord, fBCctr, fPTctr, fPTphase, fTBins));
584
585 if( fTBins != timeBins )
586 {
587 AliWarning("===============================================================================");
588 AliError(Form("Mismatch between nNTB from CDB (%d) and from HC header (%d)"
589 , timeBins, fTBins));
590 AliWarning(Form("We will use the value from the raw data (HC header): %d", fTBins));
591 AliWarning("===============================================================================");
592
593 fTimeWords = (fTBins - 1)/3 + 1;
594 }
595 }
596 }
597
598 // 3nd word (h[2])
599 if ( fHCHWords >= 2 ) {
600 // read one more word
0c349049 601 if (NextData() != kWordOK)
ecf39416 602 {
603 AliWarning("Next HC word missing");
604 fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word missing");
0c349049 605 fNextStatus = kNextHC;
ecf39416 606 return;
607 }
608 if ( (*fDataWord & 0x3) == 1 ) {
609
610 fTCon = (*fDataWord >> 29) & 0x1;
611 fPEDon = (*fDataWord >> 31) & 0x1;
612 fGAINon = (*fDataWord >> 30) & 0x1;
613 fXTon = (*fDataWord >> 28) & 0x1;
614 fNonLinOn = (*fDataWord >> 27) & 0x1;
615 fBypass = (*fDataWord >> 26) & 0x1;
616
617 fCommonAdditive = (*fDataWord >> 20) & 0x3f;
618
619// AliDebug(3, Form("0x%08x: HC header 3: TC=%d, PED=%d, GAIN=%d, XT=%d, NonLin=%d, Bypass=%d, Add=%d"
620// , fTCon, fPEDon, fGAINon, fXTon, fNonLinOn, fBypass, fCommonAdditive));
621 }
622 }
623
624}
625
626//____________________________________________________________________________
627Int_t AliTRDRawStreamV2::ChannelsToRead(Int_t ADCmask)
628{
0c349049 629 //
630 // Return the channels to read
631 //
632
ecf39416 633 memset(fADClookup, -1, 32 * sizeof(Int_t));
634 fADClookup[0] = 0; // count entries
635 fADClookup[1] = 2; // index - data start at 2
636 UInt_t mask = 0;
637 for (Int_t i = 0; i < 30; i++)
638 {
639 mask = 1 << i;
640 if ((ADCmask & mask))
641 {
642 //AliDebug(9, Form("fDataWord=0x%08x mask=0x%08x i=%d", *fDataWord, mask, i));
643 fADClookup[fADClookup[1]] = i;
644 ++fADClookup[0];
645 ++fADClookup[1];
646 }
647 }
648
649 // test the iteration - comment out for production
650 // begin of comment out section
651 char schannels[512];
652 sprintf(schannels, "ADC Channels to read: ");
653 fADClookup[1] = 2;
654 while(fADClookup[1] - 2 < fADClookup[0])
655 {
656 //AliDebug(9, Form("max=%d index=%d adc=%d", fADClookup[0], fADClookup[1], fADClookup[fADClookup[1]]));
657 strcat(schannels, Form("%d ", fADClookup[fADClookup[1]]));
658 fADClookup[1]++;
659 }
660 //AliDebug(9, Form("%s", schannels));
661 //AliDebug(9, Form("ADC channels = %d", fADClookup[0]));
662 // end of comment out section
663
664 fADClookup[1] = 2;
665 return fADClookup[0];
666}
667
668//____________________________________________________________________________
669void AliTRDRawStreamV2::DecodeTracklet()
670{
ecf39416 671 //
672 // Decode the Tracklet
673 //
674 // this function is not tested yet on real tracklets
675 //
676
677 if ( fRawVersion < 1 || fRawVersion > 3 )
678 {
679 AliError(Form(" Unsupported raw version: %d", fRawVersion));
680 }
681
682 fTracklPID = (*fDataWord >> 24) & 0xff;
683 fTracklPadRow = (*fDataWord >> 20) & 0xf; // 0:15
684 fTracklDefL = (*fDataWord >> 13) & 0x7f;
685 fTracklPadPos = (*fDataWord) & 0x1fff;
686
687 fTracklPID /= (Float_t)((1<<8) - 1); // 0:1 (steps of 0.39%)
688 fTracklDefL = (fTracklDefL - ((1<< 7)-1)/2.) * 140.e-4; // -0.889:0.889cm
689 fTracklPadPos = (fTracklPadPos - ((1<<13)-1)/2.) * 160.e-4; // -65.528:65.528 cm
690
691 //AliDebug(4, Form("0x%08x: Tracklet found: SM%d L%dS%d side %x: PadRow=%d PadPos=%f DefL=%f PID=%f"
692 // , *fDataWord, fSM, fLAYER, fSTACK, fSIDE+10
693 // , fTracklPadRow, fTracklPadPos, fTracklDefL, fTracklPID));
694
695 if( (fSTACK == 2) && (fTracklPadRow >= (Int_t) fGeo->RowmaxC0()) ||
696 (fSTACK != 2) && (fTracklPadRow >= (Int_t) fGeo->RowmaxC1()) ) {
697 AliWarning(Form("Strange Row read from Tracklet Word: %d", fTracklPadRow));
698 fRawReader->AddMajorErrorLog(kTrackletRowMismatch,Form("Word: %d", fTracklPadRow));
699 }
700
701}
702
703//____________________________________________________________________________
704void AliTRDRawStreamV2::DecodeMCMheader()
705{
ecf39416 706 //
707 // Decode the MCM header
708 //
709
710 if ( fRawVersion < 1 || fRawVersion > 3 )
711 {
712 AliError(Form(" Unsupported raw version: %d", fRawVersion));
713 }
714
715 fMCM = (*fDataWord & 0xff000000) >> 24;
716 fEv = (*fDataWord & 0x00fffff0) >> 4;
717
718 fROB = fMCM / 16;
719 fMCM = fMCM % 16;
720
721 fROW = AliTRDfeeParam::Instance()->GetPadRowFromMCM(fROB, fMCM);
722
723// AliDebug(4, Form("0x%08x: SM%d L%dS%d. MCM Header: fROB=%d fMCM=%02d fEv=%02d"
724// , *fDataWord, fSM, fLAYER, fSTACK, fROB, fMCM, fEv));
725
726 if ( fROB % 2 == 0 && fSIDE == 1 ) {
727 AliWarning(Form("SM%d L%dS%d: Mismatch between fROB (%d) and fSIDE (%d): fMCM=%02d"
728 , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
729 fRawReader->AddMajorErrorLog(kROBSideMismatch,Form("SM%d L%dS%d: fROB (%d) fSIDE (%d): fMCM=%02d"
730 , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
731 }
732 if ( fROB % 2 != 0 && fSIDE == 0 ) {
733 AliWarning(Form("SM%d L%dS%d: Mismatch between fROB (%d) and fSIDE (%d): fMCM=%02d"
734 , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
735 fRawReader->AddMajorErrorLog(kROBSideMismatch,Form("SM%d L%dS%d: fROB (%d) fSIDE (%d): fMCM=%02d"
736 , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
737 }
738 if ( (fSTACK == 2 && fROW >= fGeo->RowmaxC0()) ||
739 (fSTACK != 2 && fROW >= fGeo->RowmaxC1()) || fROW < 0 ) {
740 AliWarning(Form("SM%d L%dS%d: Wrong Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
741 , fSM, fLAYER, fSTACK, fROW, fROB, fSIDE, fMCM ));
742 fRawReader->AddMajorErrorLog(kWrongPadrow,Form("SM%d L%dS%d: Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
743 , fSM, fLAYER, fSTACK, fROW, fROB, fSIDE, fMCM ));
744 }
745
746 fMCMHctr1++;
747 fMCMHctr2++;
748
749 fMCMWordCrt = 1; // MCM header
750
751 // AdcMask for Zero supressed data
752 if ( fRawVersion == 3 )
753 {
754 // read one more word
0c349049 755 if (NextData() != kWordOK)
ecf39416 756 {
757 AliWarning("MCM ADC mask missing");
758 fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Missing");
0c349049 759 fNextStatus = kNextHC;
ecf39416 760 return;
761 }
762 else
763 {
764 ++fMCMWordCrt;
765
766 for ( Int_t ctr = 0; ctr < fGeo->ADCmax(); ctr++ ) {
767 if ( (*fDataWord >> (11+ctr)) == 0x1 ) fADCmask[ctr] = kTRUE;
768 else fADCmask[ctr] = kFALSE;
769 }
770
771 //AliDebug(4, Form("0x%08x: ADC mask", *fDataWord));
772 fNActiveADCs = ChannelsToRead(*fDataWord);
773 }
774 }
775
776 if (fRawVersion <= 2)
777 {
778 // no zero suppression
779 // raw version 2:
780 // 1 MCM header + 21 * ( Ntimebin/3)
781 // If NTimebin = 30, it is 211 words.
782 //fMCMWordsExpected = 1 + 21 * (fTBins / 3);
783 //fNActiveADCs = 21;
784 fNActiveADCs = ChannelsToRead(0x1fffff); // should be 1111 1111 1111 1111 1111 1 = 21 bits active (0-20)
785 //fMCMWordsExpected = 1 + fNActiveADCs * ((fTBins-1) / 3. + 1.);
786 //directly get it like that:
787 fMCMWordsExpected = 1 + fNActiveADCs * fTBins / 3;
788 }
789
790 if (fRawVersion >= 3)
791 {
792 // raw version 3:
793 // 1 MCM header + 1 ADC mask + NofActiveADCs * ( Ntimebin/3 )
794 //directly get it like that:
795 fMCMWordsExpected = 1 + 1 + (fTBins * fNActiveADCs) / 3;
796 }
797
798 //AliDebug(5, Form("We expect %d MCM words. We read %d so far.", fMCMWordsExpected, fMCMWordCrt));
799}
800//____________________________________________________________________________
801Bool_t AliTRDRawStreamV2::DecodeNextRawWord()
802{
0c349049 803 //
804 // Decode the next raw data word
805 //
806
ecf39416 807 //AliDebug(8, Form("-----------------------------------------"));
808 //AliDebug(8, Form("DATA IS 0x%x", *fDataWord));
809
810 if (fADClookup[1] - 2 > fADClookup[0])
811 {
812// AliDebug(8, Form("Overflow Index ADC = %d Max Index = %d Value = %d. Done with ADCs in this MCM. Is this already MCM header 0x%x?",
813// fADClookup[1] - 2, fADClookup[0], fADClookup[fADClookup[1]], *fDataWord));
814 fTbSwitchCtr = 0;
815 fMCMWordsExpected = 0;
816 AliWarning("Trying to recover. Fall back to DecodeMCM.");
817 DecodeMCM();
0c349049 818 //ChangeStatus(kNextMCM);
ecf39416 819 return kFALSE;
820 }
821
822 if ( (*fDataWord & 0x00000003) != 0x2 && (*fDataWord & 0x00000003) != 0x3) {
823 AliWarning(Form("Data %08x : Data Word ends neither with b11 nor b10", (Int_t)*fDataWord));
824 fRawReader->AddMinorErrorLog(kDataMaskError,Form("Data %08x", (Int_t)*fDataWord));
825 fMCMWordsExpected = 0;
826 AliWarning("Trying to recover. Fall back to DecodeMCM.");
827 DecodeMCM();
0c349049 828 //ChangeStatus(kNextMCM);
ecf39416 829 return kFALSE;
830 }
831
f4611d14 832 if ( (*fDataWord & 0x3) != fLastADCmask || fTbSwitchCtr > fTimeWords)
ecf39416 833 {
834 fADC = fADClookup[fADClookup[1]];
835// AliDebug(8, Form("Next fADC = %d at index = %d MCM Word Number: %d Max MCM Words is %d",
836// fADC, fADClookup[1] - 2, fMCMWordCrt, fMCMWordsExpected));
837 ++fADClookup[1];
838 fTB = 0;
f4611d14 839 fTbSwitchCtr = 0;
0c349049 840 fLastStatus = kNextData;
ecf39416 841 fLastADCmask = (*fDataWord) & 0x3;
842 }
843
f4611d14 844 ++fTbSwitchCtr;
845
ecf39416 846 //decode data here
847 Bool_t kIsDataOK = kFALSE;
848
849 // We have only 21 ADC channels.
850 if ( fADC > (Int_t)fGeo->ADCmax() - 1 )
851 {
852 AliWarning(Form("Data %08x : Data is strange. fADC is already %d", (Int_t)*fDataWord, (Int_t)fADC));
853 fRawReader->AddMinorErrorLog(kADCChannelOverflow,Form("Data %08x : fADC=%d", (Int_t)*fDataWord, (Int_t)fADC));
854 }
855 else
856 {
857 // There are 18 pads connected to each MCM ADC channels 2...19. The other channels cross to other
858 // MCMs and are good for online tracking in the MCM.
859 if ( fADC > 1 && fADC < (Int_t)fGeo->ADCmax() - 1 )
860 {
861
862 // Get Pad column
863 // fCOL = fFee->GetPadColFromADC(fROB, fMCM, fADC);
864 fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fROB, fMCM, fADC);
865
866 // We have only 144 Pad Columns
867 //if ( fCOL > fColMax-1 || fCOL < 0 )
868 if ( fCOL >= 0 && fCOL < fColMax && fROW >= 0 && fROW < fRowMax )
869 {
870 // Decode 32 bit data words with information from 3 time bins and copy the data
871 fSig[0] = (*fDataWord & 0x00000ffc) >> 2;
872 fSig[1] = (*fDataWord & 0x003ff000) >> 12;
873 fSig[2] = (*fDataWord & 0xffc00000) >> 22;
874
875 // Print data to screen:
876 //AliDebug(5, Form("DATA : 0x%x", *fDataWord));
877 // AliDebug(5, Form("SM%d L%dS%d: ROB%d MCM=%d ADC=%d (ROW=%d COL=%d): Data %04d %04d %04d\n",
878 // fSM, fLAYER, fSTACK, fROB, fMCM, fADC, fROW, fCOL, fSig[0], fSig[1], fSig[2]));
879 kIsDataOK = kTRUE;
880 }
881 else
882 {
883 AliWarning(Form("SM%d L%dS%d: Wrong Pad column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
884 fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
885 fRawReader->AddMajorErrorLog(kWrongPadcolumn,Form("SM%d L%dS%d: column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
886 fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
887 kIsDataOK = kFALSE;
888 }
889 }
890 else
891 {
892 //AliDebug(5, Form("fADC not accepted %d - DATA : 0x%x", fADC, *fDataWord));
893 fCOL = -1;
894 kIsDataOK = kFALSE;
895 }
896 }// if fADC is ok
897
898 ++fMCMWordCrt;
899 //AliDebug(5, Form("We expect %d MCM words. We read %d so far.", fMCMWordsExpected, fMCMWordCrt));
900
901 // all mcm data processed go to next one
902 if ( fMCMWordCrt >= fMCMWordsExpected)
903 {
0c349049 904 ChangeStatus(kNextMCM);
ecf39416 905 }
906
907 return kIsDataOK;
908}
909
910//____________________________________________________________________________
911Bool_t AliTRDRawStreamV2::DecodeMCM()
912{
0c349049 913 //
914 // Decode a single MCM
915 //
916
ecf39416 917 if( ((*fDataWord & 0x80000000) == 0x0) && ((*fDataWord & 0x0000000f) == 0xC) )
918 { // MCM Header
919 DecodeMCMheader();
920 if ( fMCM < 0 || fMCM > 15 || fROB < 0 || fROB > 7 )
921 {
922 AliWarning("Wrong fMCM or fROB. Skip this data");
923 fRawReader->AddMajorErrorLog(kWrongMCMorROB,Form("MCM=%d, ROB=%d",fMCM,fROB));
0c349049 924 ChangeStatus(kNextHC);
ecf39416 925 return kFALSE;
926 }
927
928 fTbSwitch = 3; // For first adc channel we expect: (*fDataWord & 3) = 3
929 fTbSwitchCtr = 0; //
930 fADC = fTB = 0; // Reset Counter
931 fLastADCmask = 0; // Reset
932
933 if (fMCMWordCrt < fMCMWordsExpected)
934 {
0c349049 935 ChangeStatus(kNextData);
ecf39416 936 }
937 else
938 {
0c349049 939 ChangeStatus(kNextMCM);
ecf39416 940 }
941 return kTRUE;
942 }
943
0c349049 944 if ( *fDataWord == fgkEndofrawdatamarker )
ecf39416 945 { // End of half-chamber data, finished
946 fGTUctr1 = -1;
0c349049 947 ChangeStatus(kNextHC);
ecf39416 948 fEndOfDataFlag = kTRUE;
949 //AliDebug(5, "Expecting MCM header but got End-Of-Raw-Data Marker");
950 if (fMCMWordsExpected == 0 || fMCMWordsExpected == fMCMWordCrt)
951 return kTRUE;
952 else
953 {
954 //AliDebug(5, Form("MCM words missing? %d [expected=%d got=%d] ", fMCMWordsExpected - fMCMWordCrt, fMCMWordsExpected, fMCMWordCrt));
955 //AliWarning(Form("MCM words missing? %d [expected=%d got=%d] ", fMCMWordsExpected - fMCMWordCrt, fMCMWordsExpected, fMCMWordCrt));
956 return kFALSE;
957 }
958 }
959
960 //AliDebug(3, Form("Expecting MCM header but got 0x%x. Going to Next MCM header.", *fDataWord));
961 AliWarning(Form("Expecting MCM header but got 0x%x. Fall back: Next MCM header.", *fDataWord));
0c349049 962 ChangeStatus(kNextMCM);
ecf39416 963
964 return kFALSE;
965}
966
967//____________________________________________________________________________
968Bool_t AliTRDRawStreamV2::DecodeHC()
969{
0c349049 970 //
971 // Decode a half chamber
972 //
973
974 if ( fNextStatus == kNextHC )
ecf39416 975 {
0c349049 976 //AliDebug(5, "kNextHC");
ecf39416 977 //
978 // 1) Find end_of_tracklet_marker
979 //
980 // GTU Link Mask?
981 if (DecodeGTUlinkMask())
982 {
983 return kTRUE;
984 }
985
986 // endoftrackletmarker?
0c349049 987 if ( *fDataWord == fgkEndoftrackletmarker )
ecf39416 988 {
989 //AliDebug(3, "End-of-tracklet-marker found");
990 //AliDebug(5, Form("Data 0x%x", *fDataWord));
0c349049 991 ChangeStatus(kSeekNonEoTracklet);
ecf39416 992 return kTRUE;
993 }
994 else
995 {
996 // Tracklets found
997 //AliDebug(3, "Tracklet found");
998 //AliDebug(5, Form("Tracklet data 0x%x", *fDataWord));
999 DecodeTracklet();
1000 return kTRUE;
1001 }
1002 } // if next HC
1003
0c349049 1004 if (fNextStatus == kSeekNonEoTracklet)
ecf39416 1005 {
0c349049 1006 //AliDebug(5, "kSeekNonEoTracklet");
ecf39416 1007
1008 //
1009 // 2) Look for non-end_of_tracklet_marker
1010 //
1011 //printf("Word %d: 0x%08x\n", fWordCtr, *fDataWord);
1012
0c349049 1013 if ( *fDataWord != fgkEndoftrackletmarker )
ecf39416 1014 {
0c349049 1015 ChangeStatus(kDecodeHC);
ecf39416 1016 //AliDebug(3, "NON end-of-tracklet-marker found");
1017 //AliDebug(5, Form("Data 0x%x", *fDataWord));
1018 //// no do not continue - this should be the hcheader
1019 }
1020 else
1021 {
1022 //just go on and find the non-end_of_tracklet_marker
1023 return kTRUE;
1024 }
1025 }
1026
0c349049 1027 if ( fNextStatus == kDecodeHC )
ecf39416 1028 {
0c349049 1029 //AliDebug(5, "kDecodeHC");
ecf39416 1030
1031 //
1032 // 3) This Word must be Half Chamber Header
1033 //
1034 if ( (*fDataWord & 0x00000003) == 1 )
1035 { // HC header
1036 DecodeHCheader(fTimeBinsCalib); // This is the new header!
1037 fLastDET = fDET;
1038 fDET = fGeo->GetDetector(fLAYER, fSTACK, fSM);
1039 fRowMax = fGeo->GetRowMax(fLAYER,fSTACK,fSM);
1040 fColMax = fGeo->GetColMax(fROC);
1041
1042 fMCMHctr2 = 0;
1043 fHCdataCtr = 0;
1044 fChamberDone[fDET]++;
1045 //AliDebug(6, Form("-------------- DET %d fChamberDone[fDET]=%d", fDET, fChamberDone[fDET]));
1046
0c349049 1047 ChangeStatus(kNextMCM);
ecf39416 1048 return kTRUE;
1049 } //HC header
1050 else
1051 {
1052 AliWarning(Form("Expecting HC header mask but got 0x%x. Fall back: Next HC.", *fDataWord));
0c349049 1053 ChangeStatus(kNextHC);
1054 // before we went to //ChangeStatus(kNextSM);
ecf39416 1055 }
1056 } // if decode HC
1057
1058 return kFALSE;
1059}
0c349049 1060
ecf39416 1061//____________________________________________________________________________
1062Bool_t AliTRDRawStreamV2::DecodeGTUlinkMask()
1063{
1064 //
1065 // Decode the link masks sent by the GTU. These marke the active optical links
1066 // between GTU and Super Module. Up to now only fully active links are found
1067 // (0xfff = 12 active links).
1068 //
1069
1070 if ( (*fDataWord & 0xfffff000) == 0xe0000000 )
1071 {
1072 if ( fRawVersion < 1 || fRawVersion > 3 )
1073 {
1074 AliError(Form(" Unsupported raw version: %d", fRawVersion));
1075 }
1076
1077 if ( fGTUctr1 == -1 ) fGTUctr2++;
1078 fGTUctr1++;
1079
1080 if ( (fGTUctr1 >= 0) && (fGTUctr1 < 5) && (fGTUctr2 >= 0) && (fGTUctr2 < 18) )
1081 {
1082 fGTUlinkMask[fGTUctr2][fGTUctr1] = (*fDataWord & 0xfff);
1083 }
1084
1085 //AliDebug(5, Form("GTU link mask 0x%x decoded 0x%x", *fDataWord, fGTUlinkMask[fGTUctr2][fGTUctr1]));
1086 return kTRUE;
1087 }
1088
1089 return kFALSE;
1090}
1091
0c349049 1092//____________________________________________________________________________
ecf39416 1093void AliTRDRawStreamV2::ChangeStatus(Int_t kstat)
1094{
0c349049 1095 //
1096 // Change the status
1097 //
1098
ecf39416 1099 fLastStatus = fNextStatus;
1100 fNextStatus = kstat;
1101}
1102
1103//____________________________________________________________________________
1104Bool_t AliTRDRawStreamV2::DecodeSM()
1105{
0c349049 1106 //
1107 // Decode a supermodule
1108 //
1109
ecf39416 1110 fDET = 0;
1111 fRetVal = 0;
1112 fEqID = 0;
1113 fDataSize = 0;
1114 fSizeOK = kFALSE;
1115
1116 // After reading the first word check for size of this data and get Eq. ID
1117 if ( fWordCtr == 1 )
1118 {
1119 fDataSize = fRawReader->GetDataSize()/4; // Size of this payload in 32bit words
1120 fEqID = fRawReader->GetEquipmentId(); // Get Equipment ID
1121 if ( fDataSize > 0 ) fSizeOK = kTRUE;
1122 //AliDebug(3, Form("fDataSize=%d fEqID=%d", fDataSize, fEqID));
1123 }
1124
1125 // GTU Link Mask?
1126 if ( DecodeGTUlinkMask() )
1127 {
0c349049 1128 ChangeStatus(kNextHC);
ecf39416 1129 return kTRUE;
1130 }
1131 else
1132 {
1133 AliWarning(Form("Equipment %d: First data word is not GTU Link Mask! Fall back: None. Stop.", fEqID));
1134 fRawReader->AddMajorErrorLog(kGTULinkMaskMissing,Form("Equipment %d",fEqID));
0c349049 1135 ChangeStatus(kStop);
ecf39416 1136 }
1137
1138 return kFALSE;
1139}
1140
1141//____________________________________________________________________________
1142Bool_t AliTRDRawStreamV2::Next()
1143{
1144 //
1145 // Updates the next data word pointer
1146 //
1147
0c349049 1148 if (fNextStatus == kStart)
ecf39416 1149 {
1150 Init();
1151 }
1152
0c349049 1153 while (fNextStatus != kStop)
1154 { // !kStop
ecf39416 1155 NextData();
1156
1157 switch (fNextStatus)
1158 {
0c349049 1159 case kNextData:
ecf39416 1160 {
1161 if (DecodeNextRawWord() == kTRUE)
1162 {
1163 fTB += 3;
1164 if (fSig[0] > fRawDigitThreshold || fSig[1] > fRawDigitThreshold || fSig[2] > fRawDigitThreshold)
1165 return kTRUE;
1166 }
1167 }; break;
0c349049 1168 case kNextMCM:
ecf39416 1169 {
1170 if (DecodeMCM() == kFALSE)
1171 AliWarning(Form("Decode MCM unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1172 }; break;
0c349049 1173 case kNextHC:
1174 case kSeekNonEoTracklet:
1175 case kDecodeHC:
ecf39416 1176 {
1177 if (DecodeHC() == kFALSE)
1178 {
1179 AliWarning(Form("Decode HC unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1180 }
1181 else
1182 {
1183 //the hc header should be decoded by now
0c349049 1184 if (fLastStatus == kDecodeHC)
ecf39416 1185 {
1186 fLastDET = fDET;
1187 fChamberDone[fDET]++;
1188 }
1189 }
1190 }; break;
0c349049 1191 case kNextSM:
ecf39416 1192 {
1193 if (DecodeSM() == kFALSE)
1194 AliWarning(Form("Decode SM unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1195 }; break;
0c349049 1196 case kStop:
ecf39416 1197 ; break;
1198 default:
1199 AliWarning(Form("Unknown state %d. Last state %d. Current Word 0x%x at pos 0x%x", fNextStatus, fLastStatus, *fDataWord, fPos));
0c349049 1200 ChangeStatus(kStop);
ecf39416 1201 };
1202
0c349049 1203 } // not kStop
ecf39416 1204
1205 //AliDebug(1, Form("That's all folks! %d", fSM));
1206 return kFALSE;
1207}
1208
1209//____________________________________________________________________________
3be28fbf 1210Int_t AliTRDRawStreamV2::NextChamber(AliTRDdigitsManager *man, UInt_t** /*trackletContainer*/)
ecf39416 1211{
1212 //
1213 // Fills single chamber digit array
1214 // Return value is the detector number
1215 //
1216
625f5260 1217 AliTRDdataArrayS *digits = 0;
ecf39416 1218 AliTRDdataArrayI *track0 = 0;
1219 AliTRDdataArrayI *track1 = 0;
1220 AliTRDdataArrayI *track2 = 0;
1221 AliTRDSignalIndex *indexes = 0;
1222
0c349049 1223 if (fNextStatus == kStart)
ecf39416 1224 {
1225 Init();
1226 }
1227
0c349049 1228// while (fNextStatus != kStop)
1229// { // !kStop
ecf39416 1230// NextData();
1231// // catch 3 things
1232// // 1) if end of raw data - if chamber complete return
1233// // 2) fill the data with signals if data decoded ok
1234// // 3) initialize (destroy old) after the det has changed -> just after HC header decoding
0c349049 1235// } // not kStop
ecf39416 1236
0c349049 1237 while (fNextStatus != kStop)
1238 { // !kStop
ecf39416 1239 NextData();
1240
1241 switch (fNextStatus)
1242 {
1243
0c349049 1244 case kNextData:
ecf39416 1245 {
1246 if (DecodeNextRawWord() == kTRUE)
1247 {
1248 for (Int_t it = 0; it < 3; it++)
1249 {
1250 if ( fTB + it < fTBins )
1251 {
1252 if ( fSig[it] > fRawDigitThreshold )
1253 {
1254 digits->SetDataUnchecked(fROW, fCOL, fTB + it, fSig[it]);
1255 indexes->AddIndexTBin(fROW, fCOL, fTB + it);
1256 if (man->UsesDictionaries())
1257 {
1258 track0->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
1259 track1->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
1260 track2->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
1261 } // if dictionaries
1262 } // signal above zero
1263 } // check the tbins range
1264 } // for each tbin of current 3
1265 fTB += 3;
1266 }
1267 else
1268 {
1269 // can be here as a fall back from decode raw data calling decodemcm
1270 if (fEndOfDataFlag == kTRUE)
1271 {
1272 if (fChamberDone[fDET] == 2)
1273 {
1274 return fDET;
1275 }
1276 fEndOfDataFlag = kFALSE;
1277 }
1278 }
1279 }; break;
1280
0c349049 1281 case kNextMCM:
ecf39416 1282 {
1283 if (DecodeMCM() == kFALSE)
1284 {
1285 AliWarning(Form("Decode MCM unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1286 }
1287 // default place for end of raw data...
1288 if (fEndOfDataFlag == kTRUE)
1289 {
1290 if (fChamberDone[fDET] == 2)
1291 {
1292 return fDET;
1293 }
1294 fEndOfDataFlag = kFALSE;
1295 }
1296 }; break;
1297
0c349049 1298 case kNextHC:
1299 case kSeekNonEoTracklet:
1300 case kDecodeHC:
ecf39416 1301 {
1302 if (DecodeHC() == kFALSE)
1303 {
1304 AliWarning(Form("Decode HC unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1305 }
1306 else
1307 {
1308 //the hc header should be decoded by now
0c349049 1309 if (fLastStatus == kDecodeHC)
ecf39416 1310 {
1311// AliDebug(4, Form("???? New DET ???? %d last %d", fDET, fLastDET));
1312 // allocate stuff for the new det
1313 //man->ResetArrays();
625f5260 1314 digits = (AliTRDdataArrayS *) man->GetDigits(fDET);
1315 track0 = (AliTRDdataArrayI *) man->GetDictionary(fDET,0);
1316 track1 = (AliTRDdataArrayI *) man->GetDictionary(fDET,1);
1317 track2 = (AliTRDdataArrayI *) man->GetDictionary(fDET,2);
ecf39416 1318
1319 // Allocate memory space for the digits buffer
1320 if (digits->GetNtime() == 0)
1321 {
1322// AliDebug(5, Form("Alloc digits for det %d rows %d cols %d tbins %d", fDET, fRowMax, fColMax, fTBins));
1323 digits->Allocate(fRowMax, fColMax, fTBins);
1324 if (man->UsesDictionaries())
1325 {
1326 track0->Allocate(fRowMax, fColMax, fTBins);
1327 track1->Allocate(fRowMax, fColMax, fTBins);
1328 track2->Allocate(fRowMax, fColMax, fTBins);
1329 }
1330 }
1331
1332 indexes = man->GetIndexes(fDET);
1333 indexes->SetSM(fSM);
1334 indexes->SetStack(fSTACK);
1335 indexes->SetLayer(fLAYER);
1336 indexes->SetDetNumber(fDET);
1337
1338 if (indexes->IsAllocated() == kFALSE)
1339 {
1340// AliDebug(4, "Allocating indexes");
1341 indexes->Allocate(fRowMax, fColMax, fTBins);
1342 }
1343 } // is the HC header already decoded?
1344 } // decode hc ok
1345 }; break;
1346
0c349049 1347 case kNextSM:
ecf39416 1348 {
1349 if (DecodeSM() == kFALSE)
1350 AliWarning(Form("Decode SM unsuccessfull. Current Word 0x%x at pos 0x%x", *fDataWord, fPos));
1351 }; break;
1352
0c349049 1353 case kStop:
ecf39416 1354 ; break;
1355
1356 default:
1357 AliWarning(Form("Unknown state %d. Last state %d. Current Word 0x%x at pos 0x%x", fNextStatus, fLastStatus, *fDataWord, fPos));
0c349049 1358 ChangeStatus(kStop);
ecf39416 1359 };
1360
0c349049 1361 } // not kStop
ecf39416 1362
1363 // we do not return chambers for which the end-of-data was not received twice (for each HC)
1364
1365 //AliDebug(1, Form("That's all folks! %d", fSM));
1366 //return kFALSE;
1367 return -1;
1368}