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