1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 Added lookup tables for
20 TRM number 3 in the left crates (TOF OR signals)
21 and detector elements (A.Silenzi)
23 Revision 1.19.1 2008/09/19 preghenella
24 Decode method updated:
25 it reads the CDH from the rawReader and sends it to the decoder;
26 LoadRawDataBuffers modified:
27 it corrects tof hit infos per ddlBC and deltaBC offsets
28 (in case of the static member fgApplyBCCorrections
29 has been setted to kTRUE);
30 Added static member fgApplyBCCorrections (kTRUE by default)
31 and the related static method ApplyBCCorrections;
33 Revision 1.19 2007/05/18 13:07:53 decaro
34 Error messages stored in the global raw-reader error log (Cvetan, Chiara)
36 Revision 1.18 2007/05/08 11:53:29 arcelli
37 Improved class flexibility for further use (R.Preghenella)
39 Revision 1.17 2007/05/03 08:53:50 decaro
40 Coding convention: RS3 violation -> suppression
42 Revision 1.16 2007/05/03 08:22:22 decaro
43 Coding convention: RN17 violation -> suppression
45 Revision 1.15 2007/04/30 15:22:06 arcelli
46 Change TOF digit Time, Tot etc to int type
48 Revision 1.14 2007/04/27 11:11:53 arcelli
49 updates for the new decoder
51 Revision 1.13 2007/03/16 11:46:35 decaro
52 Coding convention: RN17 rule violation -> suppression
54 Revision 1.12 2007/02/22 09:43:45 decaro
55 Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
57 Revision 1.11 2007/02/20 15:57:00 decaro
58 Raw data update: to read the TOF raw data defined in UNPACKED mode
60 Revision 1.10 2006/12/15 14:01:38 cvetan
63 Revision 1.9 2006/10/13 11:22:27 arcelli
64 remove warnings due to uninitialized AliTOFtdcDigit data members
66 Revision 1.8 2006/08/22 13:30:17 arcelli
67 removal of effective c++ warnings (C.Zampolli)
69 Revision 1.7 2006/08/10 14:46:54 decaro
70 TOF raw data format: updated version
72 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
73 Update TOF raw data format
74 according to the final version
75 (see the ALICE internal note in preparation
76 'ALICE TOF raw data format')
77 Added the methods for the correspoonding numbering
78 between the equipment IDs and the volume IDs:
83 Revision 0.02 2005/07/28 A. De Caro:
84 Update format TOF raw data
86 Correction of few wrong corrispondences
87 between 'software' and 'hardware' numberings
89 Revision 0.01 2005/07/22 A. De Caro
90 Implement methods Next()
98 ////////////////////////////////////////////////////////////////////////
100 // This class provides access to TOF raw data in DDL files. //
102 // It loops over all TOF raw data given by the AliRawReader. //
104 ////////////////////////////////////////////////////////////////////////
107 #include "Riostream.h"
109 #include "TClonesArray.h"
110 #include "TStopwatch.h"
114 #include "AliRawReader.h"
116 #include "AliTOFGeometry.h"
117 #include "AliTOFrawData.h"
118 #include "AliTOFRawMap.h"
119 #include "AliTOFRawStream.h"
120 #include "AliTOFdigit.h"
121 #include "AliTOFSDigit.h"
122 //#include "AliTOFCableLengthMap.h"
124 #include "AliTOFHitData.h"
126 #include "AliRawEventHeaderBase.h"
127 #include "AliRawDataHeader.h"
129 ClassImp(AliTOFRawStream)
131 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
153 const Int_t AliTOFRawStream::fgkStrip0MapCrate0[]=
154 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
155 const Int_t AliTOFRawStream::fgkStrip1MapCrate0[]=
156 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
157 const Int_t AliTOFRawStream::fgkStrip0MapCrate1[]=
158 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
159 const Int_t AliTOFRawStream::fgkStrip1MapCrate1[]=
160 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
161 const Int_t AliTOFRawStream::fgkStrip0MapCrate2[]=
162 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
163 const Int_t AliTOFRawStream::fgkStrip1MapCrate2[]=
164 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
165 const Int_t AliTOFRawStream::fgkStrip0MapCrate3[]=
166 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
167 const Int_t AliTOFRawStream::fgkStrip1MapCrate3[]=
168 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
171 const Int_t AliTOFRawStream::fgkModule0MapCrate0[]=
172 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
173 const Int_t AliTOFRawStream::fgkModule1MapCrate0[]=
174 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
175 const Int_t AliTOFRawStream::fgkModule0MapCrate1[]=
176 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
177 const Int_t AliTOFRawStream::fgkModule1MapCrate1[]=
178 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
180 const Int_t AliTOFRawStream::fgkModule0MapCrate2[]=
181 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
182 const Int_t AliTOFRawStream::fgkModule1MapCrate2[]=
183 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
184 const Int_t AliTOFRawStream::fgkModule0MapCrate3[]=
185 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
186 const Int_t AliTOFRawStream::fgkModule1MapCrate3[]=
187 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
189 const Int_t AliTOFRawStream::fgkChannelMap0[5][19]=
190 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
191 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
192 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
193 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
194 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
197 const Int_t AliTOFRawStream::fgkChainMap0[5][19]=
198 {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
199 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
200 {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,-1,-1,-1,-1},
201 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
202 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
205 const Int_t AliTOFRawStream::fgkChannelMap24[5][19]=
206 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
207 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
208 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
209 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
210 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
213 const Int_t AliTOFRawStream::fgkChainMap24[5][19]=
214 {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
215 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
216 {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,-1,-1,-1,-1},
217 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
218 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
221 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
222 //_____________________________________________________________________________
223 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
224 fRawReader(rawReader),
225 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
226 fDecoder(new AliTOFDecoder()),
251 fInsideTRMchain0(kFALSE),
252 fInsideTRMchain1(kFALSE),
254 //fPackedDataBuffer(),
255 fLocalEventCounterDRM(-1),
256 fLocalEventCounterLTM(-1),
257 //fLocalEventCounterTRM(),
258 //fLocalEventCounterChain(),
260 //fCableLengthMap(new AliTOFCableLengthMap()),
262 fNewDecoderVersion(0)
265 // create an object to read TOF raw digits
268 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
270 ResetPackedDataBuffer(i);
273 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
274 fTOFrawData->SetOwner();
277 fRawReader->Select("TOF");
279 for (Int_t jj=0;jj<13;jj++) {
280 fLocalEventCounterTRM[jj] = -1;
281 for (Int_t ii=0;ii<2;ii++) {
282 fLocalEventCounterChain[jj][ii] = -1;
283 fChainBunchID[jj][ii] = -1;
289 //_____________________________________________________________________________
290 AliTOFRawStream::AliTOFRawStream():
292 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
293 fDecoder(new AliTOFDecoder()),
318 fInsideTRMchain0(kFALSE),
319 fInsideTRMchain1(kFALSE),
321 //fPackedDataBuffer(),
322 fLocalEventCounterDRM(-1),
323 fLocalEventCounterLTM(-1),
324 //fLocalEventCounterTRM(),
325 //fLocalEventCounterChain(),
327 //fCableLengthMap(new AliTOFCableLengthMap()),
329 fNewDecoderVersion(0)
334 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
336 ResetPackedDataBuffer(i);
339 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
340 fTOFrawData->SetOwner();
342 for (Int_t j=0;j<13;j++){
343 fLocalEventCounterTRM[j] = -1;
344 for (Int_t k=0;k<2;k++){
345 fLocalEventCounterChain[j][k] = -1;
346 fChainBunchID[j][k] = -1;
352 //_____________________________________________________________________________
353 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
355 fRawReader(stream.fRawReader),
356 fTOFrawData(stream.fTOFrawData),
357 fDecoder(new AliTOFDecoder()),
360 fTRMchain(stream.fTRMchain),
362 fTDCchannel(stream.fTDCchannel),
365 fLeadingEdge(stream.fLeadingEdge),
366 fTrailingEdge(stream.fTrailingEdge),
367 fErrorFlag(stream.fErrorFlag),
368 fSector(stream.fSector),
369 fPlate(stream.fPlate),
370 fStrip(stream.fStrip),
373 fPackedDigits(stream.fPackedDigits),
374 fWordType(stream.fWordType),
375 fSlotID(stream.fSlotID),
377 fPSbit(stream.fPSbit),
378 fTDCerrorFlag(stream.fTDCerrorFlag),
379 fInsideDRM(stream.fInsideDRM),
380 fInsideTRM(stream.fInsideTRM),
381 fInsideLTM(stream.fInsideLTM),
382 fInsideTRMchain0(stream.fInsideTRMchain0),
383 fInsideTRMchain1(stream.fInsideTRMchain1),
385 //fPackedDataBuffer(),
386 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
387 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
388 //fLocalEventCounterTRM(),
389 //fLocalEventCounterChain(),
391 //fCableLengthMap(stream.fCableLengthMap),
392 fEventID(stream.fEventID),
393 fNewDecoderVersion(stream.fNewDecoderVersion)
399 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
400 fDataBuffer[i] = stream.fDataBuffer[i];
401 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
404 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
406 for (Int_t j=0;j<13;j++){
407 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
408 for (Int_t k=0;k<2;k++){
409 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
410 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
416 //_____________________________________________________________________________
417 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
420 // assignment operator
426 TObject::operator=(stream);
428 fRawReader = stream.fRawReader;
430 fTOFrawData = stream.fTOFrawData;
434 fTRMchain = stream.fTRMchain;
436 fTDCchannel = stream.fTDCchannel;
437 fTime = stream.fTime;
439 fLeadingEdge = stream.fLeadingEdge;
440 fTrailingEdge = stream.fTrailingEdge;
441 fErrorFlag = stream.fErrorFlag;
443 fSector = stream.fSector;
444 fPlate = stream.fPlate;
445 fStrip = stream.fStrip;
446 fPadX = stream.fPadX;
447 fPadZ = stream.fPadZ;
449 fPackedDigits = stream.fPackedDigits;
451 fWordType = stream.fWordType;
452 fSlotID = stream.fSlotID;
454 fPSbit = stream.fPSbit;
455 fTDCerrorFlag = stream.fTDCerrorFlag;
456 fInsideDRM = stream.fInsideDRM;
457 fInsideTRM = stream.fInsideTRM;
458 fInsideLTM = stream.fInsideLTM;
459 fInsideTRMchain0 = stream.fInsideTRMchain0;
460 fInsideTRMchain1 = stream.fInsideTRMchain1;
462 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
463 fDataBuffer[i] = stream.fDataBuffer[i];
464 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
467 fTOFrawData = stream.fTOFrawData;
469 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
470 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
471 for (Int_t j=0;j<13;j++){
472 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
473 for (Int_t k=0;k<2;k++){
474 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
475 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
479 //fCableLengthMap = stream.fCableLengthMap;
481 fEventID = stream.fEventID;
482 fNewDecoderVersion = stream.fNewDecoderVersion;
488 //_____________________________________________________________________________
489 AliTOFRawStream::~AliTOFRawStream()
497 fTOFrawData->Clear();
500 //delete fCableLengthMap;
505 //_____________________________________________________________________________
507 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
513 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
515 fTOFrawData->Clear();
517 TClonesArray &arrayTofRawData = *fTOFrawData;
521 // create raw data map
522 AliTOFRawMap rawMap(fTOFrawData);
525 Int_t slot[4] = {-1, -1, -1, -1};
527 fLocalEventCounterDRM = -1;
528 fLocalEventCounterLTM = -1;
529 for (Int_t ii=0; ii<13; ii++)
530 fLocalEventCounterTRM[ii] = -1;
531 for (Int_t ii=0; ii<13; ii++)
532 for (Int_t jj=0; jj<2; jj++) {
533 fLocalEventCounterChain[ii][jj] = -1;
534 fChainBunchID[ii][jj] = -1;
538 fRawReader->Select("TOF", indexDDL, indexDDL);
540 Bool_t signal = kFALSE;
542 AliTOFrawData *rawDigit = NULL;
546 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
548 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
553 slot[3] = fTDCchannel;
555 if (rawMap.TestHit(slot) != kEmpty) {
557 rawDigit = static_cast<AliTOFrawData*>(rawMap.GetHit(slot));
559 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
560 fLeadingEdge==-1 && fTrailingEdge!=-1) {
562 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
564 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
565 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
570 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
580 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
584 } // else if (rawMap.TestHit(slot) == kEmpty)
588 } // closed -> while (Next())
592 //_____________________________________________________________________________
593 Bool_t AliTOFRawStream::Next()
596 // Read next 32-bit word in TOF raw data files
597 // returns kFALSE if there is no word left
604 if (!fRawReader->ReadNextInt(data)) return kFALSE;
606 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
618 fDDL = fRawReader->GetDDLID();
620 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
622 switch (fWordType) { // switch word type
624 case GLOBAL_HEADER_TYPE: // global header
625 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
629 switch (fSlotID) { // switch global header slot ID
631 case DRM_ID_NUMBER: //DRM global header
632 if (fInsideDRM) { // unexpected DRM global headers -> exit
635 fInsideDRM = kTRUE; // DRM global header accepted
638 case LTM_ID_NUMBER: // LTM global header
639 if (fInsideLTM) { // unexpected LTM global headers -> exit
642 fInsideLTM = kTRUE; // LTM global header accepted
652 case 10: //TRM header
653 case 11: //TRM header
654 case 12: //TRM header
655 if (fInsideTRM) { // unexpected TRM global headers -> exit
658 fInsideTRM = kTRUE; // TRM global header accepted
659 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
662 default: // unexpected global header slot ID
665 } //end switch global header slot id
670 case GLOBAL_TRAILER_TYPE: // global trailer
671 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
673 switch (fSlotID) { // switch global trailer slot ID
675 case DRM_ID_NUMBER: // DRM global trailer
676 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
680 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
681 fLocalEventCounterDRM = GetField(data,dummy,4);
682 fInsideDRM = kFALSE; // DRM global trailer accepted
685 fInsideTRMchain0 = kFALSE;
686 fInsideTRMchain1 = kFALSE;
706 case LTM_ID_NUMBER: // LTM global trailer
707 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
711 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
712 fLocalEventCounterLTM = GetField(data,dummy,16);
713 fInsideLTM = kFALSE; // LTM global trailer accepted
715 case 15: //TRM global trailer
716 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
720 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
721 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
722 fInsideTRM = kFALSE; // TRM global trailer accepted
724 default: // unexpected global trailer slot ID
726 } //end switch global trailer slot id
732 case ERROR_TYPE: // TDC error
733 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
734 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
738 case FILLER_TYPE: // filler
742 default: // other word types
744 if (fInsideTRM) { // inside TRM
746 switch (fWordType) { // switch word type inside TRM
747 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
748 if (fInsideTRMchain0) { // unexpected TRM chain0 header
751 fInsideTRMchain0 = kTRUE;
754 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
755 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
757 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
758 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
762 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
763 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
764 fInsideTRMchain0 = kFALSE;
767 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
768 if (fInsideTRMchain1) { // unexpected TRM chain1 header
771 fInsideTRMchain1 = kTRUE;
774 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
775 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
777 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
778 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
782 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
783 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
784 fInsideTRMchain1 = kFALSE;
787 } // end switch word type inside TRM
789 } // end if (fInsideTRM)
793 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
794 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
795 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
796 ){ // inside TRM chains
798 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
799 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
800 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
801 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
810 switch (fPSbit) { // switch fPSbit bits inside TRM chains
812 case 0: // packing ok, digit time and TOT
813 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
814 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
816 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
818 if (fgApplyBCCorrections) {
819 AliDebug(2,"Apply nominal DDL BC time-shift correction");
820 AliDebug(2,"Apply deltaBC time-shift correction");
821 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
822 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
826 case 1: // leading edge digit, long digit time, no TOT
829 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
831 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
833 if (fgApplyBCCorrections) {
834 AliDebug(2,"Apply nominal DDL BC time-shift correction");
835 AliDebug(2,"Apply deltaBC time-shift correction");
836 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
837 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
841 case 2: // trailing edge digit, long digit time, no TOT
844 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
846 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
848 if (fgApplyBCCorrections) {
849 AliDebug(2,"Apply nominal DDL BC time-shift correction");
850 AliDebug(2,"Apply deltaBC time-shift correction");
851 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
852 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
856 case 3: // TOT overflow
857 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
858 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
860 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
862 if (fgApplyBCCorrections) {
863 AliDebug(2,"Apply nominal DDL BC time-shift correction");
864 AliDebug(2,"Apply deltaBC time-shift correction");
865 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
866 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
870 } // end switch PS bits inside TRM chains
872 } // end if is inside TRM chains
874 } // end switch on fWordType
880 //_____________________________________________________________________________
882 void AliTOFRawStream::SetSector()
885 // Evaluate the TOF sector number -> [ 0;17]
886 // corresponding to the TOF equipment IDs:
889 // fTRMchain -> [ 0; 1]
891 // fTDCchannel -> [ 0; 7]
896 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
901 //_____________________________________________________________________________
904 void AliTOFRawStream::SetPlate()
907 // Evaluate the TOF plate number ->[ 0; 4]
908 // corresponding to the TOF equipment IDs:
911 // fTRMchain -> [ 0; 1]
913 // fTDCchannel -> [ 0; 7]
917 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
919 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
924 //_____________________________________________________________________________
926 void AliTOFRawStream::SetStrip()
929 // Evaluate the TOF strip number per module -> [ 0; 14/18]
930 // corresponding to the TOF equipment IDs:
933 // fTRMchain -> [ 0; 1]
935 // fTDCchannel -> [ 0; 7]
940 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
941 || fSector==-1 || fPlate==-1))
942 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
947 //_____________________________________________________________________________
949 void AliTOFRawStream::SetPadZ()
952 // Evaluate the TOF padRow number per strip -> [ 0; 1]
953 // corresponding to the TOF equipment IDs:
956 // fTRMchain -> [ 0; 1]
958 // fTDCchannel -> [ 0; 7]
963 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
964 || fSector==-1 || fPlate==-1 || fStrip==-1))
966 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
967 if (iPadAlongTheStrip!=-1)
968 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
971 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
972 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
977 //_____________________________________________________________________________
979 void AliTOFRawStream::SetPadX()
982 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
983 // corresponding to the TOF equipment IDs:
986 // fTRMchain -> [ 0; 1]
988 // fTDCchannel -> [ 0; 7]
993 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
994 || fSector==-1 || fPlate==-1 || fStrip==-1))
996 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
997 if (iPadAlongTheStrip!=-1)
998 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1001 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
1002 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1008 //----------------------------------------------------------------------------
1009 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1012 // Returns 'word' masked by 'fieldMask' and shifted by 'fieldPosition'
1015 return ((word & fieldMask) >> fieldPosition);
1018 //----------------------------------------------------------------------------
1019 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1022 // Returns the TOF plate number [0;4]
1023 // corresponding to the TOF equipment ID numbers:
1024 // iDDL -> DDL number per sector [0;3]
1025 // nTRM -> TRM number [3;12]
1026 // nTDC -> TDC number [0;14]
1033 if (nTRM>=4 && nTRM<7) {
1035 } else if (nTRM==7) {
1036 if (nTDC<12) iPlate = 0;
1038 } else if (nTRM>=8 && nTRM<11) {
1040 } else if (nTRM==11) {
1041 if (nTDC<9) iPlate = 1;
1043 }else if (nTRM==12) {
1047 } else if (iDDL==1) {
1050 if (nTDC<3) iPlate = 0;
1051 } else if (nTRM>=4 && nTRM<7) {
1053 } else if (nTRM==7) {
1054 if (nTDC<6) iPlate = 1;
1056 } else if (nTRM>=8 && nTRM<11) {
1058 } else if (nTRM==11) {
1059 if (nTDC<9) iPlate = 2;
1061 } else if (nTRM==12) {
1065 } else if (iDDL==2) {
1067 if (nTRM>=4 && nTRM<7) {
1069 } else if (nTRM==7) {
1070 if (nTDC<12) iPlate = 4;
1072 } else if (nTRM>=8 && nTRM<11) {
1074 } else if (nTRM==11) {
1075 if (nTDC<9) iPlate = 3;
1077 }else if (nTRM==12) {
1081 } else if (iDDL==3) {
1084 if (nTDC<3) iPlate = 4;
1085 } else if (nTRM>=4 && nTRM<7) {
1087 } else if (nTRM==7) {
1088 if (nTDC<6) iPlate = 3;
1090 } else if (nTRM>=8 && nTRM<11) {
1092 } else if (nTRM==11) {
1093 if (nTDC<9) iPlate = 2;
1095 } else if (nTRM==12) {
1105 //----------------------------------------------------------------------------
1106 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1109 // Returns the TOF strip number per module:
1110 // [0;14], in the central plates,
1111 // [0;18], in the intermediate and external plates
1112 // corresponding to the TOF equipment ID numbers:
1113 // iDDL -> DDL number per sector [0;3]
1114 // nTRM -> TRM number [3;12]
1115 // nTDC -> TDC number [0;14]
1122 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1123 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1124 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1125 else if (nTRM== 7) {
1126 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1127 else iStrip = (Int_t)(nTDC/3.) - 4;
1129 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1130 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1131 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1132 else if (nTRM==11) {
1133 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1134 else iStrip = (Int_t)(nTDC/3.) - 3;
1136 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1138 } else if (iDDL==1) {
1140 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1141 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1142 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1143 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1144 else if (nTRM== 7) {
1145 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1146 else iStrip = 20 - (Int_t)(nTDC/3.);
1148 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1149 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1150 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1151 else if (nTRM==11) {
1152 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1153 else iStrip = 21 - (Int_t)(nTDC/3.);
1155 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1157 } else if (iDDL==2) {
1159 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1160 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1161 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1162 else if (nTRM== 7) {
1163 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1164 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1166 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1167 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1168 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1169 else if (nTRM==11) {
1170 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1171 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1173 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1175 } else if (iDDL==3) {
1177 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1178 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1179 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1180 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1181 else if (nTRM== 7) {
1182 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1183 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1185 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1186 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1187 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1188 else if (nTRM==11) {
1189 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1190 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1192 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1200 //----------------------------------------------------------------------------
1201 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1205 // Returns the TOF pad number per strip [0;95]
1206 // corresponding to the TOF equipment ID numbers:
1207 // iDDL -> DDL number per sector [0;3]
1208 // iChain -> TRM chain number [0;1]
1209 // nTDC -> TDC number [0;14]
1210 // iCH -> TDC channel number [0;7]
1213 Int_t iPadAlongTheStrip = -1;
1216 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1217 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1218 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1221 Int_t iTDClocal = -1;
1222 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1223 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1224 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1225 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1227 Int_t iCHlocal = iCH;
1228 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1230 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1232 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1233 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1234 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!\n";
1235 //AliWarning("Problems with the padX number!");
1237 return iPadAlongTheStrip;
1241 //----------------------------------------------------------------------------
1242 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1246 // Returns the TOF padX number [0;47]
1247 // corresponding to the TOF equipment ID numbers:
1248 // iDDL -> DDL number per sector [0;3]
1249 // iChain -> TRM chain number [0;1]
1250 // nTDC -> TDC number [0;14]
1251 // iCH -> TDC channel number [0;7]
1254 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1255 (Float_t(AliTOFGeometry::NpadZ())));
1261 //----------------------------------------------------------------------------
1262 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1266 // Returns the TOF padZ number [0;1]
1267 // corresponding to the TOF equipment ID numbers:
1268 // iDDL -> DDL number per sector [0;3]
1269 // iChain -> TRM chain number [0;1]
1270 // nTDC -> TDC number [0;14]
1271 // iCH -> TDC channel number [0;7]
1274 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1280 //----------------------------------------------------------------------------
1281 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1284 // Returns the sector number [0;17]
1285 // corresponing to the assigned DRM/DDL number [0;71]
1288 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1293 //----------------------------------------------------------------------------
1294 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1297 // Return the DRM/DDL number per sector [0;3]
1298 // corresponing to the assigned DRM/DDL number [0;71]
1301 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1307 //----------------------------------------------------------------------------
1308 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1310 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1312 //----------------------------------------------------------------------------
1313 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1314 Int_t nTDC, Int_t iCH,
1319 // nDDL (variable in [0;71]) -> number of the DDL file
1320 // nTRM (variable in [3;12]) -> number of the TRM slot
1321 // iChain (variable in [0; 1]) -> number of the TRM chain
1322 // nTDC (variable in [0;14]) -> number of the TDC
1323 // iCH (variable in [0; 7]) -> number of the TDC channel
1326 // sector number, i.e. volume[0] (variable in [0,17])
1327 // plate number, i.e. volume[1] (variable in [0, 5])
1328 // strip number, i.e. volume[2] (variable in [0,14/18])
1329 // padX number, i.e. volume[3] (variable in [0,47])
1330 // padZ number, i.e. volume[4] (variable in [0, 1])
1333 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1335 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1337 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1338 //printf("Info -> AliTOFRawStream::EquipmentId2VolumeId: Signal not coming from a TOF pad but -probably- from a TOF OR signal (%2d %2d %2d)\n", nDDL, nTRM, nTDC);
1342 Int_t iSector = GetSectorNumber(nDDL);
1344 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1347 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1348 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1352 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1355 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1356 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1360 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1361 if (iPadAlongTheStrip==-1) {
1363 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1364 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1365 nDDL, iChain, nTDC, iCH);
1368 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1369 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1371 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1372 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1374 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1375 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1377 volume[0] = iSector;
1384 //-----------------------------------------------------------------------------
1385 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1387 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1390 //check and fix valid DDL range
1393 fRawReader->AddMinorErrorLog(kDDLMinError);
1394 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1398 fRawReader->AddMinorErrorLog(kDDLMaxError);
1399 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1402 //select required DDLs
1403 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1406 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1408 return(Decode(verbose));
1410 //-----------------------------------------------------------------------------
1411 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1413 // New decoder method
1416 Int_t currentEquipment;
1418 const AliRawDataHeader *currentCDH;
1421 UChar_t *data = 0x0;
1423 //loop and read DDL headers
1424 while(fRawReader->ReadHeader()){
1426 //memory leak prevention (actually data should be always 0x0 here)
1430 //get equipment infos
1431 currentEquipment = fRawReader->GetEquipmentId();
1432 currentDDL = fRawReader->GetDDLID();
1433 currentCDH = fRawReader->GetDataHeader();
1434 const Int_t kDataSize = fRawReader->GetDataSize();
1435 const Int_t kDataWords = kDataSize / 4;
1436 data = new UChar_t[kDataSize];
1439 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1442 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1444 //read equipment payload
1445 if (!fRawReader->ReadNext(data, kDataSize))
1447 fRawReader->AddMajorErrorLog(kDDLdataReading);
1449 AliWarning("Error while reading DDL data. Go to next equipment");
1456 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1459 //set up the decoder
1460 fDecoder->SetVerbose(verbose);
1461 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1462 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1465 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1466 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1467 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1468 ResetDataBuffer(currentDDL);
1469 ResetPackedDataBuffer(currentDDL);
1477 fRawReader->Reset();
1480 AliInfo("All done");
1485 //---------------------------------------------------------------------------
1487 AliTOFRawStream::ResetBuffers()
1490 // To reset the buffers
1493 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1494 ResetDataBuffer(iDDL);
1495 ResetPackedDataBuffer(iDDL);
1499 //---------------------------------------------------------------------------
1501 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1504 // To load the buffers
1507 fTOFrawData->Clear();
1511 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1513 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1514 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1515 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1520 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1522 AliTOFHitData *hitData; //hit data pointer
1525 AliInfo("Filling TClonesArray ...");
1528 if (fgApplyBCCorrections) {
1529 AliInfo("Apply nominal DDL BC time-shift correction");
1530 AliInfo("Apply deltaBC time-shift correction");
1533 //loop over DDL packed hits
1534 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1535 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1536 Int_t hitACQ = hitData->GetACQ();
1537 Int_t hitPS = hitData->GetPS();
1538 Int_t hitSlotID = hitData->GetSlotID();
1539 Int_t hitChain = hitData->GetChain();
1540 Int_t hitTDC = hitData->GetTDC();
1541 Int_t hitChan = hitData->GetChan();
1542 Int_t hitTimeBin = hitData->GetTimeBin();
1543 Int_t hitTOTBin = hitData->GetTOTBin();
1544 Int_t hitDeltaBC = hitData->GetDeltaBunchID();
1545 Int_t hitL0L1Latency = hitData->GetL0L1Latency();
1547 Int_t hitLeading = hitData->GetTimeBin();
1548 Int_t hitTrailing = -1;
1549 Int_t hitError = -1;
1551 TClonesArray &arrayTofRawData = *fTOFrawData;
1552 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1559 AliInfo("Resetting buffers ...");
1561 fDataBuffer[indexDDL].Reset();
1562 fPackedDataBuffer[indexDDL].Reset();
1570 //---------------------------------------------------------------------------
1571 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1575 // nSector number -vol[0]- (variable in [0,17])
1576 // nPlate number -vol[1]- (variable in [0, 5])
1577 // nStrip number -vol[2]- (variable in [0,14/18])
1578 // nPadZ number -vol[3]- (variable in [0, 1])
1579 // nPadX number -vol[4]- (variable in [0,47])
1581 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1582 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1583 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1584 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1585 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1588 eqId[0] = Geant2DDL(vol);
1589 eqId[1] = Geant2TRM(vol);
1590 eqId[2] = Geant2TDC(vol);
1591 eqId[3] = Geant2Chain(vol);
1592 eqId[4] = Geant2Channel(vol);
1596 //---------------------------------------------------------------------------
1597 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1601 // nSector number -vol[0]- (variable in [0,17])
1602 // nPlate number -vol[1]- (variable in [0, 5])
1603 // nStrip number -vol[2]- (variable in [0,14/18])
1604 // nPadZ number -vol[3]- (variable in [0, 1])
1605 // nPadX number -vol[4]- (variable in [0,47])
1607 // nDDL (variable in [0;71]) -> number of the DDL
1613 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1614 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1617 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1618 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1621 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1622 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1625 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1626 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1627 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1628 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1629 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1630 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1634 Int_t nSector = vol[0];
1635 Int_t nPlate = vol[1];
1636 Int_t nStrip = vol[2];
1637 Int_t nPadX = vol[4];
1639 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1641 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1643 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1645 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1648 return 4*nSector+iDDL;
1652 //---------------------------------------------------------------------------
1653 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1657 // nSector number -vol[0]- (variable in [0,17])
1658 // nPlate number -vol[1]- (variable in [0, 5])
1659 // nStrip number -vol[2]- (variable in [0,14/18])
1660 // nPadZ number -vol[3]- (variable in [0, 1])
1661 // nPadX number -vol[4]- (variable in [0,47])
1663 // nTRM (variable in [3;12]) -> number of the TRM slot
1668 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1669 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1672 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1673 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1676 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1677 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1680 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1681 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1684 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1685 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1689 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1691 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1695 Int_t nPlate = vol[1];
1696 Int_t nStrip = vol[2];
1698 Int_t iDDL = Geant2DDL(vol)%4;
1705 if (nStrip<= 4) nTRM = 4;
1706 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1707 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1708 else if (nStrip>14) nTRM = 7;
1710 else if (nPlate==1) {
1711 if (nStrip== 0) nTRM = 7;
1712 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1713 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1714 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1715 else if (nStrip>15) nTRM = 11;
1717 else if (nPlate==2) {
1718 if (nStrip<= 1) nTRM = 11;
1719 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1726 if (nStrip== 0) nTRM = 3;
1727 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1728 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1729 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1730 else if (nStrip>15) nTRM = 7;
1732 else if (nPlate==1) {
1733 if (nStrip<=1) nTRM = 7;
1734 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1735 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1736 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1737 else if (nStrip>16) nTRM = 11;
1739 else if (nPlate==2) {
1740 if (nStrip<= 2) nTRM = 11;
1741 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1748 if (nStrip>=14) nTRM = 4;
1749 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1750 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1751 else if (nStrip< 4) nTRM = 7;
1753 else if (nPlate==3) {
1754 if (nStrip==18) nTRM = 7;
1755 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1756 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1757 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1758 else if (nStrip< 3) nTRM = 11;
1760 else if (nPlate==2) {
1761 if (nStrip>=13) nTRM = 11;
1762 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1769 if (nStrip==18) nTRM = 3;
1770 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1771 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1772 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1773 else if (nStrip< 3) nTRM = 7;
1775 else if (nPlate==3) {
1776 if (nStrip>=17) nTRM = 7;
1777 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1778 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1779 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1780 else if (nStrip< 2) nTRM = 11;
1782 else if (nPlate==2) {
1783 if (nStrip>=12) nTRM = 11;
1784 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1795 //---------------------------------------------------------------------------
1796 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1800 // nSector number -vol[0]- (variable in [0,17])
1801 // nPlate number -vol[1]- (variable in [0, 5])
1802 // nStrip number -vol[2]- (variable in [0,14/18])
1803 // nPadZ number -vol[3]- (variable in [0, 1])
1804 // nPadX number -vol[4]- (variable in [0,47])
1806 // nTDC (variable in [0;14]) -> number of the TDC
1811 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1812 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1815 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1816 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1819 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1820 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1823 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1824 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1825 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1826 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1827 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1828 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1832 Int_t nPlate = vol[1];
1833 Int_t nStrip = vol[2];
1834 Int_t iPadX = vol[4];
1836 Int_t iDDL = Geant2DDL(vol)%4;
1843 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1844 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1845 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1846 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1848 else if (nPlate==1) {
1849 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1850 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1851 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1852 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1853 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1855 else if (nPlate==2) {
1856 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1857 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1864 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1865 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1866 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1867 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1868 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1870 else if (nPlate==1) {
1871 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1872 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1873 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1874 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1875 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1877 else if (nPlate==2) {
1878 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1879 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1886 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1887 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1888 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1889 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1891 else if (nPlate==3) {
1892 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1893 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1894 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1895 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1896 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1898 else if (nPlate==2) {
1899 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1900 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1907 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1908 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1909 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1910 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1911 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1913 else if (nPlate==3) {
1914 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1915 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1916 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1917 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1918 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1920 else if (nPlate==2) {
1921 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1922 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1933 //---------------------------------------------------------------------------
1934 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1938 // nSector number -vol[0]- (variable in [0,17])
1939 // nPlate number -vol[1]- (variable in [0, 5])
1940 // nStrip number -vol[2]- (variable in [0,14/18])
1941 // nPadZ number -vol[3]- (variable in [0, 1])
1942 // nPadX number -vol[4]- variable in [0,47])
1944 // nChain (variable in [0; 1]) -> number of the TRM chain
1949 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1950 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1953 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1954 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1957 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1958 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1961 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1962 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1963 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1964 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1965 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1966 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1970 Int_t iPadX = vol[4];
1972 if (iPadX<12 || iPadX>=36) nChain = 0;
1979 //---------------------------------------------------------------------------
1980 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1984 // nSector number -vol[0]- (variable in [0,17])
1985 // nPlate number -vol[1]- (variable in [0, 5])
1986 // nStrip number -vol[2]- (variable in [0,14/18])
1987 // nPadZ number -vol[3]- (variable in [0, 1])
1988 // nPadX number -vol[4]- (variable in [0,47])
1990 // nChannel (variable in [0; 7]) -> number of the TDC channel
1993 Int_t nChannel = -1;
1995 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1996 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1999 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2000 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2003 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2004 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2007 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2008 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2009 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2010 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2011 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2012 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2016 Int_t iPadZ = vol[3];
2017 Int_t iPadX = vol[4];
2019 Int_t iDDL = Geant2DDL(vol)%4;
2024 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2027 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2030 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2033 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2041 //____________________________________________________________________________
2042 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray * const digitsArray)
2045 // Converts raw data to digits for TOF
2048 TStopwatch stopwatch;
2051 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
2052 //digitsTree->Branch("TOF", &fDigits);
2053 TClonesArray &aDigits = *digitsArray;
2058 SetRawReader(rawReader);
2061 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2063 TClonesArray staticRawData("AliTOFrawData",10000);
2064 staticRawData.Clear();
2065 TClonesArray * clonesRawData = &staticRawData;
2068 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2071 const Int_t kMaxNumberOfTracksPerDigit = 3;
2072 Int_t tracks[kMaxNumberOfTracksPerDigit];
2073 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2079 AliTOFrawData *tofRawDatum = 0;
2080 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2083 if (fNewDecoderVersion) {
2084 AliInfo("Using New Decoder \n");
2085 LoadRawDataBuffers(indexDDL, 0);
2088 LoadRawData(indexDDL);
2090 clonesRawData = GetRawData();
2091 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2092 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2094 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2096 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2097 if (tofRawDatum->GetTOF()==-1) continue;
2099 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2100 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2102 dummy = detectorIndex[3];
2103 detectorIndex[3] = detectorIndex[4];//padz
2104 detectorIndex[4] = dummy;//padx
2106 digit[0] = tofRawDatum->GetTOF();
2107 digit[1] = tofRawDatum->GetTOT();
2108 digit[2] = tofRawDatum->GetTOT();
2109 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2111 dummy = detectorIndex[3];
2112 detectorIndex[3] = detectorIndex[4];//padx
2113 detectorIndex[4] = dummy;//padz
2115 // Do not reconstruct anything in the holes
2116 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2117 if (detectorIndex[1]==2) { // plate with holes
2123 last = digitsArray->GetEntriesFast();
2124 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2127 if (indexDDL<10) ftxt << " " << indexDDL;
2128 else ftxt << " " << indexDDL;
2129 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2130 else ftxt << " " << tofRawDatum->GetTRM();
2131 ftxt << " " << tofRawDatum->GetTRMchain();
2132 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2133 else ftxt << " " << tofRawDatum->GetTDC();
2134 ftxt << " " << tofRawDatum->GetTDCchannel();
2136 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2137 else ftxt << " -> " << detectorIndex[0];
2138 ftxt << " " << detectorIndex[1];
2139 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2140 else ftxt << " " << detectorIndex[2];
2141 ftxt << " " << detectorIndex[4];
2142 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2143 else ftxt << " " << detectorIndex[3];
2145 if (digit[1]<10)ftxt << " " << digit[1];
2146 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2147 else ftxt << " " << digit[1];
2148 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2149 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2150 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2151 else ftxt << " " << digit[3] << endl;
2154 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2156 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2157 digit[0], digit[1], digit[3]));
2160 } // loop on tofRawData array
2162 clonesRawData->Clear();
2166 //if (fVerbose==2) ftxt.close();
2169 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2171 Int_t nDigits = digitsArray->GetEntries();
2172 AliDebug(1, Form("Got %d TOF digits", nDigits));
2173 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2174 stopwatch.RealTime(),stopwatch.CpuTime()));
2178 //____________________________________________________________________________
2179 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray * const sdigitsArray)
2182 // Converts raw data to sdigits for TOF
2185 TStopwatch stopwatch;
2190 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2191 TClonesArray &aSDigits = *sdigitsArray;
2194 SetRawReader(rawReader);
2197 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2199 TClonesArray staticRawData("AliTOFrawData",10000);
2200 staticRawData.Clear();
2201 TClonesArray * clonesRawData = &staticRawData;
2204 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2211 AliTOFrawData *tofRawDatum = 0;
2212 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2215 if (fNewDecoderVersion) {
2216 AliInfo("Using New Decoder \n");
2217 LoadRawDataBuffers(indexDDL, 0);
2220 LoadRawData(indexDDL);
2222 clonesRawData = GetRawData();
2223 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2224 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2226 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2228 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2229 if (tofRawDatum->GetTOF()==-1) continue;
2231 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2232 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2234 dummy = detectorIndex[3];
2235 detectorIndex[3] = detectorIndex[4];//padz
2236 detectorIndex[4] = dummy;//padx
2238 digit[0] = tofRawDatum->GetTOF();
2239 digit[1] = tofRawDatum->GetTOT();
2241 dummy = detectorIndex[3];
2242 detectorIndex[3] = detectorIndex[4];//padx
2243 detectorIndex[4] = dummy;//padz
2245 // Do not reconstruct anything in the holes
2246 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2247 if (detectorIndex[1]==2) { // plate with holes
2253 last = sdigitsArray->GetEntriesFast();
2254 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2257 if (indexDDL<10) ftxt << " " << indexDDL;
2258 else ftxt << " " << indexDDL;
2259 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2260 else ftxt << " " << tofRawDatum->GetTRM();
2261 ftxt << " " << tofRawDatum->GetTRMchain();
2262 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2263 else ftxt << " " << tofRawDatum->GetTDC();
2264 ftxt << " " << tofRawDatum->GetTDCchannel();
2266 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2267 else ftxt << " -> " << detectorIndex[0];
2268 ftxt << " " << detectorIndex[1];
2269 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2270 else ftxt << " " << detectorIndex[2];
2271 ftxt << " " << detectorIndex[4];
2272 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2273 else ftxt << " " << detectorIndex[3];
2275 if (digit[1]<10)ftxt << " " << digit[1];
2276 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2277 else ftxt << " " << digit[1];
2278 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2279 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2280 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2281 else ftxt << " " << digit[3] << endl;
2284 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2286 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2287 digit[0], digit[1], digit[3]));
2292 clonesRawData->Clear();
2296 //if (fVerbose==2) ftxt.close();
2298 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2300 Int_t nSDigits = sdigitsArray->GetEntries();
2301 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2302 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2303 stopwatch.RealTime(),stopwatch.CpuTime()));
2307 void AliTOFRawStream::VolumeID2LTM(Int_t detind[],
2312 Int_t iChannel) const {
2314 // To convert the TOF trigger macropad ID (i.e. detind)
2315 // into TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2318 const Int_t kFirstTDCnumber = 12;
2320 iDDL=-1, iTRM = 3 , iChain=-1, iTDC=-1, iChannel=-1;
2321 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
2329 iDDL = detind[0]*4+2;
2331 iDDL = detind[0]*4+2;
2334 iChain=fgkChainMap24[detind[1]][detind[2]];
2335 iTDC=(Int_t)(fgkChannelMap24[detind[1]][detind[2]]/8)+kFirstTDCnumber;
2336 iChannel=fgkChannelMap24[detind[1]][detind[2]]%8;
2340 void AliTOFRawStream::LTM2VolumeID(Int_t iDDL,
2345 Int_t detind0[], Int_t detind1[]) const {
2347 // To convert the TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2348 // into TOF trigger macropad IDs (i.e. detind0 and detind1).
2349 // In general, a couple of neighbouring TOF semi-strip represents a TOF trigger macropad.
2352 const Int_t kFirstTDCnumber = 12;
2354 Int_t iSector0=-1, iModule0=-1, iStrip0=-1, iPadX0=-1; // Le variabili del Volume ID
2355 Int_t iSector1=-1, iModule1=-1, iStrip1=-1, iPadX1=-1; // Le variabili del Volume ID
2357 if( iDDL%2==1 && iTRM==3 && iTDC-kFirstTDCnumber>=0 && iTDC-kFirstTDCnumber<3 ) {
2358 iSector0 = (Int_t)(iDDL/4);
2359 iSector1 = (Int_t)(iDDL/4);
2360 Int_t iChan= iChannel+(iTDC-kFirstTDCnumber)*8;
2362 if(iChain==0){ //CRATE 0
2365 iStrip0=fgkStrip0MapCrate0[iChan];
2366 iStrip1=fgkStrip1MapCrate0[iChan];
2367 iModule0=fgkModule0MapCrate0[iChan];
2368 iModule1=fgkModule1MapCrate0[iChan];
2370 if(iChain==1){// CRATE 1
2373 iStrip0=fgkStrip0MapCrate1[iChan];
2374 iStrip1=fgkStrip1MapCrate1[iChan];
2375 iModule0=fgkModule0MapCrate1[iChan];
2376 iModule1=fgkModule1MapCrate1[iChan];
2381 if(iChain==1){// CRATE 3
2384 iStrip0=fgkStrip0MapCrate3[iChan];
2385 iStrip1=fgkStrip1MapCrate3[iChan];
2386 iModule0=fgkModule0MapCrate3[iChan];
2387 iModule1=fgkModule1MapCrate3[iChan];
2389 if(iChain==0){// CRATE 2
2392 iStrip0=fgkStrip0MapCrate2[iChan];
2393 iStrip1=fgkStrip1MapCrate2[iChan];
2394 iModule0=fgkModule0MapCrate2[iChan];
2395 iModule1=fgkModule1MapCrate2[iChan];
2400 if(iStrip1==-1 || iModule1==-1){
2408 detind1[0]=iSector1;
2409 detind1[1]=iModule1;
2415 if(iStrip0==-1 || iModule0==-1){
2423 detind0[0]=iSector0;
2424 detind0[1]=iModule0;