]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawStream.h
Bug fix in treatment of the vertex finder covariance matrix (Andrea)
[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
99//DRM status header 2 word required bit pattern
100#define DRM_STATUS_HEADER_2 0x40000001
101
102//DRM enable ID mask/position
103#define DRM_ENABLE_ID_MASK 0x00007ff0
104#define DRM_ENABLE_ID_POSITION 4
105
106//DRM fault ID mask/position
107#define DRM_FAULT_ID_MASK 0x07ff0000
108#define DRM_FAULT_ID_POSITION 16
109
110//DRM status header 3 word required bit pattern
111#define DRM_STATUS_HEADER_3 0x40000001
112
113//DRM TTC event counter mask/position
114#define DRM_TTC_EVENT_COUNTER_MASK 0x0ffffff0
115#define DRM_TTC_EVENT_COUNTER_POSITION 4
116
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
121
122//DRM global trailer word required bit pattern
123#define DRM_GLOBAL_TRAILER 0x50000001
124
125//DRM local event counter mask/position
126#define DRM_LOCAL_EVENT_COUNTER_MASK 0x0000fff0
127#define DRM_LOCAL_EVENT_COUNTER_POSITION 4
128
129
130/******************************************
131TRM DATA FORMAT
132******************************************/
133
134//TRM global header word required bit pattern
135#define TRM_GLOBAL_HEADER 0x40000000
136
137//TRM slot ID mask/position
138#define TRM_SLOT_ID_MASK 0x0000000f
139#define TRM_SLOT_ID_POSITION 0
140
141//TRM event words mask/position
142#define TRM_EVENT_WORDS_MASK 0x0001fff0
143#define TRM_EVENT_WORDS_POSITION 4
144
145//TRM ACQ-bits mask/position
146#define TRM_ACQ_BITS_MASK 0x00060000
147#define TRM_ACQ_BITS_POSITION 17
148
149//TRM L-bit mask/position
150#define TRM_L_BIT_MASK 0x00080000
151#define TRM_L_BIT_POSITION 19
152
153//TRM chain-0 header word required bit pattern
154#define TRM_CHAIN_0_HEADER 0x00000000
155
156//TRM chain-1 header word required bit pattern
157#define TRM_CHAIN_1_HEADER 0x20000000
158
159//TRM bunch ID mask/position
160#define TRM_BUNCH_ID_MASK 0x0000fff0
161#define TRM_BUNCH_ID_POSITION 4
162
163//TRM PB24 temp mask/position
164#define TRM_PB24_TEMP_MASK 0x00ff0000
165#define TRM_PB24_TEMP_POSITION 16
166
167//TRM PB24 ID mask/position
168#define TRM_PB24_ID_MASK 0x07000000
169#define TRM_PB24_ID_POSITION 24
170
171//TRM TS-bit mask/position
172#define TRM_TS_BIT_MASK 0x08000000
173#define TRM_TS_BIT_POSITION 27
174
175//TRM chain-0 trailer word required bit pattern
176#define TRM_CHAIN_0_TRAILER 0x10000000
177
178//TRM chain-1 trailer word required bit pattern
179#define TRM_CHAIN_1_TRAILER 0x30000000
180
181//TRM status mask/position
182#define TRM_STATUS_MASK 0x0000000f
183#define TRM_STATUS_POSITION 0
184
185
186//TDC digit
187
188//TRM TDC digit word required bit pattern
189#define TRM_TDC_DIGIT 0x8000000
190
191//TRM digit time mask/position
192#define TRM_DIGIT_TIME_MASK 0x00001fff
193#define TRM_DIGIT_TIME_POSITION 0
194
195//TRM long digit time mask/position
196#define TRM_LONG_DIGIT_TIME_MASK 0x001fffff
197#define TRM_LONG_DIGIT_TIME_POSITION 0
198
199//TRM TOT width mask/position
200#define TRM_TOT_WIDTH_MASK 0x001fe000
201#define TRM_TOT_WIDTH_POSITION 13
202
203//TRM chan mask/position
204#define TRM_CHAN_MASK 0x00e00000
205#define TRM_CHAN_POSITION 21
206
207//TRM TDC ID mask/position
208#define TRM_TDC_ID_MASK 0x0f000000
209#define TRM_TDC_ID_POSITION 24
210
211//TRM E-bit mask/position
212#define TRM_E_BIT_MASK 0x10000000
213#define TRM_E_BIT_POSITION 28
214
215//TRM PS-bits mask/position
216#define TRM_PS_BITS_MASK 0x60000000
217#define TRM_PS_BITS_POSITION 29
218
219#define TRM_FIRST_SLOT_ID 3
220
221//define hptdc time bin width
222#ifndef TIME_BIN_WIDTH
223#define TIME_BIN_WIDTH 24.4e-3 //ns
224#endif
225
226//define hptdc tot bin width
227#ifndef TOT_BIN_WIDTH
228#define TOT_BIN_WIDTH 48.4e-3 //ns
229#endif
230
231//TRM errors
232
233//TRM TDC error word required bit pattern
234#define TRM_TDC_ERROR 0x6000000
235
236//TRM TDC diagnostic error word required bit pattern
237#define TRM_TDC_DIAGNOSTIC_ERROR 0x6f00000
238
239//TRM TDC error flags mask/position
240#define TRM_TDC_ERROR_FLAGS_MASK 0x00007fff
241#define TRM_TDC_ERROR_FLAGS_POSITION 0
242
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
246
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
250
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
254
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
258
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
262
263//TRM global trailer word required bit pattern
264//#define TRM_GLOBAL_TRAILER 0x50000000
265#define TRM_GLOBAL_TRAILER 0x5000000f
266
267//TRM event CRC mask/position
268#define TRM_EVENT_CRC_MASK 0x0000fff0
269#define TRM_EVENT_CRC_POSITION 4
270
271//TRM event counter mask/position
272#define TRM_EVENT_COUNTER_MASK 0x0fff0000
273#define TRM_EVENT_COUNTER_POSITION 16
274
275
276/******************************************
277LTM DATA FORMAT
278******************************************/
279
280//LTM global header word required bit pattern
281#define LTM_GLOBAL_HEADER 0x40000002
282
283//LTM event words mask/position
284#define LTM_EVENT_WORDS_MASK 0x0001fff0
285#define LTM_EVENT_WORDS_POSITION 4
286
287//LTM C-bit mask/position
288#define LTM_C_BIT_MASK 0x00020000
289#define LTM_C_BIT_POSITION 17
290
291//LTM fault mask/position
292#define LTM_FAULT_MASK 0x00fc0000
293#define LTM_FAULT_POSITION 18
294
295//PDL data
296
297//PDL value 1 mask/position
298#define LTM_PDL_VALUE_1_MASK 0x000000ff
299#define LTM_PDL_VALUE_1_POSITION 0
300
301//PDL value 2 mask/position
302#define LTM_PDL_VALUE_2_MASK 0x0000ff00
303#define LTM_PDL_VALUE_2_POSITION 8
304
305//PDL value 3 mask/position
306#define LTM_PDL_VALUE_3_MASK 0x00ff0000
307#define LTM_PDL_VALUE_3_POSITION 16
308
309//PDL value 4 mask/position
310#define LTM_PDL_VALUE_4_MASK 0xff000000
311#define LTM_PDL_VALUE_4_POSITION 24
312
313//ADC data
314
315//ADC value 1 mask/position
316#define LTM_ADC_VALUE_1_MASK 0x000003ff
317#define LTM_ADC_VALUE_1_POSITION 0
318
319//ADC value 2 mask/position
320#define LTM_ADC_VALUE_2_MASK 0x000ffc00
321#define LTM_ADC_VALUE_2_POSITION 10
322
323//ADC value 3 mask/position
324#define LTM_ADC_VALUE_3_MASK 0x3ff00000
325#define LTM_ADC_VALUE_3_POSITION 20
326
327//LTM global trailer word required bit pattern
328#define LTM_GLOBAL_TRAILER 0x50000002
329
330//LTM event CRC mask/position
331#define LTM_EVENT_CRC_MASK 0x0000fff0
332#define LTM_EVENT_CRC_POSITION 4
333
334//LTM event number mask/position
335#define LTM_EVENT_NUMBER_MASK 0x0fff0000
336#define LTM_EVENT_NUMBER_POSITION 16
337
338/******************************************
339 * END OF OLD DEFINITIONS
340 ******************************************/
341
342class TClonesArray;
571dda3d 343class AliRawReader;
15ec34b9 344class AliTOFGeometry;
345class AliTOFrawData;
571dda3d 346
571dda3d 347class AliTOFRawStream: public TObject {
d0eb8f39 348 public:
571dda3d 349
d0eb8f39 350 AliTOFRawStream(); // default ctr
351 AliTOFRawStream(AliRawReader* rawReader); // ctr
352 virtual ~AliTOFRawStream(); // default dtr
571dda3d 353
15ec34b9 354 virtual Bool_t Next();
571dda3d 355
15ec34b9 356 virtual void LoadRawData(Int_t indexDDL);
357
d0eb8f39 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;};
571dda3d 363
d0eb8f39 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;};
740f0695 369 Int_t GetIndex(Int_t *detId); // Get channel index for Online Calibration
571dda3d 370
7813bb1a 371 Int_t GetTofBin() const {return fTime;};
372 Int_t GetToTbin() const {return fToT;};
15ec34b9 373 Float_t GetLeadingEdge() const {return fLeadingEdge;};
374 Float_t GetTrailingEdge() const {return fTrailingEdge;};
375
376 Int_t GetPSbit() const {return fPSbit;};
377 Int_t GetACQ() const {return fACQ;};
571dda3d 378
15ec34b9 379 Int_t GetErrorFlag() const {return fErrorFlag;};
380
d0eb8f39 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;};
386
15ec34b9 387 TClonesArray *GetRawData() const {return fTOFrawData;};
388
d0eb8f39 389 void SetSector();
390 void SetPlate();
391 void SetStrip();
392 void SetPadZ();
393 void SetPadX();
7813bb1a 394
d0eb8f39 395 void EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
396 Int_t iTDC, Int_t iCH, Int_t *volume) const;
7813bb1a 397 void EquipmentId2VolumeId(AliTOFHitData *hitData, Int_t *volume) const;
d0eb8f39 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;
403
7813bb1a 404 Bool_t DecodeDDL(Int_t DDLMin, Int_t DDLMax, Int_t verbose);
2fd622fa 405 Bool_t Decode(Int_t verbose);
406 AliTOFDecoder *GetDecoder() {return fDecoder;};
407 void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fDecoder->SetV2718Patch(V2718Patch);};
408
d0eb8f39 409
7813bb1a 410 AliTOFHitDataBuffer *GetDataBuffer(Int_t DDL) {return fDataBuffer[DDL];};
411 AliTOFHitDataBuffer *GetPackedDataBuffer(Int_t DDL) {return fPackedDataBuffer[DDL];};
412
413 void ResetDataBuffer(Int_t DDL) {fDataBuffer[DDL]->Reset();};
414 void ResetPackedDataBuffer(Int_t DDL) {fPackedDataBuffer[DDL]->Reset();};
415
416 void ResetBuffers();
d0eb8f39 417
7813bb1a 418 Bool_t LoadRawDataBuffers(Int_t indexDDL, Int_t verbose = 0);
419
019f6101 420 enum ETOFRawStreamError {
421 kPadXError = 0,
422 kPadAlongStripError = 1,
423 kPlateError = 2,
424 kStripError = 3,
425 kSectorError = 4,
426 kDDLMinError = 5,
427 kDDLMaxError = 6,
428 kDDLdataReading = 7,
429 kDDLDecoder = 8
430 };
431
7813bb1a 432 private:
433
434 Int_t GetField(UInt_t word, Int_t fieldMask, Int_t fieldPosition) const;
435
d0eb8f39 436 AliTOFRawStream(const AliTOFRawStream& stream); // copy ctr
437 AliTOFRawStream& operator = (const AliTOFRawStream& stream); // ass. op.
7813bb1a 438
d0eb8f39 439 AliRawReader* fRawReader; // object for reading the raw data
440
15ec34b9 441 TClonesArray *fTOFrawData; // pointer to AliTOFrawData TClonesArray
442
7813bb1a 443 AliTOFDecoder *fDecoder; //pointer to TOF decoder
444
15ec34b9 445 Int_t fDDL; // DDL file number [0;71]
446 Int_t fTRM; // TRM number [1;12]
447 Int_t fTRMchain; // TRM chain number [0;1]
448 Int_t fTDC; // TDC number [0;14]
449 Int_t fTDCchannel; // TDC channel number [0;7]
7813bb1a 450 Int_t fTime; // time-of-flight measurement [0;8191]
451 Int_t fToT; // time-over-threshould measurement [0;255]
bf33f8f0 452 Int_t fLeadingEdge; // leading edge measurement
453 Int_t fTrailingEdge; // trailing edge measurement
15ec34b9 454 Int_t fErrorFlag; // error flag
d0eb8f39 455
456 Int_t fSector; // sector number [0;17]
457 Int_t fPlate; // plate number [0;4]
458 Int_t fStrip; // strip number [0;14/18]
459 Int_t fPadX; // pad number along the strip [0;47]
460 Int_t fPadZ; // pad-row number [0;1]
461
d3c7bfac 462 AliTOFGeometry *fTOFGeometry; // pointer to the TOF geometry
463
15ec34b9 464 Int_t fPackedDigits; // counter for packed digits
465
d0eb8f39 466 Int_t fWordType; // word type
467 Int_t fSlotID; // crate slot ID number
7813bb1a 468 Int_t fACQ; // flag to identif the aquisition kind
d0eb8f39 469 Int_t fPSbit; // flag for packing
d0eb8f39 470 Int_t fTDCerrorFlag; // TDC error flag
471 Bool_t fInsideDRM; // inside/outside DRM
472 Bool_t fInsideTRM; // inside/outside TRM
473 Bool_t fInsideLTM; // inside/outside LTM
474 Bool_t fInsideTRMchain0; // inside/outside chain 0
475 Bool_t fInsideTRMchain1; // inside/outside chain 1
571dda3d 476
fa0811c3 477 AliTOFHitDataBuffer *fDataBuffer[72]; // pointer to AliTOFHitDataBuffer
478 AliTOFHitDataBuffer *fPackedDataBuffer[72]; // pointer to AliTOFHitDataBuffer
7813bb1a 479
bf33f8f0 480 ClassDef(AliTOFRawStream, 2) // class for reading TOF raw digits
571dda3d 481};
482
483#endif