New Processing for data from pulser and noise runs implemented
[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
107 private:
108 /* SPIDER
109 * - Software Packing Inside Decoding Routines -
110 * developed by Roberto Preghenella (R+)
111 * use at your own risk
112 */
113 Bool_t InitializeSpider(); //initialize SPIDER routine
114 Bool_t ResetSpider(); //reset SPIDER routine
115 Bool_t Spider(AliTOFHitData hitData); //main SPIDER routine
116
117 Int_t fVerbose; //verbose flag
118 Bool_t fV2718Patch; //V2718 patch flag
119 AliTOFHitDataBuffer *fDataBuffer; //data buffer pointer
120 AliTOFHitDataBuffer *fPackedDataBuffer; //packed data buffe pointer
121
122 //decoding objects
123 AliTOFTRMGlobalHeader *fTRMGlobalHeader; //TRM global header
124 AliTOFTRMGlobalTrailer *fTRMGlobalTrailer; //TRM global trailer
125 AliTOFTRMChainHeader *fTRMChainHeader; //TRM chain header
126 AliTOFTRMChainTrailer *fTRMChainTrailer; //TRM chain trailer
127 AliTOFTDCPackedHit *fTDCPackedHit; //TDC packed hit
128 AliTOFTDCUnpackedHit *fTDCUnpackedHit; //TDC unpacked hit
129 AliTOFTRMTDCError *fTRMTDCError; //TRM TDC error
130 AliTOFTRMDiagnosticErrorWord1 *fTRMDiagnosticErrorWord1; //TRM diagnostic error word 1
131 AliTOFTRMDiagnosticErrorWord2 *fTRMDiagnosticErrorWord2; //TRM diagnostica error word 2
132
133 //SPIDER variables
134 Int_t fSpiderCurrentSlotID; //SPIDER current slot ID
135 Int_t fSpiderCurrentChain; //SPIDER current chain
136 Int_t fSpiderCurrentTDC; //SPIDER current TDC
137 Bool_t fSpiderLeadingFlag[N_CHANNEL]; //SPIDER channel leading flag
138 AliTOFHitData fSpiderLeadingHit[N_CHANNEL]; //SPIDER channel leading hit
139
140 ClassDef(AliTOFDecoder, 1)
141};
142
143#endif /* ALITOFDECODER_H */