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