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