Macro to Create pulser run data from an LDC
[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
73620dbf 38#define DRM_DATA_WORDS 5
2531be5d 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
2531be5d 88
89#include "TObject.h"
90#include "AliTOFRawDataFormat.h"
91#include "AliTOFHitDataBuffer.h"
92
93class AliTOFDecoder : public TObject
94{
95 public:
96 AliTOFDecoder(); //default constructor
97 AliTOFDecoder(AliTOFHitDataBuffer *DB, AliTOFHitDataBuffer *PDB); //constructor
98 AliTOFDecoder(const AliTOFDecoder &source); //copy constructor
99 AliTOFDecoder &operator = (const AliTOFDecoder &source); //operator =
100 ~AliTOFDecoder(); //distructor
101
102 Bool_t Decode(UInt_t *rawData, Int_t nWords); //main decode function
103 void SetVerbose(Int_t Verbose = 1) {fVerbose = Verbose;}; //set verbose level
104 void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fV2718Patch = V2718Patch;}; //set V2718 patch (no DRM)
105 void SetDataBuffer(AliTOFHitDataBuffer *DB) {fDataBuffer = DB;}; //set up data buffer
106 void SetPackedDataBuffer(AliTOFHitDataBuffer *PDB) {fPackedDataBuffer = PDB;}; //set up packed data buffer
974c1ccc 107
108 void GetArrayDDL(Int_t* array, Int_t iDDL); // method to return array of TOFchannels corresponding to a given DDL id
109
110enum {
111 kMinPlate0=0,kMaxPlate0=2,
112 kMinStrip0=0,kMaxStrip0=6,
113 kMinPadz0=0,kMaxPadz0=1,
114 kMinPadx0=0,kMaxPadx0=23,
115
116 kMinPlate1=0,kMaxPlate1=2,
117 kMinStrip1=0,kMaxStrip1=7,
118 kMinPadz1=0,kMaxPadz1=1,
119 kMinPadx1=24,kMaxPadx1=47,
120
121 kMinPlate2=2,kMaxPlate2=4,
122 kMinStrip2=8,kMaxStrip2=14,
123 kMinPadz2=0,kMaxPadz2=1,
124 kMinPadx2=24,kMaxPadx2=47,
125
126 kMinPlate3=2,kMaxPlate3=4,
127 kMinStrip3=7,kMaxStrip3=14,
128 kMinPadz3=0,kMaxPadz3=1,
129 kMinPadx3=0,kMaxPadx3=23
130
131};
132
133
2531be5d 134 private:
135 /* SPIDER
136 * - Software Packing Inside Decoding Routines -
137 * developed by Roberto Preghenella (R+)
138 * use at your own risk
139 */
140 Bool_t InitializeSpider(); //initialize SPIDER routine
141 Bool_t ResetSpider(); //reset SPIDER routine
142 Bool_t Spider(AliTOFHitData hitData); //main SPIDER routine
143
144 Int_t fVerbose; //verbose flag
145 Bool_t fV2718Patch; //V2718 patch flag
146 AliTOFHitDataBuffer *fDataBuffer; //data buffer pointer
147 AliTOFHitDataBuffer *fPackedDataBuffer; //packed data buffe pointer
148
149 //decoding objects
150 AliTOFTRMGlobalHeader *fTRMGlobalHeader; //TRM global header
151 AliTOFTRMGlobalTrailer *fTRMGlobalTrailer; //TRM global trailer
152 AliTOFTRMChainHeader *fTRMChainHeader; //TRM chain header
153 AliTOFTRMChainTrailer *fTRMChainTrailer; //TRM chain trailer
154 AliTOFTDCPackedHit *fTDCPackedHit; //TDC packed hit
155 AliTOFTDCUnpackedHit *fTDCUnpackedHit; //TDC unpacked hit
156 AliTOFTRMTDCError *fTRMTDCError; //TRM TDC error
157 AliTOFTRMDiagnosticErrorWord1 *fTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
158 AliTOFTRMDiagnosticErrorWord2 *fTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
159
160 //SPIDER variables
161 Int_t fSpiderCurrentSlotID; //SPIDER current slot ID
162 Int_t fSpiderCurrentChain; //SPIDER current chain
163 Int_t fSpiderCurrentTDC; //SPIDER current TDC
164 Bool_t fSpiderLeadingFlag[N_CHANNEL]; //SPIDER channel leading flag
165 AliTOFHitData fSpiderLeadingHit[N_CHANNEL]; //SPIDER channel leading hit
166
974c1ccc 167 ClassDef(AliTOFDecoder, 2)
2531be5d 168};
169
170#endif /* ALITOFDECODER_H */