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.8 2006/08/22 13:30:17 arcelli
19 removal of effective c++ warnings (C.Zampolli)
21 Revision 1.7 2006/08/10 14:46:54 decaro
22 TOF raw data format: updated version
24 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
25 Update TOF raw data format
26 according to the final version
27 (see the ALICE internal note in preparation
28 'ALICE TOF raw data format')
29 Added the methods for the correspoonding numbering
30 between the equipment IDs and the volume IDs:
35 Revision 0.02 2005/07/28 A. De Caro:
36 Update format TOF raw data
38 Correction of few wrong corrispondences
39 between 'software' and 'hardware' numberings
41 Revision 0.01 2005/07/22 A. De Caro
42 Implement methods Next()
50 ////////////////////////////////////////////////////////////////////////
52 // This class provides access to TOF raw data in DDL files. //
54 // It loops over all TOF raw data given by the AliRawReader. //
56 ////////////////////////////////////////////////////////////////////////
59 #include "AliRawReader.h"
61 #include "AliTOFGeometry.h"
62 #include "AliTOFGeometryV5.h"
63 #include "AliTOFRawStream.h"
66 /******************************************
68 ******************************************/
71 #define FILLER 0x70000000
73 //word type mask/position
74 #define WORD_TYPE_MASK 0xf0000000
75 #define WORD_TYPE_POSITION 28
77 //global header word required bit pattern
78 #define GLOBAL_HEADER 0x40000000
80 //global trailer word required bit pattern
81 #define GLOBAL_TRAILER 0x50000000
83 //error word required bit pattern
84 #define ERROR 0x30000000
86 //header slot ID mask/position
87 #define HEADER_SLOT_ID_MASK 0x0000000f
88 #define HEADER_SLOT_ID_POSITION 0
91 #define GLOBAL_HEADER_TYPE 4
92 #define GLOBAL_TRAILER_TYPE 5
95 #define TRM_CHAIN0_HEADER_TYPE 0
96 #define TRM_CHAIN0_TRAILER_TYPE 1
97 #define TRM_CHAIN1_HEADER_TYPE 2
98 #define TRM_CHAIN1_TRAILER_TYPE 3
101 #define DRM_ID_NUMBER 1
102 #define LTM_ID_NUMBER 2
105 /******************************************
107 ******************************************/
109 //DRM global header word required bit pattern
110 #define DRM_GLOBAL_HEADER 0x40000001
112 //DRM event words mask/position
113 #define DRM_EVENT_WORDS_MASK 0x001ffff0
114 #define DRM_EVENT_WORDS_POSITION 4
116 //DRM DRM ID mask/position
117 #define DRM_DRM_ID_MASK 0x0fe00000
118 #define DRM_DRM_ID_POSITION 21
120 //DRM status header 1 word required bit pattern
121 #define DRM_STATUS_HEADER_1 0x40000001
123 //DRM slot ID mask/position
124 #define DRM_SLOT_ID_MASK 0x00007ff0
125 #define DRM_SLOT_ID_POSITION 4
127 //DRM C-bit mask/position
128 #define DRM_C_BIT_MASK 0x00008000
129 #define DRM_C_BIT_POSITION 15
131 //DRM status header 2 word required bit pattern
132 #define DRM_STATUS_HEADER_2 0x40000001
134 //DRM enable ID mask/position
135 #define DRM_ENABLE_ID_MASK 0x00007ff0
136 #define DRM_ENABLE_ID_POSITION 4
138 //DRM fault ID mask/position
139 #define DRM_FAULT_ID_MASK 0x07ff0000
140 #define DRM_FAULT_ID_POSITION 16
142 //DRM status header 3 word required bit pattern
143 #define DRM_STATUS_HEADER_3 0x40000001
145 //DRM TTC event counter mask/position
146 #define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
147 #define DRM_TTC_EVENT_COUNTER_POSITION 4
149 //DRM event CRC mask/position
150 //#define DRM_EVENT_CRC_MASK 0x001ffff0
151 #define DRM_EVENT_CRC_MASK 0x000ffff0
152 #define DRM_EVENT_CRC_POSITION 4
154 //DRM global trailer word required bit pattern
155 #define DRM_GLOBAL_TRAILER 0x50000001
157 //DRM local event counter mask/position
158 #define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
159 #define DRM_LOCAL_EVENT_COUNTER_POSITION 4
162 /******************************************
164 ******************************************/
166 //TRM global header word required bit pattern
167 #define TRM_GLOBAL_HEADER 0x40000000
169 //TRM slot ID mask/position
170 #define TRM_SLOT_ID_MASK 0x0000000f
171 #define TRM_SLOT_ID_POSITION 0
173 //TRM event words mask/position
174 #define TRM_EVENT_WORDS_MASK 0x0001fff0
175 #define TRM_EVENT_WORDS_POSITION 4
177 //TRM ACQ-bits mask/position
178 #define TRM_ACQ_BITS_MASK 0x00060000
179 #define TRM_ACQ_BITS_POSITION 17
181 //TRM L-bit mask/position
182 #define TRM_L_BIT_MASK 0x00080000
183 #define TRM_L_BIT_POSITION 19
185 //TRM chain-0 header word required bit pattern
186 #define TRM_CHAIN_0_HEADER 0x00000000
188 //TRM chain-1 header word required bit pattern
189 #define TRM_CHAIN_1_HEADER 0x20000000
191 //TRM bunch ID mask/position
192 #define TRM_BUNCH_ID_MASK 0x0000fff0
193 #define TRM_BUNCH_ID_POSITION 4
195 //TRM PB24 temp mask/position
196 #define TRM_PB24_TEMP_MASK 0x00ff0000
197 #define TRM_PB24_TEMP_POSITION 16
199 //TRM PB24 ID mask/position
200 #define TRM_PB24_ID_MASK 0x07000000
201 #define TRM_PB24_ID_POSITION 24
203 //TRM TS-bit mask/position
204 #define TRM_TS_BIT_MASK 0x08000000
205 #define TRM_TS_BIT_POSITION 27
207 //TRM chain-0 trailer word required bit pattern
208 #define TRM_CHAIN_0_TRAILER 0x10000000
210 //TRM chain-1 trailer word required bit pattern
211 #define TRM_CHAIN_1_TRAILER 0x30000000
213 //TRM status mask/position
214 #define TRM_STATUS_MASK 0x0000000f
215 #define TRM_STATUS_POSITION 0
220 //TRM TDC digit word required bit pattern
221 #define TRM_TDC_DIGIT 0x8000000
223 //TRM digit time mask/position
224 #define TRM_DIGIT_TIME_MASK 0x00001fff
225 #define TRM_DIGIT_TIME_POSITION 0
227 //TRM long digit time mask/position
228 #define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
229 #define TRM_LONG_DIGIT_TIME_POSITION 0
231 //TRM TOT width mask/position
232 #define TRM_TOT_WIDTH_MASK 0x001fe000
233 #define TRM_TOT_WIDTH_POSITION 13
235 //TRM chan mask/position
236 #define TRM_CHAN_MASK 0x00e00000
237 #define TRM_CHAN_POSITION 21
239 //TRM TDC ID mask/position
240 #define TRM_TDC_ID_MASK 0x0f000000
241 #define TRM_TDC_ID_POSITION 24
243 //TRM E-bit mask/position
244 #define TRM_E_BIT_MASK 0x10000000
245 #define TRM_E_BIT_POSITION 28
247 //TRM PS-bits mask/position
248 #define TRM_PS_BITS_MASK 0x60000000
249 #define TRM_PS_BITS_POSITION 29
254 //TRM TDC error word required bit pattern
255 #define TRM_TDC_ERROR 0x6000000
257 //TRM TDC diagnostic error word required bit pattern
258 #define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
260 //TRM TDC error flags mask/position
261 #define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
262 #define TRM_TDC_ERROR_FLAGS_POSITION 0
264 //TRM TDC error TDC ID mask/position
265 #define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
266 #define TRM_TDC_ERROR_TDC_ID_POSITION 24
268 //TRM TDC fault chip flag ID mask/position
269 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
270 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
272 //TRM TDC error C-bit mask/position
273 #define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
274 #define TRM_TDC_ERROR_C_BIT_POSITION 15
276 //TRM TDC JTAG error code mask/position
277 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
278 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
280 //TRM TDC disgnostic error TDC ID mask/position
281 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
282 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
284 //TRM global trailer word required bit pattern
285 //#define TRM_GLOBAL_TRAILER 0x50000000
286 #define TRM_GLOBAL_TRAILER 0x5000000f
288 //TRM event CRC mask/position
289 #define TRM_EVENT_CRC_MASK 0x0000fff0
290 #define TRM_EVENT_CRC_POSITION 4
292 //TRM event counter mask/position
293 #define TRM_EVENT_COUNTER_MASK 0x0fff0000
294 #define TRM_EVENT_COUNTER_POSITION 16
297 /******************************************
299 ******************************************/
301 //LTM global header word required bit pattern
302 #define LTM_GLOBAL_HEADER 0x40000002
304 //LTM event words mask/position
305 #define LTM_EVENT_WORDS_MASK 0x0001fff0
306 #define LTM_EVENT_WORDS_POSITION 4
308 //LTM C-bit mask/position
309 #define LTM_C_BIT_MASK 0x00020000
310 #define LTM_C_BIT_POSITION 17
312 //LTM fault mask/position
313 #define LTM_FAULT_MASK 0x00fc0000
314 #define LTM_FAULT_POSITION 18
318 //PDL value 1 mask/position
319 #define LTM_PDL_VALUE_1_MASK 0x000000ff
320 #define LTM_PDL_VALUE_1_POSITION 0
322 //PDL value 2 mask/position
323 #define LTM_PDL_VALUE_2_MASK 0x0000ff00
324 #define LTM_PDL_VALUE_2_POSITION 8
326 //PDL value 3 mask/position
327 #define LTM_PDL_VALUE_3_MASK 0x00ff0000
328 #define LTM_PDL_VALUE_3_POSITION 16
330 //PDL value 4 mask/position
331 #define LTM_PDL_VALUE_4_MASK 0xff000000
332 #define LTM_PDL_VALUE_4_POSITION 24
336 //ADC value 1 mask/position
337 #define LTM_ADC_VALUE_1_MASK 0x000003ff
338 #define LTM_ADC_VALUE_1_POSITION 0
340 //ADC value 2 mask/position
341 #define LTM_ADC_VALUE_2_MASK 0x000ffc00
342 #define LTM_ADC_VALUE_2_POSITION 10
344 //ADC value 3 mask/position
345 #define LTM_ADC_VALUE_3_MASK 0x3ff00000
346 #define LTM_ADC_VALUE_3_POSITION 20
348 //LTM global trailer word required bit pattern
349 #define LTM_GLOBAL_TRAILER 0x50000002
351 //LTM event CRC mask/position
352 #define LTM_EVENT_CRC_MASK 0x0000fff0
353 #define LTM_EVENT_CRC_POSITION 4
355 //LTM event number mask/position
356 #define LTM_EVENT_NUMBER_MASK 0x0fff0000
357 #define LTM_EVENT_NUMBER_POSITION 16
360 ClassImp(AliTOFRawStream)
363 //_____________________________________________________________________________
364 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
380 fTOFGeometry(new AliTOFGeometryV5()),
390 fInsideTRMchain0(kFALSE),
391 fInsideTRMchain1(kFALSE),
392 fLeadingOrphane(kFALSE)
395 // create an object to read TOF raw digits
398 fRawReader = rawReader;
414 fTOFGeometry = new AliTOFGeometryV5();
416 fRawReader->Select("TOF");
427 fInsideTRMchain0 = kFALSE;
428 fInsideTRMchain1 = kFALSE;
429 fLeadingOrphane = kFALSE;
433 //_____________________________________________________________________________
434 AliTOFRawStream::AliTOFRawStream():
450 fTOFGeometry(new AliTOFGeometryV5()),
460 fInsideTRMchain0(kFALSE),
461 fInsideTRMchain1(kFALSE),
462 fLeadingOrphane(kFALSE)
483 fTOFGeometry = new AliTOFGeometryV5();
493 fInsideTRMchain0 = kFALSE;
494 fInsideTRMchain1 = kFALSE;
495 fLeadingOrphane = kFALSE;
499 //_____________________________________________________________________________
500 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
517 fTOFGeometry(new AliTOFGeometryV5()),
527 fInsideTRMchain0(kFALSE),
528 fInsideTRMchain1(kFALSE),
529 fLeadingOrphane(kFALSE)
535 fRawReader = stream.fRawReader;
539 fTRMchain = stream.fTRMchain;
540 fTDCchannel = stream.fTDCchannel;
543 fErrorFlag = stream.fErrorFlag;
545 fSector = stream.fSector;
546 fPlate = stream.fPlate;
547 fStrip = stream.fStrip;
548 fPadX = stream.fPadX;
549 fPadZ = stream.fPadZ;
551 fTOFGeometry = stream.fTOFGeometry;
553 fWordType = stream.fWordType;
554 fSlotID = stream.fSlotID;
556 fPSbit = stream.fPSbit;
557 fTime = stream.fTime;
558 fTDCerrorFlag = stream.fTDCerrorFlag;
559 fInsideDRM = stream.fInsideDRM;
560 fInsideTRM = stream.fInsideTRM;
561 fInsideLTM = stream.fInsideLTM;
562 fInsideTRMchain0 = stream.fInsideTRMchain0;
563 fInsideTRMchain1 = stream.fInsideTRMchain1;
564 fLeadingOrphane = stream.fLeadingOrphane;
568 //_____________________________________________________________________________
569 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
572 // assignment operator
575 fRawReader = stream.fRawReader;
579 fTRMchain = stream.fTRMchain;
580 fTDCchannel = stream.fTDCchannel;
583 fErrorFlag = stream.fErrorFlag;
585 fSector = stream.fSector;
586 fPlate = stream.fPlate;
587 fStrip = stream.fStrip;
588 fPadX = stream.fPadX;
589 fPadZ = stream.fPadZ;
591 fTOFGeometry = stream.fTOFGeometry;
593 fWordType = stream.fWordType;
594 fSlotID = stream.fSlotID;
596 fPSbit = stream.fPSbit;
597 fTime = stream.fTime;
598 fTDCerrorFlag = stream.fTDCerrorFlag;
599 fInsideDRM = stream.fInsideDRM;
600 fInsideTRM = stream.fInsideTRM;
601 fInsideLTM = stream.fInsideLTM;
602 fInsideTRMchain0 = stream.fInsideTRMchain0;
603 fInsideTRMchain1 = stream.fInsideTRMchain1;
604 fLeadingOrphane = stream.fLeadingOrphane;
610 //_____________________________________________________________________________
611 AliTOFRawStream::~AliTOFRawStream()
620 //_____________________________________________________________________________
621 Bool_t AliTOFRawStream::Next()
624 // Read next 32-bit word in TOF raw data files
625 // returns kFALSE if there is no word left
630 if (!fRawReader->ReadNextInt(data)) return kFALSE;
632 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
641 fDDL = fRawReader->GetDDLID();
644 AliTOFtdcDigit orphaneLeadingDigit={0,0,0,0,0,0,0};
646 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
648 switch (fWordType) { // switch word type
650 case GLOBAL_HEADER_TYPE: // global header
651 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
655 switch (fSlotID) { // switch global header slot ID
657 case DRM_ID_NUMBER: //DRM global header
658 if (fInsideDRM) { // unexpected DRM global headers -> exit
661 fInsideDRM = kTRUE; // DRM global header accepted
664 case LTM_ID_NUMBER: // LTM global header
665 if (fInsideLTM) { // unexpected LTM global headers -> exit
668 fInsideLTM = kTRUE; // LTM global header accepted
678 case 10: //TRM header
679 case 11: //TRM header
680 case 12: //TRM header
681 if (fInsideTRM) { // unexpected TRM global headers -> exit
684 fInsideTRM = kTRUE; // TRM global header accepted
685 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
688 default: // unexpected global header slot ID
691 } //end switch global header slot id
696 case GLOBAL_TRAILER_TYPE: // global trailer
697 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
700 switch (fSlotID) { // switch global trailer slot ID
702 case DRM_ID_NUMBER: // DRM global trailer
703 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
706 fInsideDRM = kFALSE; // DRM global trailer accepted
709 fInsideTRMchain0 = kFALSE;
710 fInsideTRMchain1 = kFALSE;
711 fLeadingOrphane = kFALSE;
730 case LTM_ID_NUMBER: // LTM global trailer
731 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
734 fInsideLTM = kFALSE; // LTM global trailer accepted
736 case 15: //TRM global trailer
737 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
740 fInsideTRM = kFALSE; // TRM global trailer accepted
742 default: // unexpected global trailer slot ID
744 } //end switch global trailer slot id
750 case ERROR_TYPE: // TDC error
751 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
752 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
756 case FILLER_TYPE: // filler
760 default: // other word types
762 if (fInsideTRM) { // inside TRM
764 switch (fWordType) { // switch word type inside TRM
765 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
766 if (fInsideTRMchain0) { // unexpected TRM chain0 header
769 fInsideTRMchain0 = kTRUE;
772 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
773 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
776 fInsideTRMchain0 = kFALSE;
779 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
780 if (fInsideTRMchain1) { // unexpected TRM chain1 header
783 fInsideTRMchain1 = kTRUE;
786 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
787 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
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
803 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
804 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
805 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
807 switch (fPSbit) { // switch fPSbit bits inside TRM chains
808 case 0: // packing ok, digit time and tot
809 fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
810 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
819 case 1: // leading edge digit, long digit time, no TOT
821 fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
828 // always set it as orphane leading
830 orphaneLeadingDigit.fSlotID = fSlotID;
831 orphaneLeadingDigit.fChain = fTRMchain;
832 orphaneLeadingDigit.fPS = fPSbit;
833 orphaneLeadingDigit.fTDC = fTDC;
834 orphaneLeadingDigit.fChannel = fTDCchannel;
835 orphaneLeadingDigit.fTOT = fToT;
836 orphaneLeadingDigit.fTime = fTime;
839 case 2: // trailing edge digit, long digit time, no TOT
841 fTime = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
848 if (fACQ!=3) // check if packing is disabled
850 if (!fLeadingOrphane) // check for a orphane leading edge
852 if (orphaneLeadingDigit.fSlotID != fSlotID ||
853 orphaneLeadingDigit.fChain != fTRMchain ||
854 orphaneLeadingDigit.fTDC != fTDC ||
855 orphaneLeadingDigit.fChannel != fTDCchannel) // check leading edge compatibility (fSlotID, fTRMchain, fTDC, fTDCchannel)
857 fLeadingOrphane = 0; // orphane leading is no longer orphane
864 case 3: // TOT overflow
865 fToT = GetField(data,TRM_TOT_WIDTH_MASK,TRM_TOT_WIDTH_POSITION);
866 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
874 } // end switch fPSbit bits inside TRM chains
877 } // end if is inside TRM chains
879 } // end switch on fWordType
884 //_____________________________________________________________________________
886 void AliTOFRawStream::SetSector()
889 // Evaluate the TOF sector number -> [ 0;17]
890 // corresponding to the TOF equipment IDs:
893 // fTRMchain -> [0; 1]
895 // fTDCchannel -> [ 0; 7]
900 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
905 //_____________________________________________________________________________
908 void AliTOFRawStream::SetPlate()
911 // Evaluate the TOF plate number ->[ 0; 4]
912 // corresponding to the TOF equipment IDs:
915 // fTRMchain -> [0; 1]
917 // fTDCchannel -> [ 0; 7]
921 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
923 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
928 //_____________________________________________________________________________
930 void AliTOFRawStream::SetStrip()
933 // Evaluate the TOF strip number per module -> [ 0; 14/18]
934 // corresponding to the TOF equipment IDs:
937 // fTRMchain -> [0; 1]
939 // fTDCchannel -> [ 0; 7]
944 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
945 || fSector==-1 || fPlate==-1))
946 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
951 //_____________________________________________________________________________
953 void AliTOFRawStream::SetPadZ()
956 // Evaluate the TOF padRow number per strip -> [ 0; 1]
957 // corresponding to the TOF equipment IDs:
960 // fTRMchain -> [0; 1]
962 // fTDCchannel -> [ 0; 7]
967 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
968 || fSector==-1 || fPlate==-1 || fStrip==-1))
970 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
971 if (iPadAlongTheStrip!=-1)
972 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
978 //_____________________________________________________________________________
980 void AliTOFRawStream::SetPadX()
983 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
984 // corresponding to the TOF equipment IDs:
987 // fTRMchain -> [0; 1]
989 // fTDCchannel -> [ 0; 7]
994 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
995 || fSector==-1 || fPlate==-1 || fStrip==-1))
997 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
998 if (iPadAlongTheStrip!=-1)
999 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1006 //----------------------------------------------------------------------------
1007 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1013 return ((word & fieldMask) >> fieldPosition);
1016 //----------------------------------------------------------------------------
1017 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1020 // Returns the TOF plate number [0;4]
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]
1030 if (nTRM>=4 && nTRM<7) {
1032 } else if (nTRM==7) {
1033 if (nTDC<12) iPlate = 0;
1035 } else if (nTRM>=8 && nTRM<11) {
1037 } else if (nTRM==11) {
1038 if (nTDC<9) iPlate = 1;
1040 }else if (nTRM==12) {
1044 } else if (iDDL==1) {
1047 if (nTDC<3) iPlate = 0;
1048 } else if (nTRM>=4 && nTRM<7) {
1050 } else if (nTRM==7) {
1051 if (nTDC<6) iPlate = 1;
1053 } else if (nTRM>=8 && nTRM<11) {
1055 } else if (nTRM==11) {
1056 if (nTDC<9) iPlate = 2;
1058 } else if (nTRM==12) {
1062 } else if (iDDL==2) {
1064 if (nTRM>=4 && nTRM<7) {
1066 } else if (nTRM==7) {
1067 if (nTDC<12) iPlate = 4;
1069 } else if (nTRM>=8 && nTRM<11) {
1071 } else if (nTRM==11) {
1072 if (nTDC<9) iPlate = 3;
1074 }else if (nTRM==12) {
1078 } else if (iDDL==3) {
1081 if (nTDC<3) iPlate = 4;
1082 } else if (nTRM>=4 && nTRM<7) {
1084 } else if (nTRM==7) {
1085 if (nTDC<6) iPlate = 3;
1087 } else if (nTRM>=8 && nTRM<11) {
1089 } else if (nTRM==11) {
1090 if (nTDC<9) iPlate = 2;
1092 } else if (nTRM==12) {
1102 //----------------------------------------------------------------------------
1103 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1106 // Returns the TOF strip number per module:
1107 // [0;14], in the central plates,
1108 // [0;18], in the intermediate and external plates
1109 // corresponding to the TOF equipment ID numbers:
1110 // iDDL -> DDL number per sector [0;3]
1111 // nTRM -> TRM number [3;12]
1112 // nTDC -> TDC number [0;14]
1119 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1120 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1121 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1122 else if (nTRM== 7) {
1123 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1124 else iStrip = (Int_t)(nTDC/3.) - 4;
1126 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1127 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1128 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1129 else if (nTRM==11) {
1130 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1131 else iStrip = (Int_t)(nTDC/3.) - 3;
1133 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1135 } else if (iDDL==1) {
1137 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1138 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1139 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1140 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1141 else if (nTRM== 7) {
1142 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1143 else iStrip = 20 - (Int_t)(nTDC/3.);
1145 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1146 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1147 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1148 else if (nTRM==11) {
1149 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1150 else iStrip = 21 - (Int_t)(nTDC/3.);
1152 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1154 } else if (iDDL==2) {
1156 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1157 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1158 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1159 else if (nTRM== 7) {
1160 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1161 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1163 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1164 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1165 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1166 else if (nTRM==11) {
1167 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1168 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1170 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1172 } else if (iDDL==3) {
1174 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1175 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1176 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1177 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1178 else if (nTRM== 7) {
1179 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1180 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1182 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1183 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1184 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1185 else if (nTRM==11) {
1186 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1187 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1189 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1197 //----------------------------------------------------------------------------
1198 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1202 // Returns the TOF pad number per strip [0;95]
1203 // corresponding to the TOF equipment ID numbers:
1204 // iDDL -> DDL number per sector [0;3]
1205 // iChain -> TRM chain number [0;1]
1206 // nTDC -> TDC number [0;14]
1207 // iCH -> TDC channel number [0;7]
1210 Int_t iPadAlongTheStrip = -1;
1212 Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1214 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1215 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1217 Int_t iCHlocal = iCH;
1218 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1220 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1222 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1223 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
1224 AliError("Problems with the padX number!");
1226 return iPadAlongTheStrip;
1230 //----------------------------------------------------------------------------
1231 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1234 // Returns the sector number [0;17]
1235 // corresponing to the assigned DRM/DDL number [0;71]
1238 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1243 //----------------------------------------------------------------------------
1244 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1247 // Return the DRM/DDL number per sector [0;3]
1248 // corresponing to the assigned DRM/DDL number [0;71]
1251 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1257 //----------------------------------------------------------------------------
1258 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1259 Int_t nTDC, Int_t iCH,
1260 Int_t *volume) const
1264 // nDDL (variable in [0;71]) -> number of the DDL file
1265 // nTRM (variable in [3;12]) -> number of the TRM slot
1266 // iChain (variable in [0; 1]) -> number of the TRM chain
1267 // nTDC (variable in [0;14]) -> number of the TDC
1268 // iCH (variable in [0; 7]) -> number of the TDC channel
1271 // sector number, i.e. volume[0] (variable in [0,17])
1272 // plate number, i.e. volume[1] (variable in [0, 5])
1273 // strip number, i.e. volume[2] (variable in [0,14/18])
1274 // padX number, i.e. volume[3] (variable in [0,47])
1275 // padZ number, i.e. volume[4] (variable in [0, 1])
1278 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1280 Int_t iSector = GetSectorNumber(nDDL);
1282 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1283 if (iPlate==-1) AliError("Problems with the plate number!");
1285 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1286 if (iStrip==-1) AliError("Problems with the strip number!");
1288 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1289 if (iPadAlongTheStrip==-1)
1290 AliError("Problems with the pad number along the strip!");
1292 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1293 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1295 volume[0] = iSector;