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 {3,5,1,9,11,7,15,17,13,2,-1,0,7,9,5,13,15,11,0,-1,17,-1,5,3};
155 const Int_t AliTOFRawStream::fgkStrip1MapCrate0[]=
156 {4,0,2,10,6,8,16,12,14,3,18,1,8,4,6,14,10,12,1,16,18,2,6,4};
157 const Int_t AliTOFRawStream::fgkStrip0MapCrate1[]=
158 {0,2,4,6,8,10,12,14,16,-1,0,2,4,6,8,10,12,14,-1,17,0,2,4,6};
159 const Int_t AliTOFRawStream::fgkStrip1MapCrate1[]=
160 {1,3,5,7,9,11,13,15,17,18,1,3,5,7,9,11,13,15,16,18,1,3,5,7};
161 const Int_t AliTOFRawStream::fgkStrip0MapCrate2[]=
162 {15,13,17,9,7,11,3,1,5,16,-1,18,11,9,13,5,3,7,14,-1,1,-1,9,11};
163 const Int_t AliTOFRawStream::fgkStrip1MapCrate2[]=
164 {14,18,16,8,12,10,2,6,4,15,0,17,10,14,12,4,8,6,13,2,0,12,8,10};
165 const Int_t AliTOFRawStream::fgkStrip0MapCrate3[]=
166 {18,16,14,12,10,8,6,4,2,-1,18,16,14,12,10,8,6,4,-1,1,14,12,10,8};
167 const Int_t AliTOFRawStream::fgkStrip1MapCrate3[]=
168 {17,15,13,11,9,7,5,3,1,0,17,15,13,11,9,7,5,3,2,0,13,11,9,7};
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,2,-1,1,-1,2,2};
173 const Int_t AliTOFRawStream::fgkModule1MapCrate0[]=
174 {0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,2,1,1,2,2,2};
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,1,2,2,2,2,2};
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,1,2,2,2,2,2};
179 const Int_t AliTOFRawStream::fgkModule0MapCrate2[]=
180 {4,4,4,4,4,4,4,4,4,3,-1,3,3,3,3,3,3,3,2,-1,3,-1,2,2};
181 const Int_t AliTOFRawStream::fgkModule1MapCrate2[]=
182 {4,4,4,4,4,4,4,4,4,3,4,3,3,3,3,3,3,3,2,3,3,2,2,2};
183 const Int_t AliTOFRawStream::fgkModule0MapCrate3[]=
184 {4,4,4,4,4,4,4,4,4,-1,3,3,3,3,3,3,3,3,-1,3,2,2,2,2,2};
185 const Int_t AliTOFRawStream::fgkModule1MapCrate3[]=
186 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2};
188 const Int_t AliTOFRawStream::fgkChannelMap0[5][19]=
189 {{1,2,2,0,0,1,4,5,5,3,3,4,7,8,8,6,6,7,10},
190 {11,11,9,9,13,14,14,12,12,13,16,17,17,15,15,16,19,20,20},
191 {18,18,21,23,23,22,22,23,23,22,22,21,21,20,20,-1,-1,-1,-1},
192 {19,19,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10},
193 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
196 const Int_t AliTOFRawStream::fgkChainMap0[5][19]=
197 {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
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,1,1,1,1,1,1,1,1,-1,-1,-1,-1},
200 {1,1,1,1,1,1,1,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}
204 const Int_t AliTOFRawStream::fgkChannelMap24[5][19]=
205 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
206 {10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,19,19},
207 {20,20,21,21,22,22,23,23,22,22,23,23,21,18,18,-1,-1,-1,-1},
208 {20,20,19,16,15,15,17,17,16,13,12,12,14,14,13,9,9,11,11},
209 {10,7,6,6,8,8,7,4,3,3,5,5,4,1,0,0,2,2,1}
212 const Int_t AliTOFRawStream::fgkChainMap24[5][19]=
213 {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
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,0,0,0,0,0,0,0,-1,-1,-1,-1},
216 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
217 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
220 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
221 //_____________________________________________________________________________
222 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
223 fRawReader(rawReader),
224 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
225 fDecoder(new AliTOFDecoder()),
250 fInsideTRMchain0(kFALSE),
251 fInsideTRMchain1(kFALSE),
253 //fPackedDataBuffer(),
254 fLocalEventCounterDRM(-1),
255 fLocalEventCounterLTM(-1),
256 //fLocalEventCounterTRM(),
257 //fLocalEventCounterChain(),
259 //fCableLengthMap(new AliTOFCableLengthMap()),
261 fNewDecoderVersion(0)
264 // create an object to read TOF raw digits
267 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
269 ResetPackedDataBuffer(i);
272 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
273 fTOFrawData->SetOwner();
276 fRawReader->Select("TOF");
278 for (Int_t jj=0;jj<13;jj++) {
279 fLocalEventCounterTRM[jj] = -1;
280 for (Int_t ii=0;ii<2;ii++) {
281 fLocalEventCounterChain[jj][ii] = -1;
282 fChainBunchID[jj][ii] = -1;
288 //_____________________________________________________________________________
289 AliTOFRawStream::AliTOFRawStream():
291 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
292 fDecoder(new AliTOFDecoder()),
317 fInsideTRMchain0(kFALSE),
318 fInsideTRMchain1(kFALSE),
320 //fPackedDataBuffer(),
321 fLocalEventCounterDRM(-1),
322 fLocalEventCounterLTM(-1),
323 //fLocalEventCounterTRM(),
324 //fLocalEventCounterChain(),
326 //fCableLengthMap(new AliTOFCableLengthMap()),
328 fNewDecoderVersion(0)
333 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
335 ResetPackedDataBuffer(i);
338 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
339 fTOFrawData->SetOwner();
341 for (Int_t j=0;j<13;j++){
342 fLocalEventCounterTRM[j] = -1;
343 for (Int_t k=0;k<2;k++){
344 fLocalEventCounterChain[j][k] = -1;
345 fChainBunchID[j][k] = -1;
351 //_____________________________________________________________________________
352 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
354 fRawReader(stream.fRawReader),
355 fTOFrawData(stream.fTOFrawData),
356 fDecoder(new AliTOFDecoder()),
359 fTRMchain(stream.fTRMchain),
361 fTDCchannel(stream.fTDCchannel),
364 fLeadingEdge(stream.fLeadingEdge),
365 fTrailingEdge(stream.fTrailingEdge),
366 fErrorFlag(stream.fErrorFlag),
367 fSector(stream.fSector),
368 fPlate(stream.fPlate),
369 fStrip(stream.fStrip),
372 fPackedDigits(stream.fPackedDigits),
373 fWordType(stream.fWordType),
374 fSlotID(stream.fSlotID),
376 fPSbit(stream.fPSbit),
377 fTDCerrorFlag(stream.fTDCerrorFlag),
378 fInsideDRM(stream.fInsideDRM),
379 fInsideTRM(stream.fInsideTRM),
380 fInsideLTM(stream.fInsideLTM),
381 fInsideTRMchain0(stream.fInsideTRMchain0),
382 fInsideTRMchain1(stream.fInsideTRMchain1),
384 //fPackedDataBuffer(),
385 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
386 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
387 //fLocalEventCounterTRM(),
388 //fLocalEventCounterChain(),
390 //fCableLengthMap(stream.fCableLengthMap),
391 fEventID(stream.fEventID),
392 fNewDecoderVersion(stream.fNewDecoderVersion)
398 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
399 fDataBuffer[i] = stream.fDataBuffer[i];
400 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
403 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
405 for (Int_t j=0;j<13;j++){
406 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
407 for (Int_t k=0;k<2;k++){
408 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
409 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
415 //_____________________________________________________________________________
416 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
419 // assignment operator
425 TObject::operator=(stream);
427 fRawReader = stream.fRawReader;
429 fTOFrawData = stream.fTOFrawData;
433 fTRMchain = stream.fTRMchain;
435 fTDCchannel = stream.fTDCchannel;
436 fTime = stream.fTime;
438 fLeadingEdge = stream.fLeadingEdge;
439 fTrailingEdge = stream.fTrailingEdge;
440 fErrorFlag = stream.fErrorFlag;
442 fSector = stream.fSector;
443 fPlate = stream.fPlate;
444 fStrip = stream.fStrip;
445 fPadX = stream.fPadX;
446 fPadZ = stream.fPadZ;
448 fPackedDigits = stream.fPackedDigits;
450 fWordType = stream.fWordType;
451 fSlotID = stream.fSlotID;
453 fPSbit = stream.fPSbit;
454 fTDCerrorFlag = stream.fTDCerrorFlag;
455 fInsideDRM = stream.fInsideDRM;
456 fInsideTRM = stream.fInsideTRM;
457 fInsideLTM = stream.fInsideLTM;
458 fInsideTRMchain0 = stream.fInsideTRMchain0;
459 fInsideTRMchain1 = stream.fInsideTRMchain1;
461 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
462 fDataBuffer[i] = stream.fDataBuffer[i];
463 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
466 fTOFrawData = stream.fTOFrawData;
468 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
469 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
470 for (Int_t j=0;j<13;j++){
471 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
472 for (Int_t k=0;k<2;k++){
473 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
474 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
478 //fCableLengthMap = stream.fCableLengthMap;
480 fEventID = stream.fEventID;
481 fNewDecoderVersion = stream.fNewDecoderVersion;
487 //_____________________________________________________________________________
488 AliTOFRawStream::~AliTOFRawStream()
496 fTOFrawData->Clear();
499 //delete fCableLengthMap;
504 //_____________________________________________________________________________
506 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
512 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
514 fTOFrawData->Clear();
516 TClonesArray &arrayTofRawData = *fTOFrawData;
520 // create raw data map
521 AliTOFRawMap rawMap(fTOFrawData);
524 Int_t slot[4] = {-1, -1, -1, -1};
526 fLocalEventCounterDRM = -1;
527 fLocalEventCounterLTM = -1;
528 for (Int_t ii=0; ii<13; ii++)
529 fLocalEventCounterTRM[ii] = -1;
530 for (Int_t ii=0; ii<13; ii++)
531 for (Int_t jj=0; jj<2; jj++) {
532 fLocalEventCounterChain[ii][jj] = -1;
533 fChainBunchID[ii][jj] = -1;
537 fRawReader->Select("TOF", indexDDL, indexDDL);
539 Bool_t signal = kFALSE;
541 AliTOFrawData *rawDigit = NULL;
545 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
547 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
552 slot[3] = fTDCchannel;
554 if (rawMap.TestHit(slot) != kEmpty) {
556 rawDigit = static_cast<AliTOFrawData*>(rawMap.GetHit(slot));
558 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
559 fLeadingEdge==-1 && fTrailingEdge!=-1) {
561 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
563 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
564 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
569 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
579 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
583 } // else if (rawMap.TestHit(slot) == kEmpty)
587 } // closed -> while (Next())
591 //_____________________________________________________________________________
592 Bool_t AliTOFRawStream::Next()
595 // Read next 32-bit word in TOF raw data files
596 // returns kFALSE if there is no word left
603 if (!fRawReader->ReadNextInt(data)) return kFALSE;
605 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
617 fDDL = fRawReader->GetDDLID();
619 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
621 switch (fWordType) { // switch word type
623 case GLOBAL_HEADER_TYPE: // global header
624 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
628 switch (fSlotID) { // switch global header slot ID
630 case DRM_ID_NUMBER: //DRM global header
631 if (fInsideDRM) { // unexpected DRM global headers -> exit
634 fInsideDRM = kTRUE; // DRM global header accepted
637 case LTM_ID_NUMBER: // LTM global header
638 if (fInsideLTM) { // unexpected LTM global headers -> exit
641 fInsideLTM = kTRUE; // LTM global header accepted
651 case 10: //TRM header
652 case 11: //TRM header
653 case 12: //TRM header
654 if (fInsideTRM) { // unexpected TRM global headers -> exit
657 fInsideTRM = kTRUE; // TRM global header accepted
658 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
661 default: // unexpected global header slot ID
664 } //end switch global header slot id
669 case GLOBAL_TRAILER_TYPE: // global trailer
670 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
672 switch (fSlotID) { // switch global trailer slot ID
674 case DRM_ID_NUMBER: // DRM global trailer
675 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
679 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
680 fLocalEventCounterDRM = GetField(data,dummy,4);
681 fInsideDRM = kFALSE; // DRM global trailer accepted
684 fInsideTRMchain0 = kFALSE;
685 fInsideTRMchain1 = kFALSE;
705 case LTM_ID_NUMBER: // LTM global trailer
706 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
710 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
711 fLocalEventCounterLTM = GetField(data,dummy,16);
712 fInsideLTM = kFALSE; // LTM global trailer accepted
714 case 15: //TRM global trailer
715 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
719 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
720 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
721 fInsideTRM = kFALSE; // TRM global trailer accepted
723 default: // unexpected global trailer slot ID
725 } //end switch global trailer slot id
731 case ERROR_TYPE: // TDC error
732 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
733 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
737 case FILLER_TYPE: // filler
741 default: // other word types
743 if (fInsideTRM) { // inside TRM
745 switch (fWordType) { // switch word type inside TRM
746 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
747 if (fInsideTRMchain0) { // unexpected TRM chain0 header
750 fInsideTRMchain0 = kTRUE;
753 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
754 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
756 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
757 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
761 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
762 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
763 fInsideTRMchain0 = kFALSE;
766 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
767 if (fInsideTRMchain1) { // unexpected TRM chain1 header
770 fInsideTRMchain1 = kTRUE;
773 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
774 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
776 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
777 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
781 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
782 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
783 fInsideTRMchain1 = kFALSE;
786 } // end switch word type inside TRM
788 } // end if (fInsideTRM)
792 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
793 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
794 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
795 ){ // inside TRM chains
797 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
798 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
799 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
800 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
809 switch (fPSbit) { // switch fPSbit bits inside TRM chains
811 case 0: // packing ok, digit time and TOT
812 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
813 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
815 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
817 if (fgApplyBCCorrections) {
818 AliDebug(2,"Apply nominal DDL BC time-shift correction");
819 AliDebug(2,"Apply deltaBC time-shift correction");
820 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
821 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
825 case 1: // leading edge digit, long digit time, no TOT
828 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
830 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
832 if (fgApplyBCCorrections) {
833 AliDebug(2,"Apply nominal DDL BC time-shift correction");
834 AliDebug(2,"Apply deltaBC time-shift correction");
835 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
836 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
840 case 2: // trailing edge digit, long digit time, no TOT
843 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
845 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
847 if (fgApplyBCCorrections) {
848 AliDebug(2,"Apply nominal DDL BC time-shift correction");
849 AliDebug(2,"Apply deltaBC time-shift correction");
850 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
851 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
855 case 3: // TOT overflow
856 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
857 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
859 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
861 if (fgApplyBCCorrections) {
862 AliDebug(2,"Apply nominal DDL BC time-shift correction");
863 AliDebug(2,"Apply deltaBC time-shift correction");
864 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
865 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
869 } // end switch PS bits inside TRM chains
871 } // end if is inside TRM chains
873 } // end switch on fWordType
879 //_____________________________________________________________________________
881 void AliTOFRawStream::SetSector()
884 // Evaluate the TOF sector number -> [ 0;17]
885 // corresponding to the TOF equipment IDs:
888 // fTRMchain -> [ 0; 1]
890 // fTDCchannel -> [ 0; 7]
895 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
900 //_____________________________________________________________________________
903 void AliTOFRawStream::SetPlate()
906 // Evaluate the TOF plate number ->[ 0; 4]
907 // corresponding to the TOF equipment IDs:
910 // fTRMchain -> [ 0; 1]
912 // fTDCchannel -> [ 0; 7]
916 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
918 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
923 //_____________________________________________________________________________
925 void AliTOFRawStream::SetStrip()
928 // Evaluate the TOF strip number per module -> [ 0; 14/18]
929 // corresponding to the TOF equipment IDs:
932 // fTRMchain -> [ 0; 1]
934 // fTDCchannel -> [ 0; 7]
939 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
940 || fSector==-1 || fPlate==-1))
941 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
946 //_____________________________________________________________________________
948 void AliTOFRawStream::SetPadZ()
951 // Evaluate the TOF padRow number per strip -> [ 0; 1]
952 // corresponding to the TOF equipment IDs:
955 // fTRMchain -> [ 0; 1]
957 // fTDCchannel -> [ 0; 7]
962 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
963 || fSector==-1 || fPlate==-1 || fStrip==-1))
965 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
966 if (iPadAlongTheStrip!=-1)
967 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
970 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
971 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
976 //_____________________________________________________________________________
978 void AliTOFRawStream::SetPadX()
981 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
982 // corresponding to the TOF equipment IDs:
985 // fTRMchain -> [ 0; 1]
987 // fTDCchannel -> [ 0; 7]
992 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
993 || fSector==-1 || fPlate==-1 || fStrip==-1))
995 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
996 if (iPadAlongTheStrip!=-1)
997 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1000 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
1001 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1007 //----------------------------------------------------------------------------
1008 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1011 // Returns 'word' masked by 'fieldMask' and shifted by 'fieldPosition'
1014 return ((word & fieldMask) >> fieldPosition);
1017 //----------------------------------------------------------------------------
1018 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1021 // Returns the TOF plate number [0;4]
1022 // corresponding to the TOF equipment ID numbers:
1023 // iDDL -> DDL number per sector [0;3]
1024 // nTRM -> TRM number [3;12]
1025 // nTDC -> TDC number [0;14]
1032 if (nTRM>=4 && nTRM<7) {
1034 } else if (nTRM==7) {
1035 if (nTDC<12) iPlate = 0;
1037 } else if (nTRM>=8 && nTRM<11) {
1039 } else if (nTRM==11) {
1040 if (nTDC<9) iPlate = 1;
1042 }else if (nTRM==12) {
1046 } else if (iDDL==1) {
1049 if (nTDC<3) iPlate = 0;
1050 } else if (nTRM>=4 && nTRM<7) {
1052 } else if (nTRM==7) {
1053 if (nTDC<6) iPlate = 1;
1055 } else if (nTRM>=8 && nTRM<11) {
1057 } else if (nTRM==11) {
1058 if (nTDC<9) iPlate = 2;
1060 } else if (nTRM==12) {
1064 } else if (iDDL==2) {
1066 if (nTRM>=4 && nTRM<7) {
1068 } else if (nTRM==7) {
1069 if (nTDC<12) iPlate = 4;
1071 } else if (nTRM>=8 && nTRM<11) {
1073 } else if (nTRM==11) {
1074 if (nTDC<9) iPlate = 3;
1076 }else if (nTRM==12) {
1080 } else if (iDDL==3) {
1083 if (nTDC<3) iPlate = 4;
1084 } else if (nTRM>=4 && nTRM<7) {
1086 } else if (nTRM==7) {
1087 if (nTDC<6) iPlate = 3;
1089 } else if (nTRM>=8 && nTRM<11) {
1091 } else if (nTRM==11) {
1092 if (nTDC<9) iPlate = 2;
1094 } else if (nTRM==12) {
1104 //----------------------------------------------------------------------------
1105 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1108 // Returns the TOF strip number per module:
1109 // [0;14], in the central plates,
1110 // [0;18], in the intermediate and external plates
1111 // corresponding to the TOF equipment ID numbers:
1112 // iDDL -> DDL number per sector [0;3]
1113 // nTRM -> TRM number [3;12]
1114 // nTDC -> TDC number [0;14]
1121 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1122 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1123 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1124 else if (nTRM== 7) {
1125 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1126 else iStrip = (Int_t)(nTDC/3.) - 4;
1128 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1129 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1130 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1131 else if (nTRM==11) {
1132 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1133 else iStrip = (Int_t)(nTDC/3.) - 3;
1135 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1137 } else if (iDDL==1) {
1139 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1140 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1141 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1142 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1143 else if (nTRM== 7) {
1144 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1145 else iStrip = 20 - (Int_t)(nTDC/3.);
1147 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1148 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1149 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1150 else if (nTRM==11) {
1151 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1152 else iStrip = 21 - (Int_t)(nTDC/3.);
1154 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1156 } else if (iDDL==2) {
1158 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1159 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1160 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1161 else if (nTRM== 7) {
1162 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1163 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1165 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1166 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1167 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1168 else if (nTRM==11) {
1169 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1170 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1172 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1174 } else if (iDDL==3) {
1176 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1177 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1178 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1179 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1180 else if (nTRM== 7) {
1181 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1182 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1184 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1185 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1186 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1187 else if (nTRM==11) {
1188 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1189 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1191 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1199 //----------------------------------------------------------------------------
1200 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1204 // Returns the TOF pad number per strip [0;95]
1205 // corresponding to the TOF equipment ID numbers:
1206 // iDDL -> DDL number per sector [0;3]
1207 // iChain -> TRM chain number [0;1]
1208 // nTDC -> TDC number [0;14]
1209 // iCH -> TDC channel number [0;7]
1212 Int_t iPadAlongTheStrip = -1;
1215 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1216 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1217 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1220 Int_t iTDClocal = -1;
1221 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1222 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1223 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1224 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1226 Int_t iCHlocal = iCH;
1227 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1229 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1231 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1232 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1233 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!\n";
1234 //AliWarning("Problems with the padX number!");
1236 return iPadAlongTheStrip;
1240 //----------------------------------------------------------------------------
1241 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1245 // Returns the TOF padX number [0;47]
1246 // corresponding to the TOF equipment ID numbers:
1247 // iDDL -> DDL number per sector [0;3]
1248 // iChain -> TRM chain number [0;1]
1249 // nTDC -> TDC number [0;14]
1250 // iCH -> TDC channel number [0;7]
1253 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1254 (Float_t(AliTOFGeometry::NpadZ())));
1260 //----------------------------------------------------------------------------
1261 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1265 // Returns the TOF padZ number [0;1]
1266 // corresponding to the TOF equipment ID numbers:
1267 // iDDL -> DDL number per sector [0;3]
1268 // iChain -> TRM chain number [0;1]
1269 // nTDC -> TDC number [0;14]
1270 // iCH -> TDC channel number [0;7]
1273 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1279 //----------------------------------------------------------------------------
1280 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1283 // Returns the sector number [0;17]
1284 // corresponing to the assigned DRM/DDL number [0;71]
1287 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1292 //----------------------------------------------------------------------------
1293 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1296 // Return the DRM/DDL number per sector [0;3]
1297 // corresponing to the assigned DRM/DDL number [0;71]
1300 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1306 //----------------------------------------------------------------------------
1307 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1309 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1311 //----------------------------------------------------------------------------
1312 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1313 Int_t nTDC, Int_t iCH,
1318 // nDDL (variable in [0;71]) -> number of the DDL file
1319 // nTRM (variable in [3;12]) -> number of the TRM slot
1320 // iChain (variable in [0; 1]) -> number of the TRM chain
1321 // nTDC (variable in [0;14]) -> number of the TDC
1322 // iCH (variable in [0; 7]) -> number of the TDC channel
1325 // sector number, i.e. volume[0] (variable in [0,17])
1326 // plate number, i.e. volume[1] (variable in [0, 5])
1327 // strip number, i.e. volume[2] (variable in [0,14/18])
1328 // padX number, i.e. volume[3] (variable in [0,47])
1329 // padZ number, i.e. volume[4] (variable in [0, 1])
1332 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1334 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1336 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1337 //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);
1341 Int_t iSector = GetSectorNumber(nDDL);
1343 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1346 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1347 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1351 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1354 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1355 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1359 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1360 if (iPadAlongTheStrip==-1) {
1362 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1363 printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1364 nDDL, iChain, nTDC, iCH);
1367 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1368 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1370 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1371 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1373 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1374 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1376 volume[0] = iSector;
1383 //-----------------------------------------------------------------------------
1384 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1386 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1389 //check and fix valid DDL range
1392 fRawReader->AddMinorErrorLog(kDDLMinError);
1393 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1397 fRawReader->AddMinorErrorLog(kDDLMaxError);
1398 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1401 //select required DDLs
1402 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1405 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1407 return(Decode(verbose));
1409 //-----------------------------------------------------------------------------
1410 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1412 // New decoder method
1415 Int_t currentEquipment;
1417 const AliRawDataHeader *currentCDH;
1420 UChar_t *data = 0x0;
1422 //loop and read DDL headers
1423 while(fRawReader->ReadHeader()){
1425 //memory leak prevention (actually data should be always 0x0 here)
1429 //get equipment infos
1430 currentEquipment = fRawReader->GetEquipmentId();
1431 currentDDL = fRawReader->GetDDLID();
1432 currentCDH = fRawReader->GetDataHeader();
1433 const Int_t kDataSize = fRawReader->GetDataSize();
1434 const Int_t kDataWords = kDataSize / 4;
1435 data = new UChar_t[kDataSize];
1438 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1441 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1443 //read equipment payload
1444 if (!fRawReader->ReadNext(data, kDataSize))
1446 fRawReader->AddMajorErrorLog(kDDLdataReading);
1448 AliWarning("Error while reading DDL data. Go to next equipment");
1455 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1458 //set up the decoder
1459 fDecoder->SetVerbose(verbose);
1460 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1461 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1464 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1465 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1466 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1467 ResetDataBuffer(currentDDL);
1468 ResetPackedDataBuffer(currentDDL);
1476 fRawReader->Reset();
1479 AliInfo("All done");
1484 //---------------------------------------------------------------------------
1486 AliTOFRawStream::ResetBuffers()
1489 // To reset the buffers
1492 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1493 ResetDataBuffer(iDDL);
1494 ResetPackedDataBuffer(iDDL);
1498 //---------------------------------------------------------------------------
1500 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1503 // To load the buffers
1506 fTOFrawData->Clear();
1510 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1512 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1513 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1514 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1519 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1521 AliTOFHitData *hitData; //hit data pointer
1524 AliInfo("Filling TClonesArray ...");
1527 if (fgApplyBCCorrections) {
1528 AliInfo("Apply nominal DDL BC time-shift correction");
1529 AliInfo("Apply deltaBC time-shift correction");
1532 //loop over DDL packed hits
1533 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1534 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1535 Int_t hitACQ = hitData->GetACQ();
1536 Int_t hitPS = hitData->GetPS();
1537 Int_t hitSlotID = hitData->GetSlotID();
1538 Int_t hitChain = hitData->GetChain();
1539 Int_t hitTDC = hitData->GetTDC();
1540 Int_t hitChan = hitData->GetChan();
1541 Int_t hitTimeBin = hitData->GetTimeBin();
1542 Int_t hitTOTBin = hitData->GetTOTBin();
1543 Int_t hitDeltaBC = hitData->GetDeltaBunchID();
1544 Int_t hitL0L1Latency = hitData->GetL0L1Latency();
1546 Int_t hitLeading = hitData->GetTimeBin();
1547 Int_t hitTrailing = -1;
1548 Int_t hitError = -1;
1550 TClonesArray &arrayTofRawData = *fTOFrawData;
1551 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1558 AliInfo("Resetting buffers ...");
1560 fDataBuffer[indexDDL].Reset();
1561 fPackedDataBuffer[indexDDL].Reset();
1569 //---------------------------------------------------------------------------
1570 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1574 // nSector number -vol[0]- (variable in [0,17])
1575 // nPlate number -vol[1]- (variable in [0, 5])
1576 // nStrip number -vol[2]- (variable in [0,14/18])
1577 // nPadZ number -vol[3]- (variable in [0, 1])
1578 // nPadX number -vol[4]- (variable in [0,47])
1580 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1581 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1582 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1583 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1584 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1587 eqId[0] = Geant2DDL(vol);
1588 eqId[1] = Geant2TRM(vol);
1589 eqId[2] = Geant2TDC(vol);
1590 eqId[3] = Geant2Chain(vol);
1591 eqId[4] = Geant2Channel(vol);
1595 //---------------------------------------------------------------------------
1596 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1600 // nSector number -vol[0]- (variable in [0,17])
1601 // nPlate number -vol[1]- (variable in [0, 5])
1602 // nStrip number -vol[2]- (variable in [0,14/18])
1603 // nPadZ number -vol[3]- (variable in [0, 1])
1604 // nPadX number -vol[4]- (variable in [0,47])
1606 // nDDL (variable in [0;71]) -> number of the DDL
1612 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1613 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1616 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1617 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1620 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1621 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1624 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1625 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1626 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1627 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1628 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1629 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1633 Int_t nSector = vol[0];
1634 Int_t nPlate = vol[1];
1635 Int_t nStrip = vol[2];
1636 Int_t nPadX = vol[4];
1638 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1640 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1642 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1644 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1647 return 4*nSector+iDDL;
1651 //---------------------------------------------------------------------------
1652 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1656 // nSector number -vol[0]- (variable in [0,17])
1657 // nPlate number -vol[1]- (variable in [0, 5])
1658 // nStrip number -vol[2]- (variable in [0,14/18])
1659 // nPadZ number -vol[3]- (variable in [0, 1])
1660 // nPadX number -vol[4]- (variable in [0,47])
1662 // nTRM (variable in [3;12]) -> number of the TRM slot
1667 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1668 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1671 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1672 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1675 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1676 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1679 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1680 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1683 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1684 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1688 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1690 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1694 Int_t nPlate = vol[1];
1695 Int_t nStrip = vol[2];
1697 Int_t iDDL = Geant2DDL(vol)%4;
1704 if (nStrip<= 4) nTRM = 4;
1705 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1706 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1707 else if (nStrip>14) nTRM = 7;
1709 else if (nPlate==1) {
1710 if (nStrip== 0) nTRM = 7;
1711 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1712 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1713 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1714 else if (nStrip>15) nTRM = 11;
1716 else if (nPlate==2) {
1717 if (nStrip<= 1) nTRM = 11;
1718 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1725 if (nStrip== 0) nTRM = 3;
1726 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1727 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1728 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1729 else if (nStrip>15) nTRM = 7;
1731 else if (nPlate==1) {
1732 if (nStrip<=1) nTRM = 7;
1733 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1734 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1735 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1736 else if (nStrip>16) nTRM = 11;
1738 else if (nPlate==2) {
1739 if (nStrip<= 2) nTRM = 11;
1740 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1747 if (nStrip>=14) nTRM = 4;
1748 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1749 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1750 else if (nStrip< 4) nTRM = 7;
1752 else if (nPlate==3) {
1753 if (nStrip==18) nTRM = 7;
1754 else if (nStrip<18 && nStrip>=13) nTRM = 8;
1755 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
1756 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
1757 else if (nStrip< 3) nTRM = 11;
1759 else if (nPlate==2) {
1760 if (nStrip>=13) nTRM = 11;
1761 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
1768 if (nStrip==18) nTRM = 3;
1769 else if (nStrip<18 && nStrip>=13) nTRM = 4;
1770 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
1771 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
1772 else if (nStrip< 3) nTRM = 7;
1774 else if (nPlate==3) {
1775 if (nStrip>=17) nTRM = 7;
1776 else if (nStrip<17 && nStrip>=12) nTRM = 8;
1777 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
1778 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
1779 else if (nStrip< 2) nTRM = 11;
1781 else if (nPlate==2) {
1782 if (nStrip>=12) nTRM = 11;
1783 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
1794 //---------------------------------------------------------------------------
1795 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
1799 // nSector number -vol[0]- (variable in [0,17])
1800 // nPlate number -vol[1]- (variable in [0, 5])
1801 // nStrip number -vol[2]- (variable in [0,14/18])
1802 // nPadZ number -vol[3]- (variable in [0, 1])
1803 // nPadX number -vol[4]- (variable in [0,47])
1805 // nTDC (variable in [0;14]) -> number of the TDC
1810 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1811 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1814 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1815 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1818 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1819 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1822 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1823 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1824 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1825 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1826 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1827 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1831 Int_t nPlate = vol[1];
1832 Int_t nStrip = vol[2];
1833 Int_t iPadX = vol[4];
1835 Int_t iDDL = Geant2DDL(vol)%4;
1842 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
1843 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
1844 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
1845 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
1847 else if (nPlate==1) {
1848 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
1849 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
1850 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
1851 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
1852 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
1854 else if (nPlate==2) {
1855 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1856 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1863 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
1864 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
1865 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
1866 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
1867 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
1869 else if (nPlate==1) {
1870 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
1871 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
1872 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
1873 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
1874 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
1876 else if (nPlate==2) {
1877 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
1878 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
1885 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
1886 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
1887 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
1888 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
1890 else if (nPlate==3) {
1891 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
1892 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1893 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1894 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
1895 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
1897 else if (nPlate==2) {
1898 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
1899 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
1906 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
1907 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
1908 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
1909 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
1910 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
1912 else if (nPlate==3) {
1913 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
1914 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1915 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1916 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
1917 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
1919 else if (nPlate==2) {
1920 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
1921 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
1932 //---------------------------------------------------------------------------
1933 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
1937 // nSector number -vol[0]- (variable in [0,17])
1938 // nPlate number -vol[1]- (variable in [0, 5])
1939 // nStrip number -vol[2]- (variable in [0,14/18])
1940 // nPadZ number -vol[3]- (variable in [0, 1])
1941 // nPadX number -vol[4]- variable in [0,47])
1943 // nChain (variable in [0; 1]) -> number of the TRM chain
1948 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1949 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1952 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1953 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1956 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1957 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1960 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1961 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1962 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1963 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1964 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1965 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1969 Int_t iPadX = vol[4];
1971 if (iPadX<12 || iPadX>=36) nChain = 0;
1978 //---------------------------------------------------------------------------
1979 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
1983 // nSector number -vol[0]- (variable in [0,17])
1984 // nPlate number -vol[1]- (variable in [0, 5])
1985 // nStrip number -vol[2]- (variable in [0,14/18])
1986 // nPadZ number -vol[3]- (variable in [0, 1])
1987 // nPadX number -vol[4]- (variable in [0,47])
1989 // nChannel (variable in [0; 7]) -> number of the TDC channel
1992 Int_t nChannel = -1;
1994 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1995 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1998 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1999 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2002 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2003 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2006 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2007 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2008 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2009 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2010 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2011 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2015 Int_t iPadZ = vol[3];
2016 Int_t iPadX = vol[4];
2018 Int_t iDDL = Geant2DDL(vol)%4;
2023 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2026 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2029 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2032 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2040 //____________________________________________________________________________
2041 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray * const digitsArray)
2044 // Converts raw data to digits for TOF
2047 TStopwatch stopwatch;
2050 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
2051 //digitsTree->Branch("TOF", &fDigits);
2052 TClonesArray &aDigits = *digitsArray;
2057 SetRawReader(rawReader);
2060 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2062 TClonesArray staticRawData("AliTOFrawData",10000);
2063 staticRawData.Clear();
2064 TClonesArray * clonesRawData = &staticRawData;
2067 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2070 const Int_t kMaxNumberOfTracksPerDigit = 3;
2071 Int_t tracks[kMaxNumberOfTracksPerDigit];
2072 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2078 AliTOFrawData *tofRawDatum = 0;
2079 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2082 if (fNewDecoderVersion) {
2083 AliInfo("Using New Decoder \n");
2084 LoadRawDataBuffers(indexDDL, 0);
2087 LoadRawData(indexDDL);
2089 clonesRawData = GetRawData();
2090 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2091 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2093 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2095 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2096 if (tofRawDatum->GetTOF()==-1) continue;
2098 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2099 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2101 dummy = detectorIndex[3];
2102 detectorIndex[3] = detectorIndex[4];//padz
2103 detectorIndex[4] = dummy;//padx
2105 digit[0] = tofRawDatum->GetTOF();
2106 digit[1] = tofRawDatum->GetTOT();
2107 digit[2] = tofRawDatum->GetTOT();
2108 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2110 dummy = detectorIndex[3];
2111 detectorIndex[3] = detectorIndex[4];//padx
2112 detectorIndex[4] = dummy;//padz
2114 // Do not reconstruct anything in the holes
2115 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2116 if (detectorIndex[1]==2) { // plate with holes
2122 last = digitsArray->GetEntriesFast();
2123 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2126 if (indexDDL<10) ftxt << " " << indexDDL;
2127 else ftxt << " " << indexDDL;
2128 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2129 else ftxt << " " << tofRawDatum->GetTRM();
2130 ftxt << " " << tofRawDatum->GetTRMchain();
2131 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2132 else ftxt << " " << tofRawDatum->GetTDC();
2133 ftxt << " " << tofRawDatum->GetTDCchannel();
2135 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2136 else ftxt << " -> " << detectorIndex[0];
2137 ftxt << " " << detectorIndex[1];
2138 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2139 else ftxt << " " << detectorIndex[2];
2140 ftxt << " " << detectorIndex[4];
2141 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2142 else ftxt << " " << detectorIndex[3];
2144 if (digit[1]<10)ftxt << " " << digit[1];
2145 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2146 else ftxt << " " << digit[1];
2147 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2148 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2149 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2150 else ftxt << " " << digit[3] << endl;
2153 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2155 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2156 digit[0], digit[1], digit[3]));
2159 } // loop on tofRawData array
2161 clonesRawData->Clear();
2165 //if (fVerbose==2) ftxt.close();
2168 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2170 Int_t nDigits = digitsArray->GetEntries();
2171 AliDebug(1, Form("Got %d TOF digits", nDigits));
2172 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2173 stopwatch.RealTime(),stopwatch.CpuTime()));
2177 //____________________________________________________________________________
2178 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray * const sdigitsArray)
2181 // Converts raw data to sdigits for TOF
2184 TStopwatch stopwatch;
2189 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2190 TClonesArray &aSDigits = *sdigitsArray;
2193 SetRawReader(rawReader);
2196 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2198 TClonesArray staticRawData("AliTOFrawData",10000);
2199 staticRawData.Clear();
2200 TClonesArray * clonesRawData = &staticRawData;
2203 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2210 AliTOFrawData *tofRawDatum = 0;
2211 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2214 if (fNewDecoderVersion) {
2215 AliInfo("Using New Decoder \n");
2216 LoadRawDataBuffers(indexDDL, 0);
2219 LoadRawData(indexDDL);
2221 clonesRawData = GetRawData();
2222 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2223 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2225 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2227 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2228 if (tofRawDatum->GetTOF()==-1) continue;
2230 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2231 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2233 dummy = detectorIndex[3];
2234 detectorIndex[3] = detectorIndex[4];//padz
2235 detectorIndex[4] = dummy;//padx
2237 digit[0] = tofRawDatum->GetTOF();
2238 digit[1] = tofRawDatum->GetTOT();
2240 dummy = detectorIndex[3];
2241 detectorIndex[3] = detectorIndex[4];//padx
2242 detectorIndex[4] = dummy;//padz
2244 // Do not reconstruct anything in the holes
2245 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2246 if (detectorIndex[1]==2) { // plate with holes
2252 last = sdigitsArray->GetEntriesFast();
2253 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2256 if (indexDDL<10) ftxt << " " << indexDDL;
2257 else ftxt << " " << indexDDL;
2258 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2259 else ftxt << " " << tofRawDatum->GetTRM();
2260 ftxt << " " << tofRawDatum->GetTRMchain();
2261 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2262 else ftxt << " " << tofRawDatum->GetTDC();
2263 ftxt << " " << tofRawDatum->GetTDCchannel();
2265 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2266 else ftxt << " -> " << detectorIndex[0];
2267 ftxt << " " << detectorIndex[1];
2268 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2269 else ftxt << " " << detectorIndex[2];
2270 ftxt << " " << detectorIndex[4];
2271 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2272 else ftxt << " " << detectorIndex[3];
2274 if (digit[1]<10)ftxt << " " << digit[1];
2275 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2276 else ftxt << " " << digit[1];
2277 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2278 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2279 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2280 else ftxt << " " << digit[3] << endl;
2283 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2285 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2286 digit[0], digit[1], digit[3]));
2291 clonesRawData->Clear();
2295 //if (fVerbose==2) ftxt.close();
2297 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2299 Int_t nSDigits = sdigitsArray->GetEntries();
2300 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2301 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2302 stopwatch.RealTime(),stopwatch.CpuTime()));
2306 void AliTOFRawStream::VolumeID2LTM(Int_t detind[],
2311 Int_t iChannel) const {
2313 // To convert the TOF trigger macropad ID (i.e. detind)
2314 // into TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2317 const Int_t kFirstTDCnumber = 12;
2319 iDDL=-1, iTRM = 3 , iChain=-1, iTDC=-1, iChannel=-1;
2320 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
2328 iDDL = detind[0]*4+2;
2330 iDDL = detind[0]*4+2;
2333 iChain=fgkChainMap24[detind[1]][detind[2]];
2334 iTDC=(Int_t)(fgkChannelMap24[detind[1]][detind[2]]/8)+kFirstTDCnumber;
2335 iChannel=fgkChannelMap24[detind[1]][detind[2]]%8;
2339 void AliTOFRawStream::LTM2VolumeID(Int_t iDDL,
2344 Int_t detind0[], Int_t detind1[]) const {
2346 // To convert the TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2347 // into TOF trigger macropad IDs (i.e. detind0 and detind1).
2348 // In general, a couple of neighbouring TOF semi-strip represents a TOF trigger macropad.
2351 const Int_t kFirstTDCnumber = 12;
2353 Int_t iSector0=-1, iModule0=-1, iStrip0=-1, iPadX0=-1; // Le variabili del Volume ID
2354 Int_t iSector1=-1, iModule1=-1, iStrip1=-1, iPadX1=-1; // Le variabili del Volume ID
2356 if( iDDL%2==1 && iTRM==3 && iTDC-kFirstTDCnumber>=0 && iTDC-kFirstTDCnumber<3 ) {
2357 iSector0 = (Int_t)(iDDL/4);
2358 iSector1 = (Int_t)(iDDL/4);
2359 Int_t iChan= iChannel+(iTDC-kFirstTDCnumber)*8;
2360 if(iDDL%4 == 0 || iDDL%4 == 1 ){
2361 if(iChain==0){ //CRATE 0
2364 iStrip0=fgkStrip0MapCrate0[iChan];
2365 iStrip1=fgkStrip1MapCrate0[iChan];
2366 iModule0=fgkModule0MapCrate0[iChan];
2367 iModule1=fgkModule1MapCrate0[iChan];
2369 if(iChain==1){// CRATE 1
2372 iStrip0=fgkStrip0MapCrate1[iChan];
2373 iStrip1=fgkStrip1MapCrate1[iChan];
2374 iModule0=fgkModule0MapCrate1[iChan];
2375 iModule1=fgkModule1MapCrate1[iChan];
2379 if(iDDL%4 == 2 || iDDL%4 == 3 ){
2380 if(iChain==1){// CRATE 3
2383 iStrip0=fgkStrip0MapCrate3[iChan];
2384 iStrip1=fgkStrip1MapCrate3[iChan];
2385 iModule0=fgkModule0MapCrate3[iChan];
2386 iModule1=fgkModule1MapCrate3[iChan];
2388 if(iChain==0){// CRATE 2
2391 iStrip0=fgkStrip0MapCrate2[iChan];
2392 iStrip1=fgkStrip1MapCrate2[iChan];
2393 iModule0=fgkModule0MapCrate2[iChan];
2394 iModule1=fgkModule1MapCrate2[iChan];
2398 detind1[0]=iSector1;
2399 detind1[1]=iModule1;
2403 detind0[0]=iSector0;
2404 detind0[1]=iModule0;