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 #include "AliTOFDecoderV2.h"
131 ClassImp(AliTOFRawStream)
133 const Int_t AliTOFRawStream::fgkddlBCshift[72] =
155 const Int_t AliTOFRawStream::fgkStrip0MapCrate0[]=
156 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
157 const Int_t AliTOFRawStream::fgkStrip1MapCrate0[]=
158 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
159 const Int_t AliTOFRawStream::fgkStrip0MapCrate1[]=
160 {1,3,5,7,9,11,13,15,17,0,2,4,6,8,10,12,14,16,18,1,3,5,7,-1};
161 const Int_t AliTOFRawStream::fgkStrip1MapCrate1[]=
162 {0,2,4,6,8,10,12,14,16,18,1,3,5,7,9,11,13,15,17,0,2,4,6,-1};
163 const Int_t AliTOFRawStream::fgkStrip0MapCrate2[]=
164 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
165 const Int_t AliTOFRawStream::fgkStrip1MapCrate2[]=
166 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
167 const Int_t AliTOFRawStream::fgkStrip0MapCrate3[]=
168 {17,15,13,11, 9,7,5,3,1,18,16,14,12,10,8,6,4,2, 0,13,11, 9,7,-1};
169 const Int_t AliTOFRawStream::fgkStrip1MapCrate3[]=
170 {18,16,14,12,10,8,6,4,2, 0,17,15,13,11,9,7,5,3, 1,14,12,10,8,-1};
173 const Int_t AliTOFRawStream::fgkModule0MapCrate0[]=
174 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
175 const Int_t AliTOFRawStream::fgkModule1MapCrate0[]=
176 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
177 const Int_t AliTOFRawStream::fgkModule0MapCrate1[]=
178 {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
179 const Int_t AliTOFRawStream::fgkModule1MapCrate1[]=
180 {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,-1};
182 const Int_t AliTOFRawStream::fgkModule0MapCrate2[]=
183 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
184 const Int_t AliTOFRawStream::fgkModule1MapCrate2[]=
185 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
186 const Int_t AliTOFRawStream::fgkModule0MapCrate3[]=
187 {4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
188 const Int_t AliTOFRawStream::fgkModule1MapCrate3[]=
189 {4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,2,2,2,2,-1};
191 const Int_t AliTOFRawStream::fgkChannelMap0[5][19]=
192 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
193 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
194 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
195 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
196 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
199 const Int_t AliTOFRawStream::fgkChainMap0[5][19]=
200 {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
201 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
202 {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,-1,-1,-1,-1},
203 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
204 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
207 const Int_t AliTOFRawStream::fgkChannelMap24[5][19]=
208 {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9},
209 {9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18},
210 {19,19,20,20,21,21,22,22,22,21,21,20,20,19,19,-1,-1,-1,-1},
211 {18,18,17,17,16,16,15,15,14,14,13,13,12,12,11,11,10,10,9},
212 {9,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,1,0,0}
215 const Int_t AliTOFRawStream::fgkChainMap24[5][19]=
216 {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
217 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
218 {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,-1,-1,-1,-1},
219 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
220 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
223 Bool_t AliTOFRawStream::fgApplyBCCorrections = kTRUE;
224 //_____________________________________________________________________________
225 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
226 fRawReader(rawReader),
227 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
228 fDecoder(new AliTOFDecoder()),
229 fDecoderV2(new AliTOFDecoderV2()),
254 fInsideTRMchain0(kFALSE),
255 fInsideTRMchain1(kFALSE),
257 //fPackedDataBuffer(),
258 fLocalEventCounterDRM(-1),
259 fLocalEventCounterLTM(-1),
260 //fLocalEventCounterTRM(),
261 //fLocalEventCounterChain(),
263 //fCableLengthMap(new AliTOFCableLengthMap()),
265 fNewDecoderVersion(0)
268 // create an object to read TOF raw digits
271 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
273 ResetPackedDataBuffer(i);
276 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
277 fTOFrawData->SetOwner();
280 fRawReader->Select("TOF");
282 for (Int_t jj=0;jj<13;jj++) {
283 fLocalEventCounterTRM[jj] = -1;
284 for (Int_t ii=0;ii<2;ii++) {
285 fLocalEventCounterChain[jj][ii] = -1;
286 fChainBunchID[jj][ii] = -1;
292 //_____________________________________________________________________________
293 AliTOFRawStream::AliTOFRawStream():
295 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
296 fDecoder(new AliTOFDecoder()),
297 fDecoderV2(new AliTOFDecoderV2()),
322 fInsideTRMchain0(kFALSE),
323 fInsideTRMchain1(kFALSE),
325 //fPackedDataBuffer(),
326 fLocalEventCounterDRM(-1),
327 fLocalEventCounterLTM(-1),
328 //fLocalEventCounterTRM(),
329 //fLocalEventCounterChain(),
331 //fCableLengthMap(new AliTOFCableLengthMap()),
333 fNewDecoderVersion(0)
338 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
340 ResetPackedDataBuffer(i);
343 //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
344 fTOFrawData->SetOwner();
346 for (Int_t j=0;j<13;j++){
347 fLocalEventCounterTRM[j] = -1;
348 for (Int_t k=0;k<2;k++){
349 fLocalEventCounterChain[j][k] = -1;
350 fChainBunchID[j][k] = -1;
356 //_____________________________________________________________________________
357 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
359 fRawReader(stream.fRawReader),
360 fTOFrawData(stream.fTOFrawData),
361 fDecoder(new AliTOFDecoder()),
362 fDecoderV2(new AliTOFDecoderV2()),
365 fTRMchain(stream.fTRMchain),
367 fTDCchannel(stream.fTDCchannel),
370 fLeadingEdge(stream.fLeadingEdge),
371 fTrailingEdge(stream.fTrailingEdge),
372 fErrorFlag(stream.fErrorFlag),
373 fSector(stream.fSector),
374 fPlate(stream.fPlate),
375 fStrip(stream.fStrip),
378 fPackedDigits(stream.fPackedDigits),
379 fWordType(stream.fWordType),
380 fSlotID(stream.fSlotID),
382 fPSbit(stream.fPSbit),
383 fTDCerrorFlag(stream.fTDCerrorFlag),
384 fInsideDRM(stream.fInsideDRM),
385 fInsideTRM(stream.fInsideTRM),
386 fInsideLTM(stream.fInsideLTM),
387 fInsideTRMchain0(stream.fInsideTRMchain0),
388 fInsideTRMchain1(stream.fInsideTRMchain1),
390 //fPackedDataBuffer(),
391 fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
392 fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
393 //fLocalEventCounterTRM(),
394 //fLocalEventCounterChain(),
396 //fCableLengthMap(stream.fCableLengthMap),
397 fEventID(stream.fEventID),
398 fNewDecoderVersion(stream.fNewDecoderVersion)
404 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
405 fDataBuffer[i] = stream.fDataBuffer[i];
406 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
409 fTOFrawData = new TClonesArray(*stream.fTOFrawData);
411 for (Int_t j=0;j<13;j++){
412 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
413 for (Int_t k=0;k<2;k++){
414 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
415 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
421 //_____________________________________________________________________________
422 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
425 // assignment operator
431 TObject::operator=(stream);
433 fRawReader = stream.fRawReader;
435 fTOFrawData = stream.fTOFrawData;
439 fTRMchain = stream.fTRMchain;
441 fTDCchannel = stream.fTDCchannel;
442 fTime = stream.fTime;
444 fLeadingEdge = stream.fLeadingEdge;
445 fTrailingEdge = stream.fTrailingEdge;
446 fErrorFlag = stream.fErrorFlag;
448 fSector = stream.fSector;
449 fPlate = stream.fPlate;
450 fStrip = stream.fStrip;
451 fPadX = stream.fPadX;
452 fPadZ = stream.fPadZ;
454 fPackedDigits = stream.fPackedDigits;
456 fWordType = stream.fWordType;
457 fSlotID = stream.fSlotID;
459 fPSbit = stream.fPSbit;
460 fTDCerrorFlag = stream.fTDCerrorFlag;
461 fInsideDRM = stream.fInsideDRM;
462 fInsideTRM = stream.fInsideTRM;
463 fInsideLTM = stream.fInsideLTM;
464 fInsideTRMchain0 = stream.fInsideTRMchain0;
465 fInsideTRMchain1 = stream.fInsideTRMchain1;
467 for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
468 fDataBuffer[i] = stream.fDataBuffer[i];
469 fPackedDataBuffer[i] = stream.fPackedDataBuffer[i];
472 fTOFrawData = stream.fTOFrawData;
474 fLocalEventCounterDRM = stream.fLocalEventCounterDRM;
475 fLocalEventCounterLTM = stream.fLocalEventCounterLTM;
476 for (Int_t j=0;j<13;j++){
477 fLocalEventCounterTRM[j] = stream.fLocalEventCounterTRM[j];
478 for (Int_t k=0;k<2;k++){
479 fLocalEventCounterChain[j][k] = stream.fLocalEventCounterChain[j][k];
480 fChainBunchID[j][k] = stream.fChainBunchID[j][k];
484 //fCableLengthMap = stream.fCableLengthMap;
486 fEventID = stream.fEventID;
487 fNewDecoderVersion = stream.fNewDecoderVersion;
493 //_____________________________________________________________________________
494 AliTOFRawStream::~AliTOFRawStream()
503 fTOFrawData->Clear();
506 //delete fCableLengthMap;
511 //_____________________________________________________________________________
513 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
519 fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
521 fTOFrawData->Clear();
523 TClonesArray &arrayTofRawData = *fTOFrawData;
527 // create raw data map
528 AliTOFRawMap rawMap(fTOFrawData);
531 Int_t slot[4] = {-1, -1, -1, -1};
533 fLocalEventCounterDRM = -1;
534 fLocalEventCounterLTM = -1;
535 for (Int_t ii=0; ii<13; ii++)
536 fLocalEventCounterTRM[ii] = -1;
537 for (Int_t ii=0; ii<13; ii++)
538 for (Int_t jj=0; jj<2; jj++) {
539 fLocalEventCounterChain[ii][jj] = -1;
540 fChainBunchID[ii][jj] = -1;
544 fRawReader->Select("TOF", indexDDL, indexDDL);
546 Bool_t signal = kFALSE;
548 AliTOFrawData *rawDigit = NULL;
552 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
554 AliDebug(2,Form(" %2i %1i %2i %1i %2i", fSector, fPlate, fStrip, fPadZ, fPadX));
559 slot[3] = fTDCchannel;
561 if (rawMap.TestHit(slot) != kEmpty) {
563 rawDigit = static_cast<AliTOFrawData*>(rawMap.GetHit(slot));
565 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
566 fLeadingEdge==-1 && fTrailingEdge!=-1) {
568 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
570 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
571 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
576 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
586 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
590 } // else if (rawMap.TestHit(slot) == kEmpty)
594 } // closed -> while (Next())
598 //_____________________________________________________________________________
599 Bool_t AliTOFRawStream::Next()
602 // Read next 32-bit word in TOF raw data files
603 // returns kFALSE if there is no word left
610 if (!fRawReader->ReadNextInt(data)) return kFALSE;
612 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
624 fDDL = fRawReader->GetDDLID();
626 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
628 switch (fWordType) { // switch word type
630 case GLOBAL_HEADER_TYPE: // global header
631 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
635 switch (fSlotID) { // switch global header slot ID
637 case DRM_ID_NUMBER: //DRM global header
638 if (fInsideDRM) { // unexpected DRM global headers -> exit
641 fInsideDRM = kTRUE; // DRM global header accepted
644 case LTM_ID_NUMBER: // LTM global header
645 if (fInsideLTM) { // unexpected LTM global headers -> exit
648 fInsideLTM = kTRUE; // LTM global header accepted
658 case 10: //TRM header
659 case 11: //TRM header
660 case 12: //TRM header
661 if (fInsideTRM) { // unexpected TRM global headers -> exit
664 fInsideTRM = kTRUE; // TRM global header accepted
665 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
668 default: // unexpected global header slot ID
671 } //end switch global header slot id
676 case GLOBAL_TRAILER_TYPE: // global trailer
677 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
679 switch (fSlotID) { // switch global trailer slot ID
681 case DRM_ID_NUMBER: // DRM global trailer
682 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
686 //AliInfo(Form(" DRM local event counter = %i", GetField(data,dummy,4)));
687 fLocalEventCounterDRM = GetField(data,dummy,4);
688 fInsideDRM = kFALSE; // DRM global trailer accepted
691 fInsideTRMchain0 = kFALSE;
692 fInsideTRMchain1 = kFALSE;
712 case LTM_ID_NUMBER: // LTM global trailer
713 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
717 //AliInfo(Form(" LTM local event counter = %i", GetField(data,dummy,16)));
718 fLocalEventCounterLTM = GetField(data,dummy,16);
719 fInsideLTM = kFALSE; // LTM global trailer accepted
721 case 15: //TRM global trailer
722 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
726 //AliInfo(Form(" TRM local event counter = %i", GetField(data,dummy,16)));
727 fLocalEventCounterTRM[fTRM] = GetField(data,dummy,16);
728 fInsideTRM = kFALSE; // TRM global trailer accepted
730 default: // unexpected global trailer slot ID
732 } //end switch global trailer slot id
738 case ERROR_TYPE: // TDC error
739 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
740 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
744 case FILLER_TYPE: // filler
748 default: // other word types
750 if (fInsideTRM) { // inside TRM
752 switch (fWordType) { // switch word type inside TRM
753 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
754 if (fInsideTRMchain0) { // unexpected TRM chain0 header
757 fInsideTRMchain0 = kTRUE;
760 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
761 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
763 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
764 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
768 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
769 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
770 fInsideTRMchain0 = kFALSE;
773 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
774 if (fInsideTRMchain1) { // unexpected TRM chain1 header
777 fInsideTRMchain1 = kTRUE;
780 //AliInfo(Form(" chain bunch ID = %i", GetField(data,dummy,4)));
781 fChainBunchID[fTRM][fTRMchain] = GetField(data,dummy,4);
783 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
784 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
788 //AliInfo(Form(" chain local event counter = %i", GetField(data,dummy,16)));
789 fLocalEventCounterChain[fTRM][fTRMchain] = GetField(data,dummy,16);
790 fInsideTRMchain1 = kFALSE;
793 } // end switch word type inside TRM
795 } // end if (fInsideTRM)
799 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
800 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
801 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
802 ){ // inside TRM chains
804 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
805 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
806 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
807 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
816 switch (fPSbit) { // switch fPSbit bits inside TRM chains
818 case 0: // packing ok, digit time and TOT
819 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
820 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
822 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
824 if (fgApplyBCCorrections) {
825 AliDebug(2,"Apply nominal DDL BC time-shift correction");
826 AliDebug(2,"Apply deltaBC time-shift correction");
827 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
828 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
832 case 1: // leading edge digit, long digit time, no TOT
835 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_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 fLeadingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
847 case 2: // trailing edge digit, long digit time, no TOT
850 fTrailingEdge = 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 fTrailingEdge += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
862 case 3: // TOT overflow
863 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
864 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION)
866 fCableLengthMap->GetCableTimeShiftBin(fDDL, fTRM, fTRMchain, fTDC)*/
868 if (fgApplyBCCorrections) {
869 AliDebug(2,"Apply nominal DDL BC time-shift correction");
870 AliDebug(2,"Apply deltaBC time-shift correction");
871 AliDebug(2,Form(" fChainBunchID[%d][%d] = %d ,fEventID = %d",fTRM,fTRMchain,fChainBunchID[fTRM][fTRMchain],fEventID));
872 fTime += fgkddlBCshift[fDDL] * 1024 + (fChainBunchID[fTRM][fTRMchain] - fEventID) * 1024;
876 } // end switch PS bits inside TRM chains
878 } // end if is inside TRM chains
880 } // end switch on fWordType
886 //_____________________________________________________________________________
888 void AliTOFRawStream::SetSector()
891 // Evaluate the TOF sector number -> [ 0;17]
892 // corresponding to the TOF equipment IDs:
895 // fTRMchain -> [ 0; 1]
897 // fTDCchannel -> [ 0; 7]
902 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
907 //_____________________________________________________________________________
910 void AliTOFRawStream::SetPlate()
913 // Evaluate the TOF plate number ->[ 0; 4]
914 // corresponding to the TOF equipment IDs:
917 // fTRMchain -> [ 0; 1]
919 // fTDCchannel -> [ 0; 7]
923 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
925 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
930 //_____________________________________________________________________________
932 void AliTOFRawStream::SetStrip()
935 // Evaluate the TOF strip number per module -> [ 0; 14/18]
936 // corresponding to the TOF equipment IDs:
939 // fTRMchain -> [ 0; 1]
941 // fTDCchannel -> [ 0; 7]
946 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
947 || fSector==-1 || fPlate==-1))
948 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
953 //_____________________________________________________________________________
955 void AliTOFRawStream::SetPadZ()
958 // Evaluate the TOF padRow number per strip -> [ 0; 1]
959 // corresponding to the TOF equipment IDs:
962 // fTRMchain -> [ 0; 1]
964 // fTDCchannel -> [ 0; 7]
969 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
970 || fSector==-1 || fPlate==-1 || fStrip==-1))
972 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
973 if (iPadAlongTheStrip!=-1)
974 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
977 //iPadZ = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)%AliTOFGeometry::NpadZ();
978 //iPadZ = Equip2VolNpadZ(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
983 //_____________________________________________________________________________
985 void AliTOFRawStream::SetPadX()
988 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
989 // corresponding to the TOF equipment IDs:
992 // fTRMchain -> [ 0; 1]
994 // fTDCchannel -> [ 0; 7]
999 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1000 || fSector==-1 || fPlate==-1 || fStrip==-1))
1002 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1003 if (iPadAlongTheStrip!=-1)
1004 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1007 //iPadX = (Int_t)(Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel)/(Float_t(AliTOFGeometry::NpadZ())));
1008 //iPadX = Equip2VolNpadX(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1014 //----------------------------------------------------------------------------
1015 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1018 // Returns 'word' masked by 'fieldMask' and shifted by 'fieldPosition'
1021 return ((word & fieldMask) >> fieldPosition);
1024 //----------------------------------------------------------------------------
1025 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1028 // Returns the TOF plate number [0;4]
1029 // corresponding to the TOF equipment ID numbers:
1030 // iDDL -> DDL number per sector [0;3]
1031 // nTRM -> TRM number [3;12]
1032 // nTDC -> TDC number [0;14]
1039 if (nTRM>=4 && nTRM<7) {
1041 } else if (nTRM==7) {
1042 if (nTDC<12) iPlate = 0;
1044 } else if (nTRM>=8 && nTRM<11) {
1046 } else if (nTRM==11) {
1047 if (nTDC<9) iPlate = 1;
1049 }else if (nTRM==12) {
1053 } else if (iDDL==1) {
1056 if (nTDC<3) iPlate = 0;
1057 } else if (nTRM>=4 && nTRM<7) {
1059 } else if (nTRM==7) {
1060 if (nTDC<6) iPlate = 1;
1062 } else if (nTRM>=8 && nTRM<11) {
1064 } else if (nTRM==11) {
1065 if (nTDC<9) iPlate = 2;
1067 } else if (nTRM==12) {
1071 } else if (iDDL==2) {
1073 if (nTRM>=4 && nTRM<7) {
1075 } else if (nTRM==7) {
1076 if (nTDC<12) iPlate = 4;
1078 } else if (nTRM>=8 && nTRM<11) {
1080 } else if (nTRM==11) {
1081 if (nTDC<9) iPlate = 3;
1083 }else if (nTRM==12) {
1087 } else if (iDDL==3) {
1090 if (nTDC<3) iPlate = 4;
1091 } else if (nTRM>=4 && nTRM<7) {
1093 } else if (nTRM==7) {
1094 if (nTDC<6) iPlate = 3;
1096 } else if (nTRM>=8 && nTRM<11) {
1098 } else if (nTRM==11) {
1099 if (nTDC<9) iPlate = 2;
1101 } else if (nTRM==12) {
1111 //----------------------------------------------------------------------------
1112 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
1115 // Returns the TOF strip number per module:
1116 // [0;14], in the central plates,
1117 // [0;18], in the intermediate and external plates
1118 // corresponding to the TOF equipment ID numbers:
1119 // iDDL -> DDL number per sector [0;3]
1120 // nTRM -> TRM number [3;12]
1121 // nTDC -> TDC number [0;14]
1128 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1129 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1130 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1131 else if (nTRM== 7) {
1132 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1133 else iStrip = (Int_t)(nTDC/3.) - 4;
1135 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1136 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1137 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1138 else if (nTRM==11) {
1139 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1140 else iStrip = (Int_t)(nTDC/3.) - 3;
1142 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1144 } else if (iDDL==1) {
1146 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1147 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1148 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1149 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1150 else if (nTRM== 7) {
1151 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1152 else iStrip = 20 - (Int_t)(nTDC/3.);
1154 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1155 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1156 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1157 else if (nTRM==11) {
1158 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1159 else iStrip = 21 - (Int_t)(nTDC/3.);
1161 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1163 } else if (iDDL==2) {
1165 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1166 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1167 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1168 else if (nTRM== 7) {
1169 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1170 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1172 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1173 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1174 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1175 else if (nTRM==11) {
1176 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1177 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1179 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1181 } else if (iDDL==3) {
1183 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1184 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1185 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1186 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1187 else if (nTRM== 7) {
1188 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1189 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1191 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1192 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1193 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1194 else if (nTRM==11) {
1195 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1196 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1198 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1206 //----------------------------------------------------------------------------
1207 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1211 // Returns the TOF pad number per strip [0;95]
1212 // corresponding to the TOF equipment ID numbers:
1213 // iDDL -> DDL number per sector [0;3]
1214 // iChain -> TRM chain number [0;1]
1215 // nTDC -> TDC number [0;14]
1216 // iCH -> TDC channel number [0;7]
1219 Int_t iPadAlongTheStrip = -1;
1222 //Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1223 //if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1224 //else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1227 Int_t iTDClocal = -1;
1228 Int_t iTDClocal03 = nTDC%3 + (1-iChain)*3;
1229 Int_t iTDClocal12 = 2-nTDC%3 + iChain*3;
1230 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal03;
1231 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal12);
1233 Int_t iCHlocal = iCH;
1234 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1236 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1238 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1239 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
1240 std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!\n";
1241 //AliWarning("Problems with the padX number!");
1243 return iPadAlongTheStrip;
1247 //----------------------------------------------------------------------------
1248 Int_t AliTOFRawStream::Equip2VolNpadX(Int_t iDDL, Int_t iChain, Int_t nTDC,
1252 // Returns the TOF padX number [0;47]
1253 // corresponding to the TOF equipment ID numbers:
1254 // iDDL -> DDL number per sector [0;3]
1255 // iChain -> TRM chain number [0;1]
1256 // nTDC -> TDC number [0;14]
1257 // iCH -> TDC channel number [0;7]
1260 Int_t iPadX = (Int_t)(AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)/
1261 (Float_t(AliTOFGeometry::NpadZ())));
1267 //----------------------------------------------------------------------------
1268 Int_t AliTOFRawStream::Equip2VolNpadZ(Int_t iDDL, Int_t iChain, Int_t nTDC,
1272 // Returns the TOF padZ number [0;1]
1273 // corresponding to the TOF equipment ID numbers:
1274 // iDDL -> DDL number per sector [0;3]
1275 // iChain -> TRM chain number [0;1]
1276 // nTDC -> TDC number [0;14]
1277 // iCH -> TDC channel number [0;7]
1280 Int_t iPadZ = AliTOFRawStream::Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1286 //----------------------------------------------------------------------------
1287 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL)
1290 // Returns the sector number [0;17]
1291 // corresponing to the assigned DRM/DDL number [0;71]
1294 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1299 //----------------------------------------------------------------------------
1300 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL)
1303 // Return the DRM/DDL number per sector [0;3]
1304 // corresponing to the assigned DRM/DDL number [0;71]
1307 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1313 //----------------------------------------------------------------------------
1314 void AliTOFRawStream::EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const
1316 EquipmentId2VolumeId(hitData->GetDDLID(),hitData->GetSlotID(),hitData->GetChain(),hitData->GetTDC(),hitData->GetChan(),volume);
1318 //----------------------------------------------------------------------------
1319 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1320 Int_t nTDC, Int_t iCH,
1325 // nDDL (variable in [0;71]) -> number of the DDL file
1326 // nTRM (variable in [3;12]) -> number of the TRM slot
1327 // iChain (variable in [0; 1]) -> number of the TRM chain
1328 // nTDC (variable in [0;14]) -> number of the TDC
1329 // iCH (variable in [0; 7]) -> number of the TDC channel
1332 // sector number, i.e. volume[0] (variable in [0,17])
1333 // plate number, i.e. volume[1] (variable in [0, 5])
1334 // strip number, i.e. volume[2] (variable in [0,14/18])
1335 // padX number, i.e. volume[3] (variable in [0,47])
1336 // padZ number, i.e. volume[4] (variable in [0, 1])
1339 for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
1341 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1343 if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
1344 //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);
1348 Int_t iSector = GetSectorNumber(nDDL);
1350 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1353 fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
1354 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
1358 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1361 fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
1362 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
1366 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1367 if (iPadAlongTheStrip==-1) {
1369 fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
1370 AliWarningGeneral("AliTOFRawStream", Form("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
1371 nDDL, iChain, nTDC, iCH));
1374 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1375 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1377 //Int_t iPadX = (Int_t)(Equip2VolNpad(iDDL, iChain, nTDC, iCH)/(Float_t(AliTOFGeometry::NpadZ())));
1378 //Int_t iPadZ = Equip2VolNpad(iDDL, iChain, nTDC, iCH)%AliTOFGeometry::NpadZ();
1380 //Int_t iPadX = Equip2VolNpadX(iDDL, iChain, nTDC, iCH);
1381 //Int_t iPadZ = Equip2VolNpadZ(iDDL, iChain, nTDC, iCH);
1383 volume[0] = iSector;
1390 //-----------------------------------------------------------------------------
1391 Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
1393 // To decode raw data for DDL number in [nDDLmin; nDDLmax]
1396 //check and fix valid DDL range
1399 fRawReader->AddMinorErrorLog(kDDLMinError);
1400 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1404 fRawReader->AddMinorErrorLog(kDDLMaxError);
1405 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1408 //select required DDLs
1409 fRawReader->Reset();
1410 fRawReader->Select("TOF", nDDLMin, nDDLMax);
1413 AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
1415 return(Decode(verbose));
1417 //-----------------------------------------------------------------------------
1418 Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
1420 // New decoder method
1423 Int_t currentEquipment;
1425 const AliRawDataHeader *currentCDH;
1428 UChar_t *data = 0x0;
1430 //loop and read DDL headers
1431 while(fRawReader->ReadHeader()){
1433 //memory leak prevention (actually data should be always 0x0 here)
1437 //get equipment infos
1438 currentEquipment = fRawReader->GetEquipmentId();
1439 currentDDL = fRawReader->GetDDLID();
1440 currentCDH = fRawReader->GetDataHeader();
1441 const Int_t kDataSize = fRawReader->GetDataSize();
1442 const Int_t kDataWords = kDataSize / 4;
1443 data = new UChar_t[kDataSize];
1446 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1449 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1451 //read equipment payload
1452 if (!fRawReader->ReadNext(data, kDataSize))
1454 fRawReader->AddMajorErrorLog(kDDLdataReading);
1456 AliWarning("Error while reading DDL data. Go to next equipment");
1463 AliInfo(Form("Equipment # %d (DDL # %d) data has been readed", currentEquipment, currentDDL));
1466 //set up the decoder
1467 fDecoder->SetVerbose(verbose);
1468 fDecoder->SetDataBuffer(&fDataBuffer[currentDDL]);
1469 fDecoder->SetPackedDataBuffer(&fPackedDataBuffer[currentDDL]);
1472 if (fDecoder->Decode((UInt_t *)data, kDataWords, currentCDH) == kTRUE) {
1473 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1474 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1475 ResetDataBuffer(currentDDL);
1476 ResetPackedDataBuffer(currentDDL);
1484 fRawReader->Reset();
1487 AliInfo("All done");
1492 //-----------------------------------------------------------------------------
1493 Bool_t AliTOFRawStream::DecodeV2(Int_t verbose = 0) {
1495 // Enhanced decoder method
1498 Int_t currentEquipment;
1500 const AliRawDataHeader *currentCDH;
1503 UChar_t *data = 0x0;
1506 if (!fRawReader->ReadHeader()) return kTRUE;
1508 //get equipment infos
1509 currentEquipment = fRawReader->GetEquipmentId();
1510 currentDDL = fRawReader->GetDDLID();
1511 currentCDH = fRawReader->GetDataHeader();
1512 const Int_t kDataSize = fRawReader->GetDataSize();
1513 const Int_t kDataWords = kDataSize / 4;
1514 data = new UChar_t[kDataSize];
1517 AliInfo(Form("Found equipment # %d header (DDL # %d): %d bytes (%d words)", currentEquipment, currentDDL, kDataSize, kDataWords));
1520 AliInfo(Form("Reading equipment #%d (DDL # %d) data...", currentEquipment, currentDDL));
1522 //read equipment payload
1523 if (!fRawReader->ReadNext(data, kDataSize))
1525 fRawReader->AddMajorErrorLog(kDDLdataReading);
1527 AliWarning("Error while reading DDL data. Go to next equipment");
1534 AliInfo(Form("Equipment # %d (DDL # %d) data has been read", currentEquipment, currentDDL));
1537 //set up the decoder
1538 fDecoderV2->SetVerbose(verbose);
1541 if (fDecoderV2->Decode((UInt_t *)data, kDataWords) == kTRUE) {
1542 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
1543 AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
1549 AliInfo("All done");
1554 //---------------------------------------------------------------------------
1556 AliTOFRawStream::ResetBuffers()
1559 // To reset the buffers
1562 for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
1563 ResetDataBuffer(iDDL);
1564 ResetPackedDataBuffer(iDDL);
1568 //---------------------------------------------------------------------------
1570 AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
1573 // To load the buffers
1576 fTOFrawData->Clear();
1580 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1582 if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
1583 fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
1584 AliWarning(Form("Error while decoding DDL # %d", indexDDL));
1589 AliInfo(Form("Done. %d packed %s been found.", fPackedDataBuffer[indexDDL].GetEntries(), fPackedDataBuffer[indexDDL].GetEntries() > 1 ? "hits have" : "hit has"));
1591 AliTOFHitData *hitData; //hit data pointer
1594 AliInfo("Filling TClonesArray ...");
1597 if (fgApplyBCCorrections) {
1598 AliInfo("Apply nominal DDL BC time-shift correction");
1599 AliInfo("Apply deltaBC time-shift correction");
1602 //loop over DDL packed hits
1603 for (Int_t iHit = 0; iHit < fPackedDataBuffer[indexDDL].GetEntries(); iHit++){
1604 hitData = fPackedDataBuffer[indexDDL].GetHit(iHit); //get hit data
1605 Int_t hitACQ = hitData->GetACQ();
1606 Int_t hitPS = hitData->GetPS();
1607 Int_t hitSlotID = hitData->GetSlotID();
1608 Int_t hitChain = hitData->GetChain();
1609 Int_t hitTDC = hitData->GetTDC();
1610 Int_t hitChan = hitData->GetChan();
1611 Int_t hitTimeBin = hitData->GetTimeBin();
1612 Int_t hitTOTBin = hitData->GetTOTBin();
1613 Int_t hitDeltaBC = hitData->GetDeltaBunchID();
1614 Int_t hitL0L1Latency = hitData->GetL0L1Latency();
1616 Int_t hitLeading = hitData->GetTimeBin();
1617 Int_t hitTrailing = -1;
1618 Int_t hitError = -1;
1620 TClonesArray &arrayTofRawData = *fTOFrawData;
1621 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1628 AliInfo("Resetting buffers ...");
1630 fDataBuffer[indexDDL].Reset();
1631 fPackedDataBuffer[indexDDL].Reset();
1639 //---------------------------------------------------------------------------
1641 AliTOFRawStream::LoadRawDataBuffersV2(Int_t indexDDL, Int_t verbose)
1644 // To load the buffers
1648 * decode raw data and fill output array with TOF hits.
1649 * decode algorithm may return with errors due to inconsistent
1650 * raw data format detected during decoding process.
1651 * decoder algorithm has internal recover procedure to deal with
1652 * errors in a safe condition.
1654 * the following conditions will cause total hit rejection from
1655 * specific boards where the condition is detected:
1657 * --- within DRM payload (full DRM skipped) ---
1658 * - no header/trailer detected
1660 * --- within TRM payload (full TRM skippped) ---
1661 * - no header/trailer detected
1662 * - empty event inserted
1663 * - bad event counter
1667 * --- within chain payload (full chain skipped) ---
1668 * - no header/trailer detected
1670 * - bad event counter
1672 * --- HPTDC (ful TDC skipped) ---
1677 fTOFrawData->Clear();
1681 AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
1683 //check and fix valid DDL range
1686 fRawReader->AddMinorErrorLog(kDDLMinError);
1687 AliWarning("Wrong DDL range: setting first DDL ID to 0");
1691 fRawReader->AddMinorErrorLog(kDDLMaxError);
1692 AliWarning("Wrong DDL range: setting last DDL ID to 71");
1695 //select required DDLs
1696 fRawReader->Reset();
1697 fRawReader->Select("TOF", indexDDL, indexDDL);
1700 if (DecodeV2(verbose)) return kTRUE;
1702 /* read and check CDH info */
1703 const AliRawDataHeader *currentCDH = fRawReader->GetDataHeader();
1704 Int_t currentMiniEventID = currentCDH->GetMiniEventID();
1705 Int_t currentEventID1 = currentCDH->GetEventID1();
1707 /* read decoder summary data */
1708 AliTOFDecoderSummaryData *decodersd;
1709 AliTOFDRMSummaryData *drmsd;
1710 // AliTOFLTMSummaryData *ltmsd;
1711 AliTOFTRMSummaryData *trmsd;
1712 AliTOFChainSummaryData *chainsd;
1713 AliTOFTDCHitBuffer *hitBuffer;
1715 AliTOFTDCErrorBuffer *errorBuffer;
1716 AliTOFTDCError *error;
1717 Bool_t tdcErrorFlag[15];
1718 decodersd = fDecoderV2->GetDecoderSummaryData();
1720 /* check error detected/recovered */
1721 if (decodersd->GetErrorDetected()) {
1722 AliWarning(Form("Error detected while decoding DDL %d (errorSlotID mask = %04x)", indexDDL, decodersd->GetErrorSlotID()));
1723 if (decodersd->GetRecoveringError()) {
1724 AliWarning("Couldn't recover from error");
1727 AliWarning("Error recovered, anyway something is probably lost");
1730 /* check DRM header/trailer */
1731 drmsd = decodersd->GetDRMSummaryData();
1732 if (!drmsd->GetHeader() || !drmsd->GetTrailer()) {
1733 AliWarning("DRM header/trailer missing, skip DDL");
1736 /* check partecipating mask */
1737 if (drmsd->GetPartecipatingSlotID() != drmsd->GetDecoderSlotEnableMask()) {
1738 AliWarning(Form("DRM slot enable mask differs from decoder slot enable mask (%08x != %08x) in DDL %d", drmsd->GetSlotEnableMask(), drmsd->GetDecoderSlotEnableMask(), indexDDL));
1739 for (Int_t ibit = 0; ibit < 11; ibit++)
1740 if ((drmsd->GetPartecipatingSlotID() & (0x1 << ibit)) && !(drmsd->GetDecoderSlotEnableMask() & (0x1 << ibit)))
1741 AliWarning(Form("readout slot %d data is missing in decoder", ibit + 2));
1745 Int_t currentL0BCID = drmsd->GetL0BCID();
1747 /* loop over TRM to get hits */
1748 Int_t hitACQ, hitPS, hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitDeltaBC, hitL0L1Latency, hitLeading, hitTrailing, hitError;
1749 Int_t currentBunchID;
1751 /* loop over TRMs */
1752 for (Int_t itrm = 0; itrm < 10; itrm++) {
1753 trmsd = drmsd->GetTRMSummaryData(itrm);
1754 /* check header/trailer */
1755 if (!trmsd->GetHeader() || !trmsd->GetTrailer()) continue;
1756 /* skip if TRM empty event detected */
1757 if (trmsd->GetEBit() != 0) continue;
1758 /* skip if bad TRM event counter detected */
1759 if (trmsd->GetEventCounter() != drmsd->GetLocalEventCounter()) continue;
1760 /* skip if bad TRM CRC detected */
1761 if (trmsd->GetEventCRC() != trmsd->GetDecoderCRC()) continue;
1763 /* loop over chains */
1764 for (Int_t ichain = 0; ichain < 2; ichain++) {
1765 chainsd = trmsd->GetChainSummaryData(ichain);
1766 /* check header/trailer */
1767 if (!chainsd->GetHeader() || !chainsd->GetTrailer()) continue;
1768 /* skip if chain bad status detected */
1769 if (chainsd->GetStatus() != 0) continue;
1770 /* skip if bad chain event counter detected */
1771 if (chainsd->GetEventCounter() != drmsd->GetLocalEventCounter()) continue;
1773 currentBunchID = chainsd->GetBunchID();
1774 hitBuffer = chainsd->GetTDCPackedHitBuffer();
1775 errorBuffer = chainsd->GetTDCErrorBuffer();
1777 /* check TDC errors and set TDC error flag */
1778 for (Int_t itdc = 0; itdc < 15; itdc++) tdcErrorFlag[itdc] = kFALSE;
1779 for (Int_t ierr = 0; ierr < errorBuffer->GetEntries(); ierr++) {
1780 error = errorBuffer->GetError(ierr);
1781 tdcErrorFlag[error->GetTDCID()] = kTRUE;
1784 /* loop over hits */
1785 for (Int_t ihit = 0; ihit < hitBuffer->GetEntries(); ihit++) {
1788 hit = hitBuffer->GetHit(ihit);
1789 /* skip hit if coming from a TDC with error detected */
1790 if (tdcErrorFlag[hit->GetTDCID()]) continue;
1793 hitACQ = trmsd->GetACQBits();
1794 hitPS = hit->GetPSBits();
1795 hitSlotID = trmsd->GetSlotID();
1796 hitChain = chainsd->GetChain();
1797 hitTDC = hit->GetTDCID();
1798 hitChan = hit->GetChan();
1799 hitTimeBin = hit->GetHitTime();
1800 hitTOTBin = hit->GetTOTWidth();
1801 hitDeltaBC = currentBunchID - currentEventID1;
1802 hitL0L1Latency = currentMiniEventID - currentL0BCID;
1804 hitLeading = hitTimeBin;
1809 TClonesArray &arrayTofRawData = *fTOFrawData;
1810 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError, hitDeltaBC, hitL0L1Latency);
1818 //---------------------------------------------------------------------------
1819 void AliTOFRawStream::Geant2EquipmentId(Int_t vol[], Int_t eqId[])
1823 // nSector number -vol[0]- (variable in [0,17])
1824 // nPlate number -vol[1]- (variable in [0, 5])
1825 // nStrip number -vol[2]- (variable in [0,14/18])
1826 // nPadZ number -vol[3]- (variable in [0, 1])
1827 // nPadX number -vol[4]- (variable in [0,47])
1829 // nDDL -eqId[0]- (variable in [0;71]) -> number of the DDL
1830 // nTRM -eqId[1]- (variable in [3;12]) -> number of the TRM
1831 // nTDC -eqId[2]- (variable in [0;14]) -> number of the TDC
1832 // nChain -eqId[3]- (variable in [0; 1]) -> number of the chain
1833 // nChannel -eqId[4]- (variable in [0; 8]) -> number of the channel
1836 eqId[0] = Geant2DDL(vol);
1837 eqId[1] = Geant2TRM(vol);
1838 eqId[2] = Geant2TDC(vol);
1839 eqId[3] = Geant2Chain(vol);
1840 eqId[4] = Geant2Channel(vol);
1844 //---------------------------------------------------------------------------
1845 Int_t AliTOFRawStream::Geant2DDL(Int_t vol[])
1849 // nSector number -vol[0]- (variable in [0,17])
1850 // nPlate number -vol[1]- (variable in [0, 5])
1851 // nStrip number -vol[2]- (variable in [0,14/18])
1852 // nPadZ number -vol[3]- (variable in [0, 1])
1853 // nPadX number -vol[4]- (variable in [0,47])
1855 // nDDL (variable in [0;71]) -> number of the DDL
1861 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1862 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1865 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1866 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1869 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1870 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1873 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
1874 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1875 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
1876 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1877 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
1878 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1882 Int_t nSector = vol[0];
1883 Int_t nPlate = vol[1];
1884 Int_t nStrip = vol[2];
1885 Int_t nPadX = vol[4];
1887 if ( nPadX<24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<7) ) )
1889 else if ( nPadX>=24 && ( nPlate==0 || nPlate==1 || (nPlate==2 && nStrip<8) ) )
1891 else if ( nPadX>=24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>7) ) )
1893 else if ( nPadX<24 && ( nPlate==3 || nPlate==4 || (nPlate==2 && nStrip>6) ) )
1896 return 4*nSector+iDDL;
1900 //---------------------------------------------------------------------------
1901 Int_t AliTOFRawStream::Geant2TRM(Int_t vol[])
1905 // nSector number -vol[0]- (variable in [0,17])
1906 // nPlate number -vol[1]- (variable in [0, 5])
1907 // nStrip number -vol[2]- (variable in [0,14/18])
1908 // nPadZ number -vol[3]- (variable in [0, 1])
1909 // nPadX number -vol[4]- (variable in [0,47])
1911 // nTRM (variable in [3;12]) -> number of the TRM slot
1916 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
1917 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
1920 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
1921 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
1924 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
1925 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
1928 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ()) {
1929 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
1932 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX()) {
1933 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
1937 if ( vol[3]>=AliTOFGeometry::NpadZ() )
1939 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
1943 Int_t nPlate = vol[1];
1944 Int_t nStrip = vol[2];
1946 Int_t iDDL = Geant2DDL(vol)%4;
1953 if (nStrip<= 4) nTRM = 4;
1954 else if (nStrip> 4 && nStrip<= 9) nTRM = 5;
1955 else if (nStrip> 9 && nStrip<=14) nTRM = 6;
1956 else if (nStrip>14) nTRM = 7;
1958 else if (nPlate==1) {
1959 if (nStrip== 0) nTRM = 7;
1960 else if (nStrip> 0 && nStrip<= 5) nTRM = 8;
1961 else if (nStrip> 5 && nStrip<=10) nTRM = 9;
1962 else if (nStrip>10 && nStrip<=15) nTRM = 10;
1963 else if (nStrip>15) nTRM = 11;
1965 else if (nPlate==2) {
1966 if (nStrip<= 1) nTRM = 11;
1967 else if (nStrip> 1 && nStrip< 7) nTRM = 12;
1974 if (nStrip== 0) nTRM = 3;
1975 else if (nStrip> 0 && nStrip<= 5) nTRM = 4;
1976 else if (nStrip> 5 && nStrip<=10) nTRM = 5;
1977 else if (nStrip>10 && nStrip<=15) nTRM = 6;
1978 else if (nStrip>15) nTRM = 7;
1980 else if (nPlate==1) {
1981 if (nStrip<=1) nTRM = 7;
1982 else if (nStrip> 1 && nStrip<= 6) nTRM = 8;
1983 else if (nStrip> 6 && nStrip<=11) nTRM = 9;
1984 else if (nStrip>11 && nStrip<=16) nTRM = 10;
1985 else if (nStrip>16) nTRM = 11;
1987 else if (nPlate==2) {
1988 if (nStrip<= 2) nTRM = 11;
1989 else if (nStrip> 2 && nStrip<= 7) nTRM = 12;
1996 if (nStrip>=14) nTRM = 4;
1997 else if (nStrip<14 && nStrip>= 9) nTRM = 5;
1998 else if (nStrip< 9 && nStrip>= 4) nTRM = 6;
1999 else if (nStrip< 4) nTRM = 7;
2001 else if (nPlate==3) {
2002 if (nStrip==18) nTRM = 7;
2003 else if (nStrip<18 && nStrip>=13) nTRM = 8;
2004 else if (nStrip<13 && nStrip>= 8) nTRM = 9;
2005 else if (nStrip< 8 && nStrip>= 3) nTRM = 10;
2006 else if (nStrip< 3) nTRM = 11;
2008 else if (nPlate==2) {
2009 if (nStrip>=13) nTRM = 11;
2010 else if (nStrip<13 && nStrip>= 8) nTRM = 12;
2017 if (nStrip==18) nTRM = 3;
2018 else if (nStrip<18 && nStrip>=13) nTRM = 4;
2019 else if (nStrip<13 && nStrip>= 8) nTRM = 5;
2020 else if (nStrip< 8 && nStrip>= 3) nTRM = 6;
2021 else if (nStrip< 3) nTRM = 7;
2023 else if (nPlate==3) {
2024 if (nStrip>=17) nTRM = 7;
2025 else if (nStrip<17 && nStrip>=12) nTRM = 8;
2026 else if (nStrip<12 && nStrip>= 7) nTRM = 9;
2027 else if (nStrip< 7 && nStrip>= 2) nTRM = 10;
2028 else if (nStrip< 2) nTRM = 11;
2030 else if (nPlate==2) {
2031 if (nStrip>=12) nTRM = 11;
2032 else if (nStrip <12 && nStrip>= 7) nTRM = 12;
2043 //---------------------------------------------------------------------------
2044 Int_t AliTOFRawStream::Geant2TDC(Int_t vol[])
2048 // nSector number -vol[0]- (variable in [0,17])
2049 // nPlate number -vol[1]- (variable in [0, 5])
2050 // nStrip number -vol[2]- (variable in [0,14/18])
2051 // nPadZ number -vol[3]- (variable in [0, 1])
2052 // nPadX number -vol[4]- (variable in [0,47])
2054 // nTDC (variable in [0;14]) -> number of the TDC
2059 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2060 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2063 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2064 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2067 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2068 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2071 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2072 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2073 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2074 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2075 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2076 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2080 Int_t nPlate = vol[1];
2081 Int_t nStrip = vol[2];
2082 Int_t iPadX = vol[4];
2084 Int_t iDDL = Geant2DDL(vol)%4;
2091 if (nStrip<= 4) nTDC = (3*(nStrip)+2-(iPadX/4)%3);
2092 else if (nStrip> 4 && nStrip<= 9) nTDC = (3*(nStrip- 5)+2-(iPadX/4)%3);
2093 else if (nStrip> 9 && nStrip<=14) nTDC = (3*(nStrip-10)+2-(iPadX/4)%3);
2094 else if (nStrip>14) nTDC = (3*(nStrip-15)+2-(iPadX/4)%3);
2096 else if (nPlate==1) {
2097 if (nStrip== 0) nTDC = (3*(nStrip+ 4)+2-(iPadX/4)%3);
2098 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*(nStrip- 1)+2-(iPadX/4)%3);
2099 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(nStrip- 6)+2-(iPadX/4)%3);
2100 else if (nStrip>10 && nStrip<=15) nTDC = (3*(nStrip-11)+2-(iPadX/4)%3);
2101 else if (nStrip>15) nTDC = (3*(nStrip-16)+2-(iPadX/4)%3);
2103 else if (nPlate==2) {
2104 if (nStrip<= 1) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
2105 else if (nStrip> 1 && nStrip< 7) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
2112 if (nStrip== 0) nTDC = (3*(nStrip)+(iPadX/4)%3);
2113 else if (nStrip> 0 && nStrip<= 5) nTDC = (3*( 5-nStrip)+(iPadX/4)%3);
2114 else if (nStrip> 5 && nStrip<=10) nTDC = (3*(10-nStrip)+(iPadX/4)%3);
2115 else if (nStrip>10 && nStrip<=15) nTDC = (3*(15-nStrip)+(iPadX/4)%3);
2116 else if (nStrip>15) nTDC = (3*(20-nStrip)+(iPadX/4)%3);
2118 else if (nPlate==1) {
2119 if (nStrip<= 1) nTDC = (3*( 1-nStrip)+(iPadX/4)%3);
2120 else if (nStrip> 1 && nStrip<= 6) nTDC = (3*( 6-nStrip)+(iPadX/4)%3);
2121 else if (nStrip> 6 && nStrip<=11) nTDC = (3*(11-nStrip)+(iPadX/4)%3);
2122 else if (nStrip>11 && nStrip<=16) nTDC = (3*(16-nStrip)+(iPadX/4)%3);
2123 else if (nStrip>16) nTDC = (3*(21-nStrip)+(iPadX/4)%3);
2125 else if (nPlate==2) {
2126 if (nStrip<= 2) nTDC = (3*( 2-nStrip)+(iPadX/4)%3);
2127 else if (nStrip> 2 && nStrip<= 7) nTDC = (3*( 7-nStrip)+(iPadX/4)%3);
2134 if (nStrip>=14) nTDC = (3*(18-nStrip)+((iPadX/4)%3));
2135 else if (nStrip<14 && nStrip>= 9) nTDC = (3*(13-nStrip)+((iPadX/4)%3));
2136 else if (nStrip< 9 && nStrip>= 4) nTDC = (3*( 8-nStrip)+((iPadX/4)%3));
2137 else if (nStrip< 4) nTDC = (3*( 3-nStrip)+((iPadX/4)%3));
2139 else if (nPlate==3) {
2140 if (nStrip==18) nTDC = (3*(22-nStrip)+((iPadX/4)%3));
2141 else if (nStrip<18 && nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
2142 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
2143 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*( 7-nStrip)+((iPadX/4)%3));
2144 else if (nStrip< 3) nTDC = (3*( 2-nStrip)+((iPadX/4)%3));
2146 else if (nPlate==2) {
2147 if (nStrip>=13) nTDC = (3*(17-nStrip)+((iPadX/4)%3));
2148 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(12-nStrip)+((iPadX/4)%3));
2155 if (nStrip==18) nTDC = (3*(nStrip-18)+2-(iPadX/4)%3);
2156 else if (nStrip<18 && nStrip>=13) nTDC = (3*(nStrip-13)+2-(iPadX/4)%3);
2157 else if (nStrip<13 && nStrip>= 8) nTDC = (3*(nStrip- 8)+2-(iPadX/4)%3);
2158 else if (nStrip< 8 && nStrip>= 3) nTDC = (3*(nStrip- 3)+2-(iPadX/4)%3);
2159 else if (nStrip< 3) nTDC = (3*(nStrip+ 2)+2-(iPadX/4)%3);
2161 else if (nPlate==3) {
2162 if (nStrip>=17) nTDC = (3*(nStrip-17)+2-(iPadX/4)%3);
2163 else if (nStrip<17 && nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
2164 else if (nStrip<12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
2165 else if (nStrip< 7 && nStrip>= 2) nTDC = (3*(nStrip- 2)+2-(iPadX/4)%3);
2166 else if (nStrip< 2) nTDC = (3*(nStrip+ 3)+2-(iPadX/4)%3);
2168 else if (nPlate==2) {
2169 if (nStrip>=12) nTDC = (3*(nStrip-12)+2-(iPadX/4)%3);
2170 else if (nStrip <12 && nStrip>= 7) nTDC = (3*(nStrip- 7)+2-(iPadX/4)%3);
2181 //---------------------------------------------------------------------------
2182 Int_t AliTOFRawStream::Geant2Chain(Int_t vol[])
2186 // nSector number -vol[0]- (variable in [0,17])
2187 // nPlate number -vol[1]- (variable in [0, 5])
2188 // nStrip number -vol[2]- (variable in [0,14/18])
2189 // nPadZ number -vol[3]- (variable in [0, 1])
2190 // nPadX number -vol[4]- variable in [0,47])
2192 // nChain (variable in [0; 1]) -> number of the TRM chain
2197 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2198 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2201 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2202 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2205 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2206 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2209 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2210 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2211 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2212 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2213 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2214 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2218 Int_t iPadX = vol[4];
2220 if (iPadX<12 || iPadX>=36) nChain = 0;
2227 //---------------------------------------------------------------------------
2228 Int_t AliTOFRawStream::Geant2Channel(Int_t vol[])
2232 // nSector number -vol[0]- (variable in [0,17])
2233 // nPlate number -vol[1]- (variable in [0, 5])
2234 // nStrip number -vol[2]- (variable in [0,14/18])
2235 // nPadZ number -vol[3]- (variable in [0, 1])
2236 // nPadX number -vol[4]- (variable in [0,47])
2238 // nChannel (variable in [0; 7]) -> number of the TDC channel
2241 Int_t nChannel = -1;
2243 if (vol[0]<0 || vol[0]>=AliTOFGeometry::NSectors()) {
2244 printf(" AliTOFRawStream - Error: the sector number (%i) is out of the range: [0,17]\n", vol[0]);
2247 if (vol[1]<0 || vol[1]>=AliTOFGeometry::NPlates()) {
2248 printf(" AliTOFRawStream - Error: the module number (%i) is out of the range: [0,4]\n", vol[1]);
2251 if (vol[2]<0 || vol[2]>=AliTOFGeometry::NStrip(vol[1])) {
2252 printf(" AliTOFRawStream - Error: the strip number (%i) is out of the range: [0,%i]\n", vol[2], AliTOFGeometry::NStrip(vol[1]));
2255 if (vol[3]<0 || vol[3]>=AliTOFGeometry::NpadZ())
2256 printf(" AliTOFRawStream - Error: the padz number (%i) is out of the range: [0,1]\n", vol[3]);
2257 if (vol[4]<0 || vol[4]>=AliTOFGeometry::NpadX())
2258 printf(" AliTOFRawStream - Error: the padx number (%i) is out of the range: [0,47]\n", vol[4]);
2259 if ( vol[3]>=AliTOFGeometry::NpadZ() ) {
2260 printf("Maybe you have to invert the order between vol[3](=%i) and vol[4](=%i)\n", vol[3], vol[4]);
2264 Int_t iPadZ = vol[3];
2265 Int_t iPadX = vol[4];
2267 Int_t iDDL = Geant2DDL(vol)%4;
2272 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2275 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2278 nChannel = ((2*(iPadX-24) + (iPadZ)))%8;
2281 nChannel = ((2*(23-iPadX) + (1-iPadZ)))%8;
2289 //____________________________________________________________________________
2290 void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray * const digitsArray)
2293 // Converts raw data to digits for TOF
2296 TStopwatch stopwatch;
2299 //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
2300 //digitsTree->Branch("TOF", &fDigits);
2301 TClonesArray &aDigits = *digitsArray;
2306 SetRawReader(rawReader);
2309 //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
2311 TClonesArray staticRawData("AliTOFrawData",10000);
2312 staticRawData.Clear();
2313 TClonesArray * clonesRawData = &staticRawData;
2316 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2319 const Int_t kMaxNumberOfTracksPerDigit = 3;
2320 Int_t tracks[kMaxNumberOfTracksPerDigit];
2321 for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
2327 AliTOFrawData *tofRawDatum = 0;
2328 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2331 if (fNewDecoderVersion) {
2332 AliInfo("Using New Decoder \n");
2333 LoadRawDataBuffers(indexDDL, 0);
2336 LoadRawData(indexDDL);
2338 clonesRawData = GetRawData();
2339 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2340 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2342 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2344 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2345 if (tofRawDatum->GetTOF()==-1) continue;
2347 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2348 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2350 dummy = detectorIndex[3];
2351 detectorIndex[3] = detectorIndex[4];//padz
2352 detectorIndex[4] = dummy;//padx
2354 digit[0] = tofRawDatum->GetTOF();
2355 digit[1] = tofRawDatum->GetTOT();
2356 digit[2] = tofRawDatum->GetTOT();
2357 digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
2359 dummy = detectorIndex[3];
2360 detectorIndex[3] = detectorIndex[4];//padx
2361 detectorIndex[4] = dummy;//padz
2363 // Do not reconstruct anything in the holes
2364 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2365 if (detectorIndex[1]==2) { // plate with holes
2371 last = digitsArray->GetEntriesFast();
2372 new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
2375 if (indexDDL<10) ftxt << " " << indexDDL;
2376 else ftxt << " " << indexDDL;
2377 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2378 else ftxt << " " << tofRawDatum->GetTRM();
2379 ftxt << " " << tofRawDatum->GetTRMchain();
2380 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2381 else ftxt << " " << tofRawDatum->GetTDC();
2382 ftxt << " " << tofRawDatum->GetTDCchannel();
2384 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2385 else ftxt << " -> " << detectorIndex[0];
2386 ftxt << " " << detectorIndex[1];
2387 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2388 else ftxt << " " << detectorIndex[2];
2389 ftxt << " " << detectorIndex[4];
2390 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2391 else ftxt << " " << detectorIndex[3];
2393 if (digit[1]<10)ftxt << " " << digit[1];
2394 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2395 else ftxt << " " << digit[1];
2396 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2397 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2398 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2399 else ftxt << " " << digit[3] << endl;
2402 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2404 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2405 digit[0], digit[1], digit[3]));
2408 } // loop on tofRawData array
2410 clonesRawData->Clear();
2414 //if (fVerbose==2) ftxt.close();
2417 if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
2419 Int_t nDigits = digitsArray->GetEntries();
2420 AliDebug(1, Form("Got %d TOF digits", nDigits));
2421 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
2422 stopwatch.RealTime(),stopwatch.CpuTime()));
2426 //____________________________________________________________________________
2427 void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray * const sdigitsArray)
2430 // Converts raw data to sdigits for TOF
2433 TStopwatch stopwatch;
2438 //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
2439 TClonesArray &aSDigits = *sdigitsArray;
2442 SetRawReader(rawReader);
2445 //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
2447 TClonesArray staticRawData("AliTOFrawData",10000);
2448 staticRawData.Clear();
2449 TClonesArray * clonesRawData = &staticRawData;
2452 Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
2459 AliTOFrawData *tofRawDatum = 0;
2460 for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
2463 if (fNewDecoderVersion) {
2464 AliInfo("Using New Decoder \n");
2465 LoadRawDataBuffers(indexDDL, 0);
2468 LoadRawData(indexDDL);
2470 clonesRawData = GetRawData();
2471 if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
2472 for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
2474 tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
2476 //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
2477 if (tofRawDatum->GetTOF()==-1) continue;
2479 EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
2480 tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
2482 dummy = detectorIndex[3];
2483 detectorIndex[3] = detectorIndex[4];//padz
2484 detectorIndex[4] = dummy;//padx
2486 digit[0] = tofRawDatum->GetTOF();
2487 digit[1] = tofRawDatum->GetTOT();
2489 dummy = detectorIndex[3];
2490 detectorIndex[3] = detectorIndex[4];//padx
2491 detectorIndex[4] = dummy;//padz
2493 // Do not reconstruct anything in the holes
2494 if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
2495 if (detectorIndex[1]==2) { // plate with holes
2501 last = sdigitsArray->GetEntriesFast();
2502 new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
2505 if (indexDDL<10) ftxt << " " << indexDDL;
2506 else ftxt << " " << indexDDL;
2507 if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
2508 else ftxt << " " << tofRawDatum->GetTRM();
2509 ftxt << " " << tofRawDatum->GetTRMchain();
2510 if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
2511 else ftxt << " " << tofRawDatum->GetTDC();
2512 ftxt << " " << tofRawDatum->GetTDCchannel();
2514 if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
2515 else ftxt << " -> " << detectorIndex[0];
2516 ftxt << " " << detectorIndex[1];
2517 if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
2518 else ftxt << " " << detectorIndex[2];
2519 ftxt << " " << detectorIndex[4];
2520 if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
2521 else ftxt << " " << detectorIndex[3];
2523 if (digit[1]<10)ftxt << " " << digit[1];
2524 else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
2525 else ftxt << " " << digit[1];
2526 if (digit[0]<10) ftxt << " " << digit[0] << endl;
2527 else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
2528 else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
2529 else ftxt << " " << digit[3] << endl;
2532 AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
2534 detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
2535 digit[0], digit[1], digit[3]));
2540 clonesRawData->Clear();
2544 //if (fVerbose==2) ftxt.close();
2546 if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
2548 Int_t nSDigits = sdigitsArray->GetEntries();
2549 AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
2550 AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
2551 stopwatch.RealTime(),stopwatch.CpuTime()));
2555 void AliTOFRawStream::VolumeID2LTM(Int_t detind[],
2560 Int_t iChannel) const {
2562 // To convert the TOF trigger macropad ID (i.e. detind)
2563 // into TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2566 const Int_t kFirstTDCnumber = 12;
2568 iDDL=-1, iTRM = 3 , iChain=-1, iTDC=-1, iChannel=-1;
2569 if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) {
2577 iDDL = detind[0]*4+2;
2579 iDDL = detind[0]*4+2;
2582 iChain=fgkChainMap24[detind[1]][detind[2]];
2583 iTDC=(Int_t)(fgkChannelMap24[detind[1]][detind[2]]/8)+kFirstTDCnumber;
2584 iChannel=fgkChannelMap24[detind[1]][detind[2]]%8;
2588 void AliTOFRawStream::LTM2VolumeID(Int_t iDDL,
2593 Int_t detind0[], Int_t detind1[]) const {
2595 // To convert the TOF OR signals equipment ID (i.e. iDDL, iTRM, iChain, iTDC, iChannel)
2596 // into TOF trigger macropad IDs (i.e. detind0 and detind1).
2597 // In general, a couple of neighbouring TOF semi-strip represents a TOF trigger macropad.
2600 const Int_t kFirstTDCnumber = 12;
2602 Int_t iSector0=-1, iModule0=-1, iStrip0=-1, iPadX0=-1; // Le variabili del Volume ID
2603 Int_t iSector1=-1, iModule1=-1, iStrip1=-1, iPadX1=-1; // Le variabili del Volume ID
2605 if( iDDL%2==1 && iTRM==3 && iTDC-kFirstTDCnumber>=0 && iTDC-kFirstTDCnumber<3 ) {
2606 iSector0 = (Int_t)(iDDL/4);
2607 iSector1 = (Int_t)(iDDL/4);
2608 Int_t iChan= iChannel+(iTDC-kFirstTDCnumber)*8;
2610 if(iChain==0){ //CRATE 0
2613 iStrip0=fgkStrip0MapCrate0[iChan];
2614 iStrip1=fgkStrip1MapCrate0[iChan];
2615 iModule0=fgkModule0MapCrate0[iChan];
2616 iModule1=fgkModule1MapCrate0[iChan];
2618 if(iChain==1){// CRATE 1
2621 iStrip0=fgkStrip0MapCrate1[iChan];
2622 iStrip1=fgkStrip1MapCrate1[iChan];
2623 iModule0=fgkModule0MapCrate1[iChan];
2624 iModule1=fgkModule1MapCrate1[iChan];
2629 if(iChain==1){// CRATE 3
2632 iStrip0=fgkStrip0MapCrate3[iChan];
2633 iStrip1=fgkStrip1MapCrate3[iChan];
2634 iModule0=fgkModule0MapCrate3[iChan];
2635 iModule1=fgkModule1MapCrate3[iChan];
2637 if(iChain==0){// CRATE 2
2640 iStrip0=fgkStrip0MapCrate2[iChan];
2641 iStrip1=fgkStrip1MapCrate2[iChan];
2642 iModule0=fgkModule0MapCrate2[iChan];
2643 iModule1=fgkModule1MapCrate2[iChan];
2648 if(iStrip1==-1 || iModule1==-1){
2656 detind1[0]=iSector1;
2657 detind1[1]=iModule1;
2663 if(iStrip0==-1 || iModule0==-1){
2671 detind0[0]=iSector0;
2672 detind0[1]=iModule0;