TOF Raw Data decoder
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoder.h
CommitLineData
2531be5d 1#ifndef ALITOFDECODER_H
2#define ALITOFDECODER_H
3
4#include "AliTOFGeometry.h"
5
6/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
9/* $Id$ */
10
11///////////////////////////////////////////////////////////////
12// //
13// This class provides the basic TOF raw data decoder. //
14// //
15///////////////////////////////////////////////////////////////
16
17//define decoder status and bits
18#define DRM_BIT 0x1
19#define LTM_BIT 0x2
20#define TRM_BIT 0x4
21#define CHAIN_A_BIT 0x8
22#define CHAIN_B_BIT 0x10
23
24#define DRM_HEADER_STATUS 0x0
25#define DRM_TRAILER_STATUS (DRM_BIT)
26#define LTM_HEADER_STATUS (DRM_BIT)
27#define LTM_TRAILER_STATUS (DRM_BIT|LTM_BIT)
28#define TRM_HEADER_STATUS (DRM_BIT)
29#define TRM_TRAILER_STATUS (DRM_BIT|TRM_BIT)
30#define CHAIN_A_HEADER_STATUS (DRM_BIT|TRM_BIT)
31#define CHAIN_A_TRAILER_STATUS (DRM_BIT|TRM_BIT|CHAIN_A_BIT)
32#define CHAIN_B_HEADER_STATUS (DRM_BIT|TRM_BIT)
33#define CHAIN_B_TRAILER_STATUS (DRM_BIT|TRM_BIT|CHAIN_B_BIT)
34#define CHAIN_A_TDC_HIT_STATUS (DRM_BIT|TRM_BIT|CHAIN_A_BIT)
35#define CHAIN_B_TDC_HIT_STATUS (DRM_BIT|TRM_BIT|CHAIN_B_BIT)
36
37//define DRM/LTM fixed number of words
38#define DRM_DATA_WORDS 4
39#define LTM_DATA_WORDS 33
40
41//define masks
42#define WORD_TYPE_MASK 0xf0000000
43#define SLOT_ID_MASK 0x0000000f
44
45//define word types
46#define GLOBAL_HEADER 0x40000000
47#define GLOBAL_TRAILER 0x50000000
48#define CHAIN_A_HEADER 0x00000000
49#define CHAIN_A_TRAILER 0x10000000
50#define CHAIN_B_HEADER 0x20000000
51#define CHAIN_B_TRAILER 0x30000000
52#define ERROR 0x60000000
53#define FILLER 0x70000000
54
55//define TRM ACQ status
56#define PACKING_ENABLED_ACQ 0x0
57#define LEADING_ONLY_ACQ 0x1
58#define TRAILING_ONLY_ACQ 0x2
59#define PACKING_DISABLED_ACQ 0x3
60
61//define TDC hit PS status
62#define PACKED_HIT_PS 0x0
63#define LEADING_HIT_PS 0x1
64#define TRAILING_HIT_PS 0x2
65#define TOT_OVF_HIT_PS 0x3
66
67//define mandatory numbers
68#define N_EQUIPMENT 72
69#define N_DDL N_EQUIPMENT
70#define N_TRM 10
71#define N_CHAIN 2
72#define N_TDC 15
73#define N_CHANNEL 8
74#define TRM_FIRST_SLOT_ID 3
75#define TRM_LAST_SLOT_ID 12
76
77#define TIME_BIN_WIDTH 24.4e-3//ns
78#define TOT_BIN_WIDTH 48.8e-3//ns
79#define TIME_TO_TOT_BIN_WIDTH ( TIME_BIN_WIDTH / TOT_BIN_WIDTH )
80#define TOT_TO_TIME_BIN_WIDTH ( TOT_BIN_WIDTH / TIME_BIN_WIDTH )
81
82//max hit number in a TDC
83#define MAX_TDC_HIT_NUMBER 100
84//max TDC errors
85#define MAX_TDC_ERROR_NUMBER 1000
86//max hit number in a TRM
87#define MAX_TRM_HIT_NUMBER 2400
88//data buffer size
89#define DATA_BUFFER_SIZE 1000
90
91#include "TObject.h"
92#include "AliTOFRawDataFormat.h"
93#include "AliTOFHitDataBuffer.h"
94
95class AliTOFDecoder : public TObject
96{
97 public:
98 AliTOFDecoder(); //default constructor
99 AliTOFDecoder(AliTOFHitDataBuffer *DB, AliTOFHitDataBuffer *PDB); //constructor
100 AliTOFDecoder(const AliTOFDecoder &source); //copy constructor
101 AliTOFDecoder &operator = (const AliTOFDecoder &source); //operator =
102 ~AliTOFDecoder(); //distructor
103
104 Bool_t Decode(UInt_t *rawData, Int_t nWords); //main decode function
105 void SetVerbose(Int_t Verbose = 1) {fVerbose = Verbose;}; //set verbose level
106 void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fV2718Patch = V2718Patch;}; //set V2718 patch (no DRM)
107 void SetDataBuffer(AliTOFHitDataBuffer *DB) {fDataBuffer = DB;}; //set up data buffer
108 void SetPackedDataBuffer(AliTOFHitDataBuffer *PDB) {fPackedDataBuffer = PDB;}; //set up packed data buffer
109 private:
110 /* SPIDER
111 * - Software Packing Inside Decoding Routines -
112 * developed by Roberto Preghenella (R+)
113 * use at your own risk
114 */
115 Bool_t InitializeSpider(); //initialize SPIDER routine
116 Bool_t ResetSpider(); //reset SPIDER routine
117 Bool_t Spider(AliTOFHitData hitData); //main SPIDER routine
118
119 Int_t fVerbose; //verbose flag
120 Bool_t fV2718Patch; //V2718 patch flag
121 AliTOFHitDataBuffer *fDataBuffer; //data buffer pointer
122 AliTOFHitDataBuffer *fPackedDataBuffer; //packed data buffe pointer
123
124 //decoding objects
125 AliTOFTRMGlobalHeader *fTRMGlobalHeader; //TRM global header
126 AliTOFTRMGlobalTrailer *fTRMGlobalTrailer; //TRM global trailer
127 AliTOFTRMChainHeader *fTRMChainHeader; //TRM chain header
128 AliTOFTRMChainTrailer *fTRMChainTrailer; //TRM chain trailer
129 AliTOFTDCPackedHit *fTDCPackedHit; //TDC packed hit
130 AliTOFTDCUnpackedHit *fTDCUnpackedHit; //TDC unpacked hit
131 AliTOFTRMTDCError *fTRMTDCError; //TRM TDC error
132 AliTOFTRMDiagnosticErrorWord1 *fTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
133 AliTOFTRMDiagnosticErrorWord2 *fTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
134
135 //SPIDER variables
136 Int_t fSpiderCurrentSlotID; //SPIDER current slot ID
137 Int_t fSpiderCurrentChain; //SPIDER current chain
138 Int_t fSpiderCurrentTDC; //SPIDER current TDC
139 Bool_t fSpiderLeadingFlag[N_CHANNEL]; //SPIDER channel leading flag
140 AliTOFHitData fSpiderLeadingHit[N_CHANNEL]; //SPIDER channel leading hit
141
142 ClassDef(AliTOFDecoder, 1)
143};
144
145#endif /* ALITOFDECODER_H */