AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTrackerDDLDecoderEventHandler.h
Go to the documentation of this file.
1 #ifndef ALIMUONTRACKERDDLDECODEREVENTHANDLER_H
2 #define ALIMUONTRACKERDDLDECODEREVENTHANDLER_H
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project *
5  * All rights reserved. *
6  * *
7  * Primary Authors: *
8  * Artur Szostak <artursz@iafrica.com> *
9  * *
10  * Permission to use, copy, modify and distribute this software and its *
11  * documentation strictly for non-commercial purposes is hereby granted *
12  * without fee, provided that the above copyright notice appears in all *
13  * copies and that both the copyright notice and this permission notice *
14  * appear in the supporting documentation. The authors make no claims *
15  * about the suitability of this software for any purpose. It is *
16  * provided "as is" without express or implied warranty. *
17  **************************************************************************/
18 
19 /* $Id$ */
20 
28 
29 #include <cassert>
30 #include <ostream>
31 #include <Rtypes.h>
32 
33 
34 // We use C binding for the structures because C is more uniform with its application
35 // binary interface (ABI) between compilers.
36 extern "C"
37 {
38 
39 // The following structures are the headers found in the DDL payload from the
40 // muon tracking chambers. The specification is defined in ALICE-INT-2005-012
41 // (https://edms.cern.ch/file/591904/1/ALICE-INT-2005-012.pdf)
42 
45 {
46  UInt_t fDataKey;
47  UInt_t fTotalLength;
48  UInt_t fLength;
49  UInt_t fDSPId;
50  UInt_t fL0Trigger;
51  UInt_t fMiniEventId;
52  UInt_t fEventId1;
53  UInt_t fEventId2;
54 };
55 
58 {
59  UInt_t fDataKey;
60  UInt_t fTotalLength;
61  UInt_t fLength;
62  UInt_t fDSPId;
63  UInt_t fBlkL1ATrigger;
64  UInt_t fMiniEventId;
65  UInt_t fL1ATrigger;
66  UInt_t fL1RTrigger;
67  UInt_t fPaddingWord;
68  UInt_t fErrorWord;
69 };
70 
73 {
74  UInt_t fDataKey;
75  UInt_t fTotalLength;
76  UInt_t fLength;
77  UInt_t fBusPatchId;
78 };
79 
80 } // extern "C"
81 
82 
94 
96 {
97 public:
98 
102 
105  {
106  kNoError = 0,
107  // Offset our error codes to stay clear of any common codes in AliMUONRawStreamTracker:
118  kBadDSPKey = 20,
130  kTokenLost = 32,
131  // match up error codes with AliMUONRawStreamTracker:
135  };
136 
137  // The following methods should be overridden for specific processing to
138  // take place in your event handler.
139 
146  void OnNewBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/) {}
147 
156  void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/) {}
157 
166  void OnNewBlock(const AliMUONBlockHeaderStruct* /*header*/, const void* /*data*/) {}
167 
179  void OnEndOfBlock(const AliMUONBlockHeaderStruct* /*header*/, const void* /*data*/) {}
180 
191  void OnNewDSP(const AliMUONDSPHeaderStruct* /*header*/, const void* /*data*/) {}
192 
203  void OnEndOfDSP(const AliMUONDSPHeaderStruct* /*header*/, const void* /*data*/) {}
204 
216  void OnNewBusPatch(const AliMUONBusPatchHeaderStruct* /*header*/, const void* /*data*/) {}
217 
229  void OnEndOfBusPatch(const AliMUONBusPatchHeaderStruct* /*header*/, const void* /*data*/) {}
230 
239  void OnData(UInt_t /*data*/, bool /*parityError*/) {}
240 
254  void OnError(ErrorCode /*error*/, const void* /*location*/) {}
255 
263  static void UnpackADC(
264  UInt_t data,
265  UShort_t& manuId, UChar_t& channelId, UShort_t& adc
266  )
267  {
268  manuId = (UShort_t)(data >> 18) & 0x7FF;
269  channelId = (Char_t)(data >> 12) & 0x3F;
270  adc = (UShort_t)(data & 0xFFF);
271  }
272 
277  static const char* ErrorCodeToString(ErrorCode code);
278 
283  static const char* ErrorCodeToMessage(ErrorCode code);
284 };
285 
286 //_____________________________________________________________________________
287 
289 {
294 
295  switch (code)
296  {
297  case kNoError: return "kNoError";
298  case kBufferTooBig: return "kBufferTooBig";
299  case kTooManyBlocks: return "kTooManyBlocks";
300  case kTooManyDSPs: return "kTooManyDSPs";
301  case kTooManyBusPatches: return "kTooManyBusPatches";
302  case kNoBlockHeader: return "kNoBlockHeader";
303  case kBadBlockKey: return "kBadBlockKey";
304  case kBadBlockLength: return "kBadBlockLength";
305  case kBadBlockTotalLength: return "kBadBlockTotalLength";
306  case kBlockLengthMismatch: return "kBlockLengthMismatch";
307  case kNoDSPHeader: return "kNoDSPHeader";
308  case kBadDSPKey: return "kBadDSPKey";
309  case kBadDSPLength: return "kBadDSPLength";
310  case kBadDSPTotalLength: return "kBadDSPTotalLength";
311  case kDSPLengthMismatch: return "kDSPLengthMismatch";
312  case kNoBusPatchHeader: return "kNoBusPatchHeader";
313  case kBadBusPatchKey: return "kBadBusPatchKey";
314  case kBadBusPatchLength: return "kBadBusPatchLength";
315  case kBadBusPatchTotalLength: return "kBadBusPatchTotalLength";
316  case kBusPatchLengthMismatch: return "kBusPatchLengthMismatch";
317  case kNoDDLTrailerWords: return "kNoDDLTrailerWords";
318  case kTooFewDDLTrailerWords: return "kTooFewDDLTrailerWords";
319  case kUnknownDspError: return "kUnknownDspError";
320  case kTokenLost: return "kTokenLost";
321  case kGlitchFound: return "kGlitchFound";
322  case kBadPaddingWord: return "kBadPaddingWord";
323  case kParityError: return "kParityError";
324  default: return "INVALID";
325  }
326 }
327 
328 
330 {
335 
336  switch (code)
337  {
338  case kNoError:
339  return "Decoding was successful.";
340  case kBufferTooBig:
341  return "The DDL raw data is larger than indicated by the headers;"
342  " extra bytes are probably just garbage.";
343  case kTooManyBlocks:
344  return "Too many block structures found.";
345  case kTooManyDSPs:
346  return "Too many DSP structures found in the block.";
347  case kTooManyBusPatches:
348  return "Too many bus patch structures found in the DSP structure.";
349  case kNoBlockHeader:
350  return "Missing a block header.";
351  case kBadBlockKey:
352  return "The block header key word does not contain the correct value.";
353  case kBadBlockLength:
354  return "The block length field points past the end of the raw data size.";
356  return "The total block length field points past the end of the"
357  " raw data size.";
359  return "The block length and total length fields do not correspond."
360  " One or both of these values is incorrect.";
361  case kNoDSPHeader:
362  return "Missing a DSP header.";
363  case kBadDSPKey:
364  return "The DSP header key word does not contain the correct value.";
365  case kBadDSPLength:
366  return "The DSP structure length field points past the end of the"
367  " block structure.";
368  case kBadDSPTotalLength:
369  return "The total DSP structure length field points past the end of"
370  " the block structure.";
371  case kDSPLengthMismatch:
372  return "The DSP structure length and total length fields do not"
373  " correspond. One or both of these values is incorrect.";
374  case kNoBusPatchHeader:
375  return "Missing a bus patch header.";
376  case kBadBusPatchKey:
377  return "The bus patch header key word does not contain the correct value.";
378  case kBadBusPatchLength:
379  return "The bus patch length field points past the end of the"
380  " DSP structure.";
382  return "The total bus patch length field points past the end of"
383  " the DSP structure.";
385  return "The bus patch length and total length fields do not correspond."
386  " One or both of these values is incorrect.";
387  case kNoDDLTrailerWords:
388  return "No end of DDL data key found in the trailer words.";
390  return "Only one end of DDL data key word found in the trailer but expected two.";
391  case kUnknownDspError:
392  return "The DSP error code is non-zero but of an unrecognised format.";
393  case kTokenLost:
394  return "The DSP contains a token lost error code that can affect the deadtime.";
395  case kGlitchFound:
396  return "Found a glitch. This means a 1 byte word has been randomly"
397  " inserted into the raw data by mistake.";
398  case kBadPaddingWord:
399  return "The padding word does not contain the correct value.";
400  case kParityError:
401  return "Found a parity error in the data word.";
402  default:
403  return "Unknown error code!";
404  }
405 }
406 
407 
408 inline std::ostream& operator << (std::ostream& os, AliMUONTrackerDDLDecoderEventHandler::ErrorCode code)
409 {
413 
415  return os;
416 }
417 
418 #endif // ALIMUONTRACKERDDLDECODEREVENTHANDLER_H
419 
The total DSP structure length field points past the end of the block structure.
The DSP header structure of the Tracker DDL payload.
The DSP contains a token lost error code that can affect the deadtime.
UInt_t fDataKey
Data key word for bus patch header.
void OnNewBlock(const AliMUONBlockHeaderStruct *, const void *)
The DSP header key word does not contain the correct value.
The padding word does not contain the correct value.
void OnEndOfBusPatch(const AliMUONBusPatchHeaderStruct *, const void *)
The bus patch header structure of the Tracker DDL payload.
void OnNewDSP(const AliMUONDSPHeaderStruct *, const void *)
UInt_t fBlkL1ATrigger
L1 accept in Block Structure (CRT)
The DSP structure length field points past the end of the block structure.
UInt_t fEventId2
Event Id in orbit number.
UInt_t fTotalLength
total length of block structure
The DDL raw data is larger than indicated by the headers; extra bytes are probably just garbage...
The DSP error code is non-zero but of an unrecognised format.
static const char * ErrorCodeToString(ErrorCode code)
UInt_t fDataKey
Data key word for CRT header.
UInt_t fL1RTrigger
Number of L1 reject in DSP Structure (FRT)
The total block length field points past the end of the raw data size.
static void UnpackADC(UInt_t data, UShort_t &manuId, UChar_t &channelId, UShort_t &adc)
void OnEndOfDSP(const AliMUONDSPHeaderStruct *, const void *)
The total bus patch length field points past the end of the DSP structure.
The bus patch length field points past the end of the DSP structure.
void OnNewBusPatch(const AliMUONBusPatchHeaderStruct *, const void *)
The bus patch header key word does not contain the correct value.
Too many bus patch structures found in the DSP structure.
Found a glitch. This means a 1 byte word has been randomly inserted into the raw data by mistake...
The bus patch length and total length fields do not correspond. One or both of these values is incorr...
UInt_t fTotalLength
total length of block structure (w/o padding word)
The block header key word does not contain the correct value.
static const char * ErrorCodeToMessage(ErrorCode code)
std::ostream & operator<<(std::ostream &os, AliMUONTrackerDDLDecoderEventHandler::ErrorCode code)
UInt_t fTotalLength
total length of bus patch structure
The block header structure of the Tracker DDL payload.
The DSP structure length and total length fields do not correspond. One or both of these values is in...
UInt_t fEventId1
Event Id in bunch crossing.
UInt_t fL1ATrigger
Number of L1 accept in DSP Structure (FRT)
Only one end of DDL marker trailer word found but expected two.
The block length field points past the end of the raw data size.
Callback event handler class for the AliMUONTrackerDDLDecoder.
The block length and total length fields do not correspond. One or both of these values is incorrect...
UInt_t fMiniEventId
Bunch Crossing for mini-event id (see TDR chapter 8)
void OnEndOfBlock(const AliMUONBlockHeaderStruct *, const void *)
UInt_t fMiniEventId
Mini Event Id in bunch crossing.
UInt_t fPaddingWord
padding dummy word for 64 bits transfer
UInt_t fDataKey
Data key word for FRT header.
ErrorCode
All the possible error codes for the parsing.