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