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