Improved QAchecker and plots for DQM
[u/mrichter/AliRoot.git] / TOF / AliTOFDecoderV2.h
CommitLineData
5b4ed716 1#ifndef ALITOFDECODERV2_H
2#define ALITOFDECODERV2_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id: AliTOFDecoder.h,v 1.2 2007/05/08 11:55:24 arcelli Exp $ */
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
36#define DRM_STATUS_HEADER_WORDS 4
37#define LTM_PDL_DATA_WORDS 12
38#define LTM_ADC_DATA_WORDS 20
39#define LTM_OR_DATA_WORDS 16
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//define CRC macros to convert 32-bit CRC into DRM/TRM CRC
83#define COMPUTE_DRM_CRC(a) ( ((a & 0x0000ffff) >> 0) ^\
84 ((a & 0xffff0000) >> 16) )
85#define COMPUTE_TRM_CRC(a) ( ((a & 0x00000fff) >> 0) ^\
86 ((a & 0x00fff000) >> 12) ^\
87 ((a & 0xff000000) >> 24) )
88#define COMPUTE_LTM_CRC(a) ( ((a & 0x00000fff) >> 0) ^\
89 ((a & 0x00fff000) >> 12) ^\
90 ((a & 0xff000000) >> 24) )
91
92
93#include "TObject.h"
5b4ed716 94#include "AliRawReader.h"
46b17363 95#include "AliTOFTDCHit.h"
96
97class AliTOFDecoderSummaryData;
98class AliTOFDRMSummaryData;
99class AliTOFLTMSummaryData;
100class AliTOFTRMSummaryData;
101class AliTOFChainSummaryData;
102class AliTOFTDCHitBuffer;
103class AliTOFTDCErrorBuffer;
c264c7ec 104struct AliRawDataHeader;
5b4ed716 105
106class AliTOFDecoderV2 : public TObject
107{
108 public:
109 AliTOFDecoderV2(AliRawReader *reader = NULL); //default constructor
110 AliTOFDecoderV2(const AliTOFDecoderV2 &source); //copy constructor
111 AliTOFDecoderV2 &operator = (const AliTOFDecoderV2 &source); //operator =
112 ~AliTOFDecoderV2(); //distructor
113 /* setters */
114 void SetRawReader(AliRawReader *value) {fRawReader = value;}; // set raw reader
115 void SetVerbose(Bool_t Verbose = kTRUE) {fVerbose = Verbose;}; //set verbose level
116 void SetLogErrors(Bool_t Value = kTRUE) {fLogErrors = Value;}; //set log errors
117 void SetV2718Patch(Bool_t V2718Patch = kTRUE) {fV2718Patch = V2718Patch;}; //set V2718 patch (no DRM)
118 void SetRecoverError(Bool_t RecoverError = kTRUE) {fRecoverError = RecoverError;}; //decoder will try to recover decoding errors
119 void SetRecoverErrorThr(Int_t value) {fRecoverErrorThr = value;}; // setter
0758436a 120 void SetSpider(Bool_t value = kTRUE) {fSpider = value;}; //set spider
5b4ed716 121 void SetRunNumber(Int_t RunNumber) {fRunNumber = RunNumber;}; //set run number
122 void SetEventNumber(UInt_t EventNumber) {fEventNumber = EventNumber;}; //set event number
123 void SetEquipmentID(Int_t EquipmentID) {fEquipmentID = EquipmentID;}; //set equipment ID
124 /* getters */
125 AliTOFDecoderSummaryData *GetDecoderSummaryData() {return fDecoderSummaryData;}; //get decoder summary data
126 /* methods */
127 Bool_t Decode(UInt_t *rawData, UInt_t nWords); //main decode function
128 void Spider(AliTOFTDCHit &hit);
129 void ResetSpider();
130 /* raw reader decoder interface */
131 Bool_t NextEvent() {return fRawReader ? fRawReader->NextEvent() : kFALSE;}; // next event
132 UInt_t GetEventType() {return fRawReader ? fRawReader->GetType() : 0;}; // get event type
133 Bool_t DecodeNext(); // decode next
134 const AliRawDataHeader *GetCDH() const {return fRawReader ? fRawReader->GetDataHeader() : NULL;}; // get CDH
135
136 private:
137 AliRawReader *fRawReader; // raw reader
138 Bool_t fVerbose; //verbose flag
139 Bool_t fLogErrors; //log errors flag
140 Bool_t fV2718Patch; //V2718 patch flag
141 Bool_t fRecoverError; //recover error flag
142 Int_t fRecoverErrorThr; // recover error thr
143 Bool_t fSpider; //spider flag
144 Int_t fRunNumber; //run number
145 UInt_t fEventNumber; //event number
146 Int_t fEquipmentID; //equipment ID
147
148 //summary data pointers
149 AliTOFDecoderSummaryData *fDecoderSummaryData; //decoder summary data
150 AliTOFDRMSummaryData *fDRMSummaryData; //DRM summary data
151 AliTOFLTMSummaryData *fLTMSummaryData; //LTM summary data
152 AliTOFTRMSummaryData *fTRMSummaryData; //TRM summary data
153 AliTOFChainSummaryData *fChainSummaryData; //chain summary data
154
155 //buffer pointers
156 AliTOFTDCHitBuffer *fTDCHitBuffer; //TDC hit buffer
157 AliTOFTDCHitBuffer *fTDCPackedHitBuffer; //TDC packed hit buffer
158 AliTOFTDCErrorBuffer *fTDCErrorBuffer; //TDC error buffer
159
160 //decoding objects
161 AliTOFDRMGlobalHeader *fDRMGlobalHeader; //DRM global header
162 AliTOFDRMGlobalTrailer *fDRMGlobalTrailer; //DRM global trailer
163 AliTOFDRMStatusHeader1 *fDRMStatusHeader1; //DRM status header1
164 AliTOFDRMStatusHeader2 *fDRMStatusHeader2; //DRM status header2
165 AliTOFDRMStatusHeader3 *fDRMStatusHeader3; //DRM status header3
166 AliTOFDRMStatusHeader4 *fDRMStatusHeader4; //DRM status header4
167 AliTOFDRMEventCRC *fDRMEventCRC; //DRM event CRC
168 AliTOFLTMGlobalHeader *fLTMGlobalHeader; //LTM global header
169 AliTOFLTMGlobalTrailer *fLTMGlobalTrailer; //LTM global trailer
170 AliTOFLTMPDLData *fLTMPDLData; //LTM PDL data
171 AliTOFLTMADCData *fLTMADCData; //LTM ADC data
172 AliTOFLTMORData *fLTMORData; //LTM OR data
173 AliTOFTRMGlobalHeader *fTRMGlobalHeader; //TRM global header
174 AliTOFTRMGlobalTrailer *fTRMGlobalTrailer; //TRM global trailer
175 AliTOFTRMChainHeader *fTRMChainHeader; //TRM chain header
176 AliTOFTRMChainTrailer *fTRMChainTrailer; //TRM chain trailer
177 AliTOFTDCPackedHit *fTDCPackedHit; //TDC packed hit
178 AliTOFTDCUnpackedHit *fTDCUnpackedHit; //TDC unpacked hit
179 AliTOFTRMTDCError *fTRMTDCError; //TRM TDC error
180 AliTOFTRMDiagnosticErrorWord1 *fTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
181 AliTOFTRMDiagnosticErrorWord2 *fTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
182
183 /* Spider data members */
46b17363 184 AliTOFTDCHit fSpiderBuffer[8]; // SPIDER buffer
185 Bool_t fSpiderBufferFull[8]; // SPIDER buffer full flag
186 Int_t fSpiderTDCID; // SPIDER TDC ID
187 AliTOFTDCHitBuffer *fSpiderTDCPackedHitBuffer; // SPIDER buffer
5b4ed716 188
189
190 /* Summary Data Functions */
191 //fill DRM summary data
46b17363 192 void FillDRMSummaryData(const AliTOFDRMGlobalHeader *DRMGlobalHeader); //DRM global header
193 void FillDRMSummaryData(const AliTOFDRMGlobalTrailer *DRMGlobalTrailer); //DRM global trailer
194 void FillDRMSummaryData(const AliTOFDRMStatusHeader1 *DRMStatusHeader1); //DRM status header 1
195 void FillDRMSummaryData(const AliTOFDRMStatusHeader2 *DRMStatusHeader2); //DRM status header 2
196 void FillDRMSummaryData(const AliTOFDRMStatusHeader3 *DRMStatusHeader3); //DRM status header 3
197 void FillDRMSummaryData(const AliTOFDRMStatusHeader4 *DRMStatusHeader4); //DRM status header 4
198 void FillDRMSummaryData(const AliTOFDRMEventCRC *DRMEventCRC); //DRM event CRC
5b4ed716 199 //fill LTM summary data
46b17363 200 void FillLTMSummaryData(const AliTOFLTMGlobalHeader *LTMGlobalHeader); //LTM global header
201 void FillLTMSummaryData(const AliTOFLTMGlobalTrailer *LTMGlobalTrailer); //LTM global trailer
202 void FillLTMSummaryData(const AliTOFLTMPDLData *LTMPDLData, Int_t PDLWord); //LTM PDL data
203 void FillLTMSummaryData(const AliTOFLTMADCData *LTMADCData, Int_t ADCWord); //LTM ADC data
204 void FillLTMSummaryData(const AliTOFLTMORData *LTMORData, Int_t ORWord); //LTM OR data
5b4ed716 205 //fill TRM summary data
46b17363 206 void FillTRMSummaryData(const AliTOFTRMGlobalHeader *TRMGlobalHeader); //TRM global header
207 void FillTRMSummaryData(const AliTOFTRMGlobalTrailer *TRMGlobalTrailer); //TRM global trailer
5b4ed716 208 //fill chain summary data
46b17363 209 void FillChainSummaryData(const AliTOFTRMChainHeader *TRMChainHeader); //TRM chain header
210 void FillChainSummaryData(const AliTOFTRMChainTrailer *TRMChainTrailer); //TRM chain trailer
5b4ed716 211
212 ClassDef(AliTOFDecoderV2, 1);
213};
214
215#endif /* ALITOFDECODERV2_H */