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