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