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