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