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