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.11 2007/02/20 15:57:00 decaro
19 Raw data update: to read the TOF raw data defined in UNPACKED mode
21 Revision 1.10 2006/12/15 14:01:38 cvetan
24 Revision 1.9 2006/10/13 11:22:27 arcelli
25 remove warnings due to uninitialized AliTOFtdcDigit data members
27 Revision 1.8 2006/08/22 13:30:17 arcelli
28 removal of effective c++ warnings (C.Zampolli)
30 Revision 1.7 2006/08/10 14:46:54 decaro
31 TOF raw data format: updated version
33 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
34 Update TOF raw data format
35 according to the final version
36 (see the ALICE internal note in preparation
37 'ALICE TOF raw data format')
38 Added the methods for the correspoonding numbering
39 between the equipment IDs and the volume IDs:
44 Revision 0.02 2005/07/28 A. De Caro:
45 Update format TOF raw data
47 Correction of few wrong corrispondences
48 between 'software' and 'hardware' numberings
50 Revision 0.01 2005/07/22 A. De Caro
51 Implement methods Next()
59 ////////////////////////////////////////////////////////////////////////
61 // This class provides access to TOF raw data in DDL files. //
63 // It loops over all TOF raw data given by the AliRawReader. //
65 ////////////////////////////////////////////////////////////////////////
68 #include "TClonesArray.h"
72 #include "AliRawReader.h"
74 #include "AliTOFGeometry.h"
75 #include "AliTOFGeometryV5.h"
76 #include "AliTOFrawData.h"
77 #include "AliTOFRawMap.h"
78 #include "AliTOFRawStream.h"
81 /******************************************
83 ******************************************/
86 #define FILLER 0x70000000
88 //word type mask/position
89 #define WORD_TYPE_MASK 0xf0000000
90 #define WORD_TYPE_POSITION 28
92 //global header word required bit pattern
93 #define GLOBAL_HEADER 0x40000000
95 //global trailer word required bit pattern
96 #define GLOBAL_TRAILER 0x50000000
98 //error word required bit pattern
99 #define ERROR 0x30000000
101 //header slot ID mask/position
102 #define HEADER_SLOT_ID_MASK 0x0000000f
103 #define HEADER_SLOT_ID_POSITION 0
106 #define GLOBAL_HEADER_TYPE 4
107 #define GLOBAL_TRAILER_TYPE 5
109 #define FILLER_TYPE 7
110 #define TRM_CHAIN0_HEADER_TYPE 0
111 #define TRM_CHAIN0_TRAILER_TYPE 1
112 #define TRM_CHAIN1_HEADER_TYPE 2
113 #define TRM_CHAIN1_TRAILER_TYPE 3
116 #define DRM_ID_NUMBER 1
117 #define LTM_ID_NUMBER 2
120 /******************************************
122 ******************************************/
124 //DRM global header word required bit pattern
125 #define DRM_GLOBAL_HEADER 0x40000001
127 //DRM event words mask/position
128 #define DRM_EVENT_WORDS_MASK 0x001ffff0
129 #define DRM_EVENT_WORDS_POSITION 4
131 //DRM DRM ID mask/position
132 #define DRM_DRM_ID_MASK 0x0fe00000
133 #define DRM_DRM_ID_POSITION 21
135 //DRM status header 1 word required bit pattern
136 #define DRM_STATUS_HEADER_1 0x40000001
138 //DRM slot ID mask/position
139 #define DRM_SLOT_ID_MASK 0x00007ff0
140 #define DRM_SLOT_ID_POSITION 4
142 //DRM C-bit mask/position
143 #define DRM_C_BIT_MASK 0x00008000
144 #define DRM_C_BIT_POSITION 15
146 //DRM status header 2 word required bit pattern
147 #define DRM_STATUS_HEADER_2 0x40000001
149 //DRM enable ID mask/position
150 #define DRM_ENABLE_ID_MASK 0x00007ff0
151 #define DRM_ENABLE_ID_POSITION 4
153 //DRM fault ID mask/position
154 #define DRM_FAULT_ID_MASK 0x07ff0000
155 #define DRM_FAULT_ID_POSITION 16
157 //DRM status header 3 word required bit pattern
158 #define DRM_STATUS_HEADER_3 0x40000001
160 //DRM TTC event counter mask/position
161 #define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
162 #define DRM_TTC_EVENT_COUNTER_POSITION 4
164 //DRM event CRC mask/position
165 //#define DRM_EVENT_CRC_MASK 0x001ffff0
166 #define DRM_EVENT_CRC_MASK 0x000ffff0
167 #define DRM_EVENT_CRC_POSITION 4
169 //DRM global trailer word required bit pattern
170 #define DRM_GLOBAL_TRAILER 0x50000001
172 //DRM local event counter mask/position
173 #define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
174 #define DRM_LOCAL_EVENT_COUNTER_POSITION 4
177 /******************************************
179 ******************************************/
181 //TRM global header word required bit pattern
182 #define TRM_GLOBAL_HEADER 0x40000000
184 //TRM slot ID mask/position
185 #define TRM_SLOT_ID_MASK 0x0000000f
186 #define TRM_SLOT_ID_POSITION 0
188 //TRM event words mask/position
189 #define TRM_EVENT_WORDS_MASK 0x0001fff0
190 #define TRM_EVENT_WORDS_POSITION 4
192 //TRM ACQ-bits mask/position
193 #define TRM_ACQ_BITS_MASK 0x00060000
194 #define TRM_ACQ_BITS_POSITION 17
196 //TRM L-bit mask/position
197 #define TRM_L_BIT_MASK 0x00080000
198 #define TRM_L_BIT_POSITION 19
200 //TRM chain-0 header word required bit pattern
201 #define TRM_CHAIN_0_HEADER 0x00000000
203 //TRM chain-1 header word required bit pattern
204 #define TRM_CHAIN_1_HEADER 0x20000000
206 //TRM bunch ID mask/position
207 #define TRM_BUNCH_ID_MASK 0x0000fff0
208 #define TRM_BUNCH_ID_POSITION 4
210 //TRM PB24 temp mask/position
211 #define TRM_PB24_TEMP_MASK 0x00ff0000
212 #define TRM_PB24_TEMP_POSITION 16
214 //TRM PB24 ID mask/position
215 #define TRM_PB24_ID_MASK 0x07000000
216 #define TRM_PB24_ID_POSITION 24
218 //TRM TS-bit mask/position
219 #define TRM_TS_BIT_MASK 0x08000000
220 #define TRM_TS_BIT_POSITION 27
222 //TRM chain-0 trailer word required bit pattern
223 #define TRM_CHAIN_0_TRAILER 0x10000000
225 //TRM chain-1 trailer word required bit pattern
226 #define TRM_CHAIN_1_TRAILER 0x30000000
228 //TRM status mask/position
229 #define TRM_STATUS_MASK 0x0000000f
230 #define TRM_STATUS_POSITION 0
235 //TRM TDC digit word required bit pattern
236 #define TRM_TDC_DIGIT 0x8000000
238 //TRM digit time mask/position
239 #define TRM_DIGIT_TIME_MASK 0x00001fff
240 #define TRM_DIGIT_TIME_POSITION 0
242 //TRM long digit time mask/position
243 #define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
244 #define TRM_LONG_DIGIT_TIME_POSITION 0
246 //TRM TOT width mask/position
247 #define TRM_TOT_WIDTH_MASK 0x001fe000
248 #define TRM_TOT_WIDTH_POSITION 13
250 //TRM chan mask/position
251 #define TRM_CHAN_MASK 0x00e00000
252 #define TRM_CHAN_POSITION 21
254 //TRM TDC ID mask/position
255 #define TRM_TDC_ID_MASK 0x0f000000
256 #define TRM_TDC_ID_POSITION 24
258 //TRM E-bit mask/position
259 #define TRM_E_BIT_MASK 0x10000000
260 #define TRM_E_BIT_POSITION 28
262 //TRM PS-bits mask/position
263 #define TRM_PS_BITS_MASK 0x60000000
264 #define TRM_PS_BITS_POSITION 29
266 #define TRM_FIRST_SLOT_ID 3
268 //define hptdc time bin width
269 #define TIME_BIN_WIDTH 24.4e-3 //ns
271 //define hptdc tot bin width
272 #define TOT_BIN_WIDTH 48.4e-3 //ns
276 //TRM TDC error word required bit pattern
277 #define TRM_TDC_ERROR 0x6000000
279 //TRM TDC diagnostic error word required bit pattern
280 #define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
282 //TRM TDC error flags mask/position
283 #define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
284 #define TRM_TDC_ERROR_FLAGS_POSITION 0
286 //TRM TDC error TDC ID mask/position
287 #define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
288 #define TRM_TDC_ERROR_TDC_ID_POSITION 24
290 //TRM TDC fault chip flag ID mask/position
291 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
292 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
294 //TRM TDC error C-bit mask/position
295 #define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
296 #define TRM_TDC_ERROR_C_BIT_POSITION 15
298 //TRM TDC JTAG error code mask/position
299 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
300 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
302 //TRM TDC disgnostic error TDC ID mask/position
303 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
304 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
306 //TRM global trailer word required bit pattern
307 //#define TRM_GLOBAL_TRAILER 0x50000000
308 #define TRM_GLOBAL_TRAILER 0x5000000f
310 //TRM event CRC mask/position
311 #define TRM_EVENT_CRC_MASK 0x0000fff0
312 #define TRM_EVENT_CRC_POSITION 4
314 //TRM event counter mask/position
315 #define TRM_EVENT_COUNTER_MASK 0x0fff0000
316 #define TRM_EVENT_COUNTER_POSITION 16
319 /******************************************
321 ******************************************/
323 //LTM global header word required bit pattern
324 #define LTM_GLOBAL_HEADER 0x40000002
326 //LTM event words mask/position
327 #define LTM_EVENT_WORDS_MASK 0x0001fff0
328 #define LTM_EVENT_WORDS_POSITION 4
330 //LTM C-bit mask/position
331 #define LTM_C_BIT_MASK 0x00020000
332 #define LTM_C_BIT_POSITION 17
334 //LTM fault mask/position
335 #define LTM_FAULT_MASK 0x00fc0000
336 #define LTM_FAULT_POSITION 18
340 //PDL value 1 mask/position
341 #define LTM_PDL_VALUE_1_MASK 0x000000ff
342 #define LTM_PDL_VALUE_1_POSITION 0
344 //PDL value 2 mask/position
345 #define LTM_PDL_VALUE_2_MASK 0x0000ff00
346 #define LTM_PDL_VALUE_2_POSITION 8
348 //PDL value 3 mask/position
349 #define LTM_PDL_VALUE_3_MASK 0x00ff0000
350 #define LTM_PDL_VALUE_3_POSITION 16
352 //PDL value 4 mask/position
353 #define LTM_PDL_VALUE_4_MASK 0xff000000
354 #define LTM_PDL_VALUE_4_POSITION 24
358 //ADC value 1 mask/position
359 #define LTM_ADC_VALUE_1_MASK 0x000003ff
360 #define LTM_ADC_VALUE_1_POSITION 0
362 //ADC value 2 mask/position
363 #define LTM_ADC_VALUE_2_MASK 0x000ffc00
364 #define LTM_ADC_VALUE_2_POSITION 10
366 //ADC value 3 mask/position
367 #define LTM_ADC_VALUE_3_MASK 0x3ff00000
368 #define LTM_ADC_VALUE_3_POSITION 20
370 //LTM global trailer word required bit pattern
371 #define LTM_GLOBAL_TRAILER 0x50000002
373 //LTM event CRC mask/position
374 #define LTM_EVENT_CRC_MASK 0x0000fff0
375 #define LTM_EVENT_CRC_POSITION 4
377 //LTM event number mask/position
378 #define LTM_EVENT_NUMBER_MASK 0x0fff0000
379 #define LTM_EVENT_NUMBER_POSITION 16
382 ClassImp(AliTOFRawStream)
385 //_____________________________________________________________________________
386 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
387 fRawReader(rawReader),
388 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
404 fTOFGeometry(new AliTOFGeometryV5()),
414 fInsideTRMchain0(kFALSE),
415 fInsideTRMchain1(kFALSE)
418 // create an object to read TOF raw digits
422 fRawReader->Select("TOF");
426 //_____________________________________________________________________________
427 AliTOFRawStream::AliTOFRawStream():
429 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
445 fTOFGeometry(new AliTOFGeometryV5()),
455 fInsideTRMchain0(kFALSE),
456 fInsideTRMchain1(kFALSE)
464 //_____________________________________________________________________________
465 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
468 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
484 fTOFGeometry(new AliTOFGeometryV5()),
494 fInsideTRMchain0(kFALSE),
495 fInsideTRMchain1(kFALSE)
501 fRawReader = stream.fRawReader;
503 fTOFrawData = stream.fTOFrawData;
507 fTRMchain = stream.fTRMchain;
509 fTDCchannel = stream.fTDCchannel;
510 fTime = stream.fTime;
512 fLeadingEdge = stream.fLeadingEdge;
513 fTrailingEdge = stream.fTrailingEdge;
515 fErrorFlag = stream.fErrorFlag;
517 fSector = stream.fSector;
518 fPlate = stream.fPlate;
519 fStrip = stream.fStrip;
520 fPadX = stream.fPadX;
521 fPadZ = stream.fPadZ;
523 fTOFGeometry = stream.fTOFGeometry;
525 fPackedDigits = stream.fPackedDigits;
527 fWordType = stream.fWordType;
528 fSlotID = stream.fSlotID;
530 fPSbit = stream.fPSbit;
531 fTDCerrorFlag = stream.fTDCerrorFlag;
532 fInsideDRM = stream.fInsideDRM;
533 fInsideTRM = stream.fInsideTRM;
534 fInsideLTM = stream.fInsideLTM;
535 fInsideTRMchain0 = stream.fInsideTRMchain0;
536 fInsideTRMchain1 = stream.fInsideTRMchain1;
540 //_____________________________________________________________________________
541 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
544 // assignment operator
547 fRawReader = stream.fRawReader;
549 fTOFrawData = stream.fTOFrawData;
553 fTRMchain = stream.fTRMchain;
555 fTDCchannel = stream.fTDCchannel;
556 fTime = stream.fTime;
558 fLeadingEdge = stream.fLeadingEdge;
559 fTrailingEdge = stream.fTrailingEdge;
560 fErrorFlag = stream.fErrorFlag;
562 fSector = stream.fSector;
563 fPlate = stream.fPlate;
564 fStrip = stream.fStrip;
565 fPadX = stream.fPadX;
566 fPadZ = stream.fPadZ;
568 fTOFGeometry = stream.fTOFGeometry;
570 fPackedDigits = stream.fPackedDigits;
572 fWordType = stream.fWordType;
573 fSlotID = stream.fSlotID;
575 fPSbit = stream.fPSbit;
576 fTDCerrorFlag = stream.fTDCerrorFlag;
577 fInsideDRM = stream.fInsideDRM;
578 fInsideTRM = stream.fInsideTRM;
579 fInsideLTM = stream.fInsideLTM;
580 fInsideTRMchain0 = stream.fInsideTRMchain0;
581 fInsideTRMchain1 = stream.fInsideTRMchain1;
587 //_____________________________________________________________________________
588 AliTOFRawStream::~AliTOFRawStream()
601 //_____________________________________________________________________________
603 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
607 for (Int_t indexDDL = 0;
608 indexDDL < AliDAQ::NumberOfDdls("TOF");
612 fTOFrawData->Clear();
615 // create raw data map
616 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
619 Int_t slot[4] = {-1, -1, -1, -1};
622 fRawReader->Select("TOF", indexDDL, indexDDL);
624 Bool_t signal = kFALSE;
628 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
630 //printf(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX);
635 slot[3] = fTDCchannel;
637 if (rawMap->TestHit(slot) != kEmpty) {
639 AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
641 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
642 fLeadingEdge==-1 && fTrailingEdge!=-1) {
644 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
646 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
647 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
649 /* else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
650 (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/ /*||
651 (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
652 fLeadingEdge!=-1 && fTrailingEdge==-1) */)
655 TClonesArray &arrayTofRawData = *fTOFrawData;
656 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
658 rawMap->SetHit(slot);
666 TClonesArray &arrayTofRawData = *fTOFrawData;
667 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
669 rawMap->SetHit(slot);
671 } // else if (rawMap->TestHit(slot) == kEmpty)
675 } // closed -> while (Next())
678 fDDL = fRawReader->GetDDLID();
680 for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
682 AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
684 fTRM = dummy->GetTRM();
685 fTRMchain = dummy->GetTRMchain();
686 fTDC = dummy->GetTDC();
687 fTDCchannel = dummy->GetTDCchannel();
695 printf(" %2i, %2i %1i, %2i, %1i --> %2i, %1i, %2i, %1i, %2i \n",
696 fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
697 fSector, fPlate, fStrip, fPadZ, fPadX);
699 } // closed loop on TOF raw data TClonesArray
702 //} // closed loop on indexDDL
706 //_____________________________________________________________________________
707 Bool_t AliTOFRawStream::Next()
710 // Read next 32-bit word in TOF raw data files
711 // returns kFALSE if there is no word left
716 if (!fRawReader->ReadNextInt(data)) return kFALSE;
718 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
730 fDDL = fRawReader->GetDDLID();
732 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
734 switch (fWordType) { // switch word type
736 case GLOBAL_HEADER_TYPE: // global header
737 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
741 switch (fSlotID) { // switch global header slot ID
743 case DRM_ID_NUMBER: //DRM global header
744 if (fInsideDRM) { // unexpected DRM global headers -> exit
747 fInsideDRM = kTRUE; // DRM global header accepted
750 case LTM_ID_NUMBER: // LTM global header
751 if (fInsideLTM) { // unexpected LTM global headers -> exit
754 fInsideLTM = kTRUE; // LTM global header accepted
764 case 10: //TRM header
765 case 11: //TRM header
766 case 12: //TRM header
767 if (fInsideTRM) { // unexpected TRM global headers -> exit
770 fInsideTRM = kTRUE; // TRM global header accepted
771 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
774 default: // unexpected global header slot ID
777 } //end switch global header slot id
782 case GLOBAL_TRAILER_TYPE: // global trailer
783 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
786 switch (fSlotID) { // switch global trailer slot ID
788 case DRM_ID_NUMBER: // DRM global trailer
789 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
792 fInsideDRM = kFALSE; // DRM global trailer accepted
795 fInsideTRMchain0 = kFALSE;
796 fInsideTRMchain1 = kFALSE;
816 case LTM_ID_NUMBER: // LTM global trailer
817 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
820 fInsideLTM = kFALSE; // LTM global trailer accepted
822 case 15: //TRM global trailer
823 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
826 fInsideTRM = kFALSE; // TRM global trailer accepted
828 default: // unexpected global trailer slot ID
830 } //end switch global trailer slot id
836 case ERROR_TYPE: // TDC error
837 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
838 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
842 case FILLER_TYPE: // filler
846 default: // other word types
848 if (fInsideTRM) { // inside TRM
850 switch (fWordType) { // switch word type inside TRM
851 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
852 if (fInsideTRMchain0) { // unexpected TRM chain0 header
855 fInsideTRMchain0 = kTRUE;
858 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
859 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
862 fInsideTRMchain0 = kFALSE;
865 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
866 if (fInsideTRMchain1) { // unexpected TRM chain1 header
869 fInsideTRMchain1 = kTRUE;
872 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
873 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
876 fInsideTRMchain1 = kFALSE;
879 } // end switch word type inside TRM
881 } // end if (fInsideTRM)
885 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
886 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
887 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
888 ){ // inside TRM chains
890 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
891 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
892 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
893 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
902 switch (fPSbit) { // switch fPSbit bits inside TRM chains
904 case 0: // packing ok, digit time and TOT
905 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
906 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
909 case 1: // leading edge digit, long digit time, no TOT
912 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
915 case 2: // trailing edge digit, long digit time, no TOT
918 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
921 case 3: // TOT overflow
922 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
923 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
926 } // end switch PS bits inside TRM chains
928 } // end if is inside TRM chains
930 } // end switch on fWordType
936 //_____________________________________________________________________________
938 void AliTOFRawStream::SetSector()
941 // Evaluate the TOF sector number -> [ 0;17]
942 // corresponding to the TOF equipment IDs:
945 // fTRMchain -> [ 0; 1]
947 // fTDCchannel -> [ 0; 7]
952 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
957 //_____________________________________________________________________________
960 void AliTOFRawStream::SetPlate()
963 // Evaluate the TOF plate number ->[ 0; 4]
964 // corresponding to the TOF equipment IDs:
967 // fTRMchain -> [ 0; 1]
969 // fTDCchannel -> [ 0; 7]
973 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
975 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
980 //_____________________________________________________________________________
982 void AliTOFRawStream::SetStrip()
985 // Evaluate the TOF strip number per module -> [ 0; 14/18]
986 // corresponding to the TOF equipment IDs:
989 // fTRMchain -> [ 0; 1]
991 // fTDCchannel -> [ 0; 7]
996 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
997 || fSector==-1 || fPlate==-1))
998 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
1003 //_____________________________________________________________________________
1005 void AliTOFRawStream::SetPadZ()
1008 // Evaluate the TOF padRow number per strip -> [ 0; 1]
1009 // corresponding to the TOF equipment IDs:
1012 // fTRMchain -> [ 0; 1]
1014 // fTDCchannel -> [ 0; 7]
1019 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1020 || fSector==-1 || fPlate==-1 || fStrip==-1))
1022 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1023 if (iPadAlongTheStrip!=-1)
1024 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1030 //_____________________________________________________________________________
1032 void AliTOFRawStream::SetPadX()
1035 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
1036 // corresponding to the TOF equipment IDs:
1039 // fTRMchain -> [ 0; 1]
1041 // fTDCchannel -> [ 0; 7]
1046 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1047 || fSector==-1 || fPlate==-1 || fStrip==-1))
1049 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1050 if (iPadAlongTheStrip!=-1)
1051 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1058 //----------------------------------------------------------------------------
1059 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1065 return ((word & fieldMask) >> fieldPosition);
1068 //----------------------------------------------------------------------------
1069 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1072 // Returns the TOF plate number [0;4]
1073 // corresponding to the TOF equipment ID numbers:
1074 // iDDL -> DDL number per sector [0;3]
1075 // nTRM -> TRM number [3;12]
1076 // nTDC -> TDC number [0;14]
1082 if (nTRM>=4 && nTRM<7) {
1084 } else if (nTRM==7) {
1085 if (nTDC<12) iPlate = 0;
1087 } else if (nTRM>=8 && nTRM<11) {
1089 } else if (nTRM==11) {
1090 if (nTDC<9) iPlate = 1;
1092 }else if (nTRM==12) {
1096 } else if (iDDL==1) {
1099 if (nTDC<3) iPlate = 0;
1100 } else if (nTRM>=4 && nTRM<7) {
1102 } else if (nTRM==7) {
1103 if (nTDC<6) iPlate = 1;
1105 } else if (nTRM>=8 && nTRM<11) {
1107 } else if (nTRM==11) {
1108 if (nTDC<9) iPlate = 2;
1110 } else if (nTRM==12) {
1114 } else if (iDDL==2) {
1116 if (nTRM>=4 && nTRM<7) {
1118 } else if (nTRM==7) {
1119 if (nTDC<12) iPlate = 4;
1121 } else if (nTRM>=8 && nTRM<11) {
1123 } else if (nTRM==11) {
1124 if (nTDC<9) iPlate = 3;
1126 }else if (nTRM==12) {
1130 } else if (iDDL==3) {
1133 if (nTDC<3) iPlate = 4;
1134 } else if (nTRM>=4 && nTRM<7) {
1136 } else if (nTRM==7) {
1137 if (nTDC<6) iPlate = 3;
1139 } else if (nTRM>=8 && nTRM<11) {
1141 } else if (nTRM==11) {
1142 if (nTDC<9) iPlate = 2;
1144 } else if (nTRM==12) {
1154 //----------------------------------------------------------------------------
1155 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1158 // Returns the TOF strip number per module:
1159 // [0;14], in the central plates,
1160 // [0;18], in the intermediate and external plates
1161 // corresponding to the TOF equipment ID numbers:
1162 // iDDL -> DDL number per sector [0;3]
1163 // nTRM -> TRM number [3;12]
1164 // nTDC -> TDC number [0;14]
1171 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1172 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1173 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1174 else if (nTRM== 7) {
1175 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1176 else iStrip = (Int_t)(nTDC/3.) - 4;
1178 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1179 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1180 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1181 else if (nTRM==11) {
1182 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1183 else iStrip = (Int_t)(nTDC/3.) - 3;
1185 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1187 } else if (iDDL==1) {
1189 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1190 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1191 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1192 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1193 else if (nTRM== 7) {
1194 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1195 else iStrip = 20 - (Int_t)(nTDC/3.);
1197 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1198 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1199 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1200 else if (nTRM==11) {
1201 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1202 else iStrip = 21 - (Int_t)(nTDC/3.);
1204 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1206 } else if (iDDL==2) {
1208 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1209 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1210 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1211 else if (nTRM== 7) {
1212 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1213 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1215 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1216 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1217 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1218 else if (nTRM==11) {
1219 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1220 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1222 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1224 } else if (iDDL==3) {
1226 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1227 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1228 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1229 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1230 else if (nTRM== 7) {
1231 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1232 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1234 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1235 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1236 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1237 else if (nTRM==11) {
1238 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1239 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1241 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1249 //----------------------------------------------------------------------------
1250 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1254 // Returns the TOF pad number per strip [0;95]
1255 // corresponding to the TOF equipment ID numbers:
1256 // iDDL -> DDL number per sector [0;3]
1257 // iChain -> TRM chain number [0;1]
1258 // nTDC -> TDC number [0;14]
1259 // iCH -> TDC channel number [0;7]
1262 Int_t iPadAlongTheStrip = -1;
1264 Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1266 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1267 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1269 Int_t iCHlocal = iCH;
1270 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1272 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1274 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1275 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
1276 AliError("Problems with the padX number!");
1278 return iPadAlongTheStrip;
1282 //----------------------------------------------------------------------------
1283 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1286 // Returns the sector number [0;17]
1287 // corresponing to the assigned DRM/DDL number [0;71]
1290 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1295 //----------------------------------------------------------------------------
1296 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1299 // Return the DRM/DDL number per sector [0;3]
1300 // corresponing to the assigned DRM/DDL number [0;71]
1303 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1309 //----------------------------------------------------------------------------
1310 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1311 Int_t nTDC, Int_t iCH,
1312 Int_t *volume) const
1316 // nDDL (variable in [0;71]) -> number of the DDL file
1317 // nTRM (variable in [3;12]) -> number of the TRM slot
1318 // iChain (variable in [0; 1]) -> number of the TRM chain
1319 // nTDC (variable in [0;14]) -> number of the TDC
1320 // iCH (variable in [0; 7]) -> number of the TDC channel
1323 // sector number, i.e. volume[0] (variable in [0,17])
1324 // plate number, i.e. volume[1] (variable in [0, 5])
1325 // strip number, i.e. volume[2] (variable in [0,14/18])
1326 // padX number, i.e. volume[3] (variable in [0,47])
1327 // padZ number, i.e. volume[4] (variable in [0, 1])
1330 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1332 Int_t iSector = GetSectorNumber(nDDL);
1334 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1335 if (iPlate==-1) AliError("Problems with the plate number!");
1337 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1338 if (iStrip==-1) AliError("Problems with the strip number!");
1340 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1341 if (iPadAlongTheStrip==-1)
1342 AliError("Problems with the pad number along the strip!");
1344 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1345 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1347 volume[0] = iSector;
1354 //_____________________________________________________________________________
1356 Int_t AliTOFRawStream::GetIndex(Int_t *detId)
1358 //Retrieve calibration channel index
1359 const Int_t nSectors = fTOFGeometry->NSectors();
1360 const Int_t nPlates = fTOFGeometry->NPlates();
1361 const Int_t nStripA = fTOFGeometry->NStripA();
1362 const Int_t nStripB = fTOFGeometry->NStripB();
1363 const Int_t nStripC = fTOFGeometry->NStripC();
1364 const Int_t nPadX = fTOFGeometry->NpadX();
1365 const Int_t nPadZ = fTOFGeometry->NpadZ();
1368 Int_t isector = detId[0];
1369 if (isector >= nSectors)
1370 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1371 Int_t iplate = detId[1];
1372 if (iplate >= nPlates)
1373 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1374 Int_t istrip = detId[2];
1375 Int_t ipadz = detId[3];
1376 Int_t ipadx = detId[4];
1377 Int_t stripOffset = 0;
1383 stripOffset = nStripC;
1386 stripOffset = nStripC+nStripB;
1389 stripOffset = nStripC+nStripB+nStripA;
1392 stripOffset = nStripC+nStripB+nStripA+nStripB;
1395 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1399 Int_t idet = ((2*(nStripC+nStripB)+nStripA)*nPadZ*nPadX)*isector +
1400 (stripOffset*nPadZ*nPadX)+
1401 (nPadZ*nPadX)*istrip+