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 **************************************************************************/
18 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
19 Update TOF raw data format
20 according to the final version
21 (see the ALICE internal note in preparation
22 'ALICE TOF raw data format')
23 Added the methods for the correspoonding numbering
24 between the equipment IDs and the volume IDs:
29 Revision 0.02 2005/07/28 A. De Caro:
30 Update format TOF raw data
32 Correction of few wrong corrispondences
33 between 'software' and 'hardware' numberings
35 Revision 0.01 2005/07/22 A. De Caro
36 Implement methods Next()
44 ////////////////////////////////////////////////////////////////////////
46 // This class provides access to TOF raw data in DDL files. //
48 // It loops over all TOF raw data given by the AliRawReader. //
50 ////////////////////////////////////////////////////////////////////////
53 #include "AliRawReader.h"
55 #include "AliTOFGeometry.h"
56 #include "AliTOFGeometryV5.h"
57 #include "AliTOFRawStream.h"
60 /******************************************
62 ******************************************/
65 #define FILLER 0x70000000
67 //word type mask/position
68 #define WORD_TYPE_MASK 0xf0000000
69 #define WORD_TYPE_POSITION 28
71 //global header word required bit pattern
72 #define GLOBAL_HEADER 0x40000000
74 //global trailer word required bit pattern
75 #define GLOBAL_TRAILER 0x50000000
77 //error word required bit pattern
78 #define ERROR 0x30000000
80 //header slot ID mask/position
81 #define HEADER_SLOT_ID_MASK 0x0000000f
82 #define HEADER_SLOT_ID_POSITION 0
85 #define GLOBAL_HEADER_TYPE 4
86 #define GLOBAL_TRAILER_TYPE 5
89 #define TRM_CHAIN0_HEADER_TYPE 0
90 #define TRM_CHAIN0_TRAILER_TYPE 1
91 #define TRM_CHAIN1_HEADER_TYPE 2
92 #define TRM_CHAIN1_TRAILER_TYPE 3
95 #define DRM_ID_NUMBER 1
96 #define LTM_ID_NUMBER 2
99 /******************************************
101 ******************************************/
103 //DRM global header word required bit pattern
104 #define DRM_GLOBAL_HEADER 0x40000001
106 //DRM event words mask/position
107 #define DRM_EVENT_WORDS_MASK 0x001ffff0
108 #define DRM_EVENT_WORDS_POSITION 4
110 //DRM DRM ID mask/position
111 #define DRM_DRM_ID_MASK 0x0fe00000
112 #define DRM_DRM_ID_POSITION 21
114 //DRM status header 1 word required bit pattern
115 #define DRM_STATUS_HEADER_1 0x40000001
117 //DRM slot ID mask/position
118 #define DRM_SLOT_ID_MASK 0x00007ff0
119 #define DRM_SLOT_ID_POSITION 4
121 //DRM C-bit mask/position
122 #define DRM_C_BIT_MASK 0x00008000
123 #define DRM_C_BIT_POSITION 15
125 //DRM status header 2 word required bit pattern
126 #define DRM_STATUS_HEADER_2 0x40000001
128 //DRM enable ID mask/position
129 #define DRM_ENABLE_ID_MASK 0x00007ff0
130 #define DRM_ENABLE_ID_POSITION 4
132 //DRM fault ID mask/position
133 #define DRM_FAULT_ID_MASK 0x07ff0000
134 #define DRM_FAULT_ID_POSITION 16
136 //DRM status header 3 word required bit pattern
137 #define DRM_STATUS_HEADER_3 0x40000001
139 //DRM TTC event counter mask/position
140 #define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
141 #define DRM_TTC_EVENT_COUNTER_POSITION 4
143 //DRM event CRC mask/position
144 //#define DRM_EVENT_CRC_MASK 0x001ffff0
145 #define DRM_EVENT_CRC_MASK 0x000ffff0
146 #define DRM_EVENT_CRC_POSITION 4
148 //DRM global trailer word required bit pattern
149 #define DRM_GLOBAL_TRAILER 0x50000001
151 //DRM local event counter mask/position
152 #define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
153 #define DRM_LOCAL_EVENT_COUNTER_POSITION 4
156 /******************************************
158 ******************************************/
160 //TRM global header word required bit pattern
161 #define TRM_GLOBAL_HEADER 0x40000000
163 //TRM slot ID mask/position
164 #define TRM_SLOT_ID_MASK 0x0000000f
165 #define TRM_SLOT_ID_POSITION 0
167 //TRM event words mask/position
168 #define TRM_EVENT_WORDS_MASK 0x0001fff0
169 #define TRM_EVENT_WORDS_POSITION 4
171 //TRM ACQ-bits mask/position
172 #define TRM_ACQ_BITS_MASK 0x00060000
173 #define TRM_ACQ_BITS_POSITION 17
175 //TRM L-bit mask/position
176 #define TRM_L_BIT_MASK 0x00080000
177 #define TRM_L_BIT_POSITION 19
179 //TRM chain-0 header word required bit pattern
180 #define TRM_CHAIN_0_HEADER 0x00000000
182 //TRM chain-1 header word required bit pattern
183 #define TRM_CHAIN_1_HEADER 0x20000000
185 //TRM bunch ID mask/position
186 #define TRM_BUNCH_ID_MASK 0x0000fff0
187 #define TRM_BUNCH_ID_POSITION 4
189 //TRM PB24 temp mask/position
190 #define TRM_PB24_TEMP_MASK 0x00ff0000
191 #define TRM_PB24_TEMP_POSITION 16
193 //TRM PB24 ID mask/position
194 #define TRM_PB24_ID_MASK 0x07000000
195 #define TRM_PB24_ID_POSITION 24
197 //TRM TS-bit mask/position
198 #define TRM_TS_BIT_MASK 0x08000000
199 #define TRM_TS_BIT_POSITION 27
201 //TRM chain-0 trailer word required bit pattern
202 #define TRM_CHAIN_0_TRAILER 0x10000000
204 //TRM chain-1 trailer word required bit pattern
205 #define TRM_CHAIN_1_TRAILER 0x30000000
207 //TRM status mask/position
208 #define TRM_STATUS_MASK 0x0000000f
209 #define TRM_STATUS_POSITION 0
214 //TRM TDC digit word required bit pattern
215 #define TRM_TDC_DIGIT 0x8000000
217 //TRM digit time mask/position
218 #define TRM_DIGIT_TIME_MASK 0x00001fff
219 #define TRM_DIGIT_TIME_POSITION 0
221 //TRM long digit time mask/position
222 #define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
223 #define TRM_LONG_DIGIT_TIME_POSITION 0
225 //TRM TOT width mask/position
226 #define TRM_TOT_WIDTH_MASK 0x001fe000
227 #define TRM_TOT_WIDTH_POSITION 13
229 //TRM chan mask/position
230 #define TRM_CHAN_MASK 0x00e00000
231 #define TRM_CHAN_POSITION 21
233 //TRM TDC ID mask/position
234 #define TRM_TDC_ID_MASK 0x0f000000
235 #define TRM_TDC_ID_POSITION 24
237 //TRM E-bit mask/position
238 #define TRM_E_BIT_MASK 0x10000000
239 #define TRM_E_BIT_POSITION 28
241 //TRM PS-bits mask/position
242 #define TRM_PS_BITS_MASK 0x60000000
243 #define TRM_PS_BITS_POSITION 29
248 //TRM TDC error word required bit pattern
249 #define TRM_TDC_ERROR 0x6000000
251 //TRM TDC diagnostic error word required bit pattern
252 #define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
254 //TRM TDC error flags mask/position
255 #define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
256 #define TRM_TDC_ERROR_FLAGS_POSITION 0
258 //TRM TDC error TDC ID mask/position
259 #define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
260 #define TRM_TDC_ERROR_TDC_ID_POSITION 24
262 //TRM TDC fault chip flag ID mask/position
263 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
264 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
266 //TRM TDC error C-bit mask/position
267 #define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
268 #define TRM_TDC_ERROR_C_BIT_POSITION 15
270 //TRM TDC JTAG error code mask/position
271 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
272 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
274 //TRM TDC disgnostic error TDC ID mask/position
275 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
276 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
278 //TRM global trailer word required bit pattern
279 //#define TRM_GLOBAL_TRAILER 0x50000000
280 #define TRM_GLOBAL_TRAILER 0x5000000f
282 //TRM event CRC mask/position
283 #define TRM_EVENT_CRC_MASK 0x0000fff0
284 #define TRM_EVENT_CRC_POSITION 4
286 //TRM event counter mask/position
287 #define TRM_EVENT_COUNTER_MASK 0x0fff0000
288 #define TRM_EVENT_COUNTER_POSITION 16
291 /******************************************
293 ******************************************/
295 //LTM global header word required bit pattern
296 #define LTM_GLOBAL_HEADER 0x40000002
298 //LTM event words mask/position
299 #define LTM_EVENT_WORDS_MASK 0x0001fff0
300 #define LTM_EVENT_WORDS_POSITION 4
302 //LTM C-bit mask/position
303 #define LTM_C_BIT_MASK 0x00020000
304 #define LTM_C_BIT_POSITION 17
306 //LTM fault mask/position
307 #define LTM_FAULT_MASK 0x00fc0000
308 #define LTM_FAULT_POSITION 18
312 //PDL value 1 mask/position
313 #define LTM_PDL_VALUE_1_MASK 0x000000ff
314 #define LTM_PDL_VALUE_1_POSITION 0
316 //PDL value 2 mask/position
317 #define LTM_PDL_VALUE_2_MASK 0x0000ff00
318 #define LTM_PDL_VALUE_2_POSITION 8
320 //PDL value 3 mask/position
321 #define LTM_PDL_VALUE_3_MASK 0x00ff0000
322 #define LTM_PDL_VALUE_3_POSITION 16
324 //PDL value 4 mask/position
325 #define LTM_PDL_VALUE_4_MASK 0xff000000
326 #define LTM_PDL_VALUE_4_POSITION 24
330 //ADC value 1 mask/position
331 #define LTM_ADC_VALUE_1_MASK 0x000003ff
332 #define LTM_ADC_VALUE_1_POSITION 0
334 //ADC value 2 mask/position
335 #define LTM_ADC_VALUE_2_MASK 0x000ffc00
336 #define LTM_ADC_VALUE_2_POSITION 10
338 //ADC value 3 mask/position
339 #define LTM_ADC_VALUE_3_MASK 0x3ff00000
340 #define LTM_ADC_VALUE_3_POSITION 20
342 //LTM global trailer word required bit pattern
343 #define LTM_GLOBAL_TRAILER 0x50000002
345 //LTM event CRC mask/position
346 #define LTM_EVENT_CRC_MASK 0x0000fff0
347 #define LTM_EVENT_CRC_POSITION 4
349 //LTM event number mask/position
350 #define LTM_EVENT_NUMBER_MASK 0x0fff0000
351 #define LTM_EVENT_NUMBER_POSITION 16
354 ClassImp(AliTOFRawStream)
357 //_____________________________________________________________________________
358 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader)
361 // create an object to read TOF raw digits
364 fRawReader = rawReader;
380 fTOFGeometry = new AliTOFGeometryV5();
382 fRawReader->Select("TOF");
393 fInsideTRMchain0 = kFALSE;
394 fInsideTRMchain1 = kFALSE;
395 fLeadingOrphane = kFALSE;
399 //_____________________________________________________________________________
400 AliTOFRawStream::AliTOFRawStream()
422 fTOFGeometry = new AliTOFGeometryV5();
433 fInsideTRMchain0 = kFALSE;
434 fInsideTRMchain1 = kFALSE;
435 fLeadingOrphane = kFALSE;
439 //_____________________________________________________________________________
440 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
447 fRawReader = stream.fRawReader;
451 fTRMchain = stream.fTRMchain;
452 fTDCchannel = stream.fTDCchannel;
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 fTOFGeometry = stream.fTOFGeometry;
465 fWordType = stream.fWordType;
466 fSlotID = stream.fSlotID;
468 fPSbit = stream.fPSbit;
469 fTime = stream.fTime;
470 fTDCerrorFlag = stream.fTDCerrorFlag;
471 fInsideDRM = stream.fInsideDRM;
472 fInsideTRM = stream.fInsideTRM;
473 fInsideLTM = stream.fInsideLTM;
474 fInsideTRMchain0 = stream.fInsideTRMchain0;
475 fInsideTRMchain1 = stream.fInsideTRMchain1;
476 fLeadingOrphane = stream.fLeadingOrphane;
480 //_____________________________________________________________________________
481 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
484 // assignment operator
487 fRawReader = stream.fRawReader;
491 fTRMchain = stream.fTRMchain;
492 fTDCchannel = stream.fTDCchannel;
495 fErrorFlag = stream.fErrorFlag;
497 fSector = stream.fSector;
498 fPlate = stream.fPlate;
499 fStrip = stream.fStrip;
500 fPadX = stream.fPadX;
501 fPadZ = stream.fPadZ;
503 fTOFGeometry = stream.fTOFGeometry;
505 fWordType = stream.fWordType;
506 fSlotID = stream.fSlotID;
508 fPSbit = stream.fPSbit;
509 fTime = stream.fTime;
510 fTDCerrorFlag = stream.fTDCerrorFlag;
511 fInsideDRM = stream.fInsideDRM;
512 fInsideTRM = stream.fInsideTRM;
513 fInsideLTM = stream.fInsideLTM;
514 fInsideTRMchain0 = stream.fInsideTRMchain0;
515 fInsideTRMchain1 = stream.fInsideTRMchain1;
516 fLeadingOrphane = stream.fLeadingOrphane;
522 //_____________________________________________________________________________
523 AliTOFRawStream::~AliTOFRawStream()
532 //_____________________________________________________________________________
533 Bool_t AliTOFRawStream::Next()
536 // Read next 32-bit word in TOF raw data files
537 // returns kFALSE if there is no word left
542 if (!fRawReader->ReadNextInt(data)) return kFALSE;
544 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
553 fDDL = fRawReader->GetDDLID();
556 AliTOFtdcDigit orphaneLeadingDigit;
558 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
560 switch (fWordType) { // switch word type
562 case GLOBAL_HEADER_TYPE: // global header
563 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
567 switch (fSlotID) { // switch global header slot ID
569 case DRM_ID_NUMBER: //DRM global header
570 if (fInsideDRM) { // unexpected DRM global headers -> exit
573 fInsideDRM = kTRUE; // DRM global header accepted
576 case LTM_ID_NUMBER: // LTM global header
577 if (fInsideLTM) { // unexpected LTM global headers -> exit
580 fInsideLTM = kTRUE; // LTM global header accepted
590 case 10: //TRM header
591 case 11: //TRM header
592 case 12: //TRM header
593 if (fInsideTRM) { // unexpected TRM global headers -> exit
596 fInsideTRM = kTRUE; // TRM global header accepted
597 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
600 default: // unexpected global header slot ID
603 } //end switch global header slot id
608 case GLOBAL_TRAILER_TYPE: // global trailer
609 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
612 switch (fSlotID) { // switch global trailer slot ID
614 case DRM_ID_NUMBER: // DRM global trailer
615 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
618 fInsideDRM = kFALSE; // DRM global trailer accepted
621 fInsideTRMchain0 = kFALSE;
622 fInsideTRMchain1 = kFALSE;
623 fLeadingOrphane = kFALSE;
642 case LTM_ID_NUMBER: // LTM global trailer
643 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
646 fInsideLTM = kFALSE; // LTM global trailer accepted
648 case 15: //TRM global trailer
649 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
652 fInsideTRM = kFALSE; // TRM global trailer accepted
654 default: // unexpected global trailer slot ID
656 } //end switch global trailer slot id
662 case ERROR_TYPE: // TDC error
663 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
664 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
668 case FILLER_TYPE: // filler
672 default: // other word types
674 if (fInsideTRM) { // inside TRM
676 switch (fWordType) { // switch word type inside TRM
677 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
678 if (fInsideTRMchain0) { // unexpected TRM chain0 header
681 fInsideTRMchain0 = kTRUE;
684 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
685 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
688 fInsideTRMchain0 = kFALSE;
691 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
692 if (fInsideTRMchain1) { // unexpected TRM chain1 header
695 fInsideTRMchain1 = kTRUE;
698 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
699 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
702 fInsideTRMchain1 = kFALSE;
705 } // end switch word type inside TRM
707 } // end if (fInsideTRM)
711 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
712 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
713 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
714 ){ // inside TRM chains
715 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
716 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
717 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
719 switch (fPSbit) { // switch fPSbit bits inside TRM chains
720 case 0: // packing ok, digit time and tot
721 fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
722 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
731 case 1: // leading edge digit, long digit time, no TOT
733 fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
740 // always set it as orphane leading
742 orphaneLeadingDigit.fSlotID = fSlotID;
743 orphaneLeadingDigit.fChain = fTRMchain;
744 orphaneLeadingDigit.fPS = fPSbit;
745 orphaneLeadingDigit.fTDC = fTDC;
746 orphaneLeadingDigit.fChannel = fTDCchannel;
747 orphaneLeadingDigit.fTOT = fToT;
748 orphaneLeadingDigit.fTime = fTime;
751 case 2: // trailing edge digit, long digit time, no TOT
753 fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
760 if (fACQ!=3) // check if packing is disabled
762 if (!fLeadingOrphane) // check for a orphane leading edge
764 if (orphaneLeadingDigit.fSlotID != fSlotID ||
765 orphaneLeadingDigit.fChain != fTRMchain ||
766 orphaneLeadingDigit.fTDC != fTDC ||
767 orphaneLeadingDigit.fChannel != fTDCchannel) // check leading edge compatibility (fSlotID, fTRMchain, fTDC, fTDCchannel)
769 fLeadingOrphane = 0; // orphane leading is no longer orphane
776 case 3: // TOT overflow
777 fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
778 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
786 } // end switch fPSbit bits inside TRM chains
789 } // end if is inside TRM chains
791 } // end switch on fWordType
796 //_____________________________________________________________________________
798 void AliTOFRawStream::SetSector()
801 // Evaluate the TOF sector number -> [ 0;17]
802 // corresponding to the TOF equipment IDs:
805 // fTRMchain -> [0; 1]
807 // fTDCchannel -> [ 0; 7]
812 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
817 //_____________________________________________________________________________
820 void AliTOFRawStream::SetPlate()
823 // Evaluate the TOF plate number ->[ 0; 4]
824 // corresponding to the TOF equipment IDs:
827 // fTRMchain -> [0; 1]
829 // fTDCchannel -> [ 0; 7]
833 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
835 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
840 //_____________________________________________________________________________
842 void AliTOFRawStream::SetStrip()
845 // Evaluate the TOF strip number per module -> [ 0; 14/18]
846 // corresponding to the TOF equipment IDs:
849 // fTRMchain -> [0; 1]
851 // fTDCchannel -> [ 0; 7]
856 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
857 || fSector==-1 || fPlate==-1))
858 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
863 //_____________________________________________________________________________
865 void AliTOFRawStream::SetPadZ()
868 // Evaluate the TOF padRow number per strip -> [ 0; 1]
869 // corresponding to the TOF equipment IDs:
872 // fTRMchain -> [0; 1]
874 // fTDCchannel -> [ 0; 7]
879 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
880 || fSector==-1 || fPlate==-1 || fStrip==-1))
882 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
883 if (iPadAlongTheStrip!=-1)
884 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
890 //_____________________________________________________________________________
892 void AliTOFRawStream::SetPadX()
895 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
896 // corresponding to the TOF equipment IDs:
899 // fTRMchain -> [0; 1]
901 // fTDCchannel -> [ 0; 7]
906 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
907 || fSector==-1 || fPlate==-1 || fStrip==-1))
909 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
910 if (iPadAlongTheStrip!=-1)
911 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
918 //----------------------------------------------------------------------------
919 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
925 return ((word & fieldMask) >> fieldPosition);
928 //----------------------------------------------------------------------------
929 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
932 // Returns the TOF plate number [0;4]
933 // corresponding to the TOF equipment ID numbers:
934 // iDDL -> DDL number per sector [0;3]
935 // nTRM -> TRM number [3;12]
936 // nTDC -> TDC number [0;14]
942 if (nTRM>=4 && nTRM<7) {
944 } else if (nTRM==7) {
945 if (nTDC<12) iPlate = 0;
947 } else if (nTRM>=8 && nTRM<11) {
949 } else if (nTRM==11) {
950 if (nTDC<9) iPlate = 1;
952 }else if (nTRM==12) {
956 } else if (iDDL==1) {
959 if (nTDC<3) iPlate = 0;
960 } else if (nTRM>=4 && nTRM<7) {
962 } else if (nTRM==7) {
963 if (nTDC<6) iPlate = 1;
965 } else if (nTRM>=8 && nTRM<11) {
967 } else if (nTRM==11) {
968 if (nTDC<9) iPlate = 2;
970 } else if (nTRM==12) {
974 } else if (iDDL==2) {
976 if (nTRM>=4 && nTRM<7) {
978 } else if (nTRM==7) {
979 if (nTDC<12) iPlate = 4;
981 } else if (nTRM>=8 && nTRM<11) {
983 } else if (nTRM==11) {
984 if (nTDC<9) iPlate = 3;
986 }else if (nTRM==12) {
990 } else if (iDDL==3) {
993 if (nTDC<3) iPlate = 4;
994 } else if (nTRM>=4 && nTRM<7) {
996 } else if (nTRM==7) {
997 if (nTDC<6) iPlate = 3;
999 } else if (nTRM>=8 && nTRM<11) {
1001 } else if (nTRM==11) {
1002 if (nTDC<9) iPlate = 2;
1004 } else if (nTRM==12) {
1014 //----------------------------------------------------------------------------
1015 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1018 // Returns the TOF strip number per module:
1019 // [0;14], in the central plates,
1020 // [0;18], in the intermediate and external plates
1021 // corresponding to the TOF equipment ID numbers:
1022 // iDDL -> DDL number per sector [0;3]
1023 // nTRM -> TRM number [3;12]
1024 // nTDC -> TDC number [0;14]
1031 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1032 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1033 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1034 else if (nTRM== 7) {
1035 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1036 else iStrip = (Int_t)(nTDC/3.) - 4;
1038 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1039 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1040 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1041 else if (nTRM==11) {
1042 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1043 else iStrip = (Int_t)(nTDC/3.) - 3;
1045 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1047 } else if (iDDL==1) {
1049 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1050 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1051 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1052 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1053 else if (nTRM== 7) {
1054 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1055 else iStrip = 20 - (Int_t)(nTDC/3.);
1057 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1058 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1059 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1060 else if (nTRM==11) {
1061 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1062 else iStrip = 21 - (Int_t)(nTDC/3.);
1064 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1066 } else if (iDDL==2) {
1068 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1069 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1070 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1071 else if (nTRM== 7) {
1072 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1073 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1075 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1076 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1077 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1078 else if (nTRM==11) {
1079 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1080 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1082 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1084 } else if (iDDL==3) {
1086 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1087 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1088 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1089 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1090 else if (nTRM== 7) {
1091 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1092 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1094 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1095 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1096 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1097 else if (nTRM==11) {
1098 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1099 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1101 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1109 //----------------------------------------------------------------------------
1110 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1114 // Returns the TOF pad number per strip [0;95]
1115 // corresponding to the TOF equipment ID numbers:
1116 // iDDL -> DDL number per sector [0;3]
1117 // iChain -> TRM chain number [0;1]
1118 // nTDC -> TDC number [0;14]
1119 // iCH -> TDC channel number [0;7]
1122 Int_t iPadAlongTheStrip = -1;
1124 Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1126 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1127 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1129 Int_t iCHlocal = iCH;
1130 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1132 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1134 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1135 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
1136 AliError("Problems with the padX number!");
1138 return iPadAlongTheStrip;
1142 //----------------------------------------------------------------------------
1143 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1146 // Returns the sector number [0;17]
1147 // corresponing to the assigned DRM/DDL number [0;71]
1150 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1155 //----------------------------------------------------------------------------
1156 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1159 // Return the DRM/DDL number per sector [0;3]
1160 // corresponing to the assigned DRM/DDL number [0;71]
1163 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1169 //----------------------------------------------------------------------------
1170 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1171 Int_t nTDC, Int_t iCH,
1172 Int_t *volume) const
1176 // nDDL (variable in [0;71]) -> number of the DDL file
1177 // nTRM (variable in [3;12]) -> number of the TRM slot
1178 // iChain (variable in [0; 1]) -> number of the TRM chain
1179 // nTDC (variable in [0;14]) -> number of the TDC
1180 // iCH (variable in [0; 7]) -> number of the TDC channel
1183 // sector number, i.e. volume[0] (variable in [0,17])
1184 // plate number, i.e. volume[1] (variable in [0, 5])
1185 // strip number, i.e. volume[2] (variable in [0,14/18])
1186 // padX number, i.e. volume[3] (variable in [0,47])
1187 // padZ number, i.e. volume[4] (variable in [0, 1])
1190 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1192 Int_t iSector = GetSectorNumber(nDDL);
1194 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1195 if (iPlate==-1) AliError("Problems with the plate number!");
1197 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1198 if (iStrip==-1) AliError("Problems with the strip number!");
1200 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1201 if (iPadAlongTheStrip==-1)
1202 AliError("Problems with the pad number along the strip!");
1204 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1205 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1207 volume[0] = iSector;