]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.h
- Compute parameter covariances including absorber dispersion effects
[u/mrichter/AliRoot.git] / TOF / AliTOFRawStream.h
CommitLineData
571dda3d 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 */
5
6/* $Id$ */
7
0e46b9ae 8///////////////////////////////////////////////////////////////
9// //
10// This class provides the key-reading for TOF raw data. //
11// //
12///////////////////////////////////////////////////////////////
571dda3d 13
0e46b9ae 14#include "TObject.h"
7813bb1a 15#include "AliTOFHitData.h"
16#include "AliTOFHitDataBuffer.h"
17#include "AliTOFDecoder.h"
571dda3d 18
15ec34b9 19
7813bb1a 20/**********************************
21 * OLD DEFINITIONS
22 **********************************/
23
24/******************************************
25GENERAL DATA FORMAT
26******************************************/
27
28//filler
29#ifndef FILLER
30#define FILLER 0x70000000
31#endif
32
33//word type mask/position
34#ifndef WORD_TYPE_MASK
35#define WORD_TYPE_MASK 0xf0000000
36#endif
37#define WORD_TYPE_POSITION 28
38
39//global header word required bit pattern
40#ifndef GLOBAL_HEADER
41#define GLOBAL_HEADER 0x40000000
42#endif
43
44//global trailer word required bit pattern
45#ifndef GLOBAL_TRAILER
46#define GLOBAL_TRAILER 0x50000000
47#endif
48
49//error word required bit pattern
50#ifndef ERROR
51#define ERROR 0x30000000
52#endif
53
54//header slot ID mask/position
55#define HEADER_SLOT_ID_MASK 0x0000000f
56#define HEADER_SLOT_ID_POSITION 0
57
58//word types
59#define GLOBAL_HEADER_TYPE 4
60#define GLOBAL_TRAILER_TYPE 5
61#define ERROR_TYPE 6
62#define FILLER_TYPE 7
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
67
68//slot types
69#define DRM_ID_NUMBER 1
70#define LTM_ID_NUMBER 2
71
72
73/******************************************
74DRM DATA FORMAT
75******************************************/
76
77//DRM global header word required bit pattern
78#define DRM_GLOBAL_HEADER 0x40000001
79
80//DRM event words mask/position
81#define DRM_EVENT_WORDS_MASK 0x001ffff0
82#define DRM_EVENT_WORDS_POSITION 4
83
84//DRM DRM ID mask/position
85#define DRM_DRM_ID_MASK 0x0fe00000
86#define DRM_DRM_ID_POSITION 21
87
88//DRM status header 1 word required bit pattern
89#define DRM_STATUS_HEADER_1 0x40000001
90
91//DRM slot ID mask/position
92#define DRM_SLOT_ID_MASK 0x00007ff0
93#define DRM_SLOT_ID_POSITION 4
94
95//DRM C-bit mask/position
96#define DRM_C_BIT_MASK 0x00008000
97#define DRM_C_BIT_POSITION 15
98
73620dbf 99//DRM Vers-ID mask/position
100#define DRM_VERS_ID_MASK 0x001f0000
101#define DRM_VERS_ID_POSITION 16
102
103//DRM DRM Header size mask/position
104#define DRM_HEADER_SIZE_MASK 0x01e00000
105#define DRM_HEADER_SIZE_POSITION 21
106
7813bb1a 107//DRM status header 2 word required bit pattern
108#define DRM_STATUS_HEADER_2 0x40000001
109
110//DRM enable ID mask/position
111#define DRM_ENABLE_ID_MASK 0x00007ff0
112#define DRM_ENABLE_ID_POSITION 4
113
73620dbf 114//DRM zero in word2 mask/position
115#define DRM_ZERO_WORD2_MASK 0x00008000
116#define DRM_ZERO_WORD2_POSITION 15
117
7813bb1a 118//DRM fault ID mask/position
119#define DRM_FAULT_ID_MASK 0x07ff0000
120#define DRM_FAULT_ID_POSITION 16
121
73620dbf 122//DRM RTO bit mask/position
123#define DRM_RTO_BIT_MASK 0x08000000
124#define DRM_RTO_BIT_POSITION 27
125
7813bb1a 126//DRM status header 3 word required bit pattern
127#define DRM_STATUS_HEADER_3 0x40000001
128
73620dbf 129//DRM L0 BCID mask/position
130#define DRM_L0_BCID_MASK 0x0000fff0
131#define DRM_L0_BCID_POSITION 4
132
133//DRM Run Time Info mask/position
134#define DRM_RUNTIME_INFO_MASK 0x0fff0000
135#define DRM_RUNTIME_INFO_POSITION 16
136
137//DRM status header 4 word required bit pattern
138#define DRM_STATUS_HEADER_4 0x40000001
139
140//DRM Temperature mask/position
141#define DRM_TEMPERATURE_MASK 0x00003ff0
142#define DRM_TEMPERATURE_POSITION 4
143
144//DRM 1st zero in word4 mask/position
145#define DRM_ZERO_1_WORD4_MASK 0x00004000
146#define DRM_ZERO_1_WORD4_POSITION 14
147
148//DRM ACK mask/position
149#define DRM_ACK_MASK 0x00008000
150#define DRM_ACK_POSITION 15
151
152//DRM Sens AD mask/position
153#define DRM_SENS_AD_MASK 0x00070000
154#define DRM_SENS_AD_POSITION 16
155
156//DRM 2nd zero in word4 mask/position
157#define DRM_ZERO_2_WORD4_MASK 0x00080000
158#define DRM_ZERO_2_WORD4_POSITION 19
7813bb1a 159
160//DRM event CRC mask/position
7813bb1a 161#define DRM_EVENT_CRC_MASK 0x000ffff0
162#define DRM_EVENT_CRC_POSITION 4
163
164//DRM global trailer word required bit pattern
165#define DRM_GLOBAL_TRAILER 0x50000001
166
167//DRM local event counter mask/position
168#define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
169#define DRM_LOCAL_EVENT_COUNTER_POSITION 4
170
171
172/******************************************
173TRM DATA FORMAT
174******************************************/
175
176//TRM global header word required bit pattern
177#define TRM_GLOBAL_HEADER 0x40000000
178
179//TRM slot ID mask/position
180#define TRM_SLOT_ID_MASK 0x0000000f
181#define TRM_SLOT_ID_POSITION 0
182
183//TRM event words mask/position
184#define TRM_EVENT_WORDS_MASK 0x0001fff0
185#define TRM_EVENT_WORDS_POSITION 4
186
187//TRM ACQ-bits mask/position
188#define TRM_ACQ_BITS_MASK 0x00060000
189#define TRM_ACQ_BITS_POSITION 17
190
191//TRM L-bit mask/position
192#define TRM_L_BIT_MASK 0x00080000
193#define TRM_L_BIT_POSITION 19
194
195//TRM chain-0 header word required bit pattern
196#define TRM_CHAIN_0_HEADER 0x00000000
197
198//TRM chain-1 header word required bit pattern
199#define TRM_CHAIN_1_HEADER 0x20000000
200
201//TRM bunch ID mask/position
202#define TRM_BUNCH_ID_MASK 0x0000fff0
203#define TRM_BUNCH_ID_POSITION 4
204
205//TRM PB24 temp mask/position
206#define TRM_PB24_TEMP_MASK 0x00ff0000
207#define TRM_PB24_TEMP_POSITION 16
208
209//TRM PB24 ID mask/position
210#define TRM_PB24_ID_MASK 0x07000000
211#define TRM_PB24_ID_POSITION 24
212
213//TRM TS-bit mask/position
214#define TRM_TS_BIT_MASK 0x08000000
215#define TRM_TS_BIT_POSITION 27
216
217//TRM chain-0 trailer word required bit pattern
218#define TRM_CHAIN_0_TRAILER 0x10000000
219
220//TRM chain-1 trailer word required bit pattern
221#define TRM_CHAIN_1_TRAILER 0x30000000
222
223//TRM status mask/position
224#define TRM_STATUS_MASK 0x0000000f
225#define TRM_STATUS_POSITION 0
226
227
228//TDC digit
229
230//TRM TDC digit word required bit pattern
231#define TRM_TDC_DIGIT 0x8000000
232
233//TRM digit time mask/position
234#define TRM_DIGIT_TIME_MASK 0x00001fff
235#define TRM_DIGIT_TIME_POSITION 0
236
237//TRM long digit time mask/position
238#define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
239#define TRM_LONG_DIGIT_TIME_POSITION 0
240
241//TRM TOT width mask/position
242#define TRM_TOT_WIDTH_MASK 0x001fe000
243#define TRM_TOT_WIDTH_POSITION 13
244
245//TRM chan mask/position
246#define TRM_CHAN_MASK 0x00e00000
247#define TRM_CHAN_POSITION 21
248
249//TRM TDC ID mask/position
250#define TRM_TDC_ID_MASK 0x0f000000
251#define TRM_TDC_ID_POSITION 24
252
253//TRM E-bit mask/position
254#define TRM_E_BIT_MASK 0x10000000
255#define TRM_E_BIT_POSITION 28
256
257//TRM PS-bits mask/position
258#define TRM_PS_BITS_MASK 0x60000000
259#define TRM_PS_BITS_POSITION 29
260
261#define TRM_FIRST_SLOT_ID 3
262
263//define hptdc time bin width
264#ifndef TIME_BIN_WIDTH
265#define TIME_BIN_WIDTH 24.4e-3 //ns
266#endif
267
268//define hptdc tot bin width
269#ifndef TOT_BIN_WIDTH
270#define TOT_BIN_WIDTH 48.4e-3 //ns
271#endif
272
273//TRM errors
274
275//TRM TDC error word required bit pattern
276#define TRM_TDC_ERROR 0x6000000
277
278//TRM TDC diagnostic error word required bit pattern
279#define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
280
281//TRM TDC error flags mask/position
282#define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
283#define TRM_TDC_ERROR_FLAGS_POSITION 0
284
285//TRM TDC error TDC ID mask/position
286#define TRM_TDC_ERROR_TDC_ID_MASK 0x0f00000
287#define TRM_TDC_ERROR_TDC_ID_POSITION 24
288
289//TRM TDC fault chip flag ID mask/position
290#define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_MASK 0x00007fff
291#define TRM_TDC_ERROR_FAULT_CHIP_FLAG_ID_POSITION 0
292
293//TRM TDC error C-bit mask/position
294#define TRM_TDC_ERROR_C_BIT_MASK 0x00008000
295#define TRM_TDC_ERROR_C_BIT_POSITION 15
296
297//TRM TDC JTAG error code mask/position
298#define TRM_TDC_ERROR_JTAG_ERROR_CODE_MASK 0x000007ff
299#define TRM_TDC_ERROR_JTAG_ERROR_CODE_POSITION 0
300
301//TRM TDC disgnostic error TDC ID mask/position
302#define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_MASK 0x00007800
303#define TRM_TDC_DIAGNOSTIC_ERROR_TDC_ID_POSITION 11
304
305//TRM global trailer word required bit pattern
306//#define TRM_GLOBAL_TRAILER 0x50000000
307#define TRM_GLOBAL_TRAILER 0x5000000f
308
309//TRM event CRC mask/position
310#define TRM_EVENT_CRC_MASK 0x0000fff0
311#define TRM_EVENT_CRC_POSITION 4
312
313//TRM event counter mask/position
314#define TRM_EVENT_COUNTER_MASK 0x0fff0000
315#define TRM_EVENT_COUNTER_POSITION 16
316
317
318/******************************************
319LTM DATA FORMAT
320******************************************/
321
322//LTM global header word required bit pattern
323#define LTM_GLOBAL_HEADER 0x40000002
324
325//LTM event words mask/position
326#define LTM_EVENT_WORDS_MASK 0x0001fff0
327#define LTM_EVENT_WORDS_POSITION 4
328
329//LTM C-bit mask/position
330#define LTM_C_BIT_MASK 0x00020000
331#define LTM_C_BIT_POSITION 17
332
333//LTM fault mask/position
334#define LTM_FAULT_MASK 0x00fc0000
335#define LTM_FAULT_POSITION 18
336
337//PDL data
338
339//PDL value 1 mask/position
340#define LTM_PDL_VALUE_1_MASK 0x000000ff
341#define LTM_PDL_VALUE_1_POSITION 0
342
343//PDL value 2 mask/position
344#define LTM_PDL_VALUE_2_MASK 0x0000ff00
345#define LTM_PDL_VALUE_2_POSITION 8
346
347//PDL value 3 mask/position
348#define LTM_PDL_VALUE_3_MASK 0x00ff0000
349#define LTM_PDL_VALUE_3_POSITION 16
350
351//PDL value 4 mask/position
352#define LTM_PDL_VALUE_4_MASK 0xff000000
353#define LTM_PDL_VALUE_4_POSITION 24
354
355//ADC data
356
357//ADC value 1 mask/position
358#define LTM_ADC_VALUE_1_MASK 0x000003ff
359#define LTM_ADC_VALUE_1_POSITION 0
360
361//ADC value 2 mask/position
362#define LTM_ADC_VALUE_2_MASK 0x000ffc00
363#define LTM_ADC_VALUE_2_POSITION 10
364
365//ADC value 3 mask/position
366#define LTM_ADC_VALUE_3_MASK 0x3ff00000
367#define LTM_ADC_VALUE_3_POSITION 20
368
369//LTM global trailer word required bit pattern
370#define LTM_GLOBAL_TRAILER 0x50000002
371
372//LTM event CRC mask/position
373#define LTM_EVENT_CRC_MASK 0x0000fff0
374#define LTM_EVENT_CRC_POSITION 4
375
376//LTM event number mask/position
377#define LTM_EVENT_NUMBER_MASK 0x0fff0000
378#define LTM_EVENT_NUMBER_POSITION 16
379
380/******************************************
381 * END OF OLD DEFINITIONS
382 ******************************************/
383
384class TClonesArray;
571dda3d 385class AliRawReader;
15ec34b9 386class AliTOFrawData;
571dda3d 387
571dda3d 388class AliTOFRawStream: public TObject {
d0eb8f39 389 public:
571dda3d 390
d0eb8f39 391 AliTOFRawStream(); // default ctr
392 AliTOFRawStream(AliRawReader* rawReader); // ctr
393 virtual ~AliTOFRawStream(); // default dtr
571dda3d 394
15ec34b9 395 virtual Bool_t Next();
571dda3d 396
15ec34b9 397 virtual void LoadRawData(Int_t indexDDL);
398
d0eb8f39 399 Int_t GetDDL() const {return fDDL;};
400 Int_t GetTRM() const {return fTRM;};
401 Int_t GetTDC() const {return fTDC;};
402 Int_t GetTRMchain() const {return fTRMchain;};
403 Int_t GetTDCchannel() const {return fTDCchannel;};
571dda3d 404
d0eb8f39 405 Int_t GetSector() const {return fSector;};
406 Int_t GetPlate() const {return fPlate;};
407 Int_t GetStrip() const {return fStrip;};
408 Int_t GetPadZ() const {return fPadZ;};
409 Int_t GetPadX() const {return fPadX;};
571dda3d 410
7813bb1a 411 Int_t GetTofBin() const {return fTime;};
412 Int_t GetToTbin() const {return fToT;};
15ec34b9 413 Float_t GetLeadingEdge() const {return fLeadingEdge;};
414 Float_t GetTrailingEdge() const {return fTrailingEdge;};
415
416 Int_t GetPSbit() const {return fPSbit;};
417 Int_t GetACQ() const {return fACQ;};
571dda3d 418
15ec34b9 419 Int_t GetErrorFlag() const {return fErrorFlag;};
420
d0eb8f39 421 void SetDDL(Int_t nDDL) {fDDL = nDDL;};
422 void SetTRM(Int_t nTRM) {fTRM = nTRM;};
423 void SetTDC(Int_t nTDC) {fTDC = nTDC;};
424 void SetTRMchain(Int_t nChain) {fTRMchain = nChain;};
425 void SetTDCchannel(Int_t nChannel) {fTDCchannel = nChannel;};
426
15ec34b9 427 TClonesArray *GetRawData() const {return fTOFrawData;};
428
d0eb8f39 429 void SetSector();
430 void SetPlate();
431 void SetStrip();
432 void SetPadZ();
433 void SetPadX();
7813bb1a 434
d0eb8f39 435 void EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
436 Int_t iTDC, Int_t iCH, Int_t *volume) const;
7813bb1a 437 void EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const;
d0eb8f39 438 Int_t Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const ;
439 Int_t Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const ;
440 Int_t Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC, Int_t iCH) const ;
441 Int_t GetDDLnumberPerSector(Int_t nDDL) const;
442 Int_t GetSectorNumber(Int_t nDDL) const;
443
7813bb1a 444 Bool_t DecodeDDL(Int_t DDLMin, Int_t DDLMax, Int_t verbose);
2fd622fa 445 Bool_t Decode(Int_t verbose);
446 AliTOFDecoder *GetDecoder() {return fDecoder;};
447 void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fDecoder->SetV2718Patch(V2718Patch);};
448
d0eb8f39 449
7813bb1a 450 AliTOFHitDataBuffer *GetDataBuffer(Int_t DDL) {return fDataBuffer[DDL];};
451 AliTOFHitDataBuffer *GetPackedDataBuffer(Int_t DDL) {return fPackedDataBuffer[DDL];};
452
453 void ResetDataBuffer(Int_t DDL) {fDataBuffer[DDL]->Reset();};
454 void ResetPackedDataBuffer(Int_t DDL) {fPackedDataBuffer[DDL]->Reset();};
455
456 void ResetBuffers();
d0eb8f39 457
7813bb1a 458 Bool_t LoadRawDataBuffers(Int_t indexDDL, Int_t verbose = 0);
459
019f6101 460 enum ETOFRawStreamError {
461 kPadXError = 0,
462 kPadAlongStripError = 1,
463 kPlateError = 2,
464 kStripError = 3,
465 kSectorError = 4,
466 kDDLMinError = 5,
467 kDDLMaxError = 6,
468 kDDLdataReading = 7,
469 kDDLDecoder = 8
470 };
471
7813bb1a 472 private:
473
474 Int_t GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const;
475
d0eb8f39 476 AliTOFRawStream(const AliTOFRawStream& stream); // copy ctr
477 AliTOFRawStream& operator = (const AliTOFRawStream& stream); // ass. op.
7813bb1a 478
d0eb8f39 479 AliRawReader* fRawReader; // object for reading the raw data
480
15ec34b9 481 TClonesArray *fTOFrawData; // pointer to AliTOFrawData TClonesArray
482
7813bb1a 483 AliTOFDecoder *fDecoder; //pointer to TOF decoder
484
15ec34b9 485 Int_t fDDL; // DDL file number [0;71]
486 Int_t fTRM; // TRM number [1;12]
487 Int_t fTRMchain; // TRM chain number [0;1]
488 Int_t fTDC; // TDC number [0;14]
489 Int_t fTDCchannel; // TDC channel number [0;7]
7813bb1a 490 Int_t fTime; // time-of-flight measurement [0;8191]
491 Int_t fToT; // time-over-threshould measurement [0;255]
bf33f8f0 492 Int_t fLeadingEdge; // leading edge measurement
493 Int_t fTrailingEdge; // trailing edge measurement
15ec34b9 494 Int_t fErrorFlag; // error flag
d0eb8f39 495
496 Int_t fSector; // sector number [0;17]
497 Int_t fPlate; // plate number [0;4]
498 Int_t fStrip; // strip number [0;14/18]
499 Int_t fPadX; // pad number along the strip [0;47]
500 Int_t fPadZ; // pad-row number [0;1]
501
15ec34b9 502 Int_t fPackedDigits; // counter for packed digits
503
d0eb8f39 504 Int_t fWordType; // word type
505 Int_t fSlotID; // crate slot ID number
7813bb1a 506 Int_t fACQ; // flag to identif the aquisition kind
d0eb8f39 507 Int_t fPSbit; // flag for packing
d0eb8f39 508 Int_t fTDCerrorFlag; // TDC error flag
509 Bool_t fInsideDRM; // inside/outside DRM
510 Bool_t fInsideTRM; // inside/outside TRM
511 Bool_t fInsideLTM; // inside/outside LTM
512 Bool_t fInsideTRMchain0; // inside/outside chain 0
513 Bool_t fInsideTRMchain1; // inside/outside chain 1
571dda3d 514
fa0811c3 515 AliTOFHitDataBuffer *fDataBuffer[72]; // pointer to AliTOFHitDataBuffer
516 AliTOFHitDataBuffer *fPackedDataBuffer[72]; // pointer to AliTOFHitDataBuffer
7813bb1a 517
96f01799 518 ClassDef(AliTOFRawStream, 3) // class for reading TOF raw digits
571dda3d 519};
520
521#endif