1 #ifndef ALITOFRAWSTREAM_H
2 #define ALITOFRAWSTREAM_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ///////////////////////////////////////////////////////////////
10 // This class provides the key-reading for TOF raw data. //
12 ///////////////////////////////////////////////////////////////
15 #include "AliTOFHitData.h"
16 #include "AliTOFHitDataBuffer.h"
17 #include "AliTOFDecoder.h"
20 /**********************************
22 **********************************/
24 /******************************************
26 ******************************************/
30 #define FILLER 0x70000000
33 //word type mask/position
34 #ifndef WORD_TYPE_MASK
35 #define WORD_TYPE_MASK 0xf0000000
37 #define WORD_TYPE_POSITION 28
39 //global header word required bit pattern
41 #define GLOBAL_HEADER 0x40000000
44 //global trailer word required bit pattern
45 #ifndef GLOBAL_TRAILER
46 #define GLOBAL_TRAILER 0x50000000
49 //error word required bit pattern
51 #define ERROR 0x30000000
54 //header slot ID mask/position
55 #define HEADER_SLOT_ID_MASK 0x0000000f
56 #define HEADER_SLOT_ID_POSITION 0
59 #define GLOBAL_HEADER_TYPE 4
60 #define GLOBAL_TRAILER_TYPE 5
63 #define TRM_CHAIN0_HEADER_TYPE 0
64 #define TRM_CHAIN0_TRAILER_TYPE 1
65 #define TRM_CHAIN1_HEADER_TYPE 2
66 #define TRM_CHAIN1_TRAILER_TYPE 3
69 #define DRM_ID_NUMBER 1
70 #define LTM_ID_NUMBER 2
73 /******************************************
75 ******************************************/
77 //DRM global header word required bit pattern
78 #define DRM_GLOBAL_HEADER 0x40000001
80 //DRM event words mask/position
81 #define DRM_EVENT_WORDS_MASK 0x001ffff0
82 #define DRM_EVENT_WORDS_POSITION 4
84 //DRM DRM ID mask/position
85 #define DRM_DRM_ID_MASK 0x0fe00000
86 #define DRM_DRM_ID_POSITION 21
88 //DRM status header 1 word required bit pattern
89 #define DRM_STATUS_HEADER_1 0x40000001
91 //DRM slot ID mask/position
92 #define DRM_SLOT_ID_MASK 0x00007ff0
93 #define DRM_SLOT_ID_POSITION 4
95 //DRM C-bit mask/position
96 #define DRM_C_BIT_MASK 0x00008000
97 #define DRM_C_BIT_POSITION 15
99 //DRM status header 2 word required bit pattern
100 #define DRM_STATUS_HEADER_2 0x40000001
102 //DRM enable ID mask/position
103 #define DRM_ENABLE_ID_MASK 0x00007ff0
104 #define DRM_ENABLE_ID_POSITION 4
106 //DRM fault ID mask/position
107 #define DRM_FAULT_ID_MASK 0x07ff0000
108 #define DRM_FAULT_ID_POSITION 16
110 //DRM status header 3 word required bit pattern
111 #define DRM_STATUS_HEADER_3 0x40000001
113 //DRM TTC event counter mask/position
114 #define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
115 #define DRM_TTC_EVENT_COUNTER_POSITION 4
117 //DRM event CRC mask/position
118 //#define DRM_EVENT_CRC_MASK 0x001ffff0
119 #define DRM_EVENT_CRC_MASK 0x000ffff0
120 #define DRM_EVENT_CRC_POSITION 4
122 //DRM global trailer word required bit pattern
123 #define DRM_GLOBAL_TRAILER 0x50000001
125 //DRM local event counter mask/position
126 #define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
127 #define DRM_LOCAL_EVENT_COUNTER_POSITION 4
130 /******************************************
132 ******************************************/
134 //TRM global header word required bit pattern
135 #define TRM_GLOBAL_HEADER 0x40000000
137 //TRM slot ID mask/position
138 #define TRM_SLOT_ID_MASK 0x0000000f
139 #define TRM_SLOT_ID_POSITION 0
141 //TRM event words mask/position
142 #define TRM_EVENT_WORDS_MASK 0x0001fff0
143 #define TRM_EVENT_WORDS_POSITION 4
145 //TRM ACQ-bits mask/position
146 #define TRM_ACQ_BITS_MASK 0x00060000
147 #define TRM_ACQ_BITS_POSITION 17
149 //TRM L-bit mask/position
150 #define TRM_L_BIT_MASK 0x00080000
151 #define TRM_L_BIT_POSITION 19
153 //TRM chain-0 header word required bit pattern
154 #define TRM_CHAIN_0_HEADER 0x00000000
156 //TRM chain-1 header word required bit pattern
157 #define TRM_CHAIN_1_HEADER 0x20000000
159 //TRM bunch ID mask/position
160 #define TRM_BUNCH_ID_MASK 0x0000fff0
161 #define TRM_BUNCH_ID_POSITION 4
163 //TRM PB24 temp mask/position
164 #define TRM_PB24_TEMP_MASK 0x00ff0000
165 #define TRM_PB24_TEMP_POSITION 16
167 //TRM PB24 ID mask/position
168 #define TRM_PB24_ID_MASK 0x07000000
169 #define TRM_PB24_ID_POSITION 24
171 //TRM TS-bit mask/position
172 #define TRM_TS_BIT_MASK 0x08000000
173 #define TRM_TS_BIT_POSITION 27
175 //TRM chain-0 trailer word required bit pattern
176 #define TRM_CHAIN_0_TRAILER 0x10000000
178 //TRM chain-1 trailer word required bit pattern
179 #define TRM_CHAIN_1_TRAILER 0x30000000
181 //TRM status mask/position
182 #define TRM_STATUS_MASK 0x0000000f
183 #define TRM_STATUS_POSITION 0
188 //TRM TDC digit word required bit pattern
189 #define TRM_TDC_DIGIT 0x8000000
191 //TRM digit time mask/position
192 #define TRM_DIGIT_TIME_MASK 0x00001fff
193 #define TRM_DIGIT_TIME_POSITION 0
195 //TRM long digit time mask/position
196 #define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
197 #define TRM_LONG_DIGIT_TIME_POSITION 0
199 //TRM TOT width mask/position
200 #define TRM_TOT_WIDTH_MASK 0x001fe000
201 #define TRM_TOT_WIDTH_POSITION 13
203 //TRM chan mask/position
204 #define TRM_CHAN_MASK 0x00e00000
205 #define TRM_CHAN_POSITION 21
207 //TRM TDC ID mask/position
208 #define TRM_TDC_ID_MASK 0x0f000000
209 #define TRM_TDC_ID_POSITION 24
211 //TRM E-bit mask/position
212 #define TRM_E_BIT_MASK 0x10000000
213 #define TRM_E_BIT_POSITION 28
215 //TRM PS-bits mask/position
216 #define TRM_PS_BITS_MASK 0x60000000
217 #define TRM_PS_BITS_POSITION 29
219 #define TRM_FIRST_SLOT_ID 3
221 //define hptdc time bin width
222 #ifndef TIME_BIN_WIDTH
223 #define TIME_BIN_WIDTH 24.4e-3 //ns
226 //define hptdc tot bin width
227 #ifndef TOT_BIN_WIDTH
228 #define TOT_BIN_WIDTH 48.4e-3 //ns
233 //TRM TDC error word required bit pattern
234 #define TRM_TDC_ERROR 0x6000000
236 //TRM TDC diagnostic error word required bit pattern
237 #define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
239 //TRM TDC error flags mask/position
240 #define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
241 #define TRM_TDC_ERROR_FLAGS_POSITION 0
243 //TRM TDC error TDC ID mask/position
244 #define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
245 #define TRM_TDC_ERROR_TDC_ID_POSITION 24
247 //TRM TDC fault chip flag ID mask/position
248 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
249 #define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
251 //TRM TDC error C-bit mask/position
252 #define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
253 #define TRM_TDC_ERROR_C_BIT_POSITION 15
255 //TRM TDC JTAG error code mask/position
256 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
257 #define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
259 //TRM TDC disgnostic error TDC ID mask/position
260 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
261 #define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
263 //TRM global trailer word required bit pattern
264 //#define TRM_GLOBAL_TRAILER 0x50000000
265 #define TRM_GLOBAL_TRAILER 0x5000000f
267 //TRM event CRC mask/position
268 #define TRM_EVENT_CRC_MASK 0x0000fff0
269 #define TRM_EVENT_CRC_POSITION 4
271 //TRM event counter mask/position
272 #define TRM_EVENT_COUNTER_MASK 0x0fff0000
273 #define TRM_EVENT_COUNTER_POSITION 16
276 /******************************************
278 ******************************************/
280 //LTM global header word required bit pattern
281 #define LTM_GLOBAL_HEADER 0x40000002
283 //LTM event words mask/position
284 #define LTM_EVENT_WORDS_MASK 0x0001fff0
285 #define LTM_EVENT_WORDS_POSITION 4
287 //LTM C-bit mask/position
288 #define LTM_C_BIT_MASK 0x00020000
289 #define LTM_C_BIT_POSITION 17
291 //LTM fault mask/position
292 #define LTM_FAULT_MASK 0x00fc0000
293 #define LTM_FAULT_POSITION 18
297 //PDL value 1 mask/position
298 #define LTM_PDL_VALUE_1_MASK 0x000000ff
299 #define LTM_PDL_VALUE_1_POSITION 0
301 //PDL value 2 mask/position
302 #define LTM_PDL_VALUE_2_MASK 0x0000ff00
303 #define LTM_PDL_VALUE_2_POSITION 8
305 //PDL value 3 mask/position
306 #define LTM_PDL_VALUE_3_MASK 0x00ff0000
307 #define LTM_PDL_VALUE_3_POSITION 16
309 //PDL value 4 mask/position
310 #define LTM_PDL_VALUE_4_MASK 0xff000000
311 #define LTM_PDL_VALUE_4_POSITION 24
315 //ADC value 1 mask/position
316 #define LTM_ADC_VALUE_1_MASK 0x000003ff
317 #define LTM_ADC_VALUE_1_POSITION 0
319 //ADC value 2 mask/position
320 #define LTM_ADC_VALUE_2_MASK 0x000ffc00
321 #define LTM_ADC_VALUE_2_POSITION 10
323 //ADC value 3 mask/position
324 #define LTM_ADC_VALUE_3_MASK 0x3ff00000
325 #define LTM_ADC_VALUE_3_POSITION 20
327 //LTM global trailer word required bit pattern
328 #define LTM_GLOBAL_TRAILER 0x50000002
330 //LTM event CRC mask/position
331 #define LTM_EVENT_CRC_MASK 0x0000fff0
332 #define LTM_EVENT_CRC_POSITION 4
334 //LTM event number mask/position
335 #define LTM_EVENT_NUMBER_MASK 0x0fff0000
336 #define LTM_EVENT_NUMBER_POSITION 16
338 /******************************************
339 * END OF OLD DEFINITIONS
340 ******************************************/
344 class AliTOFGeometry;
347 class AliTOFRawStream: public TObject {
350 AliTOFRawStream(); // default ctr
351 AliTOFRawStream(AliRawReader* rawReader); // ctr
352 virtual ~AliTOFRawStream(); // default dtr
354 virtual Bool_t Next();
356 virtual void LoadRawData(Int_t indexDDL);
358 Int_t GetDDL() const {return fDDL;};
359 Int_t GetTRM() const {return fTRM;};
360 Int_t GetTDC() const {return fTDC;};
361 Int_t GetTRMchain() const {return fTRMchain;};
362 Int_t GetTDCchannel() const {return fTDCchannel;};
364 Int_t GetSector() const {return fSector;};
365 Int_t GetPlate() const {return fPlate;};
366 Int_t GetStrip() const {return fStrip;};
367 Int_t GetPadZ() const {return fPadZ;};
368 Int_t GetPadX() const {return fPadX;};
369 Int_t GetIndex(Int_t *detId); // Get channel index for Online Calibration
371 Int_t GetTofBin() const {return fTime;};
372 Int_t GetToTbin() const {return fToT;};
373 Float_t GetLeadingEdge() const {return fLeadingEdge;};
374 Float_t GetTrailingEdge() const {return fTrailingEdge;};
376 Int_t GetPSbit() const {return fPSbit;};
377 Int_t GetACQ() const {return fACQ;};
379 Int_t GetErrorFlag() const {return fErrorFlag;};
381 void SetDDL(Int_t nDDL) {fDDL = nDDL;};
382 void SetTRM(Int_t nTRM) {fTRM = nTRM;};
383 void SetTDC(Int_t nTDC) {fTDC = nTDC;};
384 void SetTRMchain(Int_t nChain) {fTRMchain = nChain;};
385 void SetTDCchannel(Int_t nChannel) {fTDCchannel = nChannel;};
387 TClonesArray *GetRawData() const {return fTOFrawData;};
395 void EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
396 Int_t iTDC, Int_t iCH, Int_t *volume) const;
397 void EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const;
398 Int_t Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const ;
399 Int_t Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const ;
400 Int_t Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC, Int_t iCH) const ;
401 Int_t GetDDLnumberPerSector(Int_t nDDL) const;
402 Int_t GetSectorNumber(Int_t nDDL) const;
404 Bool_t DecodeDDL(Int_t DDLMin, Int_t DDLMax, Int_t verbose);
406 AliTOFHitDataBuffer *GetDataBuffer(Int_t DDL) {return fDataBuffer[DDL];};
407 AliTOFHitDataBuffer *GetPackedDataBuffer(Int_t DDL) {return fPackedDataBuffer[DDL];};
409 void ResetDataBuffer(Int_t DDL) {fDataBuffer[DDL]->Reset();};
410 void ResetPackedDataBuffer(Int_t DDL) {fPackedDataBuffer[DDL]->Reset();};
414 Bool_t LoadRawDataBuffers(Int_t indexDDL, Int_t verbose = 0);
418 Int_t GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const;
420 AliTOFRawStream(const AliTOFRawStream& stream); // copy ctr
421 AliTOFRawStream& operator = (const AliTOFRawStream& stream); // ass. op.
423 AliRawReader* fRawReader; // object for reading the raw data
425 TClonesArray *fTOFrawData; // pointer to AliTOFrawData TClonesArray
427 AliTOFDecoder *fDecoder; //pointer to TOF decoder
429 Int_t fDDL; // DDL file number [0;71]
430 Int_t fTRM; // TRM number [1;12]
431 Int_t fTRMchain; // TRM chain number [0;1]
432 Int_t fTDC; // TDC number [0;14]
433 Int_t fTDCchannel; // TDC channel number [0;7]
434 Int_t fTime; // time-of-flight measurement [0;8191]
435 Int_t fToT; // time-over-threshould measurement [0;255]
436 Float_t fLeadingEdge; // leading edge measurement
437 Float_t fTrailingEdge; // trailing edge measurement
438 Int_t fErrorFlag; // error flag
440 Int_t fSector; // sector number [0;17]
441 Int_t fPlate; // plate number [0;4]
442 Int_t fStrip; // strip number [0;14/18]
443 Int_t fPadX; // pad number along the strip [0;47]
444 Int_t fPadZ; // pad-row number [0;1]
446 AliTOFGeometry *fTOFGeometry; // pointer to the TOF geometry
448 Int_t fPackedDigits; // counter for packed digits
450 Int_t fWordType; // word type
451 Int_t fSlotID; // crate slot ID number
452 Int_t fACQ; // flag to identif the aquisition kind
453 Int_t fPSbit; // flag for packing
454 Int_t fTDCerrorFlag; // TDC error flag
455 Bool_t fInsideDRM; // inside/outside DRM
456 Bool_t fInsideTRM; // inside/outside TRM
457 Bool_t fInsideLTM; // inside/outside LTM
458 Bool_t fInsideTRMchain0; // inside/outside chain 0
459 Bool_t fInsideTRMchain1; // inside/outside chain 1
461 AliTOFHitDataBuffer *fDataBuffer[72];
462 AliTOFHitDataBuffer *fPackedDataBuffer[72];
464 ClassDef(AliTOFRawStream, 1) // class for reading TOF raw digits