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