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.12 2007/02/22 09:43:45 decaro
19 Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
21 Revision 1.11 2007/02/20 15:57:00 decaro
22 Raw data update: to read the TOF raw data defined in UNPACKED mode
24 Revision 1.10 2006/12/15 14:01:38 cvetan
27 Revision 1.9 2006/10/13 11:22:27 arcelli
28 remove warnings due to uninitialized AliTOFtdcDigit data members
30 Revision 1.8 2006/08/22 13:30:17 arcelli
31 removal of effective c++ warnings (C.Zampolli)
33 Revision 1.7 2006/08/10 14:46:54 decaro
34 TOF raw data format: updated version
36 Revision 1.6.1 2006/06/28 A. De Caro, R. Preghenella:
37 Update TOF raw data format
38 according to the final version
39 (see the ALICE internal note in preparation
40 'ALICE TOF raw data format')
41 Added the methods for the correspoonding numbering
42 between the equipment IDs and the volume IDs:
47 Revision 0.02 2005/07/28 A. De Caro:
48 Update format TOF raw data
50 Correction of few wrong corrispondences
51 between 'software' and 'hardware' numberings
53 Revision 0.01 2005/07/22 A. De Caro
54 Implement methods Next()
62 ////////////////////////////////////////////////////////////////////////
64 // This class provides access to TOF raw data in DDL files. //
66 // It loops over all TOF raw data given by the AliRawReader. //
68 ////////////////////////////////////////////////////////////////////////
71 #include "TClonesArray.h"
75 #include "AliRawReader.h"
77 #include "AliTOFGeometry.h"
78 #include "AliTOFGeometryV5.h"
79 #include "AliTOFrawData.h"
80 #include "AliTOFRawMap.h"
81 #include "AliTOFRawStream.h"
84 /******************************************
86 ******************************************/
89 #define FILLER 0x70000000
91 //word type mask/position
92 #define WORD_TYPE_MASK 0xf0000000
93 #define WORD_TYPE_POSITION 28
95 //global header word required bit pattern
96 #define GLOBAL_HEADER 0x40000000
98 //global trailer word required bit pattern
99 #define GLOBAL_TRAILER 0x50000000
101 //error word required bit pattern
102 #define ERROR 0x30000000
104 //header slot ID mask/position
105 #define HEADER_SLOT_ID_MASK 0x0000000f
106 #define HEADER_SLOT_ID_POSITION 0
109 #define GLOBAL_HEADER_TYPE 4
110 #define GLOBAL_TRAILER_TYPE 5
112 #define FILLER_TYPE 7
113 #define TRM_CHAIN0_HEADER_TYPE 0
114 #define TRM_CHAIN0_TRAILER_TYPE 1
115 #define TRM_CHAIN1_HEADER_TYPE 2
116 #define TRM_CHAIN1_TRAILER_TYPE 3
119 #define DRM_ID_NUMBER 1
120 #define LTM_ID_NUMBER 2
123 /******************************************
125 ******************************************/
127 //DRM global header word required bit pattern
128 #define DRM_GLOBAL_HEADER 0x40000001
130 //DRM event words mask/position
131 #define DRM_EVENT_WORDS_MASK 0x001ffff0
132 #define DRM_EVENT_WORDS_POSITION 4
134 //DRM DRM ID mask/position
135 #define DRM_DRM_ID_MASK 0x0fe00000
136 #define DRM_DRM_ID_POSITION 21
138 //DRM status header 1 word required bit pattern
139 #define DRM_STATUS_HEADER_1 0x40000001
141 //DRM slot ID mask/position
142 #define DRM_SLOT_ID_MASK 0x00007ff0
143 #define DRM_SLOT_ID_POSITION 4
145 //DRM C-bit mask/position
146 #define DRM_C_BIT_MASK 0x00008000
147 #define DRM_C_BIT_POSITION 15
149 //DRM status header 2 word required bit pattern
150 #define DRM_STATUS_HEADER_2 0x40000001
152 //DRM enable ID mask/position
153 #define DRM_ENABLE_ID_MASK 0x00007ff0
154 #define DRM_ENABLE_ID_POSITION 4
156 //DRM fault ID mask/position
157 #define DRM_FAULT_ID_MASK 0x07ff0000
158 #define DRM_FAULT_ID_POSITION 16
160 //DRM status header 3 word required bit pattern
161 #define DRM_STATUS_HEADER_3 0x40000001
163 //DRM TTC event counter mask/position
164 #define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
165 #define DRM_TTC_EVENT_COUNTER_POSITION 4
167 //DRM event CRC mask/position
168 //#define DRM_EVENT_CRC_MASK 0x001ffff0
169 #define DRM_EVENT_CRC_MASK 0x000ffff0
170 #define DRM_EVENT_CRC_POSITION 4
172 //DRM global trailer word required bit pattern
173 #define DRM_GLOBAL_TRAILER 0x50000001
175 //DRM local event counter mask/position
176 #define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
177 #define DRM_LOCAL_EVENT_COUNTER_POSITION 4
180 /******************************************
182 ******************************************/
184 //TRM global header word required bit pattern
185 #define TRM_GLOBAL_HEADER 0x40000000
187 //TRM slot ID mask/position
188 #define TRM_SLOT_ID_MASK 0x0000000f
189 #define TRM_SLOT_ID_POSITION 0
191 //TRM event words mask/position
192 #define TRM_EVENT_WORDS_MASK 0x0001fff0
193 #define TRM_EVENT_WORDS_POSITION 4
195 //TRM ACQ-bits mask/position
196 #define TRM_ACQ_BITS_MASK 0x00060000
197 #define TRM_ACQ_BITS_POSITION 17
199 //TRM L-bit mask/position
200 #define TRM_L_BIT_MASK 0x00080000
201 #define TRM_L_BIT_POSITION 19
203 //TRM chain-0 header word required bit pattern
204 #define TRM_CHAIN_0_HEADER 0x00000000
206 //TRM chain-1 header word required bit pattern
207 #define TRM_CHAIN_1_HEADER 0x20000000
209 //TRM bunch ID mask/position
210 #define TRM_BUNCH_ID_MASK 0x0000fff0
211 #define TRM_BUNCH_ID_POSITION 4
213 //TRM PB24 temp mask/position
214 #define TRM_PB24_TEMP_MASK 0x00ff0000
215 #define TRM_PB24_TEMP_POSITION 16
217 //TRM PB24 ID mask/position
218 #define TRM_PB24_ID_MASK 0x07000000
219 #define TRM_PB24_ID_POSITION 24
221 //TRM TS-bit mask/position
222 #define TRM_TS_BIT_MASK 0x08000000
223 #define TRM_TS_BIT_POSITION 27
225 //TRM chain-0 trailer word required bit pattern
226 #define TRM_CHAIN_0_TRAILER 0x10000000
228 //TRM chain-1 trailer word required bit pattern
229 #define TRM_CHAIN_1_TRAILER 0x30000000
231 //TRM status mask/position
232 #define TRM_STATUS_MASK 0x0000000f
233 #define TRM_STATUS_POSITION 0
238 //TRM TDC digit word required bit pattern
239 #define TRM_TDC_DIGIT 0x8000000
241 //TRM digit time mask/position
242 #define TRM_DIGIT_TIME_MASK 0x00001fff
243 #define TRM_DIGIT_TIME_POSITION 0
245 //TRM long digit time mask/position
246 #define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
247 #define TRM_LONG_DIGIT_TIME_POSITION 0
249 //TRM TOT width mask/position
250 #define TRM_TOT_WIDTH_MASK 0x001fe000
251 #define TRM_TOT_WIDTH_POSITION 13
253 //TRM chan mask/position
254 #define TRM_CHAN_MASK 0x00e00000
255 #define TRM_CHAN_POSITION 21
257 //TRM TDC ID mask/position
258 #define TRM_TDC_ID_MASK 0x0f000000
259 #define TRM_TDC_ID_POSITION 24
261 //TRM E-bit mask/position
262 #define TRM_E_BIT_MASK 0x10000000
263 #define TRM_E_BIT_POSITION 28
265 //TRM PS-bits mask/position
266 #define TRM_PS_BITS_MASK 0x60000000
267 #define TRM_PS_BITS_POSITION 29
269 #define TRM_FIRST_SLOT_ID 3
271 //define hptdc time bin width
272 #define TIME_BIN_WIDTH 24.4e-3 //ns
274 //define hptdc tot bin width
275 #define TOT_BIN_WIDTH 48.4e-3 //ns
279 //TRM TDC error word required bit pattern
280 #define TRM_TDC_ERROR 0x6000000
282 //TRM TDC diagnostic error word required bit pattern
283 #define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
285 //TRM TDC error flags mask/position
286 #define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
287 #define TRM_TDC_ERROR_FLAGS_POSITION 0
289 //TRM TDC error TDC ID mask/position
290 #define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
291 #define TRM_TDC_ERROR_TDC_ID_POSITION 24
293 //TRM TDC fault chip flag ID mask/position
294 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
295 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
297 //TRM TDC error C-bit mask/position
298 #define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
299 #define TRM_TDC_ERROR_C_BIT_POSITION 15
301 //TRM TDC JTAG error code mask/position
302 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
303 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
305 //TRM TDC disgnostic error TDC ID mask/position
306 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
307 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
309 //TRM global trailer word required bit pattern
310 //#define TRM_GLOBAL_TRAILER 0x50000000
311 #define TRM_GLOBAL_TRAILER 0x5000000f
313 //TRM event CRC mask/position
314 #define TRM_EVENT_CRC_MASK 0x0000fff0
315 #define TRM_EVENT_CRC_POSITION 4
317 //TRM event counter mask/position
318 #define TRM_EVENT_COUNTER_MASK 0x0fff0000
319 #define TRM_EVENT_COUNTER_POSITION 16
322 /******************************************
324 ******************************************/
326 //LTM global header word required bit pattern
327 #define LTM_GLOBAL_HEADER 0x40000002
329 //LTM event words mask/position
330 #define LTM_EVENT_WORDS_MASK 0x0001fff0
331 #define LTM_EVENT_WORDS_POSITION 4
333 //LTM C-bit mask/position
334 #define LTM_C_BIT_MASK 0x00020000
335 #define LTM_C_BIT_POSITION 17
337 //LTM fault mask/position
338 #define LTM_FAULT_MASK 0x00fc0000
339 #define LTM_FAULT_POSITION 18
343 //PDL value 1 mask/position
344 #define LTM_PDL_VALUE_1_MASK 0x000000ff
345 #define LTM_PDL_VALUE_1_POSITION 0
347 //PDL value 2 mask/position
348 #define LTM_PDL_VALUE_2_MASK 0x0000ff00
349 #define LTM_PDL_VALUE_2_POSITION 8
351 //PDL value 3 mask/position
352 #define LTM_PDL_VALUE_3_MASK 0x00ff0000
353 #define LTM_PDL_VALUE_3_POSITION 16
355 //PDL value 4 mask/position
356 #define LTM_PDL_VALUE_4_MASK 0xff000000
357 #define LTM_PDL_VALUE_4_POSITION 24
361 //ADC value 1 mask/position
362 #define LTM_ADC_VALUE_1_MASK 0x000003ff
363 #define LTM_ADC_VALUE_1_POSITION 0
365 //ADC value 2 mask/position
366 #define LTM_ADC_VALUE_2_MASK 0x000ffc00
367 #define LTM_ADC_VALUE_2_POSITION 10
369 //ADC value 3 mask/position
370 #define LTM_ADC_VALUE_3_MASK 0x3ff00000
371 #define LTM_ADC_VALUE_3_POSITION 20
373 //LTM global trailer word required bit pattern
374 #define LTM_GLOBAL_TRAILER 0x50000002
376 //LTM event CRC mask/position
377 #define LTM_EVENT_CRC_MASK 0x0000fff0
378 #define LTM_EVENT_CRC_POSITION 4
380 //LTM event number mask/position
381 #define LTM_EVENT_NUMBER_MASK 0x0fff0000
382 #define LTM_EVENT_NUMBER_POSITION 16
385 ClassImp(AliTOFRawStream)
388 //_____________________________________________________________________________
389 AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
390 fRawReader(rawReader),
391 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
407 fTOFGeometry(new AliTOFGeometryV5()),
417 fInsideTRMchain0(kFALSE),
418 fInsideTRMchain1(kFALSE)
421 // create an object to read TOF raw digits
425 fRawReader->Select("TOF");
429 //_____________________________________________________________________________
430 AliTOFRawStream::AliTOFRawStream():
432 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
448 fTOFGeometry(new AliTOFGeometryV5()),
458 fInsideTRMchain0(kFALSE),
459 fInsideTRMchain1(kFALSE)
467 //_____________________________________________________________________________
468 AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
471 fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
487 fTOFGeometry(new AliTOFGeometryV5()),
497 fInsideTRMchain0(kFALSE),
498 fInsideTRMchain1(kFALSE)
504 fRawReader = stream.fRawReader;
506 fTOFrawData = stream.fTOFrawData;
510 fTRMchain = stream.fTRMchain;
512 fTDCchannel = stream.fTDCchannel;
513 fTime = stream.fTime;
515 fLeadingEdge = stream.fLeadingEdge;
516 fTrailingEdge = stream.fTrailingEdge;
518 fErrorFlag = stream.fErrorFlag;
520 fSector = stream.fSector;
521 fPlate = stream.fPlate;
522 fStrip = stream.fStrip;
523 fPadX = stream.fPadX;
524 fPadZ = stream.fPadZ;
526 fTOFGeometry = stream.fTOFGeometry;
528 fPackedDigits = stream.fPackedDigits;
530 fWordType = stream.fWordType;
531 fSlotID = stream.fSlotID;
533 fPSbit = stream.fPSbit;
534 fTDCerrorFlag = stream.fTDCerrorFlag;
535 fInsideDRM = stream.fInsideDRM;
536 fInsideTRM = stream.fInsideTRM;
537 fInsideLTM = stream.fInsideLTM;
538 fInsideTRMchain0 = stream.fInsideTRMchain0;
539 fInsideTRMchain1 = stream.fInsideTRMchain1;
543 //_____________________________________________________________________________
544 AliTOFRawStream& AliTOFRawStream::operator = (const AliTOFRawStream& stream)
547 // assignment operator
550 fRawReader = stream.fRawReader;
552 fTOFrawData = stream.fTOFrawData;
556 fTRMchain = stream.fTRMchain;
558 fTDCchannel = stream.fTDCchannel;
559 fTime = stream.fTime;
561 fLeadingEdge = stream.fLeadingEdge;
562 fTrailingEdge = stream.fTrailingEdge;
563 fErrorFlag = stream.fErrorFlag;
565 fSector = stream.fSector;
566 fPlate = stream.fPlate;
567 fStrip = stream.fStrip;
568 fPadX = stream.fPadX;
569 fPadZ = stream.fPadZ;
571 fTOFGeometry = stream.fTOFGeometry;
573 fPackedDigits = stream.fPackedDigits;
575 fWordType = stream.fWordType;
576 fSlotID = stream.fSlotID;
578 fPSbit = stream.fPSbit;
579 fTDCerrorFlag = stream.fTDCerrorFlag;
580 fInsideDRM = stream.fInsideDRM;
581 fInsideTRM = stream.fInsideTRM;
582 fInsideLTM = stream.fInsideLTM;
583 fInsideTRMchain0 = stream.fInsideTRMchain0;
584 fInsideTRMchain1 = stream.fInsideTRMchain1;
590 //_____________________________________________________________________________
591 AliTOFRawStream::~AliTOFRawStream()
599 //delete fTOFrawData;
604 //_____________________________________________________________________________
606 void AliTOFRawStream::LoadRawData(Int_t indexDDL)
610 for (Int_t indexDDL = 0;
611 indexDDL < AliDAQ::NumberOfDdls("TOF");
615 fTOFrawData->Clear();
618 // create raw data map
619 AliTOFRawMap *rawMap = new AliTOFRawMap(fTOFrawData);
622 Int_t slot[4] = {-1, -1, -1, -1};
625 fRawReader->Select("TOF", indexDDL, indexDDL);
627 Bool_t signal = kFALSE;
631 signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
633 //printf(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX);
638 slot[3] = fTDCchannel;
640 if (rawMap->TestHit(slot) != kEmpty) {
642 AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
644 if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
645 fLeadingEdge==-1 && fTrailingEdge!=-1) {
647 rawDigit->Update(fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
649 else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
650 (fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
652 /* else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
653 (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/ /*||
654 (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
655 fLeadingEdge!=-1 && fTrailingEdge==-1) */)
658 TClonesArray &arrayTofRawData = *fTOFrawData;
659 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
661 rawMap->SetHit(slot);
669 TClonesArray &arrayTofRawData = *fTOFrawData;
670 new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
672 rawMap->SetHit(slot);
674 } // else if (rawMap->TestHit(slot) == kEmpty)
678 } // closed -> while (Next())
681 fDDL = fRawReader->GetDDLID();
683 for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
685 AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
687 fTRM = dummy->GetTRM();
688 fTRMchain = dummy->GetTRMchain();
689 fTDC = dummy->GetTDC();
690 fTDCchannel = dummy->GetTDCchannel();
698 printf(" %2i, %2i %1i, %2i, %1i --> %2i, %1i, %2i, %1i, %2i \n",
699 fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
700 fSector, fPlate, fStrip, fPadZ, fPadX);
702 } // closed loop on TOF raw data TClonesArray
705 //} // closed loop on indexDDL
709 //_____________________________________________________________________________
710 Bool_t AliTOFRawStream::Next()
713 // Read next 32-bit word in TOF raw data files
714 // returns kFALSE if there is no word left
719 if (!fRawReader->ReadNextInt(data)) return kFALSE;
721 if (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1) {
733 fDDL = fRawReader->GetDDLID();
735 fWordType = GetField(data,WORD_TYPE_MASK,WORD_TYPE_POSITION);
737 switch (fWordType) { // switch word type
739 case GLOBAL_HEADER_TYPE: // global header
740 fSlotID = GetField(data, HEADER_SLOT_ID_MASK, HEADER_SLOT_ID_POSITION);
744 switch (fSlotID) { // switch global header slot ID
746 case DRM_ID_NUMBER: //DRM global header
747 if (fInsideDRM) { // unexpected DRM global headers -> exit
750 fInsideDRM = kTRUE; // DRM global header accepted
753 case LTM_ID_NUMBER: // LTM global header
754 if (fInsideLTM) { // unexpected LTM global headers -> exit
757 fInsideLTM = kTRUE; // LTM global header accepted
767 case 10: //TRM header
768 case 11: //TRM header
769 case 12: //TRM header
770 if (fInsideTRM) { // unexpected TRM global headers -> exit
773 fInsideTRM = kTRUE; // TRM global header accepted
774 fACQ = GetField(data,TRM_ACQ_BITS_MASK,TRM_ACQ_BITS_POSITION);
777 default: // unexpected global header slot ID
780 } //end switch global header slot id
785 case GLOBAL_TRAILER_TYPE: // global trailer
786 fSlotID = GetField(data,HEADER_SLOT_ID_MASK,HEADER_SLOT_ID_POSITION);
789 switch (fSlotID) { // switch global trailer slot ID
791 case DRM_ID_NUMBER: // DRM global trailer
792 if (!fInsideDRM) { // unexpected DRM global trailers -> exit
795 fInsideDRM = kFALSE; // DRM global trailer accepted
798 fInsideTRMchain0 = kFALSE;
799 fInsideTRMchain1 = kFALSE;
819 case LTM_ID_NUMBER: // LTM global trailer
820 if (!fInsideLTM) { // unexpected LTM global trailer -> exit
823 fInsideLTM = kFALSE; // LTM global trailer accepted
825 case 15: //TRM global trailer
826 if (!fInsideTRM) { // unexpected TRM global trailers -> exit
829 fInsideTRM = kFALSE; // TRM global trailer accepted
831 default: // unexpected global trailer slot ID
833 } //end switch global trailer slot id
839 case ERROR_TYPE: // TDC error
840 fTDC = GetField(data,TRM_TDC_ERROR_TDC_ID_MASK,TRM_TDC_ERROR_TDC_ID_POSITION);
841 fTDCerrorFlag = GetField(data,TRM_TDC_ERROR_FLAGS_MASK,TRM_TDC_ERROR_FLAGS_POSITION);
845 case FILLER_TYPE: // filler
849 default: // other word types
851 if (fInsideTRM) { // inside TRM
853 switch (fWordType) { // switch word type inside TRM
854 case TRM_CHAIN0_HEADER_TYPE: // TRM chain0 header
855 if (fInsideTRMchain0) { // unexpected TRM chain0 header
858 fInsideTRMchain0 = kTRUE;
861 case TRM_CHAIN0_TRAILER_TYPE: // TRM chain0 trailer
862 if (!fInsideTRMchain0) { // unexpected TRM chain0 trailer
865 fInsideTRMchain0 = kFALSE;
868 case TRM_CHAIN1_HEADER_TYPE: // TRM chain1 header
869 if (fInsideTRMchain1) { // unexpected TRM chain1 header
872 fInsideTRMchain1 = kTRUE;
875 case TRM_CHAIN1_TRAILER_TYPE: // TRM chain1 trailer
876 if (!fInsideTRMchain1) { // unexpected TRM chain1 trailer
879 fInsideTRMchain1 = kFALSE;
882 } // end switch word type inside TRM
884 } // end if (fInsideTRM)
888 ((fInsideTRMchain0&&!fInsideTRMchain1) || (!fInsideTRMchain0&&fInsideTRMchain1))
889 && fWordType!=TRM_CHAIN0_HEADER_TYPE && fWordType!=TRM_CHAIN0_TRAILER_TYPE
890 && fWordType!=TRM_CHAIN1_HEADER_TYPE && fWordType!=TRM_CHAIN1_TRAILER_TYPE
891 ){ // inside TRM chains
893 fPSbit = GetField(data,TRM_PS_BITS_MASK,TRM_PS_BITS_POSITION);
894 fTDC = GetField(data,TRM_TDC_ID_MASK,TRM_TDC_ID_POSITION);
895 fTDCchannel = GetField(data,TRM_CHAN_MASK,TRM_CHAN_POSITION);
896 fErrorFlag = GetField(data,TRM_E_BIT_MASK,TRM_E_BIT_POSITION);
905 switch (fPSbit) { // switch fPSbit bits inside TRM chains
907 case 0: // packing ok, digit time and TOT
908 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
909 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
912 case 1: // leading edge digit, long digit time, no TOT
915 fLeadingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
918 case 2: // trailing edge digit, long digit time, no TOT
921 fTrailingEdge = GetField(data,TRM_LONG_DIGIT_TIME_MASK,TRM_LONG_DIGIT_TIME_POSITION);
924 case 3: // TOT overflow
925 fToT = GetField(data,TRM_TOT_WIDTH_MASK, TRM_TOT_WIDTH_POSITION);
926 fTime = GetField(data,TRM_DIGIT_TIME_MASK,TRM_DIGIT_TIME_POSITION);
929 } // end switch PS bits inside TRM chains
931 } // end if is inside TRM chains
933 } // end switch on fWordType
939 //_____________________________________________________________________________
941 void AliTOFRawStream::SetSector()
944 // Evaluate the TOF sector number -> [ 0;17]
945 // corresponding to the TOF equipment IDs:
948 // fTRMchain -> [ 0; 1]
950 // fTDCchannel -> [ 0; 7]
955 if (!(fDDL==-1)) iSector = Int_t((Float_t)(fDDL)/AliTOFGeometry::NDDL());
960 //_____________________________________________________________________________
963 void AliTOFRawStream::SetPlate()
966 // Evaluate the TOF plate number ->[ 0; 4]
967 // corresponding to the TOF equipment IDs:
970 // fTRMchain -> [ 0; 1]
972 // fTDCchannel -> [ 0; 7]
976 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
978 iPlate = Equip2VolNplate(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
983 //_____________________________________________________________________________
985 void AliTOFRawStream::SetStrip()
988 // Evaluate the TOF strip number per module -> [ 0; 14/18]
989 // corresponding to the TOF equipment IDs:
992 // fTRMchain -> [ 0; 1]
994 // fTDCchannel -> [ 0; 7]
999 if (!(fDDL==-1 || fTRM==-1 || fTDC==-1
1000 || fSector==-1 || fPlate==-1))
1001 iStrip = Equip2VolNstrip(GetDDLnumberPerSector(fDDL), fTRM, fTDC);
1006 //_____________________________________________________________________________
1008 void AliTOFRawStream::SetPadZ()
1011 // Evaluate the TOF padRow number per strip -> [ 0; 1]
1012 // corresponding to the TOF equipment IDs:
1015 // fTRMchain -> [ 0; 1]
1017 // fTDCchannel -> [ 0; 7]
1022 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1023 || fSector==-1 || fPlate==-1 || fStrip==-1))
1025 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1026 if (iPadAlongTheStrip!=-1)
1027 iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1033 //_____________________________________________________________________________
1035 void AliTOFRawStream::SetPadX()
1038 // Evaluate the TOF pad number per strip padRow -> [ 0;47]
1039 // corresponding to the TOF equipment IDs:
1042 // fTRMchain -> [ 0; 1]
1044 // fTDCchannel -> [ 0; 7]
1049 if (!(fDDL==-1 || fTRM==-1 || fTRMchain==-1 || fTDC==-1 || fTDCchannel==-1
1050 || fSector==-1 || fPlate==-1 || fStrip==-1))
1052 Int_t iPadAlongTheStrip = Equip2VolNpad(GetDDLnumberPerSector(fDDL), fTRMchain, fTDC, fTDCchannel);
1053 if (iPadAlongTheStrip!=-1)
1054 iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1061 //----------------------------------------------------------------------------
1062 Int_t AliTOFRawStream::GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const
1068 return ((word & fieldMask) >> fieldPosition);
1071 //----------------------------------------------------------------------------
1072 Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1075 // Returns the TOF plate number [0;4]
1076 // corresponding to the TOF equipment ID numbers:
1077 // iDDL -> DDL number per sector [0;3]
1078 // nTRM -> TRM number [3;12]
1079 // nTDC -> TDC number [0;14]
1085 if (nTRM>=4 && nTRM<7) {
1087 } else if (nTRM==7) {
1088 if (nTDC<12) iPlate = 0;
1090 } else if (nTRM>=8 && nTRM<11) {
1092 } else if (nTRM==11) {
1093 if (nTDC<9) iPlate = 1;
1095 }else if (nTRM==12) {
1099 } else if (iDDL==1) {
1102 if (nTDC<3) iPlate = 0;
1103 } else if (nTRM>=4 && nTRM<7) {
1105 } else if (nTRM==7) {
1106 if (nTDC<6) iPlate = 1;
1108 } else if (nTRM>=8 && nTRM<11) {
1110 } else if (nTRM==11) {
1111 if (nTDC<9) iPlate = 2;
1113 } else if (nTRM==12) {
1117 } else if (iDDL==2) {
1119 if (nTRM>=4 && nTRM<7) {
1121 } else if (nTRM==7) {
1122 if (nTDC<12) iPlate = 4;
1124 } else if (nTRM>=8 && nTRM<11) {
1126 } else if (nTRM==11) {
1127 if (nTDC<9) iPlate = 3;
1129 }else if (nTRM==12) {
1133 } else if (iDDL==3) {
1136 if (nTDC<3) iPlate = 4;
1137 } else if (nTRM>=4 && nTRM<7) {
1139 } else if (nTRM==7) {
1140 if (nTDC<6) iPlate = 3;
1142 } else if (nTRM>=8 && nTRM<11) {
1144 } else if (nTRM==11) {
1145 if (nTDC<9) iPlate = 2;
1147 } else if (nTRM==12) {
1157 //----------------------------------------------------------------------------
1158 Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
1161 // Returns the TOF strip number per module:
1162 // [0;14], in the central plates,
1163 // [0;18], in the intermediate and external plates
1164 // corresponding to the TOF equipment ID numbers:
1165 // iDDL -> DDL number per sector [0;3]
1166 // nTRM -> TRM number [3;12]
1167 // nTDC -> TDC number [0;14]
1174 if (nTRM== 4) iStrip = (Int_t)(nTDC/3.);
1175 else if (nTRM== 5) iStrip = 5 + (Int_t)(nTDC/3.);
1176 else if (nTRM== 6) iStrip = 10 + (Int_t)(nTDC/3.);
1177 else if (nTRM== 7) {
1178 if (nTDC<12) iStrip = 15 + (Int_t)(nTDC/3.);
1179 else iStrip = (Int_t)(nTDC/3.) - 4;
1181 else if (nTRM== 8) iStrip = 1 + (Int_t)(nTDC/3.);
1182 else if (nTRM== 9) iStrip = 6 + (Int_t)(nTDC/3.);
1183 else if (nTRM==10) iStrip = 11 + (Int_t)(nTDC/3.);
1184 else if (nTRM==11) {
1185 if (nTDC<9) iStrip = 16 + (Int_t)(nTDC/3.);
1186 else iStrip = (Int_t)(nTDC/3.) - 3;
1188 else if (nTRM==12) iStrip = 2 + (Int_t)(nTDC/3.);
1190 } else if (iDDL==1) {
1192 if (nTRM==3 && nTDC<3) iStrip = (Int_t)(nTDC/3.);
1193 else if (nTRM== 4) iStrip = 5 - (Int_t)(nTDC/3.);
1194 else if (nTRM== 5) iStrip = 10 - (Int_t)(nTDC/3.);
1195 else if (nTRM== 6) iStrip = 15 - (Int_t)(nTDC/3.);
1196 else if (nTRM== 7) {
1197 if (nTDC<6) iStrip = 1 - (Int_t)(nTDC/3.);
1198 else iStrip = 20 - (Int_t)(nTDC/3.);
1200 else if (nTRM== 8) iStrip = 6 - (Int_t)(nTDC/3.);
1201 else if (nTRM== 9) iStrip = 11 - (Int_t)(nTDC/3.);
1202 else if (nTRM==10) iStrip = 16 - (Int_t)(nTDC/3.);
1203 else if (nTRM==11) {
1204 if (nTDC<9) iStrip = 2 - (Int_t)(nTDC/3.);
1205 else iStrip = 21 - (Int_t)(nTDC/3.);
1207 else if (nTRM==12) iStrip = 7 - (Int_t)(nTDC/3.);
1209 } else if (iDDL==2) {
1211 if (nTRM== 4) iStrip = 18 - (Int_t)(nTDC/3.);
1212 else if (nTRM== 5) iStrip = 18 - ( 5 + (Int_t)(nTDC/3.));
1213 else if (nTRM== 6) iStrip = 18 - (10 + (Int_t)(nTDC/3.));
1214 else if (nTRM== 7) {
1215 if (nTDC<12) iStrip = 18 - (15 + (Int_t)(nTDC/3.));
1216 else iStrip = 18 - ((Int_t)(nTDC/3.) - 4);
1218 else if (nTRM== 8) iStrip = 18 - ( 1 + (Int_t)(nTDC/3.));
1219 else if (nTRM== 9) iStrip = 18 - ( 6 + (Int_t)(nTDC/3.));
1220 else if (nTRM==10) iStrip = 18 - (11 + (Int_t)(nTDC/3.));
1221 else if (nTRM==11) {
1222 if (nTDC<9) iStrip = 18 - (16 + (Int_t)(nTDC/3.));
1223 else iStrip = 14 - ((Int_t)(nTDC/3.) - 3);
1225 else if (nTRM==12) iStrip = 14 - ( 2 + (Int_t)(nTDC/3.));
1227 } else if (iDDL==3) {
1229 if (nTRM==3 && nTDC<3) iStrip = 18 - (Int_t)(nTDC/3.);
1230 else if (nTRM== 4) iStrip = 18 - ( 5 - (Int_t)(nTDC/3.));
1231 else if (nTRM== 5) iStrip = 18 - (10 - (Int_t)(nTDC/3.));
1232 else if (nTRM== 6) iStrip = 18 - (15 - (Int_t)(nTDC/3.));
1233 else if (nTRM== 7) {
1234 if (nTDC<6) iStrip = 18 - (1 - (Int_t)(nTDC/3.));
1235 else iStrip = 18 - (20 - (Int_t)(nTDC/3.));
1237 else if (nTRM== 8) iStrip = 18 - ( 6 - (Int_t)(nTDC/3.));
1238 else if (nTRM== 9) iStrip = 18 - (11 - (Int_t)(nTDC/3.));
1239 else if (nTRM==10) iStrip = 18 - (16 - (Int_t)(nTDC/3.));
1240 else if (nTRM==11) {
1241 if (nTDC<9) iStrip = 14 - ( 2 - (Int_t)(nTDC/3.));
1242 else iStrip = 18 - (21 - (Int_t)(nTDC/3.));
1244 else if (nTRM==12) iStrip = 14 - ( 7 - (Int_t)(nTDC/3.));
1252 //----------------------------------------------------------------------------
1253 Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
1257 // Returns the TOF pad number per strip [0;95]
1258 // corresponding to the TOF equipment ID numbers:
1259 // iDDL -> DDL number per sector [0;3]
1260 // iChain -> TRM chain number [0;1]
1261 // nTDC -> TDC number [0;14]
1262 // iCH -> TDC channel number [0;7]
1265 Int_t iPadAlongTheStrip = -1;
1267 Int_t iTDClocal = nTDC%3 + (1-iChain)*3;
1269 if (iDDL==0 || iDDL==3) iTDClocal = 5 - iTDClocal;
1270 else if (iDDL==1 || iDDL==2) iTDClocal = 6 + (5 - iTDClocal);
1272 Int_t iCHlocal = iCH;
1273 if (iDDL==0 || iDDL==3) iCHlocal = 7 - iCH;
1275 iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
1277 if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
1278 ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
1279 AliError("Problems with the padX number!");
1281 return iPadAlongTheStrip;
1285 //----------------------------------------------------------------------------
1286 Int_t AliTOFRawStream::GetSectorNumber(Int_t nDDL) const
1289 // Returns the sector number [0;17]
1290 // corresponing to the assigned DRM/DDL number [0;71]
1293 Int_t iSector = Int_t((Float_t)(nDDL)/AliTOFGeometry::NDDL());
1298 //----------------------------------------------------------------------------
1299 Int_t AliTOFRawStream::GetDDLnumberPerSector(Int_t nDDL) const
1302 // Return the DRM/DDL number per sector [0;3]
1303 // corresponing to the assigned DRM/DDL number [0;71]
1306 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1312 //----------------------------------------------------------------------------
1313 void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
1314 Int_t nTDC, Int_t iCH,
1315 Int_t *volume) const
1319 // nDDL (variable in [0;71]) -> number of the DDL file
1320 // nTRM (variable in [3;12]) -> number of the TRM slot
1321 // iChain (variable in [0; 1]) -> number of the TRM chain
1322 // nTDC (variable in [0;14]) -> number of the TDC
1323 // iCH (variable in [0; 7]) -> number of the TDC channel
1326 // sector number, i.e. volume[0] (variable in [0,17])
1327 // plate number, i.e. volume[1] (variable in [0, 5])
1328 // strip number, i.e. volume[2] (variable in [0,14/18])
1329 // padX number, i.e. volume[3] (variable in [0,47])
1330 // padZ number, i.e. volume[4] (variable in [0, 1])
1333 Int_t iDDL = GetDDLnumberPerSector(nDDL);
1335 Int_t iSector = GetSectorNumber(nDDL);
1337 Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
1338 if (iPlate==-1) AliError("Problems with the plate number!");
1340 Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
1341 if (iStrip==-1) AliError("Problems with the strip number!");
1343 Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
1344 if (iPadAlongTheStrip==-1)
1345 AliError("Problems with the pad number along the strip!");
1347 Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
1348 Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
1350 volume[0] = iSector;
1357 //_____________________________________________________________________________
1359 Int_t AliTOFRawStream::GetIndex(Int_t *detId)
1361 //Retrieve calibration channel index
1362 const Int_t kSectors = fTOFGeometry->NSectors();
1363 const Int_t kPlates = fTOFGeometry->NPlates();
1364 const Int_t kStripA = fTOFGeometry->NStripA();
1365 const Int_t kStripB = fTOFGeometry->NStripB();
1366 const Int_t kStripC = fTOFGeometry->NStripC();
1367 const Int_t kPadX = fTOFGeometry->NpadX();
1368 const Int_t kPadZ = fTOFGeometry->NpadZ();
1371 Int_t isector = detId[0];
1372 if (isector >= kSectors)
1373 AliError(Form("Wrong sector number in TOF (%d) !",isector));
1374 Int_t iplate = detId[1];
1375 if (iplate >= kPlates)
1376 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1377 Int_t istrip = detId[2];
1378 Int_t ipadz = detId[3];
1379 Int_t ipadx = detId[4];
1380 Int_t stripOffset = 0;
1386 stripOffset = kStripC;
1389 stripOffset = kStripC+kStripB;
1392 stripOffset = kStripC+kStripB+kStripA;
1395 stripOffset = kStripC+kStripB+kStripA+kStripB;
1398 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
1402 Int_t idet = ((2*(kStripC+kStripB)+kStripA)*kPadZ*kPadX)*isector +
1403 (stripOffset*kPadZ*kPadX)+
1404 (kPadZ*kPadX)*istrip+