1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
4 //-----------------------------------
6 // decoding of TRD raw data stream
7 // and translation into digits
9 //----------------------------------
11 #ifndef ALITRDRAWSTREAM_H
12 #define ALITRDRAWSTREAM_H
16 #include "AliTRDrawStreamBase.h"
17 //#include "AliRawReader.h"
24 class AliTRDdigitsManager;
25 class AliTRDdigitsParam;
27 class AliTRDSignalIndex;
29 class AliTRDrawStream : public AliTRDrawStreamBase
32 AliTRDrawStream(AliRawReader *rawReader = 0x0);
35 Bool_t SetReader(AliRawReader *rawReader) { fRawReader = rawReader; return kTRUE; }
36 void SetDigitsManager(AliTRDdigitsManager *digMgr) { fDigitsManager = digMgr; }
38 Bool_t ReadEvent(TTree *trackletTree = 0x0);
41 Int_t NextChamber(AliTRDdigitsManager *digMgr,
42 UInt_t ** /* trackletContainer */, UShort_t ** /* errorContainer */);
44 Bool_t ConnectTracklets(TTree *trklTree);
46 // legacy code, to be removed
47 Bool_t SetRawVersion(Int_t) { return kTRUE; }
48 void SetSharedPadReadout(Bool_t) {}
49 void SetNoErrorWarning() {}
74 TTree* GetErrorTree() const { return fErrors; }
75 static const char* GetErrorMessage(ErrorCode_t errCode);
79 Int_t ReadStackIndexHeader(Int_t stack);
82 Int_t ReadTracklets();
84 Int_t ReadTPData(Int_t mode = 1);
86 Int_t ReadNonZSData();
88 // MCM header decoding
89 Int_t ROB(UInt_t mcmhdr) const { return 0x7 & mcmhdr >> 28; }
90 Int_t MCM(UInt_t mcmhdr) const { return 0xf & mcmhdr >> 24; }
91 Int_t Row(UInt_t mcmhdr) const { return (ROB(mcmhdr) / 2) * 4 + MCM(mcmhdr) / 4; }
92 Int_t AdcColOffset(UInt_t mcmhdr) const { return (MCM(mcmhdr) % 4 + 1) * 21 + (ROB(mcmhdr) % 2) * 84 - 1; }
93 Int_t PadColOffset(UInt_t mcmhdr) const { return (MCM(mcmhdr) % 4 + 1) * 18 + (ROB(mcmhdr) % 2) * 72 + 1; }
94 Int_t EvNo(UInt_t mcmhdr) const { return 0xfffff & mcmhdr >> 4; }
95 Int_t Check(UInt_t mcmhdr) const { return 0xf & mcmhdr; }
96 Int_t CouldBeMCMhdr(UInt_t mcmhdr) const { return ((0xf & mcmhdr) == 0xc); }
98 Int_t GetMCMReadoutPos(Int_t mcm) const { return (mcm > -1 && mcm < 16) ? fgkMcmOrder[mcm] : -1; }
99 Int_t GetROBReadoutPos(Int_t rob) const { return (rob > -1 && rob < 4) ? fgkRobOrder[rob] : -1; }
102 Int_t GetActiveChannels(UInt_t adcmask) const { return 0x1fffff & adcmask >> 4; }
103 Int_t GetNActiveChannelsFromMask(UInt_t adcmask) const; // { Int_t nch = 0; for (Int_t i = 0; i < 21; i++) if ((GetActiveChannels(adcmask) & 1 << i)) nch++; return nch; }
104 Int_t GetNActiveChannels(UInt_t adcmask) const { return (0x1f & ~(adcmask >> 25)); }
105 Int_t CouldBeADCmask(UInt_t adcmask) const { return ((0xf & adcmask) == 0xc && (0x3 & adcmask >> 30) == 0x1); }
107 // error message generation
108 TString EquipmentError(ErrorCode_t err = kUnknown, TString msg = "");
109 TString StackError (ErrorCode_t err = kUnknown, TString msg = "");
110 TString LinkError (ErrorCode_t err = kUnknown, TString msg = "");
111 TString ROBError (ErrorCode_t err = kUnknown, TString msg = "");
112 TString MCMError (ErrorCode_t err = kUnknown, TString msg = "");
114 static char* fgErrorMessages[kLastErrorCode]; // error messages corresponding to the error codes
117 AliRawReader *fRawReader; // pointer to the raw reader to take the data from
118 AliTRDdigitsManager *fDigitsManager; // pointer to the digitsManager to fill the data
119 AliTRDdigitsParam *fDigitsParam; // pointer to the parameters belonging to the digits
121 TTree *fErrors; // tree containing the occured error codes
122 struct { Int_t fSector; Int_t fStack; Int_t fLink; Int_t fError; Int_t fRob; Int_t fMcm; }
123 fLastError; // last error which occured
125 UInt_t *fPayloadStart; // pointer to start of data payload
126 UInt_t *fPayloadCurr; // pointer to current reading position in the payload
127 Int_t fPayloadSize; // size of the payload
129 static const Int_t fgkNlinks; // number of links to read
130 static const Int_t fgkNstacks; // number of stacks to read
131 static const UInt_t fgkDataEndmarker; // data endmarker
132 static const UInt_t fgkTrackletEndmarker; // tracklet endmarker
133 static const Int_t fgkMcmOrder []; // expected readout order of the MCMs
134 static const Int_t fgkRobOrder []; // expected readout order of the ROBs
136 // persistent information
137 Int_t fNtimebins; // number of timebins
138 Int_t fLastEvId; // Event ID of last event
140 // information valid at current reader position
141 // all the variables fCurr... refer to the value at the current
143 Int_t fCurrSlot; // current slot
144 Int_t fCurrLink; // current link
145 Int_t fCurrRobPos; // current ROB number
146 Int_t fCurrMcmPos; // current MCM number
149 UInt_t fCurrEquipmentId; // current Equipment ID
152 UInt_t fCurrSmuIndexHeaderSize; // current size of the SMU index header
153 UInt_t fCurrSmuIndexHeaderVersion; // current version of the SMU index header
154 UInt_t fCurrTrackEnable; // current value of track enable
155 UInt_t fCurrTrackletEnable; // current value of tracklet enable
156 UInt_t fCurrStackMask; // current mask of active stacks
158 // Stack index header
159 UInt_t *fCurrStackIndexWord; // current stack index words
160 UInt_t *fCurrStackHeaderSize; // current stack index sizes
161 UInt_t *fCurrStackHeaderVersion; // current stack header versions
162 UInt_t *fCurrLinkMask; // current link masks
163 UInt_t *fCurrCleanCheckout; // current clean checkout flags
164 UInt_t *fCurrBoardId; // current board IDs
165 UInt_t *fCurrHwRev; // current hardware revision
166 UInt_t *fCurrLinkMonitorFlags; // current link monitor flags
167 UInt_t *fCurrLinkDataTypeFlags; // current link data flags
168 UInt_t *fCurrLinkDebugFlags; // current link debug flags
171 Int_t fCurrSpecial; // current value of the special flag
172 Int_t fCurrMajor; // current major version
173 Int_t fCurrMinor; // current minor version
174 Int_t fCurrAddHcWords; // current number of additional HC-header words
175 Int_t fCurrSm; // current sector
176 Int_t fCurrStack; // current stack
177 Int_t fCurrLayer; // current layer
178 Int_t fCurrSide; // current side
179 Int_t fCurrHC; // current HC
180 Int_t fCurrCheck; // current check bits
181 Int_t fCurrNtimebins; // current number of timebins
182 Int_t fCurrBC; // current BC
183 Int_t fCurrPtrgCnt; // current pretrigger count
184 Int_t fCurrPtrgPhase; // current pretrigger phase
186 // tracklet information
187 TClonesArray *fTrackletArray; // pointer to array for tracklet storage
190 AliTRDarrayADC *fAdcArray; // pointer to ADC array
191 AliTRDSignalIndex *fSignalIndex; // pointer to the signal index
192 TTree *fTrackletTree; // pointer to the tree for tracklet storage
194 AliTRDrawStream(const AliTRDrawStream&); // not implemented
195 AliTRDrawStream& operator=(const AliTRDrawStream&); // not implemented
197 ClassDef(AliTRDrawStream, 0);