]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDRawStream.cxx
New fast cluster finder by Mateusz
[u/mrichter/AliRoot.git] / TRD / AliTRDRawStream.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // This class provides access to TRD digits in raw data.                     //
21 //                                                                           //
22 // It loops over all TRD digits in the raw data given by the AliRawReader.   //
23 // The Next method goes to the next digit. If there are no digits left       //
24 // it returns kFALSE.                                                        //
25 // Several getters provide information about the current digit.              //
26 //                                                                           //
27 // Author: C. Lippmann (C.Lippmann@gsi.de)                                   //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include "AliLog.h"
32 #include "AliRawReader.h"
33 #include "AliTRDRawStream.h"
34 #include "AliTRDgeometry.h"
35 #include "AliTRDcalibDB.h"
36
37 #include "AliTRDdigitsManager.h"
38 #include "AliTRDdataArrayI.h"
39 #include "AliTRDSignalIndex.h"
40
41 ClassImp(AliTRDRawStream)
42
43 //_____________________________________________________________________________
44 AliTRDRawStream::AliTRDRawStream() 
45   :TObject()
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)
60   ,fDET(0)
61   ,fLastDET(-1)
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)
72   ,fXTon(0)
73   ,fNonLinOn(0)
74   ,fBypass(0)
75   ,fCommonAdditive(0)
76   ,fZeroSuppressed(0)
77   ,fHCHctr1(0)
78   ,fHCHctr2(0)
79   ,fMCMHctr1(0)
80   ,fMCMHctr2(0)
81   ,fGTUctr1(0)
82   ,fGTUctr2(0)
83   ,fHCdataCtr(0)
84   ,fTracklPID(0.)
85   ,fTracklDefL(0.)
86   ,fTracklPadPos(0.)
87   ,fTracklPadRow(0)
88   ,fGTUlinkMask()
89   ,fRawReader(NULL)
90   ,fRawVersion(2)
91   ,fNextStatus(0)
92   ,fTbSwitch(0)
93   ,fTbSwitchCtr(0)
94   ,fTimeWords(0)
95   ,fWordCtr(0)
96   ,fRowMax(0)
97   ,fColMax(0)
98   ,fADCmask()
99   ,fChamberDone()
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)
110   ,fGeo(NULL) 
111 {
112   //
113   // Default constructor
114   //
115
116   for (Int_t i = 0; i < 540; i++) {
117     fChamberDone[i] = 0;
118   }
119
120 }
121
122 //_____________________________________________________________________________
123 AliTRDRawStream::AliTRDRawStream(AliRawReader *rawReader) 
124   :TObject()
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)
139   ,fDET(0)
140   ,fLastDET(-1)
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)
151   ,fXTon(0)
152   ,fNonLinOn(0)
153   ,fBypass(0)
154   ,fCommonAdditive(0)
155   ,fZeroSuppressed(0)
156   ,fHCHctr1(0)
157   ,fHCHctr2(0)
158   ,fMCMHctr1(0)
159   ,fMCMHctr2(0)
160   ,fGTUctr1(0)
161   ,fGTUctr2(0)
162   ,fHCdataCtr(0)
163   ,fTracklPID(0.)
164   ,fTracklDefL(0.)
165   ,fTracklPadPos(0.)
166   ,fTracklPadRow(0)
167   ,fGTUlinkMask()
168   ,fRawReader(rawReader)
169   ,fRawVersion(2)
170   ,fNextStatus(0)
171   ,fTbSwitch(0)
172   ,fTbSwitchCtr(0)
173   ,fTimeWords(0)
174   ,fWordCtr(0)
175   ,fRowMax(0)
176   ,fColMax(0)
177   ,fADCmask()
178   ,fChamberDone()
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)
189   ,fGeo(NULL) 
190 {
191   //
192   // Create an object to read TRD raw digits
193   //
194
195   fRawReader->Select("TRD");
196
197   for (Int_t i = 0; i < 540; i++) {
198     fChamberDone[i] = 0;
199   }
200
201 }
202
203 //_____________________________________________________________________________
204 AliTRDRawStream::AliTRDRawStream(const AliTRDRawStream& stream)
205   :TObject(stream)
206   ,fSig()
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)
220   ,fDET(0)
221   ,fLastDET(-1)
222   ,fBCctr(-1)
223   ,fPTctr(-1)
224   ,fPTphase(-1)
225   ,fRVmajor(-1)
226   ,fRVminor(-1)
227   ,fHCHWords(-1)
228   ,fTBins(-1)
229   ,fTCon(0)
230   ,fPEDon(0)
231   ,fGAINon(0)
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)
248   ,fGTUlinkMask()
249   ,fRawReader(NULL)
250   ,fRawVersion(-1)
251   ,fNextStatus(0)
252   ,fTbSwitch(0)
253   ,fTbSwitchCtr(0)
254   ,fTimeWords(0)
255   ,fWordCtr(0)
256   ,fRowMax(-1)
257   ,fColMax(-1)
258   ,fADCmask()
259   ,fChamberDone()
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)
271 {
272   //
273   // Copy constructor
274   //
275
276   AliFatal("Copy constructor not implemented");
277
278 }
279
280 //_____________________________________________________________________________
281 AliTRDRawStream& AliTRDRawStream::operator = (const AliTRDRawStream& 
282                                               /* stream */)
283 {
284   //
285   // Assigment operator
286   //
287
288   Fatal("operator =", "assignment operator not implemented");
289   return *this;
290
291 }
292
293 //_____________________________________________________________________________
294 AliTRDRawStream::~AliTRDRawStream()
295 {
296   //
297   // Destructor
298   //
299
300   if (fGeo) {  
301     delete fGeo;
302   }
303
304 }
305
306 //_____________________________________________________________________________
307 void AliTRDRawStream::SetRawReader(AliRawReader *rawReader) 
308 {
309   if (rawReader)
310     {
311       fRawReader = rawReader;
312     }
313 }
314
315 //_____________________________________________________________________________
316 Bool_t AliTRDRawStream::SetRawVersion(Int_t rv)
317 {
318   //
319   // Set the raw data version
320   //
321
322   if ( rv >= 0 && rv <= 3 ) {
323     fRawVersion = rv;
324     return kTRUE;
325   }
326
327   return kFALSE;
328
329 }
330
331
332 //____________________________________________________________________________
333 Int_t AliTRDRawStream::Init()
334 {
335   //
336   // Initialization
337   //
338
339   if (!AliTRDcalibDB::Instance()) {
340     AliError("Could not get calibration object");
341     return 0;
342   }
343
344   if (!fGeo) {
345     fGeo = new AliTRDgeometry();
346   }
347   
348   fTimeBinsCalib = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
349   AliDebug(2, Form("Number of Timebins read from CDB: %d", fTimeBinsCalib));
350
351   // The number of data words needed for this number of time bins (there
352   // are 3 time bins in one word)
353   fTimeWords = (fTimeBinsCalib-1)/3 + 1;
354
355   fTbSwitch    = 3;
356   fTbSwitchCtr = 0;
357
358   fHCHctr1 = fHCHctr2 =  0;
359   fGTUctr1 = fGTUctr2 = -1;
360
361   fHCdataCtr = 0;
362   fWordCtr   = 0;  
363
364   fDET     = 0;
365   fLastDET     = -1;
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 }
381
382 //____________________________________________________________________________
383 Int_t AliTRDRawStream::NextData()
384 {
385   //
386   // Updates the next data word pointer
387   //
388
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;
400         }
401       else
402         {
403           fNextStatus = fkStop;
404           return fkNoMoreData;
405         }
406     }
407   else
408     {
409
410       fPos += kSizeWord;
411       fCountBytes += kSizeWord;   
412       fDataWord = (UInt_t*)fPos;
413       fWordCtr++;
414       return fkWordOK;
415     }
416 }
417
418 //____________________________________________________________________________
419 Bool_t AliTRDRawStream::Next()
420 {
421   //
422   // Updates the next data word pointer
423   //
424
425   if (fNextStatus == fkStart)
426     {
427       Init();
428     }
429
430   while (fNextStatus != fkStop)
431     { // !fkStop
432       NextData();
433       if (fNextStatus == fkNextMCM || fNextStatus == fkNextData)
434         {
435           fHCdataCtr += 4;
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;
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;
543             }
544         }
545
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!
556               fLastDET = fDET;
557               fDET    = fGeo->GetDetector(fLAYER, fSTACK, fSM);
558               fRowMax = fGeo->GetRowMax(fLAYER,fSTACK,fSM);
559               fColMax = fGeo->GetColMax(fROC);
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
576
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;
613 }
614
615 //____________________________________________________________________________
616 Int_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);
704                               track0->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
705                               track1->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
706                               track2->SetDataUnchecked(fROW, fCOL, fTB + it, 0);
707                             }
708                         } // check the tbins range
709                     } // for each tbin of current 3
710                   fTB += 3;             
711                 }// real pad                    
712               } // if fRetVal == 1
713             
714             // following ifs have been moved to DEcodeDatawordV1V2
715 //          if ( fADC > 1 && fADC < (Int_t)fGeo->ADCmax()-1 ) 
716 //            {       
717 //              // Write Digits
718 //              if ( fCOL >= 0 && fCOL < fColMax && fROW >= 0 && fROW < fRowMax ) 
719 //                {  // A real pad
720 //                  fTB += 3;           
721 //                  return kTRUE;
722 //                }            
723 //            }
724 //          else 
725 //            {
726 //              fCOL = -1;             
727 //            }
728             }// fkNextData  
729           
730 //        NextData(); // if while loop!
731           continue; //if if
732         } //next mcm
733
734       if ( fNextStatus == fkNextHC )
735         {
736           //
737           // 1) Find end_of_tracklet_marker
738           //
739           // GTU Link Mask?
740           if ( (*fDataWord & 0xfffff000) ==  0xe0000000 ) 
741             {
742               DecodeGTUlinkMask();
743               continue;
744             }
745           
746           // endoftrackletmarker?
747           if ( *fDataWord == kEndoftrackletmarker ) 
748             {
749               AliDebug(3, "end-of-tracklet-marker found");
750               fNextStatus = fkSeekNonEoTracklet;
751               continue;
752             } 
753           else 
754             {
755               // Tracklets found
756               AliDebug(3, "Tracklet found");
757               DecodeTracklet();
758               continue;
759             }
760         } //if next HC
761
762       if (fNextStatus == fkSeekNonEoTracklet)
763         {
764           //
765           // 2) Look for non-end_of_tracklet_marker
766           //
767           //printf("Word %d: 0x%08x\n", fWordCtr, *fDataWord); 
768
769           if ( *fDataWord != kEndoftrackletmarker ) 
770             {
771               fNextStatus = fkDecodeHC;
772               AliDebug(3, "NON end-of-tracklet-marker found");
773               //// no do not continue - this should be the hcheader
774             }
775           else
776             {
777               //just go on and find the non-end_of_tracklet_marker
778               continue;
779             }
780         }
781
782       if ( fNextStatus == fkDecodeHC )
783         {
784           AliDebug(3, "Decode HC");
785
786           //
787           // 3) This Word must be Half Chamber Header
788           //
789           if ( (*fDataWord & 0x00000003) == 1 ) 
790             { // HC header
791               DecodeHCheader(fTimeBinsCalib); // This is the new header!
792               fDET    = fGeo->GetDetector(fLAYER, fSTACK, fSM);
793               fRowMax = fGeo->GetRowMax(fLAYER,fSTACK,fSM);
794               fColMax = fGeo->GetColMax(fROC);
795
796               if (fLastDET != fDET)
797                 {
798                   AliDebug(4, "New DET!");            
799                   // allocate stuff for the new det
800                   digits = man->GetDigits(fDET);
801                   track0 = man->GetDictionary(fDET,0);
802                   track1 = man->GetDictionary(fDET,1);
803                   track2 = man->GetDictionary(fDET,2);
804                   
805                   // Allocate memory space for the digits buffer
806                   if (digits->GetNtime() == 0) 
807                     {
808                       AliDebug(4, "Allocating digits");       
809                       //AliDebug(5, Form("Alloc digits for det %d", det));
810                       digits->Allocate(fRowMax, fColMax, fTBins);
811                       track0->Allocate(fRowMax, fColMax, fTBins);
812                       track1->Allocate(fRowMax, fColMax, fTBins);
813                       track2->Allocate(fRowMax, fColMax, fTBins);
814                     }
815                   
816                   indexes = man->GetIndexes(fDET);
817                   indexes->SetSM(fSM);
818                   indexes->SetStack(fSTACK);
819                   indexes->SetLayer(fLAYER);
820                   indexes->SetDetNumber(fDET);
821                   
822                   if (indexes->IsAllocated() == kFALSE)
823                     {
824                       AliDebug(4, "Allocating indexes");              
825                       indexes->Allocate(fRowMax, fColMax, fTBins);
826                     }
827                   fLastDET = fDET;
828                 }
829               
830               fMCMHctr2 = 0;
831               fHCdataCtr = 0;
832               
833               fChamberDone[fDET]++;
834               fNextStatus = fkNextMCM;
835               AliDebug(3, "Decode HC OK");            
836               continue;
837             } //HC header
838           else
839             {
840               AliDebug(3, "Decode HC NOT OK");        
841               fNextStatus = fkNextSM;
842               continue;
843             }
844         } // if decode HC
845
846       if (fNextStatus == fkNextSM)
847         {
848           
849           fDET     = 0;
850           fRetVal = 0;
851           fEqID     = 0;
852           fDataSize = 0;
853           fSizeOK = kFALSE;
854           
855           // After reading the first word check for size of this data and get Eq. ID
856           if ( fWordCtr == 1 ) 
857             {
858               fDataSize = fRawReader->GetDataSize()/4;  // Size of this payload in 32bit words
859               fEqID     = fRawReader->GetEquipmentId(); // Get Equipment ID
860               if ( fDataSize > 0 ) fSizeOK = kTRUE;
861             }
862           
863           // GTU Link Mask?
864           if ( (*fDataWord & 0xfffff000) ==  0xe0000000 ) 
865             {
866               DecodeGTUlinkMask();
867               fNextStatus = fkNextHC;
868               continue;
869             } 
870           else 
871             {
872               AliWarning(Form("Equipment %d: First data word is not GTU Link Mask!", fEqID));
873               fRawReader->AddMajorErrorLog(kGTULinkMaskMissing,Form("Equipment %d",fEqID));
874               fNextStatus = fkStop;
875             }       
876         }// if nextSM
877
878     } // not fkStop
879
880   AliDebug(1, Form("That's all folks! %d", fSM));
881   //return kFALSE;
882   return -1;
883 }
884
885 //============================================================================
886 // Decoding functions
887 //============================================================================
888
889
890 //____________________________________________________________________________
891 void AliTRDRawStream::DecodeHCheader(Int_t timeBins)
892 {
893   //
894   // Decode the HC header (fRawVersion == 2, 3, 4, ???)
895   //
896
897   fRVmajor = (*fDataWord >> 24) & 0x7f;
898   fRVminor = (*fDataWord >> 17) & 0x7f;
899
900   if (fRVmajor < 2 || fRVmajor > 4)
901     AliError(Form(" Unsupported raw version: %d", fRawVersion))
902   
903   if ( fRawVersion != fRVmajor ) {
904     
905     AliWarning("===============================================================================");
906     AliWarning(Form("Mismatch between fRawVersion (%d) and fRVmajor from HC header (%d)"
907                     ,fRawVersion,fRVmajor));
908     AliWarning(Form("Setting fRawVersion to %d", fRVmajor));
909     AliWarning("===============================================================================");
910     fRawVersion = fRVmajor;
911
912   }
913
914   //
915   // check for zero suppression
916   if ( fRawVersion >= 3 || fRawVersion <= 4 ) fZeroSuppressed = kTRUE;
917   else                                        fZeroSuppressed = kFALSE;
918   
919   // 1st word (h[0])
920   if ( (*fDataWord & 0x3) == 1 ) {
921
922     fHCHWords = (*fDataWord >> 14) & 0x7;
923     fSM       = (*fDataWord >>  9) & 0x1f;
924     fLAYER    = (*fDataWord >>  6) & 0x7;
925     fSTACK    = (*fDataWord >>  3) & 0x7;
926     fSIDE     = (*fDataWord >>  2) & 0x1;
927
928     fROC      = fGeo->GetDetectorSec(fLAYER, fSTACK);
929
930     AliDebug(3, Form("0x%08x: HC header: sm=%d; roc=%d; side=%x", *fDataWord, fSM, fROC, fSIDE+10));
931
932     if ((fSM    <  0) || 
933         (fSM    > 17) || 
934         (fLAYER <  0) || 
935         (fLAYER >  5) || 
936         (fSTACK <  0) || 
937         (fSTACK >  4) || 
938         (fSIDE  <  0) || 
939         (fSIDE  >  1)) {
940       AliWarning(Form("0x%08x: Strange HC header: dcs=%d; sm=%d; layer=%d; stack=%d.",
941                      *fDataWord, fDCS, fSM, fLAYER, fSTACK));
942       fRawReader->AddMajorErrorLog(kHCHeaderCorrupt,Form("0x%08x:dcs=%d; sm=%d; layer=%d; stack=%d.",
943                                                          *fDataWord, fDCS, fSM, fLAYER, fSTACK));
944     } 
945     else {
946       fHCHctr1++;
947       fHCHctr2++;
948     }
949   } 
950   else { 
951     AliWarning(Form("0x%08x: No HC header when it was expected.", *fDataWord)); 
952     fRawReader->AddMajorErrorLog(kHCHeaderMissing,Form("0x%08x", *fDataWord));
953   }
954
955   // 2nd word (h[1])
956   if ( fHCHWords >= 1 ) {
957     // read one more word
958     if (NextData() != fkWordOK)
959       {
960         AliWarning("Next HC word missing");
961         fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word missing"); 
962         fNextStatus = fkNextHC;
963         return;
964       }
965     if ( (*fDataWord & 0x3) == 1 ) {
966       
967       fBCctr   =  (*fDataWord >> 16);
968       fPTctr   =  (*fDataWord >> 12) & 0xf;
969       fPTphase =  (*fDataWord >>  8) & 0xf;
970       fTBins   = ((*fDataWord >>  2) & 0x3f) + 1;
971
972       AliDebug(3, Form("0x%08x: HC header 2: BCctr=%d PTctr=%d PTph=%d TB=%d"
973                       , *fDataWord, fBCctr, fPTctr, fPTphase, fTBins));
974
975       if( fTBins != timeBins ) {
976
977         AliWarning("===============================================================================");
978         AliError(Form("Mismatch between nNTB from CDB (%d) and from HC header (%d)"
979                       , timeBins, fTBins));
980         AliWarning(Form("We will use the value from the raw data (HC header): %d", fTBins));
981         AliWarning("===============================================================================");
982
983         fTimeWords = (fTBins - 1)/3 + 1;        
984       }
985
986     }
987
988   }
989
990   // 3nd word (h[2])
991   if ( fHCHWords >= 2 ) {
992     // read one more word
993     if (NextData() != fkWordOK)
994       {
995         AliWarning("Next HC word missing");
996         fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word missing"); 
997         fNextStatus = fkNextHC;
998         return;
999       }
1000     if ( (*fDataWord & 0x3) == 1 ) {
1001        
1002       fTCon     = (*fDataWord >> 29) & 0x1;
1003       fPEDon    = (*fDataWord >> 31) & 0x1;
1004       fGAINon   = (*fDataWord >> 30) & 0x1;
1005       fXTon     = (*fDataWord >> 28) & 0x1;
1006       fNonLinOn = (*fDataWord >> 27) & 0x1;
1007       fBypass   = (*fDataWord >> 26) & 0x1;
1008
1009       fCommonAdditive = (*fDataWord >> 20) & 0x3f;
1010
1011       AliDebug(3, Form("0x%08x: HC header 3: TC=%d, PED=%d, GAIN=%d, XT=%d, NonLin=%d, Bypass=%d, Add=%d"
1012                       , fTCon, fPEDon, fGAINon, fXTon, fNonLinOn, fBypass, fCommonAdditive));
1013     }
1014   }
1015
1016 }  
1017
1018 //____________________________________________________________________________
1019 void AliTRDRawStream::DecodeMCMheader()
1020 {
1021
1022   //
1023   // Decode the MCM header
1024   //
1025
1026   if ( fRawVersion < 1 || fRawVersion > 3 ) 
1027     {
1028       AliError(Form(" Unsupported raw version: %d", fRawVersion));      
1029     }
1030
1031   fMCM  = (*fDataWord & 0xff000000) >> 24;
1032   fEv   = (*fDataWord & 0x00fffff0) >> 4;
1033
1034   fROB  = fMCM / 16;
1035   fMCM  = fMCM % 16;
1036
1037   fROW  = fGeo->GetPadRowFromMCM(fROB, fMCM);
1038
1039   AliDebug(4, Form("0x%08x: SM%d L%dS%d. MCM Header: fROB=%d fMCM=%02d fEv=%02d"
1040                   , *fDataWord, fSM, fLAYER, fSTACK, fROB, fMCM, fEv));
1041
1042   if ( fROB % 2 == 0 && fSIDE == 1 ) {
1043     AliWarning(Form("SM%d L%dS%d: Mismatch between fROB (%d) and fSIDE (%d): fMCM=%02d"
1044                    , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
1045     fRawReader->AddMajorErrorLog(kROBSideMismatch,Form("SM%d L%dS%d: fROB (%d) fSIDE (%d): fMCM=%02d"
1046                                                        , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
1047   }
1048   if ( fROB % 2 != 0 && fSIDE == 0 ) {
1049     AliWarning(Form("SM%d L%dS%d: Mismatch between fROB (%d) and fSIDE (%d): fMCM=%02d"
1050                    , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
1051     fRawReader->AddMajorErrorLog(kROBSideMismatch,Form("SM%d L%dS%d: fROB (%d) fSIDE (%d): fMCM=%02d"
1052                                                        , fSM, fLAYER, fSTACK, fROB, fSIDE, fMCM ));
1053   }
1054   if ( (fSTACK == 2 && fROW >= fGeo->RowmaxC0()) ||
1055        (fSTACK != 2 && fROW >= fGeo->RowmaxC1()) || fROW < 0 ) {
1056     AliWarning(Form("SM%d L%dS%d: Wrong Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
1057                    , fSM, fLAYER, fSTACK, fROW, fROB, fSIDE, fMCM ));
1058     fRawReader->AddMajorErrorLog(kWrongPadrow,Form("SM%d L%dS%d: Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
1059                                                   , fSM, fLAYER, fSTACK, fROW, fROB, fSIDE, fMCM ));
1060   }
1061   
1062   fMCMHctr1++;
1063   fMCMHctr2++;
1064
1065   // AdcMask for Zero supressed data
1066   if ( fRawVersion == 3 ) {
1067     // read one more word
1068     if (NextData() != fkWordOK)
1069       {
1070         AliWarning("MCM ADC mask missing");
1071         fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Missing"); 
1072         fNextStatus = fkNextHC;
1073         return;
1074       }
1075     if ( (*fDataWord & 0x000007ff) == 0xC ) {     // at the moment bits 4-10 are empty
1076       
1077       for ( Int_t ctr = 0; ctr < fGeo->ADCmax(); ctr++ ) {
1078         if ( (*fDataWord >> (11+ctr)) == 0x1 ) fADCmask[ctr] = kTRUE;
1079         else                                  fADCmask[ctr] = kFALSE;
1080       }
1081
1082       AliDebug(4, Form("0x%08x: ADC mask", *fDataWord));
1083
1084     }
1085     else {
1086       AliWarning("Expected ADC mask but did not find one!");
1087       fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Decode error"); 
1088     }
1089
1090   }
1091
1092 }
1093
1094 //____________________________________________________________________________
1095 void AliTRDRawStream::DecodeTracklet()
1096 {
1097
1098   //
1099   // Decode the Tracklet
1100   //
1101   // this function is not tested yet on real tracklets
1102   //
1103
1104   if ( fRawVersion < 1 || fRawVersion > 3 ) 
1105     {
1106       AliError(Form(" Unsupported raw version: %d", fRawVersion));      
1107     }
1108
1109   fTracklPID    = (*fDataWord >> 24) & 0xff;
1110   fTracklPadRow = (*fDataWord >> 20) & 0xf;    // 0:15
1111   fTracklDefL   = (*fDataWord >> 13) & 0x7f;
1112   fTracklPadPos = (*fDataWord)       & 0x1fff;
1113
1114   fTracklPID    /= (Float_t)((1<<8) - 1);                      // 0:1 (steps of 0.39%)
1115   fTracklDefL    = (fTracklDefL  - ((1<< 7)-1)/2.) * 140.e-4;  // -0.889:0.889cm 
1116   fTracklPadPos  = (fTracklPadPos - ((1<<13)-1)/2.) * 160.e-4; // -65.528:65.528 cm
1117
1118   //AliDebug(4, Form("0x%08x: Tracklet found: SM%d L%dS%d side %x: PadRow=%d PadPos=%f DefL=%f PID=%f"
1119   //              , *fDataWord, fSM, fLAYER, fSTACK, fSIDE+10
1120   //                , fTracklPadRow, fTracklPadPos, fTracklDefL, fTracklPID));
1121
1122   if( (fSTACK == 2) && (fTracklPadRow >= (Int_t) fGeo->RowmaxC0()) ||
1123       (fSTACK != 2) && (fTracklPadRow >= (Int_t) fGeo->RowmaxC1()) ) {
1124     AliWarning(Form("Strange Row read from Tracklet Word: %d", fTracklPadRow));
1125     fRawReader->AddMajorErrorLog(kTrackletRowMismatch,Form("Word: %d", fTracklPadRow));
1126   }
1127
1128 }
1129
1130 //____________________________________________________________________________
1131 void AliTRDRawStream::DecodeGTUlinkMask()
1132 {
1133
1134   //
1135   // Decode the link masks sent by the GTU. These marke the active optical links
1136   // between GTU and Super Module. Up to now only fully active links are found
1137   // (0xfff = 12 active links).
1138   //
1139
1140   if ( fRawVersion < 1 || fRawVersion > 3 ) 
1141     {
1142       AliError(Form(" Unsupported raw version: %d", fRawVersion));      
1143     }
1144
1145   if ( fGTUctr1 == -1 ) fGTUctr2++;
1146   fGTUctr1++;
1147
1148   if ( (fGTUctr1 >= 0) && (fGTUctr1 < 5) && (fGTUctr2 >= 0) && (fGTUctr2 < 18) ) {
1149     fGTUlinkMask[fGTUctr2][fGTUctr1] = (*fDataWord & 0xfff);
1150   }
1151
1152 }
1153
1154 //____________________________________________________________________________
1155 Int_t  AliTRDRawStream::DecodeDataWord()
1156 {
1157
1158   //
1159   // Decode the Data
1160   //
1161
1162   if      ( fRawVersion >= 1 && fRawVersion <= 2 ) {
1163     return DecodeDataWordV1V2();
1164   }
1165   else if ( fRawVersion >= 3 && fRawVersion <= 3 ) {
1166     return DecodeDataWordV3();
1167   }
1168
1169   AliError(Form(" Unsupported raw version: %d", fRawVersion));
1170   return -1;
1171
1172 }
1173
1174 //____________________________________________________________________________
1175 Int_t  AliTRDRawStream::DecodeDataWordV1V2()
1176 {
1177
1178   //
1179   // Decode the Data (full raw data. No zero suppression. 21 adc channels)
1180   //
1181   // return  0 means continue to next data word
1182   // return -1 means break data loop
1183   //
1184
1185 //   //  check the content first! - something wrong with that...
1186 //   // Decode 32 bit data words with information from 3 time bins and copy the data
1187 //   fSig[0] = (*fDataWord & 0x00000ffc) >> 2;
1188 //   fSig[1] = (*fDataWord & 0x003ff000) >> 12;
1189 //   fSig[2] = (*fDataWord & 0xffc00000) >> 22;  
1190 //   if (fSig[0] <= 0 && fSig[1] <= 0 && fSig[2] <= 0)
1191 //     return 0;
1192
1193   if ( (*fDataWord & 0x00000003) != 0x2 && (*fDataWord & 0x00000003) != 0x3) {
1194     //AliWarning(Form("Data %08x : Data Word ends neither with b11 nor b10", (Int_t)*fDataWord));
1195     fRawReader->AddMinorErrorLog(kDataMaskError,Form("Data %08x", (Int_t)*fDataWord));
1196     return -1;
1197   }
1198
1199   if ( (*fDataWord & 0x00000003) != fTbSwitch ) {    // Next ADC channel found
1200     fTbSwitch = (fTbSwitch & 2) | !(fTbSwitch & 1);   // 0x3 <--> 0x2
1201     fTbSwitchCtr = 0;
1202     fADC++;
1203     fTB=0;
1204   }
1205
1206   fTbSwitchCtr++; // Just read one word
1207
1208   // We have only timeTotal time bins
1209   if ( fTbSwitchCtr > fTimeWords ) {
1210     //AliWarning(Form("Data is strange. Already found %d words for this ADC channel", (Int_t)fTbSwitchCtr));
1211     fRawReader->AddMinorErrorLog(kADCNumberOverflow,Form("%d words", (Int_t)fTbSwitchCtr));
1212     return 0;
1213   }
1214
1215   // We have only 21 ADC channels.
1216   if ( fADC > (Int_t)fGeo->ADCmax()-1 ) {
1217     //AliWarning(Form("Data %08x : Data is strange. fADC is already %d", (Int_t)*fDataWord, (Int_t)fADC));
1218     fRawReader->AddMinorErrorLog(kADCChannelOverflow,Form("Data %08x : fADC=%d", (Int_t)*fDataWord, (Int_t)fADC));
1219     return 0;
1220   }
1221
1222   // There are 18 pads connected to each MCM ADC channels 2...19. The other channels cross to other
1223   // MCMs and are good for online tracking in the MCM.
1224   if ( fADC > 1 && fADC < (Int_t)fGeo->ADCmax()-1 ) {
1225
1226     // Get Pad column
1227     fCOL = fGeo->GetPadColFromADC(fROB, fMCM, fADC);
1228
1229     // We have only 144 Pad Columns
1230     //if ( fCOL > fColMax-1 || fCOL < 0 ) {
1231     if ( fCOL >= 0 && fCOL < fColMax && fROW >= 0 && fROW < fRowMax ) 
1232       {
1233         // Decode 32 bit data words with information from 3 time bins and copy the data
1234         fSig[0] = (*fDataWord & 0x00000ffc) >> 2;
1235         fSig[1] = (*fDataWord & 0x003ff000) >> 12;
1236         fSig[2] = (*fDataWord & 0xffc00000) >> 22;
1237         
1238         if (fSig[0] > 0 || fSig[1] > 0 || fSig[2] > 0)
1239           return 1;
1240         else
1241           return 0;
1242       }
1243     else
1244       {
1245 //      AliWarning(Form("SM%d L%dS%d: Wrong Pad column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
1246 //                      fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
1247         fRawReader->AddMajorErrorLog(kWrongPadcolumn,Form("SM%d L%dS%d: column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
1248                                                           fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
1249         return 0;
1250       }
1251     // Print data to screen:
1252     // Do NOT switch on for default production, it is VERY slow
1253     //    AliDebug(5, Form("SM%d L%dS%d: ROB%d MCM=%d ADC=%d (ROW=%d COL=%d): Data %04d %04d %04d\n",
1254     //               fSM, fLAYER, fSTACK, fROB, fMCM, fADC, fROW, fCOL, fSig[0], fSig[1], fSig[2]));
1255     
1256   }
1257   else {
1258     
1259     fCOL = -1;
1260     return 0;
1261   }
1262
1263   return 1;
1264
1265 }
1266
1267 //____________________________________________________________________________
1268 Int_t  AliTRDRawStream::DecodeDataWordV3()
1269 {
1270
1271   //
1272   // Decode the data (Zero suppresses data. 21 adc channels)
1273   //
1274   // return  0 means continue to next data word
1275   // return -1 means break data loop
1276   //
1277   // NOT TESTED YET!!!!!!!!
1278   //
1279
1280   if ( (*fDataWord & 0x00000003) != 0x2 && (*fDataWord & 0x00000003) != 0x3) {
1281     AliWarning(Form("Data %08x : Data Word ends neither with b11 nor b10", (Int_t)*fDataWord));
1282     fRawReader->AddMinorErrorLog(kDataMaskError,Form("Data %08x", (Int_t)*fDataWord));
1283     return -1;
1284   }
1285
1286   if ( (*fDataWord & 0x00000003) != fTbSwitch ) {    // Next ADC channel found
1287     fTbSwitch = (fTbSwitch & 2) | !(fTbSwitch & 1);   // 0x3 <--> 0x2
1288     fTbSwitchCtr = 0;
1289     //
1290     // Jump to next ADC channel that is not masked
1291     do {
1292       fADC++;
1293     } while ( ((fADC < fGeo->ADCmax()) && (fADCmask[fADC] == kFALSE)) || (fADC >= fGeo->ADCmax()) );
1294     fTB=0;
1295   }
1296
1297   fTbSwitchCtr++; // Just read one word
1298
1299   // We have only timeTotal time bins
1300   if ( fTbSwitchCtr > fTimeWords ) {
1301     AliWarning(Form("Data is strange. Already found %d words for this ADC channel", (Int_t)fTbSwitchCtr));
1302     fRawReader->AddMinorErrorLog(kADCNumberOverflow,Form("%d words", (Int_t)fTbSwitchCtr));
1303     return 0;
1304   }
1305
1306   // We have only 21 ADC channels.
1307   if ( fADC > (Int_t)fGeo->ADCmax()-1 ) {
1308     AliWarning(Form("Data %08x : Data is strange. fADC is already %d", (Int_t)*fDataWord, (Int_t)fADC));
1309     fRawReader->AddMinorErrorLog(kADCChannelOverflow,Form("Data %08x : fADC=%d", (Int_t)*fDataWord, (Int_t)fADC));
1310     return 0;
1311   }
1312
1313   // There are 18 pads connected to each MCM ADC channels 2...19. The other channels cross to other
1314   // MCMs and are good for online tracking in the MCM.
1315   if ( fADC > 1 && fADC < (Int_t)fGeo->ADCmax()-1 ) {
1316
1317     // Get Pad column
1318     fCOL = fGeo->GetPadColFromADC(fROB, fMCM, fADC);
1319
1320     // We have only 144 Pad Columns
1321     if ( fCOL > fColMax-1 || fCOL < 0 ) {
1322       AliWarning(Form("SM%d L%dS%d: Wrong Pad column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
1323                     fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
1324       fRawReader->AddMajorErrorLog(kWrongPadcolumn,Form("SM%d L%dS%d: column (%d) fROB=%d, fSIDE=%d, fMCM=%02d", fSM,
1325                     fLAYER, fSTACK, fCOL, fROB, fSIDE, fMCM ));
1326     }
1327
1328     // Decode 32 bit data words with information from 3 time bins and copy the data
1329     fSig[0] = (*fDataWord & 0x00000ffc) >> 2;
1330     fSig[1] = (*fDataWord & 0x003ff000) >> 12;
1331     fSig[2] = (*fDataWord & 0xffc00000) >> 22;
1332
1333     // Print data to screen:
1334     AliDebug(5, Form("SM%d L%dS%d: ROB%d MCM=%d ADC=%d (ROW=%d COL=%d): Data %04d %04d %04d\n",
1335                      fSM, fLAYER, fSTACK, fROB, fMCM, fADC, fROW, fCOL, fSig[0], fSig[1], fSig[2]));
1336     
1337   }
1338   else {
1339     
1340     fCOL = -1;
1341     
1342   }
1343
1344   return 1;
1345
1346 }