]>
Commit | Line | Data |
---|---|---|
987ba9a3 | 1 | #ifndef ALITRDRAWSTREAMTB_H |
2 | #define ALITRDRAWSTREAMTB_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: AliTRDrawStream.h 27696 2008-07-31 09:18:53Z cblume $ */ | |
8 | ||
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | // // | |
11 | // This class provides access to TRD digits in raw data. // | |
12 | // // | |
13 | /////////////////////////////////////////////////////////////////////////////// | |
14 | ||
15 | #include "TObject.h" | |
16 | #include "TString.h" | |
17 | #include "AliTRDrawStreamBase.h" | |
18 | ||
19 | class AliTRDgeometry; | |
20 | class AliRawReader; | |
21 | class AliTRDdigitsManager; | |
22 | class TTreeSRedirector; | |
23 | class AliTRDfeeParam; | |
24 | ||
987ba9a3 | 25 | |
26 | class AliTRDrawStream : public AliTRDrawStreamBase | |
27 | { // class def begin | |
28 | ||
29 | public: | |
30 | ||
31 | //-------------------------------------------------------- | |
32 | ||
33 | // THE STRUCTURES | |
34 | ||
35 | //-------------------------------------------------------- | |
36 | ||
37 | struct AliTRDrawADC | |
38 | {//adc struct | |
39 | ||
40 | UInt_t *fPos; //! position of ADC 1st word in the buffer | |
41 | Short_t fADCnumber; // number of the ADC 0 .. 20 | |
42 | Short_t fCOL; // column - row from MCM | |
43 | Int_t fSignals[TRD_MAX_TBINS]; // signals for this adc | |
44 | Bool_t fIsShared; // is pad chared between MCMs | |
45 | Short_t fCorrupted; // is adc word corrupted | |
46 | ||
47 | AliTRDrawADC() | |
48 | : fPos(0) | |
49 | , fADCnumber(0) | |
50 | , fCOL(0) | |
51 | , fSignals() | |
52 | , fIsShared(kFALSE) | |
53 | , fCorrupted(0) | |
54 | { | |
55 | // default constructor | |
56 | }; | |
57 | ||
58 | AliTRDrawADC(const AliTRDrawADC& p): | |
59 | fPos(p.fPos) | |
60 | , fADCnumber(p.fADCnumber) | |
61 | , fCOL(p.fCOL) | |
62 | , fSignals() | |
63 | , fIsShared(p.fIsShared) | |
64 | , fCorrupted(p.fCorrupted) | |
65 | { | |
66 | // copy constructor | |
67 | }; | |
68 | ||
69 | AliTRDrawADC &operator=(const AliTRDrawADC &) | |
70 | { | |
71 | // assignment operator | |
72 | // not implemented | |
73 | return *this; | |
74 | }; | |
75 | ||
76 | }; | |
77 | ||
78 | //-------------------------------------------------------- | |
79 | ||
80 | struct AliTRDrawMCM | |
81 | { // mcm struct | |
82 | Int_t fROB; // ROB number | |
83 | Int_t fMCM; // MCM number | |
84 | Int_t fROW; // row number filed during decoding | |
85 | ||
86 | UInt_t fEvCounter; // MCM event counter | |
87 | UInt_t fADCMask; // ADC mask | |
88 | UInt_t fADCMaskWord; // word with ADC mask in | |
89 | UInt_t fADCchannel[TRD_MAX_ADC]; // channels to be decoded accrording to ADC mask | |
90 | ||
91 | Int_t fADCmax; // number of ADCs fired | |
92 | Int_t fADCcount; // number of ADCs fired from double checking bit | |
93 | Int_t fMCMADCWords; // mcm words to expect | |
94 | Int_t fSingleADCwords; // n of words per ADC | |
95 | ||
96 | Int_t fMCMhdCorrupted; // is mcm header corrupted | |
97 | Int_t fADCmaskCorrupted; // is mcm adc mask corrupted | |
98 | Int_t fCorrupted; // is mcm data missing | |
99 | ||
100 | UInt_t *fPos; //! position of mcm header in the buffer | |
101 | UInt_t *fAdcDataPos; //! start of ADC data for this mcm | |
102 | ||
103 | Int_t fADCcounter; // count the adcs decoded | |
104 | AliTRDrawADC fADCs[TRD_MAX_ADC]; // 21 adcs | |
105 | ||
106 | AliTRDrawMCM() | |
107 | : fROB(-1) | |
108 | , fMCM(-1) | |
109 | , fROW(-1) | |
110 | , fEvCounter(0) | |
111 | , fADCMask(0) | |
112 | , fADCMaskWord(0) | |
113 | , fADCchannel() | |
114 | , fADCmax(0) | |
115 | , fADCcount(0) | |
116 | , fMCMADCWords(0) | |
117 | , fSingleADCwords(0) | |
118 | , fMCMhdCorrupted(0) | |
119 | , fADCmaskCorrupted(0) | |
120 | , fCorrupted(0) | |
121 | , fPos(0) | |
122 | , fAdcDataPos(0) | |
123 | , fADCcounter(0) | |
124 | , fADCs() | |
125 | { | |
126 | // default constructor | |
127 | }; | |
128 | ||
129 | AliTRDrawMCM(const AliTRDrawMCM & p): | |
130 | fROB(p.fROB) | |
131 | , fMCM(p.fMCM) | |
132 | , fROW(p.fROW) | |
133 | , fEvCounter(p.fEvCounter) | |
134 | , fADCMask(p.fADCMask) | |
135 | , fADCMaskWord(p.fADCMaskWord) | |
136 | , fADCchannel() | |
137 | , fADCmax(p.fADCmax) | |
138 | , fADCcount(p.fADCcount) | |
139 | , fMCMADCWords(p.fMCMADCWords) | |
140 | , fSingleADCwords(p.fSingleADCwords) | |
141 | , fMCMhdCorrupted(p.fMCMhdCorrupted) | |
142 | , fADCmaskCorrupted(p.fADCmaskCorrupted) | |
143 | , fCorrupted(p.fCorrupted) | |
144 | , fPos(p.fPos) | |
145 | , fAdcDataPos(p.fAdcDataPos) | |
146 | , fADCcounter(p.fADCcounter) | |
147 | , fADCs() | |
148 | { | |
149 | // copy constructor | |
150 | }; | |
151 | ||
152 | AliTRDrawMCM &operator=(const AliTRDrawMCM &) | |
153 | { | |
154 | // assignment operator | |
155 | // not implemented | |
156 | return *this; | |
157 | }; | |
158 | ||
159 | }; | |
160 | ||
161 | //-------------------------------------------------------- | |
162 | ||
163 | struct AliTRDrawHC | |
164 | { // hc struct | |
165 | ||
166 | //tacklet words of given HC | |
167 | UInt_t fTrackletWords[MAX_TRACKLETS_PERHC]; // array to keep tracklet words [mj] | |
168 | Short_t fTrackletError; // tracklet error | |
169 | Short_t fNTracklets; // number of tracklet | |
170 | ||
171 | // header word 0 | |
172 | Int_t fSpecialRawV; // Raw data version | |
173 | Int_t fRawVMajor; // Raw data version | |
174 | Int_t fRawVMajorOpt; // Raw data version | |
175 | Int_t fRawVMinor; // Raw data version | |
176 | Int_t fNExtraWords; // N extra HC header words | |
177 | Int_t fDCSboard; // DCS board number | |
178 | Int_t fSM; // Super Module number | |
179 | Int_t fStack; // Stack number (some people might call it a chamber) | |
180 | Int_t fLayer; // Layer number (some people might call it a plane) | |
181 | Int_t fSide; // Side of HC | |
182 | ||
183 | // header word 1 | |
184 | Int_t fTimeBins; // N of t bins | |
185 | UInt_t fBunchCrossCounter; // Bunch crossing counter | |
186 | UInt_t fPreTriggerCounter; // Pre Trigger counter | |
187 | UInt_t fPreTriggerPhase; // Pre Trigger phase | |
188 | ||
189 | // error | |
190 | Int_t fH0Corrupted; // is hc header 0 corrupted | |
191 | Int_t fH1Corrupted; // is hc header 1 corrupted | |
192 | Int_t fCorrupted; // is hc data corrupted | |
193 | ||
194 | UInt_t *fPos[2]; //! position of the header words in buffer | |
195 | ||
196 | Int_t fDET; // filled while decoding | |
197 | Int_t fROC; // filled while decoding | |
198 | Int_t fRowMax; // filled while decoding | |
199 | Int_t fColMax; // filled while decoding | |
200 | ||
201 | // hc data | |
202 | Int_t fMCMmax; // number of mcm found | |
203 | AliTRDrawMCM fMCMs[TRD_MAX_MCM]; // 4 ROBS 16 each | |
204 | ||
205 | AliTRDrawHC() | |
206 | : fTrackletWords() //[mj] | |
207 | , fTrackletError(0) | |
208 | , fNTracklets(0) | |
209 | , fSpecialRawV(0) | |
210 | , fRawVMajor(0) | |
211 | , fRawVMajorOpt(0) | |
212 | , fRawVMinor(0) | |
213 | , fNExtraWords(0) | |
214 | , fDCSboard(-1) | |
215 | , fSM(-1) | |
216 | , fStack(-1) | |
217 | , fLayer(-1) | |
218 | , fSide(-1) | |
219 | , fTimeBins(0) | |
220 | , fBunchCrossCounter(0) | |
221 | , fPreTriggerCounter(0) | |
222 | , fPreTriggerPhase(0) | |
223 | , fH0Corrupted(0) | |
224 | , fH1Corrupted(0) | |
225 | , fCorrupted(0) | |
226 | , fPos() | |
227 | , fDET(-1) | |
228 | , fROC(-1) | |
229 | , fRowMax(-1) | |
230 | , fColMax(-1) | |
231 | , fMCMmax(0) | |
232 | , fMCMs() | |
233 | { | |
234 | // default constructor hc info | |
235 | }; | |
236 | ||
237 | AliTRDrawHC(const AliTRDrawHC & p): | |
238 | fTrackletWords() //[mj] | |
239 | , fTrackletError(p.fTrackletError) | |
240 | , fNTracklets(p.fNTracklets) | |
241 | , fSpecialRawV(p.fSpecialRawV) | |
242 | , fRawVMajor(p.fRawVMajor) | |
243 | , fRawVMajorOpt(p.fRawVMajorOpt) | |
244 | , fRawVMinor(p.fRawVMinor) | |
245 | , fNExtraWords(p.fNExtraWords) | |
246 | , fDCSboard(p.fDCSboard) | |
247 | , fSM(p.fSM) | |
248 | , fStack(p.fStack) | |
249 | , fLayer(p.fLayer) | |
250 | , fSide(p.fSide) | |
251 | , fTimeBins(p.fTimeBins) | |
252 | , fBunchCrossCounter(p.fBunchCrossCounter) | |
253 | , fPreTriggerCounter(p.fPreTriggerCounter) | |
254 | , fPreTriggerPhase(p.fPreTriggerPhase) | |
255 | , fH0Corrupted(p.fH0Corrupted) | |
256 | , fH1Corrupted(p.fH1Corrupted) | |
257 | , fCorrupted(p.fCorrupted) | |
258 | , fPos() | |
259 | , fDET(p.fDET) | |
260 | , fROC(p.fROC) | |
261 | , fRowMax(p.fRowMax) | |
262 | , fColMax(p.fColMax) | |
263 | , fMCMmax(p.fMCMmax) | |
264 | , fMCMs() | |
265 | { | |
266 | // copy constructor | |
267 | }; | |
268 | ||
269 | AliTRDrawHC &operator=(const AliTRDrawHC &) | |
270 | { | |
271 | // assignment operator | |
272 | // not implemented | |
273 | return *this; | |
274 | }; | |
275 | ||
276 | }; | |
277 | ||
278 | //-------------------------------------------------------- | |
279 | ||
280 | struct AliTRDrawStack | |
281 | { | |
282 | UInt_t fHeaderSize; // header size of the stack info | |
283 | Bool_t fLinksActive[12]; // data links active - 1 per half chamber | |
284 | Short_t fLinksDataType[12]; // 0 indicating real data for the front-end electronics | |
285 | Short_t fLinksMonitor[12]; // 0 indicating properly operating link | |
286 | Short_t fLinkMonitorError[12]; // record link monitor error | |
287 | Int_t fActiveLinks; // number of active links | |
288 | UInt_t *fPos; //! position in the buffer | |
289 | ||
290 | AliTRDrawHC fHalfChambers[12]; // 12 half chambers in a stack | |
291 | ||
292 | AliTRDrawStack() | |
293 | : fHeaderSize(0) | |
294 | , fLinksActive() | |
295 | , fLinksDataType() | |
296 | , fLinksMonitor() | |
297 | , fLinkMonitorError() | |
298 | , fActiveLinks(0) | |
299 | , fPos(0) | |
300 | , fHalfChambers() | |
301 | { | |
302 | // default constructor | |
303 | }; | |
304 | ||
305 | AliTRDrawStack(const AliTRDrawStack & p): | |
306 | fHeaderSize(p.fHeaderSize) | |
307 | , fLinksActive() | |
308 | , fLinksDataType() | |
309 | , fLinksMonitor() | |
310 | , fLinkMonitorError() | |
311 | , fActiveLinks(p.fActiveLinks) | |
312 | , fPos(p.fPos) | |
313 | , fHalfChambers() | |
314 | { | |
315 | // copy constructor | |
316 | }; | |
317 | ||
318 | AliTRDrawStack &operator=(const AliTRDrawStack &) | |
319 | { | |
320 | // assignment operator | |
321 | // not implemented | |
322 | return *this; | |
323 | }; | |
324 | ||
325 | }; | |
326 | ||
327 | //-------------------------------------------------------- | |
328 | ||
329 | struct AliTRDrawSM | |
330 | { | |
331 | UInt_t fHeaderSize; // size of the header in words | |
332 | Bool_t fTrackletEnable; // tracklet enable bit | |
333 | Bool_t fStackActive[5]; // map of active/expected stacks | |
334 | Int_t fActiveStacks; // number of active stacks | |
335 | Int_t fCorrupted; // is sm info corrupted | |
336 | Int_t fNexpectedHalfChambers; // number of half chambers to be read out in this sm | |
337 | Bool_t fClean; // true if everything went OK - false is some error occured | |
338 | UInt_t *fPos; // location of the sm info - should be the first word (after CDH if not DDL buffer) | |
339 | ||
340 | AliTRDrawStack fStacks[5]; | |
341 | ||
342 | AliTRDrawSM() | |
343 | : fHeaderSize(0) | |
344 | , fTrackletEnable(0) | |
345 | , fStackActive() | |
346 | , fActiveStacks(0) | |
347 | , fCorrupted(0) | |
348 | , fNexpectedHalfChambers(0) | |
349 | , fClean(kTRUE) | |
350 | , fPos(0) | |
351 | , fStacks() | |
352 | { | |
353 | // Default constructor | |
354 | }; | |
355 | ||
356 | AliTRDrawSM(const AliTRDrawSM & p): | |
357 | fHeaderSize(p.fHeaderSize) | |
358 | , fTrackletEnable(p.fTrackletEnable) | |
359 | , fStackActive() | |
360 | , fActiveStacks(p.fActiveStacks) | |
361 | , fCorrupted(p.fCorrupted) | |
362 | , fNexpectedHalfChambers(p.fNexpectedHalfChambers) | |
363 | , fClean(p.fClean) | |
364 | , fPos(p.fPos) | |
365 | , fStacks() | |
366 | { | |
367 | // copy constructor | |
368 | }; | |
369 | ||
370 | AliTRDrawSM &operator=(const AliTRDrawSM &) | |
371 | { | |
372 | // assignment operator | |
373 | // not implemented | |
374 | return *this; | |
375 | }; | |
376 | ||
377 | }; | |
378 | ||
379 | //-------------------------------------------------------- | |
380 | ||
381 | AliTRDrawStream(); | |
382 | AliTRDrawStream(AliRawReader *rawReader); | |
383 | virtual ~AliTRDrawStream(); | |
384 | ||
385 | //-------------------------------------------------------- | |
386 | ||
387 | virtual Bool_t Next(); // read the next data in the memory | |
388 | //virtual Int_t NextChamber(AliTRDdigitsManager *man); // read next chamber data in the momory | |
389 | virtual Int_t NextChamber(AliTRDdigitsManager *man, UInt_t **trackletContainer); // read next chamber data in the memory | |
390 | virtual Bool_t Init(); // initialize some internal variables | |
391 | ||
392 | Int_t NextBuffer(); // go and init next buffer if available - check the implementation file for return values | |
393 | ||
394 | Bool_t SetRawVersion(Int_t fraw); // set the raw version - used for backward compat. | |
395 | ||
396 | Bool_t IsCurrentPadShared() const {return fADC->fIsShared;} // is current pad shared between mcms | |
397 | void SetSharedPadReadout(Bool_t fv) {fSharedPadsOn = fv;} // set the flag on if the reader should return the shared pads | |
398 | ||
399 | Bool_t DecodeSM(void *buffer, UInt_t length); // decode a buffer | |
400 | Int_t DecodeSM(); // used with raw reader | |
401 | Int_t DecodeSM(AliRawReader *reader); // used with raw reader | |
402 | ||
403 | Bool_t SetReader(AliRawReader *reader); // set the raw reader to use | |
404 | ||
405 | // info from Supermodule Index Word | |
406 | Bool_t IsTrackletEnableBitSet() const {return fSM.fTrackletEnable;} // get status of tracklet enable bit | |
407 | Bool_t IsStackActive(Int_t is) const {return fSM.fStackActive[is];} // get status of stack enable bit | |
408 | Int_t GetNofActiveStacks() const {return fSM.fActiveStacks;} // get number of active stacks from stack mask | |
409 | UInt_t *GetGTUheaderWords() const {return fSM.fPos;} // get number of active stacks from stack mask | |
410 | ||
411 | // info from Stack Index Word | |
412 | Int_t GetNexpectedHalfChambers() const {return fSM.fNexpectedHalfChambers;} // get number of expected HC in a sm | |
413 | Int_t GetNofActiveLinksInStack(Int_t is) const {return fSM.fStacks[is].fActiveLinks;} // get number of active links in a stack | |
414 | Bool_t IsLinkActiveInStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinksActive[il];} // check whether the link is active | |
415 | ||
416 | // info from Stack Header Word | |
417 | Short_t GetLinkMonitorError(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinkMonitorError[il];} // get link monitor error | |
418 | ||
419 | // info from Tracklet Data | |
420 | Int_t GetTrackletErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fTrackletError;} | |
421 | Int_t GetNTracklets(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fNTracklets;} // get number of tracklets | |
422 | ||
423 | // info from HC Header Word | |
424 | Int_t GetSM(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSM;} | |
425 | Int_t GetLayer(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fLayer;} | |
426 | Int_t GetStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fStack;} | |
427 | Int_t GetSide(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSide;} | |
428 | Int_t GetH0ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH0Corrupted;} | |
429 | Int_t GetH1ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH1Corrupted;} | |
430 | Int_t GetNumberOfTimeBins(Int_t is, Int_t il) const { return fSM.fStacks[is].fHalfChambers[il].fTimeBins;} | |
431 | UInt_t *GetTrackletWords(Int_t is, Int_t il) { return fSM.fStacks[is].fHalfChambers[il].fTrackletWords;} | |
432 | ||
433 | // info from HC data | |
434 | Int_t GetHCErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fCorrupted;} | |
435 | Int_t GetHCMCMmax(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fMCMmax;} | |
436 | ||
437 | // from MCM Header Word | |
438 | // rob and mcm ordering | |
439 | // side 0(even link) - ROB: 0 2 4 6 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 | |
440 | // side 1( odd link) - ROB: 1 3 5 7 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3 | |
441 | Int_t GetMCM(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCM;} | |
442 | Int_t GetROB(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROB;} | |
443 | Int_t GetMCMhdErrorCode(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCMhdCorrupted;} | |
444 | Int_t GetMCMADCMaskErrorCode(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCmaskCorrupted;} | |
445 | Int_t GetEventNumber(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fEvCounter;} | |
446 | Int_t GetADCcount(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCcount;} | |
447 | ||
448 | // info from MCM data words | |
449 | Int_t GetMCMErrorCode(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fCorrupted;} // get MCM data error code | |
450 | Int_t GetADCErrorCode(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCorrupted;} // get ADC error code | |
451 | Int_t GetADCnumber(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fADCnumber;} // get ADC error code | |
452 | ||
453 | Int_t GetRow(Int_t stack, Int_t link, Int_t mcm) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROW;} // get current row number | |
454 | Int_t GetCol(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCOL;} // get current column number | |
455 | ||
456 | // info from ADC data words | |
457 | Int_t *GetSignalDirect(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fSignals;} | |
458 | ||
459 | ||
460 | // from here, only works with returning ADC channel pointer using Next() | |
461 | UInt_t *GetTrackletWords() const { return fHC->fTrackletWords;} // return tracklet words pointer per hc [mj] | |
462 | Int_t GetTrackletErrorCode() const {return fHC ? fHC->fTrackletError : -1;} // get tracklet error code | |
463 | Int_t GetNTracklets() const {return fHC ? fHC->fNTracklets : -1;} // get number of tracklets | |
464 | ||
465 | Int_t GetSpecialRawVersion() const {return fHC ? fHC->fSpecialRawV : -1;} // return special raw version | |
466 | Int_t GetMajorRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // major raw version getter | |
467 | Int_t GetRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // compatibility see funtion above | |
468 | Int_t GetMinorRawVersion() const {return fHC ? fHC->fRawVMinor : -1;} // minor raw version | |
469 | ||
470 | Int_t GetSM() const {return fHC ? fHC->fSM : -1;} // SM Position of CURRENT half chamber in full TRD | |
471 | Int_t GetLayer() const {return fHC ? fHC->fLayer : -1;} // Layer Position of CURRENT half chamber in full TRD | |
472 | Int_t GetStack() const {return fHC ? fHC->fStack : -1;} // Stack Position of CURRENT half chamber in full TRD | |
473 | Int_t GetSide() const {return fHC ? fHC->fSide : -1;} // get side | |
474 | Int_t GetDCS() const { return fHC ? fHC->fDCSboard : -1;} // DCS board number read from data (HC header) | |
475 | Int_t GetROC() const { return fHC ? fHC->fROC : -1;} // ROB Position of CURRENT half chamber in full TRD | |
476 | Int_t GetNumberOfTimeBins() const { return fHC ? fHC->fTimeBins : 0;} // Get Ntime bins | |
477 | UInt_t GetBunchCrossCounter() const {return fHC ? fHC->fBunchCrossCounter : 0;} // get bunch cross counter | |
478 | UInt_t GetPreTriggerCounter() const {return fHC ? fHC->fPreTriggerCounter : 0;} // get pre trigger info | |
479 | UInt_t GetPreTriggerPhase() const {return fHC ? fHC->fPreTriggerPhase : 0;} // get trigger phase | |
480 | ||
481 | Int_t GetRow() const {return fMCM ? fMCM->fROW : -1;} // get current row number | |
482 | Int_t GetCol() const {return fADC ? fADC->fCOL : -1;} // get current column number | |
483 | Int_t GetRowMax() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC | |
484 | Int_t GetColMax() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC | |
485 | // compatibility | |
486 | Int_t GetMaxRow() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC | |
487 | Int_t GetMaxCol() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC | |
488 | ||
489 | UInt_t GetHCword0() const {return fHC ? *fHC->fPos[0] : 0;} // get the HC word 0 | |
490 | UInt_t GetHCword1() const {return fHC ? *fHC->fPos[1] : 0;} // get the HC word 1 | |
491 | ||
492 | Int_t GetDET() const {return fHC ? fHC->fDET : -1;} // get current det number | |
493 | Int_t GetDet() const {return fHC ? fHC->fDET : -1;} // get current det number | |
494 | ||
495 | Int_t GetROB() const {return fMCM ? fMCM->fROB : -1;} // get current ROB number | |
496 | Int_t GetMCM() const {return fMCM ? fMCM->fMCM : -1;} // get current MCM number | |
497 | Int_t GetEventNumber() const { return fMCM->fEvCounter;} // MCM Event number and position of current MCM on TRD chamber | |
498 | ||
499 | Int_t GetADC() const { return fADC ? fADC->fADCnumber : -1;} // MCM ADC channel and Time Bin of word 1 | |
500 | Int_t GetTimeBin() const { return 0;} // MCM ADC channel and Time Bin of word 1 | |
501 | Int_t *GetSignals() const { return fADC ? fADC->fSignals : (Int_t *)fgEmptySignals;} // signals in the n-time bins from data word | |
502 | ||
503 | Int_t GetHCErrorCode() const {return fHC ? fHC->fCorrupted : -1;} // get HC error code | |
504 | Int_t GetH0ErrorCode() const {return fHC ? fHC->fH0Corrupted : -1;} // get HC header word0 error code | |
505 | Int_t GetH1ErrorCode() const {return fHC ? fHC->fH1Corrupted : -1;} // get HC header word1 error code | |
506 | Int_t GetMCMErrorCode() const {return fMCM ? fMCM->fCorrupted : -1;} // get MCM data error code | |
507 | Int_t GetADCErrorCode() const {return fADC ? fADC->fCorrupted : -1;} // get ADC data error code | |
508 | Int_t GetMCMhdErrorCode() const {return fMCM ? fMCM->fMCMhdCorrupted: -1;} // get MCM header word error code | |
509 | Int_t GetMCMADCMaskErrorCode() const {return fMCM ? fMCM->fADCmaskCorrupted: -1;} // get MCM adc mask error code | |
510 | ||
511 | UInt_t *GetSMstreamPosition() const {return fSM.fPos;} // get position of the SM index word in the buffer | |
512 | ||
513 | Bool_t IsSMbufferClean() const {return fSM.fClean;} // is data clean | |
514 | ||
515 | //---------------------------------------------------------- | |
516 | ||
517 | static void SetNoDebug() {fgDebugFlag = kFALSE;} // allow debug info | |
518 | static void EnableMemoryReset() {fgEnableMemoryReset = kTRUE;} // allow memory reset | |
519 | static void SetNoErrorWarning() {fgWarnError = kFALSE;} // disable warning and error info | |
520 | static void SetForceCleanDataOnly() {fgCleanDataOnly = kTRUE;} // clean data only | |
521 | static void AllowCorruptedData() {fgCleanDataOnly = kFALSE;} // accept corrupted data | |
522 | ||
523 | static void SetExtraWordsFix() {fgExtraSkip = kTRUE;} // extra skip of 24 32-bit words | |
524 | static void SetSkipCDH() {fgSkipCDH = kTRUE;} // skip of 8 32-bit words | |
525 | static void SetDumpHead(UInt_t iv) {fgDumpHead = iv;} | |
526 | static void DisableStackNumberChecker() {fgStackNumberChecker = kFALSE;} // set false to cleanroom data | |
527 | static void DisableStackLinkNumberChecker() {fgStackLinkNumberChecker = kFALSE;} | |
528 | static void DisableSkipData() {fgSkipData = kFALSE;} // keep reading next words even previous words were corrupted - debugging purpose | |
529 | static void SetDumpingEnable() {fDumpingEnable = kTRUE;} | |
530 | static void SetDumpingMCM(Int_t sm, Int_t stack, Int_t layer, Int_t rob, Int_t mcm) {fDumpingSM = sm; fDumpingStack = stack; fDumpingLayer = layer; fDumpingROB = rob; fDumpingMCM = mcm;} | |
531 | ||
532 | // this is a temporary solution! | |
533 | // baseline should come with the HC header word 2 (count from 0!) | |
534 | static void SetSubtractBaseline(Int_t baseline) {fgCommonAdditive = baseline;} | |
535 | Int_t GetCommonAdditive() const {return fgCommonAdditive;} // return the common additive | |
536 | ||
537 | //-------------------------------------------------------- | |
538 | // Decoding functions | |
539 | //-------------------------------------------------------- | |
540 | ||
541 | void DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const ; | |
542 | const char *DumpSMInfo(const struct AliTRDrawSM *sm); | |
543 | void DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const; | |
544 | void DecodeStackHeader(const UInt_t *word, struct AliTRDrawStack *st, Int_t iword) const; | |
545 | const char *DumpStackInfo(const struct AliTRDrawStack *st); | |
546 | Bool_t DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const; | |
547 | Bool_t DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const; | |
548 | const char *DumpHCinfoH0(const struct AliTRDrawHC *hc); | |
549 | const char *DumpHCinfoH1(const struct AliTRDrawHC *hc); | |
550 | void DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const; | |
551 | UInt_t GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const; | |
552 | void DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const; | |
553 | void MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const; | |
554 | const char *DumpMCMinfo(const struct AliTRDrawMCM *mcm); | |
555 | const char *DumpMCMadcMask(const struct AliTRDrawMCM *mcm); | |
556 | ||
557 | ||
558 | protected: | |
559 | ||
560 | Bool_t InitBuffer(void *buffer, UInt_t length); // init the buffer - called by DecodeSM(void*, UInt_t) | |
561 | Bool_t DumpWords(UInt_t *px, UInt_t iw, UInt_t marker = 0); // dump some words onto the screen | |
562 | ||
563 | void SwapOnEndian(); // swap if endian is BIG | |
564 | Bool_t SkipWords(UInt_t iw); // skip number of words | |
565 | Bool_t DecodeGTUheader(); // decode data in GTU header | |
566 | Bool_t DecodeTracklets(); // decode tracklets | |
567 | Bool_t DecodeHC(); // decode data in HC | |
568 | ||
569 | Bool_t DecodeADC(); // decode 10 ADC words | |
570 | ||
571 | Bool_t DecodeHCheader(); // decode HC header | |
572 | Bool_t SeekEndOfData(); // go to next end of raw data marker (actually 1 word after) | |
573 | Bool_t SkipMCMdata(UInt_t iw); // skip this mcm data due to mcm header corruption | |
574 | Bool_t SeekNextMCMheader(); // go to next mcm header | |
575 | Bool_t DecodeMCMheader(); // decode mcm header | |
576 | ||
577 | Bool_t IsRowValid(); // check if row within the range | |
578 | Bool_t IsHCheaderOK(); // check if current hc header data make sense | |
579 | Bool_t IsMCMheaderOK(); // check if current mcm header data make sense | |
580 | ||
581 | void ResetCounters(); // reset some counters | |
582 | void ResetIterators(); // needed for Next() | |
583 | void ResetPerSM(); // reset every SM | |
584 | void ResetPerStack(); // reset every Stack | |
585 | void ResetPerHC(); // reset every HC | |
586 | void ResetPerMCM(); // reset every MCM | |
587 | void ResetPerADC(); // reset every ADC | |
588 | void ResetMemory(); // reset all data members | |
589 | ||
590 | AliTRDrawStream(const AliTRDrawStream& st); | |
591 | AliTRDrawStream &operator=(const AliTRDrawStream &); | |
592 | ||
593 | // ----------------- DATA MEMBERS START | |
594 | ||
595 | struct AliTRDrawSM fSM; // one SM per buffer | |
596 | struct AliTRDrawStack *fStack; //! pointer to the current stack | |
597 | struct AliTRDrawHC *fHC; //! current HC | |
598 | struct AliTRDrawMCM *fMCM; //! current MCM | |
599 | struct AliTRDrawADC *fADC; //! current ADC | |
600 | ||
601 | UInt_t *fpPos; // current position in the buffer | |
602 | UInt_t *fpBegin; // begin - pointer to the buffer word 0 | |
603 | UInt_t *fpEnd; // end of the buffer | |
604 | ||
605 | UInt_t fWordLength; // length of the buffer in 32bit words | |
606 | ||
607 | Int_t fStackNumber; // current stack number | |
608 | Int_t fStackLinkNumber; // current link in the stack | |
609 | ||
610 | Int_t fhcMCMcounter; // mcm counter inside single hc - used in Next() | |
611 | Int_t fmcmADCcounter; // adc counrer inside single adc - used in Next() | |
612 | ||
613 | Int_t fLinkTrackletCounter; // count the tracklets in the current HC | |
614 | Int_t fEndOfTrackletCount; // count link by link (hc by hc) used for debug | |
615 | Int_t fNWordsCounter; // counts words of given hc having link monitor error | |
616 | ||
617 | UInt_t fMaskADCword; // temp mask when decoding adcs | |
618 | UInt_t fTbinADC; // temp adc | |
619 | Int_t fDecodedADCs; // counter of decoded adcs [mj] do we need? | |
620 | ||
621 | UInt_t fEventCounter; // stores the valid/current MCM event counter | |
622 | UInt_t fLastEventCounter; // last known event counter of MCM | |
623 | ||
624 | Bool_t fSharedPadsOn; // do we want to output shared pads - default is off | |
625 | Int_t fMaxADCgeom; // maximum ADC channels per mcm | |
626 | ||
627 | Bool_t fBufferRead; | |
628 | ||
629 | AliTRDgeometry *fGeometry; //! TRD geometry | |
630 | AliRawReader *fRawReader; //! raw reader | |
631 | ||
632 | AliTRDfeeParam *fTRDfeeParam; // pointer to the fee params | |
633 | ||
634 | // STATIC | |
635 | ||
636 | static Bool_t fgExtraSkip; // whether we should skip the leading 24 words | |
637 | static Bool_t fgSkipCDH; // whether we should skip CDH (8 words) | |
638 | static Bool_t fgWarnError; // no errors no warnings | |
639 | static Bool_t fgCleanDataOnly; // release only clean events = no errors | |
640 | static Bool_t fgDebugFlag; // allow debugging info | |
641 | static Bool_t fgEnableMemoryReset; // allow memory reset | |
642 | static Bool_t fgStackNumberChecker; // decide if we check stack number insanity - set false to cleanroom data | |
643 | static Bool_t fgStackLinkNumberChecker; // decide if we check stack link number insanity - debuging purpose | |
644 | static Bool_t fgSkipData; // decide if we skip corrupted data of given HC | |
645 | static UInt_t fgDumpHead; // number of words to dump (from the start of the buffer) on each Init | |
646 | static Int_t fgEmptySignals[30]; // empty signals in case of ADC pointer = NULL | |
647 | static Short_t fgMCMordering[16]; // mcm number odering for mcm header corruption check | |
648 | static Short_t fgROBordering[16]; // mcm number odering for mcm header corruption check | |
649 | static Int_t fgLastHC; | |
650 | static Int_t fgLastROB; | |
651 | static Int_t fgLastIndex; | |
652 | ||
653 | static Bool_t fDumpingEnable; | |
654 | ||
655 | static Int_t fDumpingSM; | |
656 | static Int_t fDumpingStack; | |
657 | static Int_t fDumpingLayer; | |
658 | static Int_t fDumpingROB; | |
659 | static Int_t fDumpingMCM; | |
660 | ||
661 | // this is a temporary solution! | |
662 | // baseline should come with the HC header word 2 (count from 0!) | |
663 | static Int_t fgCommonAdditive; // common additive - should be decoded! from HC word2 | |
664 | ||
665 | // ----------------- DATA MEMBERS STOP | |
666 | ||
667 | enum ETRDzRawStreamError | |
668 | { | |
669 | kDecodeStackInfo = 1 // | |
670 | , kMissingData = 2 // | |
671 | , kLinkDataMissing = 3 // | |
672 | , kHCdataMissing = 4 // | |
673 | , kTrackletOverflow = 5 // | |
674 | , kEOTrackeltsMissing = 6 // | |
675 | , kWrongPadrow = 7 // | |
676 | , kMCMheaderCorrupted = 8 // | |
677 | , kWrongMCMorROB = 9 // | |
678 | , kMCMeventMissmatch = 10 // | |
679 | , kMCMADCMaskMissing = 11 // | |
680 | , kHCHeaderCorrupt = 12 // | |
681 | , kHCHeaderWrongStack = 13 // | |
682 | , kHCHeaderWrongLayer = 14 // | |
683 | , kHCHeaderWrongSide = 15 // | |
684 | , kHCHeaderWrongSM = 16 // | |
685 | , kHCHeaderWrongDet = 17 // | |
686 | , kHCHeaderWrongROC = 18 // | |
687 | , kHCWordMissing = 19 // | |
688 | , kMCMdataMissing = 20 // | |
689 | , kMCMoverflow = 21 // | |
690 | , kADCdataMissing = 22 // | |
691 | , kADCmaskMissmatch = 23 // | |
692 | , kWrongPadcolumn = 24 // | |
693 | }; | |
694 | ||
695 | ClassDef(AliTRDrawStream, 0) | |
696 | }; //clas def end | |
697 | ||
698 | #endif |