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