]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFRawStream.cxx
Added some memory cleaning
[u/mrichter/AliRoot.git] / TOF / AliTOFRawStream.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 /*
17 $Log$
18 Revision 1.19  2007/05/18 13:07:53  decaro
19 Error messages stored in the global raw-reader error log (Cvetan, Chiara)
20
21 Revision 1.18  2007/05/08 11:53:29  arcelli
22 Improved class flexibility for further use (R.Preghenella)
23
24 Revision 1.17  2007/05/03 08:53:50  decaro
25 Coding convention: RS3 violation -> suppression
26
27 Revision 1.16  2007/05/03 08:22:22  decaro
28 Coding convention: RN17 violation -> suppression
29
30 Revision 1.15  2007/04/30 15:22:06  arcelli
31 Change TOF digit Time, Tot etc to int type
32
33 Revision 1.14  2007/04/27 11:11:53  arcelli
34 updates for the new decoder
35
36 Revision 1.13  2007/03/16 11:46:35  decaro
37 Coding convention: RN17 rule violation -> suppression
38
39 Revision 1.12  2007/02/22 09:43:45  decaro
40 Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
41
42 Revision 1.11  2007/02/20 15:57:00  decaro
43 Raw data update: to read the TOF raw data defined in UNPACKED mode
44
45 Revision 1.10  2006/12/15 14:01:38  cvetan
46 Memory leak fixed
47
48 Revision 1.9  2006/10/13 11:22:27  arcelli
49 remove warnings due to uninitialized AliTOFtdcDigit data members
50
51 Revision 1.8  2006/08/22 13:30:17  arcelli
52 removal of effective c++ warnings (C.Zampolli)
53
54 Revision 1.7  2006/08/10 14:46:54  decaro
55 TOF raw data format: updated version
56
57 Revision 1.6.1  2006/06/28 A. De Caro, R. Preghenella:
58         Update TOF raw data format
59         according to the final version
60         (see the ALICE internal note in preparation
61          'ALICE TOF raw data format')
62         Added the methods for the correspoonding numbering
63          between the equipment IDs and the volume IDs:
64            Equip2VolNPlate(...)
65            Equip2VolNStrip(...)
66            Equip2VolNPad(...)
67
68 Revision 0.02  2005/07/28 A. De Caro:
69         Update format TOF raw data
70                (temporary solution) 
71         Correction of few wrong corrispondences
72                between 'software' and 'hardware' numberings
73
74 Revision 0.01  2005/07/22 A. De Caro
75         Implement methods Next()
76                           GetSector(),
77                           GetPlate(),
78                           GetStrip(),
79                           GetPadZ(),
80                           GetPadX()
81 */
82
83 ////////////////////////////////////////////////////////////////////////
84 //                                                                    //
85 //     This class provides access to TOF raw data in DDL files.       //
86 //                                                                    //
87 //      It loops over all TOF raw data given by the AliRawReader.     //
88 //                                                                    //
89 ////////////////////////////////////////////////////////////////////////
90
91
92 #include "TClonesArray.h"
93
94 #include "AliDAQ.h"
95 #include "AliLog.h"
96 #include "AliRawReader.h"
97
98 #include "AliTOFGeometry.h"
99 #include "AliTOFrawData.h"
100 #include "AliTOFRawMap.h"
101 #include "AliTOFRawStream.h"
102
103
104 ClassImp(AliTOFRawStream)
105
106
107 //_____________________________________________________________________________
108 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
109   fRawReader(rawReader),
110   //  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
111   fTOFrawData(0x0),
112   fDecoder(new AliTOFDecoder()),
113   fDDL(-1),
114   fTRM(-1),
115   fTRMchain(-1),
116   fTDC(-1),
117   fTDCchannel(-1),
118   fTime(-1),
119   fToT(-1),
120   fLeadingEdge(-1),
121   fTrailingEdge(-1),
122   fErrorFlag(-1),
123   fSector(-1),
124   fPlate(-1),
125   fStrip(-1),
126   fPadX(-1),
127   fPadZ(-1),
128   fPackedDigits(0),
129   fWordType(-1),
130   fSlotID(-1),
131   fACQ(-1),
132   fPSbit(-1),
133   fTDCerrorFlag(-1),
134   fInsideDRM(kFALSE),
135   fInsideTRM(kFALSE),
136   fInsideLTM(kFALSE),
137   fInsideTRMchain0(kFALSE),
138   fInsideTRMchain1(kFALSE)
139 {
140   //
141   // create an object to read TOF raw digits
142   //
143
144   for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
145     fDataBuffer[i]=new AliTOFHitDataBuffer();
146     fPackedDataBuffer[i]=new AliTOFHitDataBuffer();
147   }
148
149   fTOFrawData = new TClonesArray("AliTOFrawData",1000);
150   fTOFrawData->SetOwner();
151
152   fRawReader->Reset();
153   fRawReader->Select("TOF");
154 }
155
156 //_____________________________________________________________________________
157 AliTOFRawStream::AliTOFRawStream():
158   fRawReader(0x0), 
159   //  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
160   fTOFrawData(0x0),
161   fDecoder(new AliTOFDecoder()),
162   fDDL(-1),
163   fTRM(-1),
164   fTRMchain(-1),
165   fTDC(-1),
166   fTDCchannel(-1),
167   fTime(-1),
168   fToT(-1),
169   fLeadingEdge(-1),
170   fTrailingEdge(-1),
171   fErrorFlag(-1),
172   fSector(-1),
173   fPlate(-1),
174   fStrip(-1),
175   fPadX(-1),
176   fPadZ(-1),
177   fPackedDigits(0),
178   fWordType(-1),
179   fSlotID(-1),
180   fACQ(-1),
181   fPSbit(-1),
182   fTDCerrorFlag(-1),
183   fInsideDRM(kFALSE),
184   fInsideTRM(kFALSE),
185   fInsideLTM(kFALSE),
186   fInsideTRMchain0(kFALSE),
187   fInsideTRMchain1(kFALSE)
188 {
189   //
190   // default ctr
191   //
192   for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
193     fDataBuffer[i]=new AliTOFHitDataBuffer();
194     fPackedDataBuffer[i]=new AliTOFHitDataBuffer();
195   }
196
197   fTOFrawData = new TClonesArray("AliTOFrawData",1000);
198   fTOFrawData->SetOwner();
199 }
200
201 //_____________________________________________________________________________
202 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
203   TObject(stream),
204   fRawReader(0x0),
205   //  fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
206   fTOFrawData(0x0),
207   fDecoder(new AliTOFDecoder()),
208   fDDL(-1),
209   fTRM(-1),
210   fTRMchain(-1),
211   fTDC(-1),
212   fTDCchannel(-1),
213   fTime(-1),
214   fToT(-1),
215   fLeadingEdge(-1),
216   fTrailingEdge(-1),
217   fErrorFlag(-1),
218   fSector(-1),
219   fPlate(-1),
220   fStrip(-1),
221   fPadX(-1),
222   fPadZ(-1),
223   fPackedDigits(0),
224   fWordType(-1),
225   fSlotID(-1),
226   fACQ(-1),
227   fPSbit(-1),
228   fTDCerrorFlag(-1),
229   fInsideDRM(kFALSE),
230   fInsideTRM(kFALSE),
231   fInsideLTM(kFALSE),
232   fInsideTRMchain0(kFALSE),
233   fInsideTRMchain1(kFALSE)
234 {
235   //
236   // copy constructor
237   //
238
239   fRawReader = stream.fRawReader;
240
241   fTOFrawData = stream.fTOFrawData;
242
243   fDDL = stream.fDDL;
244   fTRM = stream.fTRM;
245   fTRMchain = stream.fTRMchain;
246   fTDC = stream.fTDC;
247   fTDCchannel = stream.fTDCchannel;
248   fTime = stream.fTime;
249   fToT = stream.fToT;
250   fLeadingEdge = stream.fLeadingEdge;
251   fTrailingEdge = stream.fTrailingEdge;
252
253   fErrorFlag = stream.fErrorFlag;
254
255   fSector = stream.fSector;
256   fPlate = stream.fPlate;
257   fStrip = stream.fStrip;
258   fPadX = stream.fPadX;
259   fPadZ = stream.fPadZ;
260
261   fPackedDigits = stream.fPackedDigits;
262
263   fWordType = stream.fWordType;
264   fSlotID = stream.fSlotID;
265   fACQ = stream.fACQ;
266   fPSbit = stream.fPSbit;
267   fTDCerrorFlag = stream.fTDCerrorFlag;
268   fInsideDRM = stream.fInsideDRM;
269   fInsideTRM = stream.fInsideTRM;
270   fInsideLTM = stream.fInsideLTM;
271   fInsideTRMchain0 = stream.fInsideTRMchain0;
272   fInsideTRMchain1 = stream.fInsideTRMchain1;
273
274   for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
275     fDataBuffer[i]= new AliTOFHitDataBuffer(*stream.fDataBuffer[i]);
276     fPackedDataBuffer[i]= new AliTOFHitDataBuffer(*stream.fPackedDataBuffer[i]);
277   }
278
279   fTOFrawData = new TClonesArray(*stream.fTOFrawData);
280   
281 }
282
283 //_____________________________________________________________________________
284 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
285 {
286   //
287   // assignment operator
288   //
289
290   fRawReader = stream.fRawReader;
291
292   fTOFrawData = stream.fTOFrawData;
293
294   fDDL = stream.fDDL;
295   fTRM = stream.fTRM;
296   fTRMchain = stream.fTRMchain;
297   fTDC = stream.fTDC;
298   fTDCchannel = stream.fTDCchannel;
299   fTime = stream.fTime;
300   fToT = stream.fToT;
301   fLeadingEdge = stream.fLeadingEdge;
302   fTrailingEdge = stream.fTrailingEdge;
303   fErrorFlag = stream.fErrorFlag;
304
305   fSector = stream.fSector;
306   fPlate = stream.fPlate;
307   fStrip = stream.fStrip;
308   fPadX = stream.fPadX;
309   fPadZ = stream.fPadZ;
310
311   fPackedDigits = stream.fPackedDigits;
312
313   fWordType = stream.fWordType;
314   fSlotID = stream.fSlotID;
315   fACQ = stream.fACQ;
316   fPSbit = stream.fPSbit;
317   fTDCerrorFlag = stream.fTDCerrorFlag;
318   fInsideDRM = stream.fInsideDRM;
319   fInsideTRM = stream.fInsideTRM;
320   fInsideLTM = stream.fInsideLTM;
321   fInsideTRMchain0 = stream.fInsideTRMchain0;
322   fInsideTRMchain1 = stream.fInsideTRMchain1;
323   
324   for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){ 
325     fDataBuffer[i] = stream.fDataBuffer[i];
326     fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
327   }
328   
329   fTOFrawData = stream.fTOFrawData;
330   
331   return *this;
332
333 }
334
335 //_____________________________________________________________________________
336 AliTOFRawStream::~AliTOFRawStream()
337 {
338 // destructor
339
340   fPackedDigits = 0;
341
342   for (Int_t i=0;i<72;i++){ 
343     delete fDataBuffer[i];
344     delete fPackedDataBuffer[i];
345   }
346
347   delete fDecoder;
348
349   fTOFrawData->Clear();
350   delete fTOFrawData;
351 }
352
353
354 //_____________________________________________________________________________
355
356 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
357 {
358
359   /*
360     for (Int_t indexDDL = 0;
361     indexDDL < AliDAQ::NumberOfDdls("TOF");
362     indexDDL++) {
363   */
364
365   fTOFrawData->Clear();
366   //fTOFrawData = new TClonesArray("AliTOFrawData",1000); //potential memory leak
367   //fTOFrawData->Clear();
368   TClonesArray &arrayTofRawData =  *fTOFrawData;
369
370   fPackedDigits = 0;
371
372   // create raw data map
373   AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
374   rawMap->Clear();
375
376   Int_t slot[4] = {-1, -1, -1, -1};
377
378   fRawReader->Reset();
379   fRawReader->Select("TOF", indexDDL, indexDDL);
380     
381   Bool_t signal = kFALSE;
382
383   AliTOFrawData *rawDigit = NULL;
384
385   while(Next()) {
386
387     signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
388     if (signal) {
389       //printf("  %2i  %1i  %2i  %1i  %2i  \n", fSector, fPlate, fStrip, fPadZ, fPadX);
390
391       slot[0] = fTRM;
392       slot[1] = fTRMchain;
393       slot[2] = fTDC;
394       slot[3] = fTDCchannel;
395
396       if (rawMap->TestHit(slot) != kEmpty) {
397
398         rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
399
400         if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
401             fLeadingEdge==-1 && fTrailingEdge!=-1) {
402
403           rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
404         }
405         else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
406                    (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
407
408 /*      else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
409                    (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/  /*||
410                   (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
411                   fLeadingEdge!=-1 && fTrailingEdge==-1) */)
412           {
413
414             //TClonesArray &arrayTofRawData =  *fTOFrawData;
415             new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
416
417             rawMap->SetHit(slot);
418
419           }
420
421
422       }
423       else {
424
425         //TClonesArray &arrayTofRawData =  *fTOFrawData;
426         new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
427
428         rawMap->SetHit(slot);
429
430       } // else if (rawMap->TestHit(slot) == kEmpty)
431
432     } // if (signal)
433
434   } // closed -> while (Next())
435
436     /*
437       fDDL  = fRawReader->GetDDLID();
438
439       for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
440
441       AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
442
443       fTRM = dummy->GetTRM();
444       fTRMchain = dummy->GetTRMchain();
445       fTDC = dummy->GetTDC();
446       fTDCchannel = dummy->GetTDCchannel();
447
448       SetSector();
449       SetPlate();
450       SetStrip();
451       SetPadZ();
452       SetPadX();
453
454       printf("  %2i, %2i %1i, %2i, %1i  -->  %2i, %1i, %2i, %1i, %2i  \n",
455              fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
456              fSector, fPlate, fStrip, fPadZ, fPadX);
457
458              } // closed loop on TOF raw data TClonesArray
459     */
460
461     //} // closed loop on indexDDL
462
463   rawMap->Delete();
464
465 }
466
467 //_____________________________________________________________________________
468 Bool_t AliTOFRawStream::Next()
469 {
470   //
471   // Read next 32-bit word in TOF raw data files
472   // returns kFALSE if there is no word left
473   //
474
475   UInt_t data;
476
477   if (!fRawReader->ReadNextInt(data)) return kFALSE;
478
479   if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
480     fSector = -1;
481     fPlate  = -1;
482     fStrip  = -1;
483     fPadZ   = -1;
484     fPadX   = -1;
485     fTime   = -1;
486     fToT    = -1;
487     fLeadingEdge  = -1;
488     fTrailingEdge = -1;
489   }
490
491   fDDL  = fRawReader->GetDDLID();
492
493   fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
494
495   switch (fWordType) { // switch word type
496
497   case GLOBAL_HEADER_TYPE: // global header
498     fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
499     fTRM = fSlotID;
500
501
502     switch (fSlotID) { // switch global header slot ID
503
504     case DRM_ID_NUMBER: //DRM global header
505       if (fInsideDRM) { // unexpected DRM global headers -> exit
506         break;
507       }
508       fInsideDRM = kTRUE; // DRM global header accepted
509       break;
510
511     case LTM_ID_NUMBER: // LTM global header
512       if (fInsideLTM) { // unexpected LTM global headers -> exit
513         break;
514       }
515       fInsideLTM = kTRUE; // LTM global header accepted
516       break;
517
518     case  3: //TRM header
519     case  4: //TRM header
520     case  5: //TRM header
521     case  6: //TRM header
522     case  7: //TRM header
523     case  8: //TRM header
524     case  9: //TRM header
525     case 10: //TRM header
526     case 11: //TRM header
527     case 12: //TRM header
528       if (fInsideTRM) { // unexpected TRM global headers -> exit
529         break;
530       }
531       fInsideTRM = kTRUE; // TRM global header accepted
532       fACQ =  GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
533       break;
534
535     default: // unexpected global header slot ID
536       break;
537
538     } //end switch global header slot id
539
540     break;
541
542
543   case GLOBAL_TRAILER_TYPE: // global trailer
544     fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
545     
546
547     switch (fSlotID) { // switch global trailer slot ID
548
549     case DRM_ID_NUMBER: // DRM global trailer
550       if (!fInsideDRM) { // unexpected DRM global trailers -> exit
551         break;
552       }
553       fInsideDRM = kFALSE; // DRM global trailer accepted
554       fInsideTRM = kFALSE;
555       fInsideLTM = kFALSE;
556       fInsideTRMchain0 = kFALSE;
557       fInsideTRMchain1 = kFALSE;
558       fSector = -1;
559       fPlate  = -1;
560       fStrip  = -1;
561       fPadZ   = -1;
562       fPadX   = -1;
563       fDDL        = -1;
564       fTRM        = -1;
565       fTDC        = -1;
566       fTRMchain   = -1;
567       fTDCchannel = -1;
568       fTime = -1;
569       fToT  = -1;
570       fLeadingEdge  = -1;
571       fTrailingEdge = -1;
572       fErrorFlag = -1;
573       fACQ   = -1;
574       fPSbit = -1;
575       fTDCerrorFlag = -1;
576       break;
577     case LTM_ID_NUMBER: // LTM global trailer
578       if (!fInsideLTM) { // unexpected LTM global trailer -> exit
579         break;
580       }
581       fInsideLTM = kFALSE; // LTM global trailer accepted
582       break;
583     case 15: //TRM global trailer
584       if (!fInsideTRM) { // unexpected TRM global trailers -> exit
585         break;
586       }
587       fInsideTRM = kFALSE; // TRM global trailer accepted
588       break;
589     default: // unexpected global trailer slot ID
590       break;
591     } //end switch global trailer slot id
592
593
594     break;
595
596
597   case ERROR_TYPE: // TDC error
598     fTDC          = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
599     fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
600     break;
601
602
603   case FILLER_TYPE: // filler
604     break;
605
606
607   default: // other word types
608
609     if (fInsideTRM) { // inside TRM
610
611       switch (fWordType) { // switch word type inside TRM
612       case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
613         if (fInsideTRMchain0) { // unexpected TRM chain0 header
614           break;
615         }
616         fInsideTRMchain0 = kTRUE;
617         fTRMchain = 0;
618         break;
619       case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
620         if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
621           break;
622         }
623         fInsideTRMchain0 = kFALSE;
624         fTRMchain = -1;
625         break;
626       case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
627         if (fInsideTRMchain1) { // unexpected TRM chain1 header
628           break;
629         }
630         fInsideTRMchain1 = kTRUE;
631         fTRMchain = 1;
632         break;
633       case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
634         if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
635           break;
636         }
637         fInsideTRMchain1 = kFALSE;
638         fTRMchain = -1;
639         break;
640       } // end switch word type inside TRM
641
642     } // end if (fInsideTRM)
643
644       
645     if (
646         ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1)) 
647         && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
648         && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
649         ){ // inside TRM chains
650
651       fPSbit      = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
652       fTDC        = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
653       fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
654       fErrorFlag  = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
655
656       SetSector();
657       SetPlate();
658       SetStrip();
659       SetPadZ();
660       SetPadX();
661
662
663       switch (fPSbit) { // switch fPSbit bits inside TRM chains
664
665       case 0: // packing ok, digit time and TOT
666         fToT  = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
667         fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
668         break;
669
670       case 1: // leading edge digit, long digit time, no TOT
671         //fToT  = -1;
672         //fTime  = -1;
673         fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
674         break;
675
676       case 2: // trailing edge digit, long digit time, no TOT
677         //fToT  = -1;
678         //fTime  = -1;
679         fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
680         break;
681
682       case 3: // TOT overflow
683         fToT  = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
684         fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
685         break;
686
687       } // end switch PS bits inside TRM chains
688
689     } // end if is inside TRM chains
690
691   } // end switch on fWordType
692
693
694   return kTRUE;
695   
696 }
697 //_____________________________________________________________________________
698
699 void AliTOFRawStream::SetSector()
700 {
701   //
702   // Evaluate the TOF sector number -> [ 0;17]
703   // corresponding to the TOF equipment IDs:
704   //                                  fDDL        -> [ 0;71]
705   //                                  fTRM        -> [ 3;12]
706   //                                  fTRMchain   -> [ 0; 1]
707   //                                  fTDC        -> [ 0;14]
708   //                                  fTDCchannel -> [ 0; 7]
709   //
710
711   Int_t iSector = -1;
712
713   if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
714
715   fSector = iSector;
716
717 }
718 //_____________________________________________________________________________
719
720
721 void AliTOFRawStream::SetPlate()
722 {
723   //
724   // Evaluate the TOF plate number ->[ 0; 4]
725   // corresponding to the TOF equipment IDs:
726   //                                  fDDL        -> [ 0;71]
727   //                                  fTRM        -> [ 3;12]
728   //                                  fTRMchain   -> [ 0; 1]
729   //                                  fTDC        -> [ 0;14]
730   //                                  fTDCchannel -> [ 0; 7]
731   //
732
733   Int_t iPlate = -1;
734   if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
735         || fSector==-1))
736     iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
737
738   fPlate = iPlate;
739
740 }
741 //_____________________________________________________________________________
742
743 void AliTOFRawStream::SetStrip()
744 {
745   //
746   // Evaluate the TOF strip number per module -> [ 0; 14/18]
747   // corresponding to the TOF equipment IDs:
748   //                                  fDDL        -> [ 0;71]
749   //                                  fTRM        -> [ 3;12]
750   //                                  fTRMchain   -> [ 0; 1]
751   //                                  fTDC        -> [ 0;14]
752   //                                  fTDCchannel -> [ 0; 7]
753   //
754
755   Int_t iStrip = -1;
756
757   if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
758         || fSector==-1 || fPlate==-1))
759     iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
760
761   fStrip = iStrip;
762
763 }
764 //_____________________________________________________________________________
765
766 void AliTOFRawStream::SetPadZ()
767 {
768   //
769   // Evaluate the TOF padRow number per strip -> [ 0; 1]
770   // corresponding to the TOF equipment IDs:
771   //                                  fDDL        -> [ 0;71]
772   //                                  fTRM        -> [ 3;12]
773   //                                  fTRMchain   -> [ 0; 1]
774   //                                  fTDC        -> [ 0;14]
775   //                                  fTDCchannel -> [ 0; 7]
776   //
777
778   Int_t iPadZ = -1;
779
780   if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
781         || fSector==-1 || fPlate==-1 || fStrip==-1))
782     {
783       Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
784       if (iPadAlongTheStrip!=-1)
785         iPadZ  = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
786     }
787
788   fPadZ = iPadZ;
789
790 }
791 //_____________________________________________________________________________
792
793 void AliTOFRawStream::SetPadX()
794 {
795   //
796   // Evaluate the TOF pad number per strip padRow -> [ 0;47]
797   // corresponding to the TOF equipment IDs:
798   //                                  fDDL        -> [ 0;71]
799   //                                  fTRM        -> [ 3;12]
800   //                                  fTRMchain   -> [ 0; 1]
801   //                                  fTDC        -> [ 0;14]
802   //                                  fTDCchannel -> [ 0; 7]
803   //
804
805   Int_t iPadX = -1;
806
807   if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
808         || fSector==-1 || fPlate==-1 || fStrip==-1))
809     {
810       Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
811       if (iPadAlongTheStrip!=-1)
812         iPadX  = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
813     }
814
815   fPadX = iPadX;
816
817 }
818
819 //----------------------------------------------------------------------------
820 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
821 {
822   // 
823   // 
824   // 
825
826   return ((word & fieldMask) >> fieldPosition);
827 }
828
829 //----------------------------------------------------------------------------
830 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const 
831 {
832   //
833   // Returns the TOF plate number [0;4]
834   // corresponding to the TOF equipment ID numbers:
835   //                          iDDL -> DDL number per sector [0;3]
836   //                          nTRM -> TRM number [3;12]
837   //                          nTDC -> TDC number [0;14]
838   //
839
840   Int_t iPlate = -1;
841   if (iDDL==0) {
842
843     if (nTRM>=4 && nTRM<7) {
844       iPlate = 0;
845     } else if (nTRM==7) {
846       if (nTDC<12) iPlate = 0;
847       else iPlate = 1;
848     } else if (nTRM>=8 && nTRM<11) {
849       iPlate = 1;
850     } else if (nTRM==11) {
851       if (nTDC<9) iPlate = 1;
852       else iPlate = 2;
853     }else if (nTRM==12) {
854       iPlate = 2;
855     } 
856
857   } else if (iDDL==1) {
858
859     if (nTRM==3) {
860       if (nTDC<3) iPlate = 0;
861     } else if (nTRM>=4 && nTRM<7) {
862       iPlate = 0;
863     } else if (nTRM==7) {
864       if (nTDC<6) iPlate = 1;
865       else iPlate = 0;
866     } else if (nTRM>=8 && nTRM<11) {
867       iPlate = 1;
868     } else if (nTRM==11) {
869       if (nTDC<9) iPlate = 2;
870       else iPlate = 1;
871     } else if (nTRM==12) {
872       iPlate = 2;
873     } 
874
875   } else if (iDDL==2) {
876
877     if (nTRM>=4 && nTRM<7) {
878       iPlate = 4;
879     } else if (nTRM==7) {
880       if (nTDC<12) iPlate = 4;
881       else iPlate = 3;
882     } else if (nTRM>=8 && nTRM<11) {
883       iPlate = 3;
884     } else if (nTRM==11) {
885       if (nTDC<9) iPlate = 3;
886       else iPlate = 2;
887     }else if (nTRM==12) {
888       iPlate = 2;
889     } 
890
891   }  else if (iDDL==3) {
892
893     if (nTRM==3) {
894       if (nTDC<3) iPlate = 4;
895     } else if (nTRM>=4 && nTRM<7) {
896       iPlate = 4;
897     } else if (nTRM==7) {
898       if (nTDC<6) iPlate = 3;
899       else iPlate = 4;
900     } else if (nTRM>=8 && nTRM<11) {
901       iPlate = 3;
902     } else if (nTRM==11) {
903       if (nTDC<9) iPlate = 2;
904       else iPlate = 3;
905     } else if (nTRM==12) {
906       iPlate = 2;
907     } 
908
909   }
910
911   return iPlate;
912
913 }
914
915 //----------------------------------------------------------------------------
916 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const 
917 {
918   //
919   // Returns the TOF strip number per module:
920   //                                [0;14], in the central plates,
921   //                                [0;18], in the intermediate and external plates
922   // corresponding to the TOF equipment ID numbers:
923   //                                iDDL -> DDL number per sector [0;3]
924   //                                nTRM -> TRM number [3;12]
925   //                                nTDC -> TDC number [0;14]
926   //
927
928   Int_t iStrip = -1;
929
930   if (iDDL==0) {
931
932     if (nTRM== 4) iStrip =  (Int_t)(nTDC/3.);
933     else if (nTRM== 5) iStrip =  5 + (Int_t)(nTDC/3.);
934     else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
935     else if (nTRM== 7) {
936       if (nTDC<12) iStrip =  15 + (Int_t)(nTDC/3.);
937       else iStrip = (Int_t)(nTDC/3.) -  4;
938     }
939     else if (nTRM== 8) iStrip =  1 + (Int_t)(nTDC/3.);
940     else if (nTRM== 9) iStrip =  6 + (Int_t)(nTDC/3.);
941     else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
942     else if (nTRM==11) {
943       if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
944       else iStrip = (Int_t)(nTDC/3.) -  3;
945     }
946     else if (nTRM==12) iStrip =  2 + (Int_t)(nTDC/3.);
947
948   } else if (iDDL==1) {
949
950     if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
951     else if (nTRM== 4) iStrip =  5 - (Int_t)(nTDC/3.);
952     else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
953     else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
954     else if (nTRM== 7) {
955       if (nTDC<6) iStrip =  1 - (Int_t)(nTDC/3.);
956       else iStrip = 20 - (Int_t)(nTDC/3.);
957     }
958     else if (nTRM== 8) iStrip =  6 - (Int_t)(nTDC/3.);
959     else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
960     else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
961     else if (nTRM==11) {
962       if (nTDC<9) iStrip =  2 - (Int_t)(nTDC/3.);
963       else iStrip = 21 - (Int_t)(nTDC/3.);
964     }
965     else if (nTRM==12) iStrip =  7 - (Int_t)(nTDC/3.);
966
967   } else if (iDDL==2) {
968
969     if (nTRM== 4) iStrip =  18 - (Int_t)(nTDC/3.);
970     else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
971     else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
972     else if (nTRM== 7) {
973       if (nTDC<12) iStrip =  18 - (15 + (Int_t)(nTDC/3.));
974       else iStrip = 18 - ((Int_t)(nTDC/3.) -  4);
975     }
976     else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
977     else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
978     else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
979     else if (nTRM==11) {
980       if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
981       else iStrip = 14 - ((Int_t)(nTDC/3.) -  3);
982     }
983     else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
984
985   } else if (iDDL==3) {
986
987     if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
988     else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
989     else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
990     else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
991     else if (nTRM== 7) {
992       if (nTDC<6) iStrip =  18 - (1 - (Int_t)(nTDC/3.));
993       else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
994     }
995     else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
996     else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
997     else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
998     else if (nTRM==11) {
999       if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1000       else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1001     }
1002     else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1003
1004   } 
1005
1006   return iStrip;
1007
1008 }
1009
1010 //----------------------------------------------------------------------------
1011 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1012                                 Int_t iCH) const 
1013 {
1014   //
1015   // Returns the TOF pad number per strip [0;95]
1016   // corresponding to the TOF equipment ID numbers:
1017   //                          iDDL -> DDL number per sector [0;3]
1018   //                        iChain -> TRM chain number [0;1]
1019   //                          nTDC -> TDC number [0;14]
1020   //                           iCH -> TDC channel number [0;7]
1021   //
1022
1023   Int_t iPadAlongTheStrip = -1;
1024
1025   Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1026
1027   if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1028   else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1029
1030   Int_t iCHlocal = iCH;
1031   if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1032
1033   iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1034
1035   if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1036       ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1037     fRawReader->AddMajorErrorLog(kPadXError);
1038     AliWarning("Problems with the padX number!");
1039   }
1040   return iPadAlongTheStrip;
1041
1042 }
1043
1044 //----------------------------------------------------------------------------
1045 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1046 {
1047   //
1048   // Returns the sector number [0;17]
1049   // corresponing to the assigned DRM/DDL number [0;71]
1050   //
1051
1052   Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1053
1054   return iSector;
1055
1056 }
1057 //----------------------------------------------------------------------------
1058 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1059 {
1060   //
1061   // Return the DRM/DDL number per sector [0;3]
1062   // corresponing to the assigned DRM/DDL number [0;71]
1063   //
1064
1065   Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1066
1067   return iDDL;
1068
1069 }
1070
1071 //----------------------------------------------------------------------------
1072 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1073 {
1074   EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1075 }
1076 //----------------------------------------------------------------------------
1077 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1078                                         Int_t nTDC, Int_t iCH,
1079                                         Int_t *volume) const
1080 {
1081   //
1082   // To convert:
1083   //            nDDL   (variable in [0;71]) -> number of the DDL file 
1084   //            nTRM   (variable in [3;12]) -> number of the TRM slot
1085   //            iChain (variable in [0; 1]) -> number of the TRM chain
1086   //            nTDC   (variable in [0;14]) -> number of the TDC
1087   //            iCH    (variable in [0; 7]) -> number of the TDC channel
1088   //
1089   // in:
1090   //      sector number, i.e. volume[0] (variable in [0,17])
1091   //      plate  number, i.e. volume[1] (variable in [0, 5])
1092   //      strip  number, i.e. volume[2] (variable in [0,14/18])
1093   //      padX   number, i.e. volume[3] (variable in [0,47])
1094   //      padZ   number, i.e. volume[4] (variable in [0, 1])
1095   //
1096
1097   Int_t iDDL = GetDDLnumberPerSector(nDDL);
1098
1099   Int_t iSector = GetSectorNumber(nDDL);
1100
1101   Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1102   if (iPlate==-1) {
1103     fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");
1104     AliWarning("Problems with the plate number!");
1105   }
1106
1107   Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1108   if (iStrip==-1) {
1109     fRawReader->AddMajorErrorLog(kStripError,"strip = -1");
1110     AliWarning("Problems with the strip number!");
1111   }
1112
1113   Int_t iPadAlongTheStrip  = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1114   if (iPadAlongTheStrip==-1){
1115     fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");
1116     AliWarning("Problems with the pad number along the strip!");
1117   }
1118
1119   Int_t iPadX  = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1120   Int_t iPadZ  = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1121
1122   volume[0] = iSector;
1123   volume[1] = iPlate;
1124   volume[2] = iStrip;
1125   volume[3] = iPadX;
1126   volume[4] = iPadZ;
1127
1128 }
1129 //-----------------------------------------------------------------------------
1130 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1131   //
1132   // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1133   //
1134
1135   //check and fix valid DDL range
1136   if (nDDLMin < 0){
1137     nDDLMin = 0;
1138     fRawReader->AddMinorErrorLog(kDDLMinError);
1139     AliWarning("Wrong DDL range: setting first DDL ID to 0");
1140   }
1141   if (nDDLMax > 71){
1142     nDDLMax = 71;
1143     fRawReader->AddMinorErrorLog(kDDLMaxError);
1144     AliWarning("Wrong DDL range: setting last DDL ID to 71");
1145   }  
1146
1147   //select required DDLs
1148   fRawReader->Select("TOF", nDDLMin, nDDLMax);
1149
1150   if (verbose)
1151     AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1152
1153   return(Decode(verbose));
1154 }
1155 //-----------------------------------------------------------------------------
1156 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1157   //
1158   // New decoder method
1159   //
1160
1161   Int_t currentEquipment;
1162   Int_t currentDDL;
1163
1164   //pointers
1165   UChar_t *data = 0x0;
1166   
1167   //loop and read DDL headers 
1168   while(fRawReader->ReadHeader()){
1169
1170     //memory leak prevention (actually data should be always 0x0 here)
1171     if (data != 0x0)
1172       delete [] data;
1173
1174     //get equipment infos
1175     currentEquipment = fRawReader->GetEquipmentId();
1176     currentDDL = fRawReader->GetDDLID();
1177     const Int_t kDataSize = fRawReader->GetDataSize();
1178     const Int_t kDataWords = kDataSize / 4;
1179     data = new UChar_t[kDataSize];
1180     
1181     if (verbose)
1182       AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1183     
1184     if (verbose)
1185       AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1186     
1187     //read equipment payload
1188     if (!fRawReader->ReadNext(data, kDataSize))
1189       {
1190         fRawReader->AddMajorErrorLog(kDDLdataReading);
1191         if (verbose)
1192           AliWarning("Error while reading DDL data. Go to next equipment");
1193         delete [] data;
1194         data = 0x0;
1195         continue;
1196       }
1197     
1198     if (verbose)
1199       AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1200     
1201     
1202     //set up the decoder
1203     fDecoder->SetVerbose(verbose);
1204     fDecoder->SetDataBuffer(fDataBuffer[currentDDL]);
1205     fDecoder->SetPackedDataBuffer(fPackedDataBuffer[currentDDL]);
1206     
1207     //start decoding
1208     if (fDecoder->Decode((UInt_t *)data, kDataWords) == kTRUE) {
1209       fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1210       AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1211     }
1212     
1213     delete [] data;
1214     data = 0x0;
1215   }
1216   
1217   //reset reader
1218   fRawReader->Reset();
1219
1220   if (verbose)
1221     AliInfo("All done");
1222     
1223   return kFALSE;
1224   
1225 }
1226 //---------------------------------------------------------------------------
1227 void
1228 AliTOFRawStream::ResetBuffers()
1229 {
1230   //
1231   // To reset the buffers
1232   //
1233
1234   for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1235     ResetDataBuffer(iDDL);
1236     ResetPackedDataBuffer(iDDL);
1237   }
1238 }
1239   
1240 //---------------------------------------------------------------------------
1241 Bool_t
1242 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1243 {
1244   //
1245   // To load the buffers
1246   //
1247
1248   fTOFrawData->Clear();
1249   fPackedDigits = 0;
1250   
1251   if (verbose > 0)
1252     AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1253
1254   if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1255     fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1256     AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1257     return kTRUE;
1258   }
1259   
1260   if (verbose > 0)
1261     AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL]->GetEntries(), fPackedDataBuffer[indexDDL]->GetEntries() > 1 ? "hits have" : "hit has"));
1262   
1263   AliTOFHitData *hitData; //hit data pointer
1264   
1265   if (verbose > 0)
1266     AliInfo("Filling TClonesArray ...");
1267
1268   //loop over DDL packed hits
1269   for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL]->GetEntries(); iHit++){
1270     hitData = fPackedDataBuffer[indexDDL]->GetHit(iHit); //get hit data
1271     Int_t   hitACQ = hitData->GetACQ();
1272     Int_t   hitPS = hitData->GetPS();
1273     Int_t   hitSlotID = hitData->GetSlotID();
1274     Int_t   hitChain = hitData->GetChain();
1275     Int_t   hitTDC = hitData->GetTDC();
1276     Int_t   hitChan = hitData->GetChan();
1277     Int_t   hitTimeBin = hitData->GetTimeBin();
1278     Int_t   hitTOTBin = hitData->GetTOTBin();
1279     
1280     Int_t hitLeading = -1;
1281     Int_t hitTrailing = -1;
1282     Int_t hitError = -1;
1283     
1284     TClonesArray &arrayTofRawData =  *fTOFrawData;
1285     new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
1286   }
1287
1288   if (verbose > 0)
1289     AliInfo("Done.");
1290
1291   if (verbose > 0)
1292     AliInfo("Resetting buffers ...");
1293
1294   fDataBuffer[indexDDL]->Reset();
1295   fPackedDataBuffer[indexDDL]->Reset();
1296
1297   if (verbose > 0)
1298     AliInfo("Done.");
1299
1300   return kFALSE;
1301 }
1302