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"
128 #include "AliRawDataHeaderV3.h"
130 #include "AliTOFDecoderV2.h"
131 #include "AliTOFTDCHit.h"
132 #include "AliTOFDecoderSummaryData.h"
133 #include "AliTOFDRMSummaryData.h"
134 #include "AliTOFLTMSummaryData.h"
135 #include "AliTOFTRMSummaryData.h"
136 #include "AliTOFChainSummaryData.h"
137 #include "AliTOFTDCHitBuffer.h"
138 #include "AliTOFTDCErrorBuffer.h"
140 ClassImp(AliTOFRawStream)
142 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
164 const Int_t AliTOFRawStream::fgkStrip0MapCrate0[]=
165 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
166 const Int_t AliTOFRawStream::fgkStrip1MapCrate0[]=
167 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
168 const Int_t AliTOFRawStream::fgkStrip0MapCrate1[]=
169 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
170 const Int_t AliTOFRawStream::fgkStrip1MapCrate1[]=
171 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
172 const Int_t AliTOFRawStream::fgkStrip0MapCrate2[]=
173 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
174 const Int_t AliTOFRawStream::fgkStrip1MapCrate2[]=
175 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
176 const Int_t AliTOFRawStream::fgkStrip0MapCrate3[]=
177 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
178 const Int_t AliTOFRawStream::fgkStrip1MapCrate3[]=
179 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
182 const Int_t AliTOFRawStream::fgkModule0MapCrate0[]=
183 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
184 const Int_t AliTOFRawStream::fgkModule1MapCrate0[]=
185 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
186 const Int_t AliTOFRawStream::fgkModule0MapCrate1[]=
187 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
188 const Int_t AliTOFRawStream::fgkModule1MapCrate1[]=
189 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
191 const Int_t AliTOFRawStream::fgkModule0MapCrate2[]=
192 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
193 const Int_t AliTOFRawStream::fgkModule1MapCrate2[]=
194 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
195 const Int_t AliTOFRawStream::fgkModule0MapCrate3[]=
196 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
197 const Int_t AliTOFRawStream::fgkModule1MapCrate3[]=
198 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
200 const Int_t AliTOFRawStream::fgkChannelMap0[5][19]=
201 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
202 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
203 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
204 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
205 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
208 const Int_t AliTOFRawStream::fgkChainMap0[5][19]=
209 {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
210 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
211 {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,-1,-1,-1,-1},
212 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
213 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
216 const Int_t AliTOFRawStream::fgkChannelMap24[5][19]=
217 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
218 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
219 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
220 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
221 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
224 const Int_t AliTOFRawStream::fgkChainMap24[5][19]=
225 {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
226 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
227 {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,-1,-1,-1,-1},
228 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
229 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
232 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
233 //_____________________________________________________________________________
234 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
235 fRawReader(rawReader),
236 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
237 fDecoder(new AliTOFDecoder()),
238 fDecoderV2(new AliTOFDecoderV2()),
263 fInsideTRMchain0(kFALSE),
264 fInsideTRMchain1(kFALSE),
266 //fPackedDataBuffer(),
267 fLocalEventCounterDRM(-1),
268 fLocalEventCounterLTM(-1),
269 //fLocalEventCounterTRM(),
270 //fLocalEventCounterChain(),
272 //fCableLengthMap(new AliTOFCableLengthMap()),
274 fNewDecoderVersion(0)
277 // create an object to read TOF raw digits
280 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
282 ResetPackedDataBuffer(i);
285 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
286 fTOFrawData->SetOwner();
289 fRawReader->Select("TOF");
291 for (Int_t jj=0;jj<13;jj++) {
292 fLocalEventCounterTRM[jj] = -1;
293 for (Int_t ii=0;ii<2;ii++) {
294 fLocalEventCounterChain[jj][ii] = -1;
295 fChainBunchID[jj][ii] = -1;
301 //_____________________________________________________________________________
302 AliTOFRawStream::AliTOFRawStream():
304 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
305 fDecoder(new AliTOFDecoder()),
306 fDecoderV2(new AliTOFDecoderV2()),
331 fInsideTRMchain0(kFALSE),
332 fInsideTRMchain1(kFALSE),
334 //fPackedDataBuffer(),
335 fLocalEventCounterDRM(-1),
336 fLocalEventCounterLTM(-1),
337 //fLocalEventCounterTRM(),
338 //fLocalEventCounterChain(),
340 //fCableLengthMap(new AliTOFCableLengthMap()),
342 fNewDecoderVersion(0)
347 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
349 ResetPackedDataBuffer(i);
352 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
353 fTOFrawData->SetOwner();
355 for (Int_t j=0;j<13;j++){
356 fLocalEventCounterTRM[j] = -1;
357 for (Int_t k=0;k<2;k++){
358 fLocalEventCounterChain[j][k] = -1;
359 fChainBunchID[j][k] = -1;
365 //_____________________________________________________________________________
366 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
368 fRawReader(stream.fRawReader),
369 fTOFrawData(stream.fTOFrawData),
370 fDecoder(new AliTOFDecoder()),
371 fDecoderV2(new AliTOFDecoderV2()),
374 fTRMchain(stream.fTRMchain),
376 fTDCchannel(stream.fTDCchannel),
379 fLeadingEdge(stream.fLeadingEdge),
380 fTrailingEdge(stream.fTrailingEdge),
381 fErrorFlag(stream.fErrorFlag),
382 fSector(stream.fSector),
383 fPlate(stream.fPlate),
384 fStrip(stream.fStrip),
387 fPackedDigits(stream.fPackedDigits),
388 fWordType(stream.fWordType),
389 fSlotID(stream.fSlotID),
391 fPSbit(stream.fPSbit),
392 fTDCerrorFlag(stream.fTDCerrorFlag),
393 fInsideDRM(stream.fInsideDRM),
394 fInsideTRM(stream.fInsideTRM),
395 fInsideLTM(stream.fInsideLTM),
396 fInsideTRMchain0(stream.fInsideTRMchain0),
397 fInsideTRMchain1(stream.fInsideTRMchain1),
399 //fPackedDataBuffer(),
400 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
401 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
402 //fLocalEventCounterTRM(),
403 //fLocalEventCounterChain(),
405 //fCableLengthMap(stream.fCableLengthMap),
406 fEventID(stream.fEventID),
407 fNewDecoderVersion(stream.fNewDecoderVersion)
413 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
414 fDataBuffer[i] = stream.fDataBuffer[i];
415 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
418 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
420 for (Int_t j=0;j<13;j++){
421 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
422 for (Int_t k=0;k<2;k++){
423 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
424 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
430 //_____________________________________________________________________________
431 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
434 // assignment operator
440 TObject::operator=(stream);
442 fRawReader = stream.fRawReader;
444 fTOFrawData = stream.fTOFrawData;
448 fTRMchain = stream.fTRMchain;
450 fTDCchannel = stream.fTDCchannel;
451 fTime = stream.fTime;
453 fLeadingEdge = stream.fLeadingEdge;
454 fTrailingEdge = stream.fTrailingEdge;
455 fErrorFlag = stream.fErrorFlag;
457 fSector = stream.fSector;
458 fPlate = stream.fPlate;
459 fStrip = stream.fStrip;
460 fPadX = stream.fPadX;
461 fPadZ = stream.fPadZ;
463 fPackedDigits = stream.fPackedDigits;
465 fWordType = stream.fWordType;
466 fSlotID = stream.fSlotID;
468 fPSbit = stream.fPSbit;
469 fTDCerrorFlag = stream.fTDCerrorFlag;
470 fInsideDRM = stream.fInsideDRM;
471 fInsideTRM = stream.fInsideTRM;
472 fInsideLTM = stream.fInsideLTM;
473 fInsideTRMchain0 = stream.fInsideTRMchain0;
474 fInsideTRMchain1 = stream.fInsideTRMchain1;
476 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
477 fDataBuffer[i] = stream.fDataBuffer[i];
478 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
481 fTOFrawData = stream.fTOFrawData;
483 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
484 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
485 for (Int_t j=0;j<13;j++){
486 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
487 for (Int_t k=0;k<2;k++){
488 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
489 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
493 //fCableLengthMap = stream.fCableLengthMap;
495 fEventID = stream.fEventID;
496 fNewDecoderVersion = stream.fNewDecoderVersion;
502 //_____________________________________________________________________________
503 AliTOFRawStream::~AliTOFRawStream()
512 fTOFrawData->Clear("C");
516 //delete fCableLengthMap;
521 //_____________________________________________________________________________
523 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
529 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
531 fTOFrawData->Clear();
533 TClonesArray &arrayTofRawData = *fTOFrawData;
537 // create raw data map
538 AliTOFRawMap rawMap(fTOFrawData);
541 Int_t slot[4] = {-1, -1, -1, -1};
543 fLocalEventCounterDRM = -1;
544 fLocalEventCounterLTM = -1;
545 for (Int_t ii=0; ii<13; ii++)
546 fLocalEventCounterTRM[ii] = -1;
547 for (Int_t ii=0; ii<13; ii++)
548 for (Int_t jj=0; jj<2; jj++) {
549 fLocalEventCounterChain[ii][jj] = -1;
550 fChainBunchID[ii][jj] = -1;
554 fRawReader->Select("TOF", indexDDL, indexDDL);
556 Bool_t signal = kFALSE;
558 AliTOFrawData *rawDigit = NULL;
562 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
564 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
569 slot[3] = fTDCchannel;
571 if (rawMap.TestHit(slot) != kEmpty) {
573 rawDigit = static_cast<AliTOFrawData*>(rawMap.GetHit(slot));
575 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
576 fLeadingEdge==-1 && fTrailingEdge!=-1) {
578 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
580 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
581 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
586 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
596 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
600 } // else if (rawMap.TestHit(slot) == kEmpty)
604 } // closed -> while (Next())
608 //_____________________________________________________________________________
609 Bool_t AliTOFRawStream::Next()
612 // Read next 32-bit word in TOF raw data files
613 // returns kFALSE if there is no word left
620 if (!fRawReader->ReadNextInt(data)) return kFALSE;
622 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
634 fDDL = fRawReader->GetDDLID();
636 fRawReader->AddMajorErrorLog(kDDLdataReading);
637 AliWarning("Error when load DDL. Go to next DDL");
641 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
643 switch (fWordType) { // switch word type
645 case GLOBAL_HEADER_TYPE: // global header
646 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
650 switch (fSlotID) { // switch global header slot ID
652 case DRM_ID_NUMBER: //DRM global header
653 if (fInsideDRM) { // unexpected DRM global headers -> exit
656 fInsideDRM = kTRUE; // DRM global header accepted
659 case LTM_ID_NUMBER: // LTM global header
660 if (fInsideLTM) { // unexpected LTM global headers -> exit
663 fInsideLTM = kTRUE; // LTM global header accepted
673 case 10: //TRM header
674 case 11: //TRM header
675 case 12: //TRM header
676 if (fInsideTRM) { // unexpected TRM global headers -> exit
679 fInsideTRM = kTRUE; // TRM global header accepted
680 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
683 default: // unexpected global header slot ID
686 } //end switch global header slot id
691 case GLOBAL_TRAILER_TYPE: // global trailer
692 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
694 switch (fSlotID) { // switch global trailer slot ID
696 case DRM_ID_NUMBER: // DRM global trailer
697 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
701 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
702 fLocalEventCounterDRM = GetField(data,dummy,4);
703 fInsideDRM = kFALSE; // DRM global trailer accepted
706 fInsideTRMchain0 = kFALSE;
707 fInsideTRMchain1 = kFALSE;
727 case LTM_ID_NUMBER: // LTM global trailer
728 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
732 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
733 fLocalEventCounterLTM = GetField(data,dummy,16);
734 fInsideLTM = kFALSE; // LTM global trailer accepted
736 case 15: //TRM global trailer
737 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
741 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
742 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
743 fInsideTRM = kFALSE; // TRM global trailer accepted
745 default: // unexpected global trailer slot ID
747 } //end switch global trailer slot id
753 case ERROR_TYPE: // TDC error
754 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
755 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
759 case FILLER_TYPE: // filler
763 default: // other word types
765 if (fInsideTRM) { // inside TRM
767 switch (fWordType) { // switch word type inside TRM
768 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
769 if (fInsideTRMchain0) { // unexpected TRM chain0 header
772 fInsideTRMchain0 = kTRUE;
775 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
776 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
778 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
779 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
783 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
784 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
785 fInsideTRMchain0 = kFALSE;
788 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
789 if (fInsideTRMchain1) { // unexpected TRM chain1 header
792 fInsideTRMchain1 = kTRUE;
795 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
796 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
798 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
799 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
803 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
804 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
805 fInsideTRMchain1 = kFALSE;
808 } // end switch word type inside TRM
810 } // end if (fInsideTRM)
814 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
815 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
816 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
817 ){ // inside TRM chains
819 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
820 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
821 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
822 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
831 switch (fPSbit) { // switch fPSbit bits inside TRM chains
833 case 0: // packing ok, digit time and TOT
834 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
835 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
837 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
839 if (fgApplyBCCorrections) {
840 AliDebug(2,"Apply nominal DDL BC time-shift correction");
841 AliDebug(2,"Apply deltaBC time-shift correction");
842 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
843 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
847 case 1: // leading edge digit, long digit time, no TOT
850 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
852 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
854 if (fgApplyBCCorrections) {
855 AliDebug(2,"Apply nominal DDL BC time-shift correction");
856 AliDebug(2,"Apply deltaBC time-shift correction");
857 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
858 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
862 case 2: // trailing edge digit, long digit time, no TOT
865 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION)
867 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
869 if (fgApplyBCCorrections) {
870 AliDebug(2,"Apply nominal DDL BC time-shift correction");
871 AliDebug(2,"Apply deltaBC time-shift correction");
872 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
873 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
877 case 3: // TOT overflow
878 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
879 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
881 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
883 if (fgApplyBCCorrections) {
884 AliDebug(2,"Apply nominal DDL BC time-shift correction");
885 AliDebug(2,"Apply deltaBC time-shift correction");
886 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
887 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
891 } // end switch PS bits inside TRM chains
893 } // end if is inside TRM chains
895 } // end switch on fWordType
901 //_____________________________________________________________________________
903 void AliTOFRawStream::SetSector()
906 // Evaluate the TOF sector number -> [ 0;17]
907 // corresponding to the TOF equipment IDs:
910 // fTRMchain -> [ 0; 1]
912 // fTDCchannel -> [ 0; 7]
917 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
922 //_____________________________________________________________________________
925 void AliTOFRawStream::SetPlate()
928 // Evaluate the TOF plate number ->[ 0; 4]
929 // corresponding to the TOF equipment IDs:
932 // fTRMchain -> [ 0; 1]
934 // fTDCchannel -> [ 0; 7]
938 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
940 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
945 //_____________________________________________________________________________
947 void AliTOFRawStream::SetStrip()
950 // Evaluate the TOF strip number per module -> [ 0; 14/18]
951 // corresponding to the TOF equipment IDs:
954 // fTRMchain -> [ 0; 1]
956 // fTDCchannel -> [ 0; 7]
961 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
962 || fSector==-1 || fPlate==-1))
963 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
968 //_____________________________________________________________________________
970 void AliTOFRawStream::SetPadZ()
973 // Evaluate the TOF padRow number per strip -> [ 0; 1]
974 // corresponding to the TOF equipment IDs:
977 // fTRMchain -> [ 0; 1]
979 // fTDCchannel -> [ 0; 7]
984 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
985 || fSector==-1 || fPlate==-1 || fStrip==-1))
987 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
988 if (iPadAlongTheStrip!=-1)
989 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
992 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
993 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
998 //_____________________________________________________________________________
1000 void AliTOFRawStream::SetPadX()
1003 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
1004 // corresponding to the TOF equipment IDs:
1007 // fTRMchain -> [ 0; 1]
1009 // fTDCchannel -> [ 0; 7]
1014 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1015 || fSector==-1 || fPlate==-1 || fStrip==-1))
1017 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1018 if (iPadAlongTheStrip!=-1)
1019 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1022 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
1023 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1029 //----------------------------------------------------------------------------
1030 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1033 // Returns 'word' masked by 'fieldMask' and shifted by 'fieldPosition'
1036 return ((word & fieldMask) >> fieldPosition);
1039 //----------------------------------------------------------------------------
1040 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1043 // Returns the TOF plate number [0;4]
1044 // corresponding to the TOF equipment ID numbers:
1045 // iDDL -> DDL number per sector [0;3]
1046 // nTRM -> TRM number [3;12]
1047 // nTDC -> TDC number [0;14]
1054 if (nTRM>=4 && nTRM<7) {
1056 } else if (nTRM==7) {
1057 if (nTDC<12) iPlate = 0;
1059 } else if (nTRM>=8 && nTRM<11) {
1061 } else if (nTRM==11) {
1062 if (nTDC<9) iPlate = 1;
1064 }else if (nTRM==12) {
1068 } else if (iDDL==1) {
1071 if (nTDC<3) iPlate = 0;
1072 } else if (nTRM>=4 && nTRM<7) {
1074 } else if (nTRM==7) {
1075 if (nTDC<6) iPlate = 1;
1077 } else if (nTRM>=8 && nTRM<11) {
1079 } else if (nTRM==11) {
1080 if (nTDC<9) iPlate = 2;
1082 } else if (nTRM==12) {
1086 } else if (iDDL==2) {
1088 if (nTRM>=4 && nTRM<7) {
1090 } else if (nTRM==7) {
1091 if (nTDC<12) iPlate = 4;
1093 } else if (nTRM>=8 && nTRM<11) {
1095 } else if (nTRM==11) {
1096 if (nTDC<9) iPlate = 3;
1098 }else if (nTRM==12) {
1102 } else if (iDDL==3) {
1105 if (nTDC<3) iPlate = 4;
1106 } else if (nTRM>=4 && nTRM<7) {
1108 } else if (nTRM==7) {
1109 if (nTDC<6) iPlate = 3;
1111 } else if (nTRM>=8 && nTRM<11) {
1113 } else if (nTRM==11) {
1114 if (nTDC<9) iPlate = 2;
1116 } else if (nTRM==12) {
1126 //----------------------------------------------------------------------------
1127 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1130 // Returns the TOF strip number per module:
1131 // [0;14], in the central plates,
1132 // [0;18], in the intermediate and external plates
1133 // corresponding to the TOF equipment ID numbers:
1134 // iDDL -> DDL number per sector [0;3]
1135 // nTRM -> TRM number [3;12]
1136 // nTDC -> TDC number [0;14]
1143 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1144 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1145 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1146 else if (nTRM== 7) {
1147 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1148 else iStrip = (Int_t)(nTDC/3.) - 4;
1150 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1151 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1152 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1153 else if (nTRM==11) {
1154 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1155 else iStrip = (Int_t)(nTDC/3.) - 3;
1157 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1159 } else if (iDDL==1) {
1161 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1162 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1163 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1164 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1165 else if (nTRM== 7) {
1166 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1167 else iStrip = 20 - (Int_t)(nTDC/3.);
1169 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1170 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1171 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1172 else if (nTRM==11) {
1173 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1174 else iStrip = 21 - (Int_t)(nTDC/3.);
1176 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1178 } else if (iDDL==2) {
1180 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1181 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1182 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1183 else if (nTRM== 7) {
1184 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1185 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1187 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1188 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1189 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1190 else if (nTRM==11) {
1191 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1192 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1194 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1196 } else if (iDDL==3) {
1198 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1199 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1200 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1201 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1202 else if (nTRM== 7) {
1203 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1204 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1206 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1207 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1208 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1209 else if (nTRM==11) {
1210 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1211 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1213 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1221 //----------------------------------------------------------------------------
1222 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1226 // Returns the TOF pad number per strip [0;95]
1227 // corresponding to the TOF equipment ID numbers:
1228 // iDDL -> DDL number per sector [0;3]
1229 // iChain -> TRM chain number [0;1]
1230 // nTDC -> TDC number [0;14]
1231 // iCH -> TDC channel number [0;7]
1234 Int_t iPadAlongTheStrip = -1;
1237 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1238 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1239 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1242 Int_t iTDClocal = -1;
1243 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1244 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1245 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1246 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1248 Int_t iCHlocal = iCH;
1249 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1251 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1253 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1254 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1255 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!\n";
1256 //AliWarning("Problems with the padX number!");
1258 return iPadAlongTheStrip;
1262 //----------------------------------------------------------------------------
1263 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1267 // Returns the TOF padX number [0;47]
1268 // corresponding to the TOF equipment ID numbers:
1269 // iDDL -> DDL number per sector [0;3]
1270 // iChain -> TRM chain number [0;1]
1271 // nTDC -> TDC number [0;14]
1272 // iCH -> TDC channel number [0;7]
1275 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1276 (Float_t(AliTOFGeometry::NpadZ())));
1282 //----------------------------------------------------------------------------
1283 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1287 // Returns the TOF padZ number [0;1]
1288 // corresponding to the TOF equipment ID numbers:
1289 // iDDL -> DDL number per sector [0;3]
1290 // iChain -> TRM chain number [0;1]
1291 // nTDC -> TDC number [0;14]
1292 // iCH -> TDC channel number [0;7]
1295 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1301 //----------------------------------------------------------------------------
1302 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1305 // Returns the sector number [0;17]
1306 // corresponing to the assigned DRM/DDL number [0;71]
1309 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1314 //----------------------------------------------------------------------------
1315 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1318 // Return the DRM/DDL number per sector [0;3]
1319 // corresponing to the assigned DRM/DDL number [0;71]
1322 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1328 //----------------------------------------------------------------------------
1329 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1331 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1333 //----------------------------------------------------------------------------
1334 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1335 Int_t nTDC, Int_t iCH,
1340 // nDDL (variable in [0;71]) -> number of the DDL file
1341 // nTRM (variable in [3;12]) -> number of the TRM slot
1342 // iChain (variable in [0; 1]) -> number of the TRM chain
1343 // nTDC (variable in [0;14]) -> number of the TDC
1344 // iCH (variable in [0; 7]) -> number of the TDC channel
1347 // sector number, i.e. volume[0] (variable in [0,17])
1348 // plate number, i.e. volume[1] (variable in [0, 5])
1349 // strip number, i.e. volume[2] (variable in [0,14/18])
1350 // padX number, i.e. volume[3] (variable in [0,47])
1351 // padZ number, i.e. volume[4] (variable in [0, 1])
1354 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1356 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1358 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1359 //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);
1363 Int_t iSector = GetSectorNumber(nDDL);
1365 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1368 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1369 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1373 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1376 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1377 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1381 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1382 if (iPadAlongTheStrip==-1) {
1384 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1385 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1386 nDDL, iChain, nTDC, iCH));
1389 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1390 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1392 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1393 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1395 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1396 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1398 volume[0] = iSector;
1405 //-----------------------------------------------------------------------------
1406 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1408 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1411 //check and fix valid DDL range
1414 fRawReader->AddMinorErrorLog(kDDLMinError);
1415 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1419 fRawReader->AddMinorErrorLog(kDDLMaxError);
1420 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1423 //select required DDLs
1424 fRawReader->Reset();
1425 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1428 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1430 return(Decode(verbose));
1432 //-----------------------------------------------------------------------------
1433 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1435 // New decoder method
1438 Int_t currentEquipment;
1440 const AliRawDataHeader *currentCDH = 0x0;
1441 const AliRawDataHeaderV3 *currentCDHV3 = 0x0;
1444 UChar_t *data = 0x0;
1446 //loop and read DDL headers
1447 while(fRawReader->ReadHeader()){
1449 //get equipment infos
1450 currentEquipment = fRawReader->GetEquipmentId();
1452 currentDDL = fRawReader->GetDDLID();
1453 if (currentDDL==-1) {
1454 fRawReader->AddMajorErrorLog(kDDLdataReading);
1456 AliWarning("Error when load DDL. Go to next DDL");
1460 currentCDH = fRawReader->GetDataHeader();
1461 if (!currentCDH) currentCDHV3 = fRawReader->GetDataHeaderV3();
1462 const Int_t kDataSize = fRawReader->GetDataSize();
1463 const Int_t kDataWords = kDataSize / 4;
1464 data = new UChar_t[kDataSize];
1467 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1470 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1472 //read equipment payload
1473 if (!fRawReader->ReadNext(data, kDataSize))
1475 fRawReader->AddMajorErrorLog(kDDLdataReading);
1477 AliWarning("Error while reading DDL data. Go to next equipment");
1484 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1487 //set up the decoder
1488 fDecoder->SetVerbose(verbose);
1489 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1490 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1493 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH, currentCDHV3) == kTRUE) {
1494 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1495 if (verbose) AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1496 ResetDataBuffer(currentDDL);
1497 ResetPackedDataBuffer(currentDDL);
1505 fRawReader->Reset();
1508 AliInfo("All done");
1513 //-----------------------------------------------------------------------------
1514 Bool_t AliTOFRawStream::DecodeV2(Int_t verbose = 0) {
1516 // Enhanced decoder method
1519 Int_t currentEquipment;
1521 //const AliRawDataHeader *currentCDH;
1524 UChar_t *data = 0x0;
1527 if (!fRawReader->ReadHeader()) return kTRUE;
1529 //get equipment infos
1530 currentEquipment = fRawReader->GetEquipmentId();
1531 currentDDL = fRawReader->GetDDLID();
1532 //currentCDH = fRawReader->GetDataHeader();
1533 const Int_t kDataSize = fRawReader->GetDataSize();
1534 const Int_t kDataWords = kDataSize / 4;
1535 data = new UChar_t[kDataSize];
1538 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1541 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1543 //read equipment payload
1544 if (!fRawReader->ReadNext(data, kDataSize))
1546 fRawReader->AddMajorErrorLog(kDDLdataReading);
1548 AliWarning("Error while reading DDL data. Go to next equipment");
1555 AliInfo(Form("Equipment # %d (DDL # %d) data has been read", currentEquipment, currentDDL));
1558 //set up the decoder
1559 fDecoderV2->SetVerbose(verbose);
1562 if (fDecoderV2->Decode((UInt_t *)data, kDataWords) == kTRUE) {
1563 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1564 if (verbose) AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1570 AliInfo("All done");
1575 //---------------------------------------------------------------------------
1577 AliTOFRawStream::ResetBuffers()
1580 // To reset the buffers
1583 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1584 ResetDataBuffer(iDDL);
1585 ResetPackedDataBuffer(iDDL);
1589 //---------------------------------------------------------------------------
1591 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1594 // To load the buffers
1597 fTOFrawData->Clear();
1601 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1603 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1604 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1605 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1610 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1612 AliTOFHitData *hitData; //hit data pointer
1615 AliInfo("Filling TClonesArray ...");
1618 if (fgApplyBCCorrections) {
1619 AliInfo("Apply nominal DDL BC time-shift correction");
1620 AliInfo("Apply deltaBC time-shift correction");
1623 //loop over DDL packed hits
1624 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1625 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1626 Int_t hitACQ = hitData->GetACQ();
1627 Int_t hitPS = hitData->GetPS();
1628 Int_t hitSlotID = hitData->GetSlotID();
1629 Int_t hitChain = hitData->GetChain();
1630 Int_t hitTDC = hitData->GetTDC();
1631 Int_t hitChan = hitData->GetChan();
1632 Int_t hitTimeBin = hitData->GetTimeBin();
1633 Int_t hitTOTBin = hitData->GetTOTBin();
1634 Int_t hitDeltaBC = hitData->GetDeltaBunchID();
1635 Int_t hitL0L1Latency = hitData->GetL0L1Latency();
1637 Int_t hitLeading = hitData->GetTimeBin();
1638 Int_t hitTrailing = -1;
1639 Int_t hitError = -1;
1641 TClonesArray &arrayTofRawData = *fTOFrawData;
1642 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1649 AliInfo("Resetting buffers ...");
1651 fDataBuffer[indexDDL].Reset();
1652 fPackedDataBuffer[indexDDL].Reset();
1660 //---------------------------------------------------------------------------
1662 AliTOFRawStream::LoadRawDataBuffersV2(Int_t indexDDL, Int_t verbose)
1665 // To load the buffers
1669 * decode raw data and fill output array with TOF hits.
1670 * decode algorithm may return with errors due to inconsistent
1671 * raw data format detected during decoding process.
1672 * decoder algorithm has internal recover procedure to deal with
1673 * errors in a safe condition.
1675 * the following conditions will cause total hit rejection from
1676 * specific boards where the condition is detected:
1678 * --- within DRM payload (full DRM skipped) ---
1679 * - no header/trailer detected
1681 * --- within TRM payload (full TRM skippped) ---
1682 * - no header/trailer detected
1683 * - empty event inserted
1684 * - bad event counter
1688 * --- within chain payload (full chain skipped) ---
1689 * - no header/trailer detected
1691 * - bad event counter
1693 * --- HPTDC (ful TDC skipped) ---
1698 fTOFrawData->Clear();
1702 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1704 //check and fix valid DDL range
1707 fRawReader->AddMinorErrorLog(kDDLMinError);
1708 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1712 fRawReader->AddMinorErrorLog(kDDLMaxError);
1713 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1716 //select required DDLs
1717 fRawReader->Reset();
1718 fRawReader->Select("TOF", indexDDL, indexDDL);
1721 if (DecodeV2(verbose)) return kTRUE;
1723 /* read and check CDH info */
1724 const AliRawDataHeader *currentCDH = fRawReader->GetDataHeader();
1725 const AliRawDataHeaderV3 *currentCDHV3 = fRawReader->GetDataHeaderV3();
1726 Int_t currentMiniEventID = currentCDH ? currentCDH->GetMiniEventID(): -1;
1727 currentMiniEventID = currentCDHV3 ? currentCDHV3->GetMiniEventID(): currentMiniEventID;
1728 Int_t currentEventID1 = currentCDH? currentCDH->GetEventID1() : -1;
1729 currentEventID1 = currentCDHV3? currentCDHV3->GetEventID1() : currentEventID1;
1731 /* read decoder summary data */
1732 AliTOFDecoderSummaryData *decodersd;
1733 AliTOFDRMSummaryData *drmsd;
1734 // AliTOFLTMSummaryData *ltmsd;
1735 AliTOFTRMSummaryData *trmsd;
1736 AliTOFChainSummaryData *chainsd;
1737 AliTOFTDCHitBuffer *hitBuffer;
1739 AliTOFTDCErrorBuffer *errorBuffer;
1740 AliTOFTDCError *error;
1741 Bool_t tdcErrorFlag[15];
1742 decodersd = fDecoderV2->GetDecoderSummaryData();
1744 /* check error detected/recovered */
1745 if (decodersd->GetErrorDetected()) {
1746 AliDebug(2, Form("Error detected while decoding DDL %d (errorSlotID mask = %04x)", indexDDL, decodersd->GetErrorSlotID()));
1747 if (decodersd->GetRecoveringError()) {
1748 AliDebug(2, "Couldn't recover from error");
1751 AliDebug(2, "Error recovered, anyway something is probably lost");
1754 /* check DRM header/trailer */
1755 drmsd = decodersd->GetDRMSummaryData();
1756 if (!drmsd->GetHeader() || !drmsd->GetTrailer()) {
1757 AliWarning("DRM header/trailer missing, skip DDL");
1760 /* check partecipating mask */
1761 if (drmsd->GetPartecipatingSlotID() != drmsd->GetDecoderSlotEnableMask()) {
1762 AliDebug(2, Form("DRM slot enable mask differs from decoder slot enable mask (%08x != %08x) in DDL %d", drmsd->GetSlotEnableMask(), drmsd->GetDecoderSlotEnableMask(), indexDDL));
1763 for (Int_t ibit = 0; ibit < 11; ibit++)
1764 if ((drmsd->GetPartecipatingSlotID() & (0x1 << ibit)) && !(drmsd->GetDecoderSlotEnableMask() & (0x1 << ibit)))
1765 AliDebug(2, Form("readout slot %d data is missing in decoder", ibit + 2));
1769 Int_t currentL0BCID = drmsd->GetL0BCID();
1771 /* loop over TRM to get hits */
1772 Int_t hitACQ, hitPS, hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitDeltaBC, hitL0L1Latency, hitLeading, hitTrailing, hitError;
1773 Int_t currentBunchID;
1775 /* loop over TRMs */
1776 for (Int_t itrm = 0; itrm < 10; itrm++) {
1777 trmsd = drmsd->GetTRMSummaryData(itrm);
1778 /* check header/trailer */
1779 if (!trmsd->GetHeader() || !trmsd->GetTrailer()) continue;
1780 /* skip if TRM empty event detected */
1781 if (trmsd->GetEBit() != 0) continue;
1782 /* skip if bad TRM event counter detected */
1783 if (trmsd->GetEventCounter() != drmsd->GetLocalEventCounter()) continue;
1784 /* skip if bad TRM CRC detected */
1785 AliDebug(2,Form("~~~~~~ %02d %02d --- TRM CRC: as written in raw data =%d and as computed =%d ~~~~~~",indexDDL,itrm,trmsd->GetEventCRC(), trmsd->GetDecoderCRC()));
1786 if (trmsd->GetEventCRC() != trmsd->GetDecoderCRC()) continue;
1788 /* loop over chains */
1789 for (Int_t ichain = 0; ichain < 2; ichain++) {
1790 chainsd = trmsd->GetChainSummaryData(ichain);
1791 /* check header/trailer */
1792 if (!chainsd->GetHeader() || !chainsd->GetTrailer()) continue;
1793 /* skip if chain bad status detected */
1794 if (chainsd->GetStatus() != 0) continue;
1795 /* skip if bad chain event counter detected */
1796 if (chainsd->GetEventCounter() != drmsd->GetLocalEventCounter()) continue;
1798 currentBunchID = chainsd->GetBunchID();
1799 hitBuffer = chainsd->GetTDCPackedHitBuffer();
1800 errorBuffer = chainsd->GetTDCErrorBuffer();
1802 /* check TDC errors and set TDC error flag */
1803 for (Int_t itdc = 0; itdc < 15; itdc++) tdcErrorFlag[itdc] = kFALSE;
1804 for (Int_t ierr = 0; ierr < errorBuffer->GetEntries(); ierr++) {
1805 error = errorBuffer->GetError(ierr);
1806 tdcErrorFlag[error->GetTDCID()] = kTRUE;
1809 /* loop over hits */
1810 for (Int_t ihit = 0; ihit < hitBuffer->GetEntries(); ihit++) {
1813 hit = hitBuffer->GetHit(ihit);
1814 /* skip hit if coming from a TDC with error detected */
1815 if (tdcErrorFlag[hit->GetTDCID()]) continue;
1818 hitACQ = trmsd->GetACQBits();
1819 hitPS = hit->GetPSBits();
1820 hitSlotID = trmsd->GetSlotID();
1821 hitChain = chainsd->GetChain();
1822 hitTDC = hit->GetTDCID();
1823 hitChan = hit->GetChan();
1824 hitTimeBin = hit->GetHitTime();
1825 hitTOTBin = hit->GetTOTWidth();
1826 hitDeltaBC = currentBunchID - currentEventID1;
1827 hitL0L1Latency = currentMiniEventID - currentL0BCID;
1829 hitLeading = hitTimeBin;
1834 TClonesArray &arrayTofRawData = *fTOFrawData;
1835 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1843 //---------------------------------------------------------------------------
1844 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1848 // nSector number -vol[0]- (variable in [0,17])
1849 // nPlate number -vol[1]- (variable in [0, 5])
1850 // nStrip number -vol[2]- (variable in [0,14/18])
1851 // nPadZ number -vol[3]- (variable in [0, 1])
1852 // nPadX number -vol[4]- (variable in [0,47])
1854 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1855 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1856 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1857 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1858 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1861 eqId[0] = Geant2DDL(vol);
1862 eqId[1] = Geant2TRM(vol);
1863 eqId[2] = Geant2TDC(vol);
1864 eqId[3] = Geant2Chain(vol);
1865 eqId[4] = Geant2Channel(vol);
1869 //---------------------------------------------------------------------------
1870 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1874 // nSector number -vol[0]- (variable in [0,17])
1875 // nPlate number -vol[1]- (variable in [0, 5])
1876 // nStrip number -vol[2]- (variable in [0,14/18])
1877 // nPadZ number -vol[3]- (variable in [0, 1])
1878 // nPadX number -vol[4]- (variable in [0,47])
1880 // nDDL (variable in [0;71]) -> number of the DDL
1886 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1887 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1890 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1891 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1894 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1895 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1898 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1899 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1900 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1901 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1902 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1903 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1907 Int_t nSector = vol[0];
1908 Int_t nPlate = vol[1];
1909 Int_t nStrip = vol[2];
1910 Int_t nPadX = vol[4];
1912 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1914 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1916 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1918 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1921 return 4*nSector+iDDL;
1925 //---------------------------------------------------------------------------
1926 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1930 // nSector number -vol[0]- (variable in [0,17])
1931 // nPlate number -vol[1]- (variable in [0, 5])
1932 // nStrip number -vol[2]- (variable in [0,14/18])
1933 // nPadZ number -vol[3]- (variable in [0, 1])
1934 // nPadX number -vol[4]- (variable in [0,47])
1936 // nTRM (variable in [3;12]) -> number of the TRM slot
1941 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1942 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1945 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1946 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1949 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1950 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1953 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1954 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1957 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1958 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1962 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1964 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1968 Int_t nPlate = vol[1];
1969 Int_t nStrip = vol[2];
1971 Int_t iDDL = Geant2DDL(vol)%4;
1978 if (nStrip<= 4) nTRM = 4;
1979 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1980 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1981 else if (nStrip>14) nTRM = 7;
1983 else if (nPlate==1) {
1984 if (nStrip== 0) nTRM = 7;
1985 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1986 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1987 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1988 else if (nStrip>15) nTRM = 11;
1990 else if (nPlate==2) {
1991 if (nStrip<= 1) nTRM = 11;
1992 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1999 if (nStrip== 0) nTRM = 3;
2000 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
2001 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
2002 else if (nStrip>10 && nStrip<=15) nTRM = 6;
2003 else if (nStrip>15) nTRM = 7;
2005 else if (nPlate==1) {
2006 if (nStrip<=1) nTRM = 7;
2007 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
2008 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
2009 else if (nStrip>11 && nStrip<=16) nTRM = 10;
2010 else if (nStrip>16) nTRM = 11;
2012 else if (nPlate==2) {
2013 if (nStrip<= 2) nTRM = 11;
2014 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
2021 if (nStrip>=14) nTRM = 4;
2022 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
2023 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
2024 else if (nStrip< 4) nTRM = 7;
2026 else if (nPlate==3) {
2027 if (nStrip==18) nTRM = 7;
2028 else if (nStrip<18 && nStrip>=13) nTRM = 8;
2029 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
2030 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
2031 else if (nStrip< 3) nTRM = 11;
2033 else if (nPlate==2) {
2034 if (nStrip>=13) nTRM = 11;
2035 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
2042 if (nStrip==18) nTRM = 3;
2043 else if (nStrip<18 && nStrip>=13) nTRM = 4;
2044 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
2045 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
2046 else if (nStrip< 3) nTRM = 7;
2048 else if (nPlate==3) {
2049 if (nStrip>=17) nTRM = 7;
2050 else if (nStrip<17 && nStrip>=12) nTRM = 8;
2051 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
2052 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
2053 else if (nStrip< 2) nTRM = 11;
2055 else if (nPlate==2) {
2056 if (nStrip>=12) nTRM = 11;
2057 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
2068 //---------------------------------------------------------------------------
2069 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
2073 // nSector number -vol[0]- (variable in [0,17])
2074 // nPlate number -vol[1]- (variable in [0, 5])
2075 // nStrip number -vol[2]- (variable in [0,14/18])
2076 // nPadZ number -vol[3]- (variable in [0, 1])
2077 // nPadX number -vol[4]- (variable in [0,47])
2079 // nTDC (variable in [0;14]) -> number of the TDC
2084 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2085 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2088 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2089 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2092 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2093 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2096 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2097 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2098 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2099 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2100 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2101 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2105 Int_t nPlate = vol[1];
2106 Int_t nStrip = vol[2];
2107 Int_t iPadX = vol[4];
2109 Int_t iDDL = Geant2DDL(vol)%4;
2116 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
2117 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
2118 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
2119 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
2121 else if (nPlate==1) {
2122 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
2123 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
2124 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
2125 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
2126 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
2128 else if (nPlate==2) {
2129 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
2130 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
2137 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
2138 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
2139 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
2140 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
2141 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
2143 else if (nPlate==1) {
2144 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
2145 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
2146 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
2147 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
2148 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
2150 else if (nPlate==2) {
2151 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
2152 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
2159 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
2160 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
2161 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
2162 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
2164 else if (nPlate==3) {
2165 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
2166 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
2167 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
2168 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
2169 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
2171 else if (nPlate==2) {
2172 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
2173 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
2180 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
2181 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
2182 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
2183 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
2184 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
2186 else if (nPlate==3) {
2187 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
2188 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
2189 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
2190 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
2191 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
2193 else if (nPlate==2) {
2194 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
2195 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
2206 //---------------------------------------------------------------------------
2207 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
2211 // nSector number -vol[0]- (variable in [0,17])
2212 // nPlate number -vol[1]- (variable in [0, 5])
2213 // nStrip number -vol[2]- (variable in [0,14/18])
2214 // nPadZ number -vol[3]- (variable in [0, 1])
2215 // nPadX number -vol[4]- variable in [0,47])
2217 // nChain (variable in [0; 1]) -> number of the TRM chain
2222 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2223 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2226 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2227 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2230 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2231 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2234 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2235 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2236 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2237 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2238 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2239 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2243 Int_t iPadX = vol[4];
2245 if (iPadX<12 || iPadX>=36) nChain = 0;
2252 //---------------------------------------------------------------------------
2253 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
2257 // nSector number -vol[0]- (variable in [0,17])
2258 // nPlate number -vol[1]- (variable in [0, 5])
2259 // nStrip number -vol[2]- (variable in [0,14/18])
2260 // nPadZ number -vol[3]- (variable in [0, 1])
2261 // nPadX number -vol[4]- (variable in [0,47])
2263 // nChannel (variable in [0; 7]) -> number of the TDC channel
2266 Int_t nChannel = -1;
2268 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2269 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2272 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2273 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2276 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2277 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2280 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2281 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2282 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2283 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2284 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2285 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2289 Int_t iPadZ = vol[3];
2290 Int_t iPadX = vol[4];
2292 Int_t iDDL = Geant2DDL(vol)%4;
2297 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2300 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2303 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2306 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2314 //____________________________________________________________________________
2315 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray * const digitsArray)
2318 // Converts raw data to digits for TOF
2321 TStopwatch stopwatch;
2324 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
2325 //digitsTree->Branch("TOF", &fDigits);
2326 TClonesArray &aDigits = *digitsArray;
2331 SetRawReader(rawReader);
2334 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2336 TClonesArray staticRawData("AliTOFrawData",10000);
2337 staticRawData.Clear();
2338 TClonesArray * clonesRawData = &staticRawData;
2341 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2344 const Int_t kMaxNumberOfTracksPerDigit = 3;
2345 Int_t tracks[kMaxNumberOfTracksPerDigit];
2346 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2352 AliTOFrawData *tofRawDatum = 0;
2353 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2356 if (fNewDecoderVersion) {
2357 AliInfo("Using New Decoder \n");
2358 LoadRawDataBuffers(indexDDL, 0);
2361 LoadRawData(indexDDL);
2363 clonesRawData = GetRawData();
2364 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2365 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2367 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2369 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2370 if (tofRawDatum->GetTOF()==-1) continue;
2372 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2373 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2375 dummy = detectorIndex[3];
2376 detectorIndex[3] = detectorIndex[4];//padz
2377 detectorIndex[4] = dummy;//padx
2379 digit[0] = tofRawDatum->GetTOF();
2380 digit[1] = tofRawDatum->GetTOT();
2381 digit[2] = tofRawDatum->GetTOT();
2382 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2384 dummy = detectorIndex[3];
2385 detectorIndex[3] = detectorIndex[4];//padx
2386 detectorIndex[4] = dummy;//padz
2388 // Do not reconstruct anything in the holes
2389 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2390 if (detectorIndex[1]==2) { // plate with holes
2396 last = digitsArray->GetEntriesFast();
2397 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2400 if (indexDDL<10) ftxt << " " << indexDDL;
2401 else ftxt << " " << indexDDL;
2402 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2403 else ftxt << " " << tofRawDatum->GetTRM();
2404 ftxt << " " << tofRawDatum->GetTRMchain();
2405 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2406 else ftxt << " " << tofRawDatum->GetTDC();
2407 ftxt << " " << tofRawDatum->GetTDCchannel();
2409 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2410 else ftxt << " -> " << detectorIndex[0];
2411 ftxt << " " << detectorIndex[1];
2412 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2413 else ftxt << " " << detectorIndex[2];
2414 ftxt << " " << detectorIndex[4];
2415 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2416 else ftxt << " " << detectorIndex[3];
2418 if (digit[1]<10)ftxt << " " << digit[1];
2419 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2420 else ftxt << " " << digit[1];
2421 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2422 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2423 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2424 else ftxt << " " << digit[3] << endl;
2427 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2429 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2430 digit[0], digit[1], digit[3]));
2433 } // loop on tofRawData array
2435 clonesRawData->Clear();
2439 //if (fVerbose==2) ftxt.close();
2442 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2444 Int_t nDigits = digitsArray->GetEntries();
2445 AliDebug(1, Form("Got %d TOF digits", nDigits));
2446 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2447 stopwatch.RealTime(),stopwatch.CpuTime()));
2451 //____________________________________________________________________________
2452 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray * const sdigitsArray)
2455 // Converts raw data to sdigits for TOF
2458 TStopwatch stopwatch;
2463 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2464 TClonesArray &aSDigits = *sdigitsArray;
2467 SetRawReader(rawReader);
2470 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2472 TClonesArray staticRawData("AliTOFrawData",10000);
2473 staticRawData.Clear();
2474 TClonesArray * clonesRawData = &staticRawData;
2477 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2484 AliTOFrawData *tofRawDatum = 0;
2485 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2488 if (fNewDecoderVersion) {
2489 AliInfo("Using New Decoder \n");
2490 LoadRawDataBuffers(indexDDL, 0);
2493 LoadRawData(indexDDL);
2495 clonesRawData = GetRawData();
2496 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2497 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2499 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2501 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2502 if (tofRawDatum->GetTOF()==-1) continue;
2504 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2505 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2507 dummy = detectorIndex[3];
2508 detectorIndex[3] = detectorIndex[4];//padz
2509 detectorIndex[4] = dummy;//padx
2511 digit[0] = tofRawDatum->GetTOF();
2512 digit[1] = tofRawDatum->GetTOT();
2514 dummy = detectorIndex[3];
2515 detectorIndex[3] = detectorIndex[4];//padx
2516 detectorIndex[4] = dummy;//padz
2518 // Do not reconstruct anything in the holes
2519 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2520 if (detectorIndex[1]==2) { // plate with holes
2526 last = sdigitsArray->GetEntriesFast();
2527 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2530 if (indexDDL<10) ftxt << " " << indexDDL;
2531 else ftxt << " " << indexDDL;
2532 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2533 else ftxt << " " << tofRawDatum->GetTRM();
2534 ftxt << " " << tofRawDatum->GetTRMchain();
2535 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2536 else ftxt << " " << tofRawDatum->GetTDC();
2537 ftxt << " " << tofRawDatum->GetTDCchannel();
2539 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2540 else ftxt << " -> " << detectorIndex[0];
2541 ftxt << " " << detectorIndex[1];
2542 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2543 else ftxt << " " << detectorIndex[2];
2544 ftxt << " " << detectorIndex[4];
2545 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2546 else ftxt << " " << detectorIndex[3];
2548 if (digit[1]<10)ftxt << " " << digit[1];
2549 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2550 else ftxt << " " << digit[1];
2551 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2552 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2553 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2554 else ftxt << " " << digit[3] << endl;
2557 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d)",
2559 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2560 digit[0], digit[1]));
2565 clonesRawData->Clear();
2569 //if (fVerbose==2) ftxt.close();
2571 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2573 Int_t nSDigits = sdigitsArray->GetEntries();
2574 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2575 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2576 stopwatch.RealTime(),stopwatch.CpuTime()));
2580 void AliTOFRawStream::VolumeID2LTM(Int_t detind[],
2585 Int_t &iChannel) const {
2587 // To convert the TOF trigger macropad ID (i.e. detind)
2588 // into TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2591 const Int_t kFirstTDCnumber = 12;
2593 iDDL=-1, iTRM = 3 , iChain=-1, iTDC=-1, iChannel=-1;
2594 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
2602 iDDL = detind[0]*4+2;
2604 iDDL = detind[0]*4+2;
2607 iChain=fgkChainMap24[detind[1]][detind[2]];
2608 iTDC=(Int_t)(fgkChannelMap24[detind[1]][detind[2]]/8)+kFirstTDCnumber;
2609 iChannel=fgkChannelMap24[detind[1]][detind[2]]%8;
2613 void AliTOFRawStream::LTM2VolumeID(Int_t iDDL,
2618 Int_t detind0[], Int_t detind1[]) const {
2620 // To convert the TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2621 // into TOF trigger macropad IDs (i.e. detind0 and detind1).
2622 // In general, a couple of neighbouring TOF semi-strip represents a TOF trigger macropad.
2625 const Int_t kFirstTDCnumber = 12;
2627 Int_t iSector0=-1, iModule0=-1, iStrip0=-1, iPadX0=-1; // Le variabili del Volume ID
2628 Int_t iSector1=-1, iModule1=-1, iStrip1=-1, iPadX1=-1; // Le variabili del Volume ID
2630 if( iDDL%2==1 && iTRM==3 && iTDC-kFirstTDCnumber>=0 && iTDC-kFirstTDCnumber<3 ) {
2631 iSector0 = (Int_t)(iDDL/4);
2632 iSector1 = (Int_t)(iDDL/4);
2633 Int_t iChan= iChannel+(iTDC-kFirstTDCnumber)*8;
2635 if(iChain==0){ //CRATE 0
2638 iStrip0=fgkStrip0MapCrate0[iChan];
2639 iStrip1=fgkStrip1MapCrate0[iChan];
2640 iModule0=fgkModule0MapCrate0[iChan];
2641 iModule1=fgkModule1MapCrate0[iChan];
2643 if(iChain==1){// CRATE 1
2646 iStrip0=fgkStrip0MapCrate1[iChan];
2647 iStrip1=fgkStrip1MapCrate1[iChan];
2648 iModule0=fgkModule0MapCrate1[iChan];
2649 iModule1=fgkModule1MapCrate1[iChan];
2654 if(iChain==1){// CRATE 3
2657 iStrip0=fgkStrip0MapCrate3[iChan];
2658 iStrip1=fgkStrip1MapCrate3[iChan];
2659 iModule0=fgkModule0MapCrate3[iChan];
2660 iModule1=fgkModule1MapCrate3[iChan];
2662 if(iChain==0){// CRATE 2
2665 iStrip0=fgkStrip0MapCrate2[iChan];
2666 iStrip1=fgkStrip1MapCrate2[iChan];
2667 iModule0=fgkModule0MapCrate2[iChan];
2668 iModule1=fgkModule1MapCrate2[iChan];
2673 if(iStrip1==-1 || iModule1==-1){
2681 detind1[0]=iSector1;
2682 detind1[1]=iModule1;
2688 if(iStrip0==-1 || iModule0==-1){
2696 detind0[0]=iSector0;
2697 detind0[1]=iModule0;