]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONRawStreamTrackerHP.h
New raw-reader class which deals with events taken from shared memory via the DATE...
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTrackerHP.h
CommitLineData
e3a2b9c9 1#ifndef ALIMUONRAWSTREAMTRACKERHP_H
2#define ALIMUONRAWSTREAMTRACKERHP_H
3/* This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id$*/
8
9///
10/// \file AliMUONRawStreamTrackerHP.h
11/// \author Artur Szostak <artursz@iafrica.com>
12/// \date 29-11-2007
13/// \brief Declaration of the high performance decoder for muon trigger chamber raw streams.
14///
15
16#include "AliMUONVRawStreamTracker.h"
17#include "AliMUONTrackerDDLDecoder.h"
18
19class AliMUONRawStreamTrackerHP : public AliMUONVRawStreamTracker
20{
21public:
8a0dae7c 22 class AliDspHeader;
23 class AliBusPatch;
e3a2b9c9 24
25 /// Default constructor.
26 AliMUONRawStreamTrackerHP();
27
28 /// Constructor for setting the raw reader.
29 AliMUONRawStreamTrackerHP(AliRawReader* rawReader);
30
31 /// Default destructor.
32 virtual ~AliMUONRawStreamTrackerHP();
33
34 // The following public methods are all inherited from AliMUONVRawStreamTracker:
35
36 /// Initialize iterator
37 virtual void First();
38
39 /// DDL iterator
40 virtual Bool_t NextDDL();
41
42 /// Whether the iteration is finished or not
43 virtual Bool_t IsDone() const;
44
45 /// Nothing is actually done in the AddErrorMessage method because we log
46 /// the error messages as we find them in AliDecoderEventHandler::OnError().
8a0dae7c 47 virtual void AddErrorMessage() { };
e3a2b9c9 48
49 /// Advance one step in the iteration. Returns false if finished.
50 virtual Bool_t Next(Int_t& busPatchId,
51 UShort_t& manuId, UChar_t& manuChannel,
52 UShort_t& adc);
53
54 /// Returns the next batch of decoded channel data.
29ee96d8 55 const AliBusPatch* Next();
e3a2b9c9 56
57 /// Return maximum number of blocks per DDL allowed.
58 virtual Int_t GetMaxBlock() const { return (Int_t) fDecoder.MaxBlocks(); }
59 /// Return maximum number of Dsp per block allowed.
60 virtual Int_t GetMaxDsp() const { return (Int_t) fDecoder.MaxDSPs(); }
61 /// Return maximum number of Buspatch per Dsp allowed.
62 virtual Int_t GetMaxBus() const { return (Int_t) fDecoder.MaxBusPatches(); }
63
64 /// Set maximum number of blocks per DDL allowed.
8a0dae7c 65 virtual void SetMaxBlock(Int_t blk);
e3a2b9c9 66 /// Set maximum number of Dsp per block allowed.
8a0dae7c 67 virtual void SetMaxDsp(Int_t dsp);
e3a2b9c9 68 /// Set maximum number of Buspatch per Dsp allowed.
8a0dae7c 69 virtual void SetMaxBus(Int_t bus);
e3a2b9c9 70
71 /// Return number of the current DDL.
72 virtual Int_t GetDDL() const { return fDDL - 1; }
73
74 /// check error/Warning presence
75 virtual Bool_t IsErrorMessage() const { return fHadError; }
8a0dae7c 76
77 /// Get number of parity errors
78 Int_t GetParityErrors() const
79 {
80 return (Int_t) fDecoder.GetHandler().ParityErrorCount();
81 }
82
83 /// Get number of glitch errors
84 Int_t GetGlitchErrors() const
85 {
86 return (Int_t) fDecoder.GetHandler().GlitchErrorCount();
87 }
88
89 /// Get number of padding word errors
90 Int_t GetPaddingErrors() const
91 {
92 return (Int_t) fDecoder.GetHandler().PaddingErrorCount();
93 }
94
95 /// Set warnings flag to disable warnings on data errors.
96 void DisableWarnings() { fDecoder.GetHandler().Warnings(kFALSE); }
97 /// Set warnings flag to enable warnings on data errors.
98 void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); }
99
100 /// Returns the "try to recover from errors" flag.
101 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
102
103 /// Sets the "try to recover from errors" flag.
104 /// i.e. should the decoder try to recover from errors found in the
105 /// payload headers.
106 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
107
108 /// Light weight interface class to the block header data.
109 class AliBlockHeader
110 {
111 public:
112 /// Default constructor.
113 AliBlockHeader(
114 AliDspHeader* dspArray = NULL,
115 const AliMUONBlockHeaderStruct* header = NULL
116 )
117 : fNext(NULL), fDspCount(0), fFirstDsp(dspArray), fHeader(header)
118 {
119 }
120
121 /// Implement shallow copying in the copy constructor.
122 AliBlockHeader(const AliBlockHeader& o) :
123 fNext(o.fNext), fDspCount(o.fDspCount), fFirstDsp(o.fFirstDsp), fHeader(o.fHeader)
124 {
125 }
126
127 /// Implement shallow copying in the assignment operator.
128 AliBlockHeader& operator = (const AliBlockHeader& object)
129 {
130 memcpy(this, &object, sizeof(AliBlockHeader));
131 return *this;
132 }
133
134 /// Default destructor.
135 ~AliBlockHeader() {};
136
137 /// Return data key word for CRT header
138 Int_t GetDataKey() const {assert(fHeader != NULL); return fHeader->fDataKey;}
139 /// Return total length of block structure (w/o padding word)
140 Int_t GetTotalLength() const {assert(fHeader != NULL); return fHeader->fTotalLength;}
141 /// Return length of raw data
142 Int_t GetLength() const {assert(fHeader != NULL); return fHeader->fLength;}
143 /// Return Dsp id
144 Int_t GetDspId() const {assert(fHeader != NULL); return fHeader->fDSPId;}
145 /// Return L0 trigger word
146 Int_t GetL0Trigger() const {assert(fHeader != NULL); return fHeader->fL0Trigger;}
147 /// Return Bunch Crossing for mini-event id (see TDR chapter 8)
148 Int_t GetMiniEventId() const {assert(fHeader != NULL); return fHeader->fMiniEventId;}
149 /// Return Event Id in bunch crossing
150 Int_t GetEventId1() const {assert(fHeader != NULL); return fHeader->fEventId1;}
151 /// Return Event Id in orbit number
152 Int_t GetEventId2() const {assert(fHeader != NULL); return fHeader->fEventId2;}
153
154 /// Return the header's raw data.
29ee96d8 155 const AliMUONBlockHeaderStruct* GetHeader() const {return fHeader;}
8a0dae7c 156
157 /// Return the next block header.
158 const AliBlockHeader* Next() const { return fNext; }
159
160 /// Returns the first AliDspHeader class in this block.
161 const AliDspHeader* GetFirstDspHeader() const { return fFirstDsp; }
162
163 /// Returns the number of DSPs within this block.
164 UInt_t GetDspCount() const { return fDspCount; }
165
166 /// Return the i'th DSP in this block.
167 const AliDspHeader* GetDspHeader(UInt_t i) const
168 {
169 return i < fDspCount ? GetFirstDspHeader() + i : NULL;
170 }
171
172 /// Sets the next block header.
173 void SetNext(const AliBlockHeader* next) { fNext = next; }
174
175 /// Increments the DSP count.
176 void IncDspCount() { fDspCount++; };
177
178 /// Print the contents of the header to screen.
179 void Print() const;
180
181 private:
182
183 const AliBlockHeader* fNext; ///< Pointer to next block.
184 UInt_t fDspCount; ///< The number of AliDspHeader objects found in the array pointed to by fFirstDsp.
185 const AliDspHeader* fFirstDsp; ///< The first DSP associated with this block.
186 const AliMUONBlockHeaderStruct* fHeader; ///< Pointer to header in DDL payload.
187 };
188
189 /// Light weight interface class to the DSP header data.
190 class AliDspHeader
191 {
192 public:
193 /// Default constructor.
194 AliDspHeader(
195 const AliBlockHeader* block = NULL,
196 const AliBusPatch* busPatchArray = NULL,
197 const AliMUONDSPHeaderStruct* header = NULL
198 ) :
199 fBlock(block), fNext(NULL), fBusPatchCount(0),
200 fFirstBusPatch(busPatchArray), fHeader(header)
201 {
202 }
203
204 /// Implement shallow copying in the copy constructor.
205 AliDspHeader(const AliDspHeader& o) :
206 fBlock(o.fBlock), fNext(o.fNext), fBusPatchCount(o.fBusPatchCount),
207 fFirstBusPatch(o.fFirstBusPatch), fHeader(o.fHeader)
208 {
209 }
210
211 /// Implement shallow copying in the assignment operator.
212 AliDspHeader& operator = (const AliDspHeader& object)
213 {
214 memcpy(this, &object, sizeof(AliDspHeader));
215 return *this;
216 }
217
218 /// Default destructor.
219 ~AliDspHeader() {};
220
221 /// Return Data key word for FRT header
222 Int_t GetDataKey() const {assert(fHeader != NULL); return fHeader->fDataKey;}
223 /// Return total length of block structure
224 Int_t GetTotalLength() const {assert(fHeader != NULL); return fHeader->fTotalLength;}
225 /// Return length of raw data
226 Int_t GetLength() const {assert(fHeader != NULL); return fHeader->fLength;}
227 /// Return Dsp id
228 Int_t GetDspId() const {assert(fHeader != NULL); return fHeader->fDSPId;}
229 /// Return L1 accept in Block Structure (CRT)
230 Int_t GetBlkL1ATrigger() const {assert(fHeader != NULL); return fHeader->fBlkL1ATrigger;}
231 /// Return Mini Event Id in bunch crossing
232 Int_t GetMiniEventId() const {assert(fHeader != NULL); return fHeader->fMiniEventId;}
233 /// Return Number of L1 accept in DSP Structure (FRT)
234 Int_t GetL1ATrigger() const {assert(fHeader != NULL); return fHeader->fL1ATrigger;}
235 /// Return Number of L1 reject in DSP Structure (FRT)
236 Int_t GetL1RTrigger() const {assert(fHeader != NULL); return fHeader->fL1RTrigger;}
237 /// Return padding dummy word for 64 bits transfer
238 UInt_t GetPaddingWord() const {assert(fHeader != NULL); return fHeader->fPaddingWord;}
239 /// Return Error word
240 Int_t GetErrorWord() const {assert(fHeader != NULL); return fHeader->fErrorWord;}
241
242 /// Return raw data of header
29ee96d8 243 const AliMUONDSPHeaderStruct* GetHeader() const { return fHeader; }
8a0dae7c 244
245 /// Return the parent block header.
246 const AliBlockHeader* GetBlockHeader() const { return fBlock; }
247
248 /// Return the next DSP header.
249 const AliDspHeader* Next() const { return fNext; }
250
251 /// Returns the first AliBusPatch class in this DSP.
252 const AliBusPatch* GetFirstBusPatch() const { return fFirstBusPatch; }
253
254 /// Returns the number of bus patches within this DSP.
255 UInt_t GetBusPatchCount() const { return fBusPatchCount; }
256
257 /// Return the i'th bus patch in this DSP.
258 const AliBusPatch* GetBusPatch(UInt_t i) const
259 {
260 return i < fBusPatchCount ? GetFirstBusPatch() + i : NULL;
261 }
262
263 /// Sets the next DSP header.
264 void SetNext(const AliDspHeader* next) { fNext = next; }
265
266 /// Increments the bus patch count.
267 void IncBusPatchCount() { fBusPatchCount++; };
268
269 /// Print the contents of the header to screen.
270 void Print() const;
271
272 private:
273
274 const AliBlockHeader* fBlock; ///< Pointer to parent block structure.
275 const AliDspHeader* fNext; ///< Pointer to next DSP.
276 UInt_t fBusPatchCount; ///< The number of AliDspHeader objects found in the array pointed to by fFirstBusPatch
277 const AliBusPatch* fFirstBusPatch; ///< The first bus patch of this DSP.
278 const AliMUONDSPHeaderStruct* fHeader; ///< Pointer to header in DDL payload.
279 };
280
281 /// Light weight interface class to the bus patch data.
282 class AliBusPatch
283 {
284 public:
285 /// Default constructor.
286 AliBusPatch(
287 const AliDspHeader* dsp = NULL,
288 const AliMUONBusPatchHeaderStruct* header = NULL,
289 const UInt_t* data = NULL,
290 const Bool_t* parityOk = NULL
291 ) :
292 fDSP(dsp),
293 fNext(NULL),
294 fHeader(header),
295 fData(data),
296 fParityOk(parityOk)
297 {
298 }
299
300 /// Implement shallow copying in the copy constructor.
301 AliBusPatch(const AliBusPatch& o) :
302 fDSP(o.fDSP),
303 fNext(o.fNext),
304 fHeader(o.fHeader),
305 fData(o.fData),
306 fParityOk(o.fParityOk)
307 {
308 }
309
310 /// Implement shallow copying in the assignment operator.
311 AliBusPatch& operator = (const AliBusPatch& object)
312 {
313 memcpy(this, &object, sizeof(AliBusPatch));
314 return *this;
315 }
316
317 /// Default destructor.
318 ~AliBusPatch() {};
319
320 /// Return Data key word for bus patch header.
321 Int_t GetDataKey() const {assert(fHeader != NULL); return fHeader->fDataKey;}
322 /// Return total length of buspatch structure
323 Int_t GetTotalLength() const {assert(fHeader != NULL); return fHeader->fTotalLength;}
324 /// Return length of raw data
325 Int_t GetLength() const {assert(fHeader != NULL); return fHeader->fLength;}
326 /// Return bus patch id
327 Int_t GetBusPatchId() const {assert(fHeader != NULL); return fHeader->fBusPatchId;}
328
329 /// Return raw data of header
29ee96d8 330 const AliMUONBusPatchHeaderStruct* GetHeader() const {return fHeader;}
8a0dae7c 331 /// Return raw digit data
332 const UInt_t* GetData() const {return fData;}
333 /// Returns the number of raw data words within this bus patch.
334 UInt_t GetDataCount() const { return (UInt_t)GetLength(); }
335
336 /// Returns the parity bit of the n'th raw data word.
337 Char_t GetParity(UInt_t n) const
338 {
29ee96d8 339 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 340 return (Char_t)(fData[n] >> 31) & 0x1;
341 }
342
343 /// Returns the MANU ID of the n'th raw data word.
344 UShort_t GetManuId(UInt_t n) const
345 {
29ee96d8 346 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 347 return (UShort_t)(fData[n] >> 18) & 0x7FF;
348 }
349
350 /// Returns the channel ID of the n'th raw data word.
351 UChar_t GetChannelId(UInt_t n) const
352 {
29ee96d8 353 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 354 return (Char_t)(fData[n] >> 12) & 0x3F;
355 }
356
357 /// Returns the charge/signal of the n'th raw data word.
358 UShort_t GetCharge(UInt_t n) const
359 {
29ee96d8 360 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 361 return (UShort_t)(fData[n] & 0xFFF);
362 }
363
364 /// Returns the n'th raw data word.
365 UInt_t GetData(UInt_t n) const
366 {
29ee96d8 367 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 368 return fData[n];
369 }
370
371 /// Returns kTRUE if the parity of the n'th raw data word is OK
372 /// and kFALSE otherwise.
373 Bool_t IsParityOk(UInt_t n) const
374 {
29ee96d8 375 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 376 return fParityOk[n];
377 }
378
379 /// Unpacks and returns the fields of the n'th raw data word. kTRUE
380 /// is returned if the data word's parity was OK and kFALSE otherwise.
381 Bool_t GetData(UInt_t n, UShort_t& manuId, UChar_t& channelId, UShort_t& adc) const
382 {
29ee96d8 383 assert( fHeader != NULL && n < fHeader->fLength );
8a0dae7c 384 AliMUONTrackerDDLDecoderEventHandler::UnpackADC(fData[n], manuId, channelId, adc);
385 return fParityOk[n];
386 }
387
388 /// Return the parent block header.
389 const AliDspHeader* GetDspHeader() const { return fDSP; }
390
391 /// Return the next bus patch header.
392 const AliBusPatch* Next() const { return fNext; }
393
394 /// Sets the next bus patch.
395 void SetNext(const AliBusPatch* next) { fNext = next; }
396
397 /// Print the contents of the bus patch to screen.
398 void Print(const Option_t* opt = "") const;
399
400 private:
401
402 const AliDspHeader* fDSP; ///< The DSP this bus patch belongs to.
403 const AliBusPatch* fNext; ///< Next bus patch object in the DSP.
404 const AliMUONBusPatchHeaderStruct* fHeader; ///< Pointer to bus patch in DDL payload.
405 const UInt_t* fData; ///< Pointer to the bus patch data.
406 const Bool_t* fParityOk; ///< Array of flags indicating if the parity of the given data word in fData is good or not.
407 };
408
409 /// Return the number of blocks in the DDL payload.
410 UInt_t GetBlockCount() const
411 {
412 return fDecoder.GetHandler().BlockCount();
413 }
414
415 /// Return the first block header.
416 const AliBlockHeader* GetFirstBlockHeader() const
417 {
418 return fDecoder.GetHandler().BlockHeader(0);
419 }
420
421 /// Return the i'th block header or NULL if not found.
422 const AliBlockHeader* GetBlockHeader(UInt_t i) const
423 {
424 return fDecoder.GetHandler().BlockHeader(i);
425 }
426
427 /// Returns the number of DSPs for the given block number.
428 UInt_t GetDspCount(UInt_t block) const
429 {
430 const AliBlockHeader* b = GetBlockHeader(block);
431 return b != NULL ? b->GetDspCount() : 0;
432 }
433
434 /// Returns the i'th DSP header for the given block number or NULL if not found.
435 const AliDspHeader* GetDspHeader(UInt_t block, UInt_t i) const
436 {
437 const AliBlockHeader* b = GetBlockHeader(block);
438 return b != NULL ? b->GetDspHeader(i) : NULL;
439 }
440
441 /// Returns the number of bus patches for the given block and dsp number.
442 UInt_t GetBusPatchCount(UInt_t block, UInt_t dsp) const
443 {
444 const AliDspHeader* d = GetDspHeader(block, dsp);
445 return d != NULL ? d->GetBusPatchCount() : 0;
446 }
447
448 /// Returns the i'th bus patch for the given block and dsp.
449 const AliBusPatch* GetBusPatch(UInt_t block, UInt_t dsp, UInt_t i) const
450 {
451 const AliDspHeader* d = GetDspHeader(block, dsp);
452 return d != NULL ? d->GetBusPatch(i) : NULL;
453 }
454
455 /// Returns the current bus patch being decoded or NULL if none found.
456 const AliBusPatch* CurrentBusPatch() const
457 {
458 return (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch()) ?
459 fCurrentBusPatch : NULL;
460 }
461
462 /// Returns the current DSP being decoded or NULL if none found.
463 const AliDspHeader* CurrentDspHeader() const
464 {
465 const AliBusPatch* busPatch = CurrentBusPatch();
466 return (busPatch != NULL) ? busPatch->GetDspHeader() : NULL;
467 }
468
469 /// Returns the current block header being decoded or NULL if none found.
470 const AliBlockHeader* CurrentBlockHeader() const
471 {
472 const AliDspHeader* dsp = CurrentDspHeader();
473 return (dsp != NULL) ? dsp->GetBlockHeader() : NULL;
474 }
e3a2b9c9 475
476private:
477
478 // Do not allow copying of this class.
479 /// Not implemented
480 AliMUONRawStreamTrackerHP(const AliMUONRawStreamTrackerHP& stream);
481 /// Not implemented
482 AliMUONRawStreamTrackerHP& operator = (const AliMUONRawStreamTrackerHP& stream);
483
484 /// This is the custom event handler (callback interface) class which
485 /// unpacks raw data words and fills an internal buffer with decoded digits
486 /// as they are decoded by the high performance decoder.
487 /// Any errors are logged to the parent AliMUONVRawStreamTracker, so one
488 /// must set this pointer appropriately before decoding and DDL payload.
489 class AliDecoderEventHandler : public AliMUONTrackerDDLDecoderEventHandler
490 {
491 public:
492
493 /// Default constructor.
494 AliDecoderEventHandler();
495 /// Default destructor.
496 virtual ~AliDecoderEventHandler();
497
8a0dae7c 498 /// Sets the internal arrays based on the maximum number of structures allowed.
499 void SetMaxStructs(UInt_t maxBlocks, UInt_t maxDsps, UInt_t maxBusPatches);
500
e3a2b9c9 501 /// Sets the raw stream object which should be the parent of this class.
502 void SetRawStream(AliMUONVRawStreamTracker* rawStream) { fRawStream = rawStream; }
503
8a0dae7c 504 /// Return the number of blocks found in the payload.
505 UInt_t BlockCount() const { return fBlockCount; };
e3a2b9c9 506
8a0dae7c 507 /// Return the i'th block structure.
508 const AliBlockHeader* BlockHeader(UInt_t i) const
509 {
510 return i < fBlockCount ? &fBlocks[i] : NULL;
511 }
512
513 /// Return the first bus patch decoded.
514 const AliBusPatch* FirstBusPatch() const { return fBusPatches; }
515
516 /// Returns the marker to the end of bus patches. i.e. one position past the last bus patch.
517 const AliBusPatch* EndOfBusPatch() const { return fEndOfBusPatches; }
518
519 /// Returns the number of parity errors found in the DDL.
520 UInt_t ParityErrorCount() const { return fParityErrors; }
521 /// Returns the number of glitch errors found in the DDL.
522 UInt_t GlitchErrorCount() const { return fGlitchErrors; }
523 /// Returns the number of padding errors found in the DDL.
524 UInt_t PaddingErrorCount() const { return fPaddingErrors; }
525
526 /// Returns the warnings flag.
527 Bool_t Warnings() const { return fWarnings; }
528 /// Sets the warnings flag.
529 void Warnings(Bool_t value) { fWarnings = value; }
e3a2b9c9 530
531 // The following methods are inherited from AliMUONTrackerDDLDecoderEventHandler:
532
533 /// New buffer handler.
534 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
8a0dae7c 535
536 /// End of buffer handler marks the end of bus patches.
537 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
538 {
539 fEndOfBusPatches = fCurrentBusPatch+1;
540 }
541
542 /// New block handler is called by the decoder whenever a new block
543 /// structure is found. We just mark the new block and increment the
544 /// internal counter.
29ee96d8 545 void OnNewBlock(const AliMUONBlockHeaderStruct* header, const void* /*data*/);
8a0dae7c 546
547 /// New DSP handler is called by the decoder whenever a new DSP
548 /// structure is found. We just mark the DSP and increment the
549 /// appropriate counters.
29ee96d8 550 void OnNewDSP(const AliMUONDSPHeaderStruct* header, const void* /*data*/);
e3a2b9c9 551
552 /// New bus patch handler.
8a0dae7c 553 /// This is called by the high performance decoder when a new bus patch
554 /// is found within the DDL payload.
29ee96d8 555 void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* header, const void* data);
e3a2b9c9 556
557 /// Raw data word handler.
8a0dae7c 558 void OnData(UInt_t /*data*/, bool parityError)
559 {
560 assert( fCurrentParityOkFlag < fParityOk + fMaxChannels );
561 *(++fCurrentParityOkFlag) = Bool_t(not parityError);
562 }
e3a2b9c9 563
564 /// Error handler.
565 void OnError(ErrorCode error, const void* location);
566
567 private:
568
569 // Do not allow copying of this class.
570 /// Not implemented
571 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
572 /// Not implemented
573 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
574
e3a2b9c9 575 AliMUONVRawStreamTracker* fRawStream; //!< Pointer to the parent raw stream object.
576 const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer.
8a0dae7c 577 UInt_t fBlockCount; //!< Number of blocks filled in fBlocks.
578 AliBlockHeader* fBlocks; //!< Array of blocks. [0..fMaxBlocks-1]
579 AliDspHeader* fDSPs; //!< Array of DSPs. [0..fMaxDsps*fMaxBlocks-1]
580 AliBusPatch* fBusPatches; //!< Array of bus patches. [0..fMaxBusPatches*fMaxDsps*fMaxBlocks-1]
581 AliBusPatch* fEndOfBusPatches; //!< Marks the last bus patch.
582 UInt_t fMaxChannels; //!< Maximum number of elements that can be stored in fParityOk.
583 Bool_t* fParityOk; //!< Array of flags for indicating if the parity is good for a raw data word.
584 AliBlockHeader* fCurrentBlock; //!< Current block in fBlocks.
585 AliDspHeader* fCurrentDSP; //!< Current DSP in fDSPs.
586 AliBusPatch* fCurrentBusPatch; //!< Current bus patch in fBusPatches.
587 Bool_t* fCurrentParityOkFlag; //!< Current parity flag to be set in fParityOk.
588 UInt_t fParityErrors; //!< Number of parity errors found in DDL.
589 UInt_t fGlitchErrors; //!< Number of glitch errors found in DDL.
590 UInt_t fPaddingErrors; //!< Number of padding errors found in DDL.
591 Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors.
e3a2b9c9 592 };
593
594 AliMUONTrackerDDLDecoder<AliDecoderEventHandler> fDecoder; //!< The decoder for the DDL payload.
595 Int_t fDDL; //!< The current DDL number being handled.
e3a2b9c9 596 Int_t fBufferSize; //!< This is the buffer size in bytes of fBuffer.
597 UChar_t* fBuffer; //!< This is the buffer in which we store the DDL payload read from AliRawReader.
8a0dae7c 598 const AliBusPatch* fCurrentBusPatch; //!< The current data word to return by Next().
599 const UInt_t* fCurrentData; //!< The current data word to return by Next().
600 const UInt_t* fEndOfData; //!< The last data word in the current bus patch.
e3a2b9c9 601 Bool_t fHadError; //!< Flag indicating if there was a decoding error or not.
8a0dae7c 602 Bool_t fDone; //!< Flag indicating if the iteration is done or not.
e3a2b9c9 603
604 ClassDef(AliMUONRawStreamTrackerHP, 0) // High performance decoder for reading MUON raw digits from tracking chamber DDL data.
605};
606
29ee96d8 607////////////////////////////////////////////////////////////////////////////////
608
609inline const AliMUONRawStreamTrackerHP::AliBusPatch* AliMUONRawStreamTrackerHP::Next()
610{
611 /// Returns the next batch of decoded channel data.
612 do {
613 if (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
614 return fCurrentBusPatch++;
615 } while (NextDDL());
616 return NULL;
617}
618
619inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewBlock(
620 const AliMUONBlockHeaderStruct* header, const void* /*data*/
621 )
622{
623 /// New block handler is called by the decoder whenever a new block
624 /// structure is found. We just mark the new block and increment the
625 /// internal counter.
626
627 assert( header != NULL );
628 assert( fBlockCount < (UInt_t)fRawStream->GetMaxBlock() );
629 // Link the block unless it is the first one.
630 if (fBlockCount > 0) fCurrentBlock->SetNext(fCurrentBlock+1);
631 *(++fCurrentBlock) = AliBlockHeader(fCurrentDSP+1, header);
632 fBlockCount++;
633}
634
635inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewDSP(
636 const AliMUONDSPHeaderStruct* header, const void* /*data*/
637 )
638{
639 /// New DSP handler is called by the decoder whenever a new DSP
640 /// structure is found. We just mark the DSP and increment the
641 /// appropriate counters.
642
643 assert( header != NULL );
644 assert( fCurrentBlock->GetDspCount() < (UInt_t)fRawStream->GetMaxDsp() );
645 // Link the DSP unless it is the first one.
646 if (fCurrentBlock->GetDspCount() > 0) fCurrentDSP->SetNext(fCurrentDSP+1);
647 *(++fCurrentDSP) = AliDspHeader(fCurrentBlock, fCurrentBusPatch+1, header);
648 fCurrentBlock->IncDspCount();
649}
650
651inline void AliMUONRawStreamTrackerHP::AliDecoderEventHandler::OnNewBusPatch(
652 const AliMUONBusPatchHeaderStruct* header, const void* data
653 )
654{
655 /// New bus patch handler.
656 /// This is called by the high performance decoder when a new bus patch
657 /// is found within the DDL payload.
658
659 assert( header != NULL );
660 assert( data != NULL );
661 assert( fCurrentDSP->GetBusPatchCount() < (UInt_t)fRawStream->GetMaxBus() );
662 // Link the bus patch unless it is the first one.
663 if (fCurrentDSP->GetBusPatchCount() > 0) fCurrentBusPatch->SetNext(fCurrentBusPatch+1);
664 *(++fCurrentBusPatch) = AliBusPatch(
665 fCurrentDSP,
666 header,
667 reinterpret_cast<const UInt_t*>(data),
668 fCurrentParityOkFlag+1
669 );
670 fCurrentDSP->IncBusPatchCount();
671}
672
e3a2b9c9 673#endif // ALIMUONRAWSTREAMTRACKERHP_H
8a0dae7c 674