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