]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONRawStreamTriggerHP.cxx
Corrected printout
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTriggerHP.cxx
CommitLineData
1788245f 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: *
6 * Artur Szostak <artursz@iafrica.com> *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/* $Id$ */
18
19/// \class AliMUONRawStreamTriggerHP
20///
21/// Implementation of a streamer interface to the high performance trigger decoder.
22/// This is the raw stream class which interfaces between the high performance
23/// core decoder for MUON trigger chambers and the AliRawReader class.
24/// To gain the most out of the decoder, the Next() method should be used,
25/// for example:
26/// \code
27/// AliMUONRawStreamTriggerHP* rawStream; // assume initialised
28/// const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct;
29/// while ((localStruct = rawStream->Next()) != NULL)
30/// {
31/// // Do something with localStruct here.
32/// }
33/// \endcode
34///
35/// This decoder tries to implement as similar an interface as possible to
36/// AliMUONRawStreamTrigger where possible. However certain constructs which
37/// would slow us down too much are avoided.
38///
39/// \author Artur Szostak <artursz@iafrica.com>
40
41#include "AliMUONRawStreamTriggerHP.h"
481d8064 42#include "AliMUONDarcHeader.h"
43#include "AliMUONRegHeader.h"
44#include "AliMUONLocalStruct.h"
45#include "AliMUONDDLTrigger.h"
1788245f 46#include "AliRawReader.h"
47#include "AliLog.h"
48#include <cassert>
49#include <iostream>
1788245f 50using std::cout;
51using std::endl;
52using std::hex;
53using std::dec;
54
55/// \cond CLASSIMP
56ClassImp(AliMUONRawStreamTriggerHP)
57/// \endcond
58
59const Int_t AliMUONRawStreamTriggerHP::fgkMaxDDL = 2;
60
61
62AliMUONRawStreamTriggerHP::AliMUONRawStreamTriggerHP() :
63 AliMUONVRawStreamTrigger(),
64 fDecoder(),
65 fDDL(0),
66 fBufferSize(8192),
67 fBuffer(new UChar_t[8192]),
586dda01 68 fkCurrentLocalStruct(NULL),
1788245f 69 fHadError(kFALSE),
481d8064 70 fDone(kFALSE),
71 fDDLObject(NULL)
1788245f 72{
73 ///
74 /// Default constructor.
75 ///
76
77 fDecoder.ExitOnError(false);
78
79 fDecoder.GetHandler().SetMaxStructs(
80 fDecoder.MaxRegionals(),
81 fDecoder.MaxLocals()
82 );
83
84 fDecoder.GetHandler().SetRawStream(this);
85}
86
87
88AliMUONRawStreamTriggerHP::AliMUONRawStreamTriggerHP(AliRawReader* rawReader) :
89 AliMUONVRawStreamTrigger(rawReader),
90 fDecoder(),
91 fDDL(0),
92 fBufferSize(8192),
93 fBuffer(new UChar_t[8192]),
586dda01 94 fkCurrentLocalStruct(NULL),
1788245f 95 fHadError(kFALSE),
481d8064 96 fDone(kFALSE),
97 fDDLObject(NULL)
1788245f 98{
99 ///
100 /// Constructor with AliRawReader as argument.
101 ///
102
103 fDecoder.ExitOnError(false);
104
105 fDecoder.GetHandler().SetMaxStructs(
106 fDecoder.MaxRegionals(),
107 fDecoder.MaxLocals()
108 );
109
110 fDecoder.GetHandler().SetRawStream(this);
111}
112
113
114AliMUONRawStreamTriggerHP::~AliMUONRawStreamTriggerHP()
115{
116 ///
117 /// Default destructor which cleans up the memory allocated.
118 ///
119
120 if (fBuffer != NULL)
121 {
122 delete [] fBuffer;
123 }
481d8064 124 if (fDDLObject != NULL)
125 {
126 delete fDDLObject;
127 }
1788245f 128}
129
130
131void AliMUONRawStreamTriggerHP::First()
132{
133 /// Initialise or reset the iterator.
134 /// The first DDL will be found and decoded.
135
136 assert( GetReader() != NULL );
137
138 fDDL = 0;
139 fDone = kFALSE;
140 NextDDL();
141}
142
143
144Bool_t AliMUONRawStreamTriggerHP::NextDDL()
145{
146 /// Read in the next trigger DDL and decode the payload with the
147 /// high performance decoder.
148 /// \return kTRUE if the next DDL was successfully read and kFALSE
149 /// otherwise.
150
151 assert( GetReader() != NULL );
152
481d8064 153 // The temporary object if generated in GetDDLTracker, is now stale,
154 // so delete it.
155 if (fDDLObject != NULL)
156 {
157 delete fDDLObject;
158 fDDLObject = NULL;
159 }
160
586dda01 161 fkCurrentLocalStruct = NULL;
1788245f 162
163 while (fDDL < GetMaxDDL())
164 {
165 GetReader()->Reset();
166 GetReader()->Select("MUONTRG", fDDL, fDDL); // Select the DDL file to be read.
167 if (GetReader()->ReadHeader()) break;
168 AliDebug(3, Form("Skipping DDL %d which does not seem to be there", fDDL+1));
169 fDDL++;
170 }
171
172 // If we reach the end of the DDL list for this event then reset the
173 // DDL counter, mark the iteration as done and exit.
174 if (fDDL >= GetMaxDDL())
175 {
176 fDDL = 0;
177 fDone = kTRUE;
178 return kFALSE;
179 }
180 else
181 {
182 fDone = kFALSE;
183 }
184
185 AliDebug(3, Form("DDL Number %d\n", fDDL));
186
187 Int_t dataSize = GetReader()->GetDataSize(); // in bytes
188 // Check if we have enough buffer space already in fBuffer. If we do then
189 // just continue reading otherwise we need to resize the buffer.
190 if (fBufferSize < dataSize)
191 {
192 if (fBuffer != NULL)
193 {
194 delete [] fBuffer;
195 fBuffer = NULL;
196 fBufferSize = 0;
197 }
198 try
199 {
200 fBuffer = new UChar_t[dataSize];
201 fBufferSize = dataSize;
202 }
203 catch (const std::bad_alloc&)
204 {
205 AliError("Could not allocate more buffer space. Cannot decode DDL.");
206 return kFALSE;
207 }
208 }
209
210 if (not GetReader()->ReadNext(fBuffer, dataSize))
211 {
212 return kFALSE;
213 }
214
215#ifndef R__BYTESWAP
216 Swap(reinterpret_cast<UInt_t*>(fBuffer), dataSize / sizeof(UInt_t)); // Swap needed for mac power pc.
217#endif
218
a53aa6cf 219 // Check if this is a scalar event.
521e22cc 220 bool scalerEvent = (GetReader()->GetDataHeader()->GetL1TriggerMessage() & 0x1) == 0x1;
a53aa6cf 221
1788245f 222 bool result = false;
223 try
224 {
225 // Since we might allocate memory inside OnNewBuffer in the event
226 // handler we need to trap any memory allocation exception to be robust.
a53aa6cf 227 result = fDecoder.Decode(fBuffer, dataSize, scalerEvent);
1788245f 228 fHadError = (result == true ? kFALSE : kTRUE);
229 }
230 catch (const std::bad_alloc&)
231 {
232 AliError("Could not allocate more buffer space. Cannot decode DDL.");
233 return kFALSE;
234 }
235
236 // Update the current local structure pointer.
586dda01 237 fkCurrentLocalStruct = fDecoder.GetHandler().FirstLocalStruct();
1788245f 238
239 fDDL++; // Remember to increment index to next DDL.
240 return kTRUE;
241}
242
243
244Bool_t AliMUONRawStreamTriggerHP::IsDone() const
245{
246 /// Indicates whether the iteration is finished or not.
247 /// \return kTRUE if we already read all the digits and kFALSE if not.
248
249 return fDone;
250}
251
252
253Bool_t AliMUONRawStreamTriggerHP::Next(
254 UChar_t& id, UChar_t& dec, Bool_t& trigY,
255 UChar_t& yPos, UChar_t& sXDev, UChar_t& xDev,
256 UChar_t& xPos, Bool_t& triggerY, Bool_t& triggerX,
257 TArrayS& xPattern, TArrayS& yPattern
258 )
259{
586dda01 260 /// Advance one step in the iteration. Returns kFALSE if finished.
261 /// If kTRUE is returned then the output parameters are filled with
262 /// the values found in the next local trigger circuit structure.
263
1788245f 264 const AliLocalStruct* localStruct = Next();
265 if (localStruct == NULL) return kFALSE;
266
267 id = localStruct->GetId();
268 dec = localStruct->GetDec();
269 trigY = localStruct->GetTrigY();
270 yPos = localStruct->GetYPos();
271 sXDev = localStruct->GetSXDev();
272 xDev = localStruct->GetXDev();
273 xPos = localStruct->GetXPos();
274
275 triggerX = localStruct->GetTriggerX();
276 triggerY = localStruct->GetTriggerY();
277
278 localStruct->GetXPattern(xPattern);
279 localStruct->GetYPattern(yPattern);
280
281 return kTRUE;
282}
283
284
481d8064 285AliMUONDDLTrigger* AliMUONRawStreamTriggerHP::GetDDLTrigger() const
286{
287 /// Construct and return a pointer to the DDL payload object.
288 /// \return Pointer to internally constructed AliMUONDDLTrigger object.
289 /// The object is owned by this class and should not be deleted
290 /// by the caller.
291 ///
292 /// \note This method should not be used just to gain access to the DDL
293 /// payload, unless there is a good reason to have the AliMUONDDLTrigger
294 /// object. For example, if you want to modify the data and then save it
295 /// to another DDL stream. Otherwise it can be an order of magnitude
296 /// faster to access the DDL headers and data with the GetHeaders,
297 /// GetRegionalHeader and GetLocalStruct methods for example.
298 /// Refer to the MUONRawStreamTrigger.C macro to see how to use the fast
299 /// decoder interface optimally.
300
301 if (fDDLObject != NULL) return fDDLObject;
302
303 fDDLObject = new AliMUONDDLTrigger;
304
305 // Copy over all DARC, global headers and scalars.
306 AliMUONDarcHeader* darcHeader = fDDLObject->GetDarcHeader();
307 const AliHeader* hdr = GetHeaders();
308 UInt_t word = hdr->GetDarcHeader();
309 memcpy(darcHeader->GetHeader(), &word, sizeof(word));
310 if (hdr->GetDarcScalars() != NULL)
311 {
312 memcpy(darcHeader->GetDarcScalers(), hdr->GetDarcScalars(), sizeof(AliMUONDarcScalarsStruct));
313 }
314 memcpy(darcHeader->GetGlobalInput(), hdr->GetGlobalHeader(), sizeof(AliMUONGlobalHeaderStruct));
315 if (hdr->GetGlobalScalars() != NULL)
316 {
317 memcpy(darcHeader->GetGlobalScalers(), hdr->GetGlobalScalars(), sizeof(AliMUONGlobalScalarsStruct));
318 }
319
320 for (Int_t iReg = 0; iReg < (Int_t)GetRegionalHeaderCount(); iReg++)
321 {
322 AliMUONRegHeader regHeader;
323 AliMUONLocalStruct localStruct;
324
325 const AliRegionalHeader* rh = GetRegionalHeader(iReg);
326 // Copy local structure and scalars and add everything into DDL object.
327 memcpy(regHeader.GetHeader(), rh->GetHeader(), sizeof(AliMUONRegionalHeaderStruct));
328 if (rh->GetScalars() != NULL)
329 {
330 memcpy(regHeader.GetScalers(), rh->GetScalars(), sizeof(AliMUONRegionalScalarsStruct));
331 }
332 fDDLObject->AddRegHeader(regHeader);
333
a53aa6cf 334 const AliLocalStruct* lstruct = rh->GetFirstLocalStruct();
335 while (lstruct != NULL)
481d8064 336 {
337 // Copy local structure and scalars and add everything into DDL object.
a53aa6cf 338 memcpy(localStruct.GetData(), lstruct->GetData(), sizeof(AliMUONLocalInfoStruct));
339 if (lstruct->GetScalars() != NULL)
481d8064 340 {
a53aa6cf 341 memcpy(localStruct.GetScalers(), lstruct->GetScalars(), sizeof(AliMUONLocalScalarsStruct));
481d8064 342 }
343 fDDLObject->AddLocStruct(localStruct, iReg);
a53aa6cf 344 lstruct = lstruct->Next();
481d8064 345 }
346 }
347
348 return fDDLObject;
349}
350
351
1788245f 352void AliMUONRawStreamTriggerHP::SetMaxRegAllowed(Int_t reg)
353{
354 /// Set the maximum allowed number of regional cards in the DDL.
355
356 fDecoder.MaxRegionals( (UInt_t) reg );
357
358 fDecoder.GetHandler().SetMaxStructs(
359 fDecoder.MaxRegionals(),
360 fDecoder.MaxLocals()
361 );
362}
363
364
365void AliMUONRawStreamTriggerHP::SetMaxLoc(Int_t loc)
366{
367 /// Sets the maximum number of local cards in the DDL.
368
369 fDecoder.MaxLocals( (UInt_t) loc );
370
371 fDecoder.GetHandler().SetMaxStructs(
372 fDecoder.MaxRegionals(),
373 fDecoder.MaxLocals()
374 );
375}
376
377///////////////////////////////////////////////////////////////////////////////
378
379void AliMUONRawStreamTriggerHP::AliHeader::Print() const
380{
381 /// Print DARC header, global header and global scalars to screen.
382
383 cout << "===== DARC info =====" << endl;
384 cout << "Header bits : 0x" << hex << fDarcHeader << dec << endl;
385 if (fDarcScalars != NULL)
386 {
387 cout << "L0R : " << fDarcScalars->fL0R << " (0x"
388 << hex << fDarcScalars->fL0R << dec << ")" << endl;
389 cout << "L1P : " << fDarcScalars->fL1P << " (0x"
390 << hex << fDarcScalars->fL1P << dec << ")" << endl;
391 cout << "L1S : " << fDarcScalars->fL1S << " (0x"
392 << hex << fDarcScalars->fL1S << dec << ")" << endl;
393 cout << "L2A : " << fDarcScalars->fL2A << " (0x"
394 << hex << fDarcScalars->fL2A << dec << ")" << endl;
395 cout << "L2R : " << fDarcScalars->fL2R << " (0x"
396 << hex << fDarcScalars->fL2R << dec << ")" << endl;
397 cout << "Clock : " << fDarcScalars->fClk << " (0x"
398 << hex << fDarcScalars->fClk << dec << ")" << endl;
399 cout << "Hold : " << fDarcScalars->fHold << " (0x"
400 << hex << fDarcScalars->fHold << dec << ")" << endl;
401 cout << "Spare : " << fDarcScalars->fSpare << " (0x"
402 << hex << fDarcScalars->fSpare << dec << ")" << endl;
403 }
404 else
405 {
406 cout << "Scalars == NULL" << endl;
407 }
408
409 cout << "===== Global info =====" << endl;
410 for (int i = 0; i < 4; i++)
411 {
412 cout << "Input[" << i << "] : " << fGlobalHeader->fInput[i] << " (0x"
413 << hex << fGlobalHeader->fInput[i] << dec << ")" << endl;
414 }
415 cout << "Output : " << fGlobalHeader->fOutput << " (0x"
416 << hex << fGlobalHeader->fOutput << dec << ")" << endl;
417 if (fGlobalScalars != NULL)
418 {
419 cout << "L0 : " << fGlobalScalars->fL0 << " (0x"
420 << hex << fGlobalScalars->fL0 << dec << ")" << endl;
421 cout << "Clock : " << fGlobalScalars->fClk << " (0x"
422 << hex << fGlobalScalars->fClk << dec << ")" << endl;
423 for (int j = 0; j < 4; j++)
424 {
425 cout << "Scaler[" << j << "] : " << fGlobalScalars->fScaler[j] << " (0x"
426 << hex << fGlobalScalars->fScaler[j] << dec << ")" << endl;
427 }
428 cout << "Hold : " << fGlobalScalars->fHold << " (0x"
429 << hex << fGlobalScalars->fHold << dec << ")" << endl;
430 cout << "Spare : " << fGlobalScalars->fSpare << " (0x"
431 << hex << fGlobalScalars->fSpare << dec << ")" << endl;
432 }
433 else
434 {
435 cout << "Scalars == NULL" << endl;
436 }
437}
438
439void AliMUONRawStreamTriggerHP::AliRegionalHeader::Print() const
440{
441 /// Print the regional header and scalars to screen.
442
443 cout << "===== Regional card info =====" << endl;
444 cout << "DarcWord : " << fHeader->fDarcWord << " (0x"
445 << hex << fHeader->fDarcWord << dec << ")" << endl;
446 cout << "Word : " << fHeader->fWord << " (0x"
447 << hex << fHeader->fWord << dec << ")" << endl;
448 cout << "Input[0] : " << fHeader->fInput[0] << " (0x"
449 << hex << fHeader->fInput[0] << dec << ")" << endl;
450 cout << "Input[1] : " << fHeader->fInput[1] << " (0x"
451 << hex << fHeader->fInput[1] << dec << ")" << endl;
452 cout << "L0/Mask : " << fHeader->fL0CountAndMask << " (0x"
453 << hex << fHeader->fL0CountAndMask << dec << ")" << endl;
454 if (fScalars != NULL)
455 {
456 cout << "Clock : " << fScalars->fClk << " (0x"
457 << hex << fScalars->fClk << dec << ")" << endl;
458 for (int i = 0; i < 8; i++)
459 {
460 cout << "Scaler[" << i << "] : " << fScalars->fScaler[i] << " (0x"
461 << hex << fScalars->fScaler[i] << dec << ")" << endl;
462 }
463 cout << "Hold : " << fScalars->fHold << " (0x"
464 << hex << fScalars->fHold << dec << ")" << endl;
465 }
466 else
467 {
468 cout << "Scalars == NULL" << endl;
469 }
470}
471
472void AliMUONRawStreamTriggerHP::AliLocalStruct::Print() const
473{
474 /// Print local trigger structure and scalars to screen.
475
476 cout << "===== Local card info =====" << endl;
477 cout << "X2X1 : " << fLocalStruct->fX2X1 << " (0x"
478 << hex << fLocalStruct->fX2X1 << dec << ")" << endl;
479 cout << "X4X3 : " << fLocalStruct->fX4X3 << " (0x"
480 << hex << fLocalStruct->fX4X3 << dec << ")" << endl;
481 cout << "Y2Y1 : " << fLocalStruct->fY2Y1 << " (0x"
482 << hex << fLocalStruct->fY2Y1 << dec << ")" << endl;
483 cout << "Y4Y3 : " << fLocalStruct->fY4Y3 << " (0x"
484 << hex << fLocalStruct->fY4Y3 << dec << ")" << endl;
485 cout << "Trigger bits : " << fLocalStruct->fTriggerBits << " (0x"
486 << hex << fLocalStruct->fTriggerBits << dec << ")" << endl;
487 if (fScalars != NULL)
488 {
489 cout << "L0 : " << fScalars->fL0 << " (0x"
490 << hex << fScalars->fL0 << dec << ")" << endl;
491 cout << "Hold : " << fScalars->fHold << " (0x"
492 << hex << fScalars->fHold << dec << ")" << endl;
493 cout << "Clock : " << fScalars->fClk << " (0x"
494 << hex << fScalars->fClk << dec << ")" << endl;
495 cout << "LPtNTrig : " << fScalars->fLPtNTrig << " (0x"
496 << hex << fScalars->fLPtNTrig << dec << ")" << endl;
497 cout << "HPtNTrig : " << fScalars->fHPtNTrig << " (0x"
498 << hex << fScalars->fHPtNTrig << dec << ")" << endl;
499 cout << "LPtRTrig : " << fScalars->fLPtRTrig << " (0x"
500 << hex << fScalars->fLPtRTrig << dec << ")" << endl;
501 cout << "HPtRTrig : " << fScalars->fHPtRTrig << " (0x"
502 << hex << fScalars->fHPtRTrig << dec << ")" << endl;
503 cout << "LPtLTrig : " << fScalars->fLPtLTrig << " (0x"
504 << hex << fScalars->fLPtLTrig << dec << ")" << endl;
505 cout << "HPtLTrig : " << fScalars->fHPtLTrig << " (0x"
506 << hex << fScalars->fHPtLTrig << dec << ")" << endl;
507 cout << "LPtSTrig : " << fScalars->fLPtSTrig << " (0x"
508 << hex << fScalars->fLPtSTrig << dec << ")" << endl;
509 cout << "HPtSTrig : " << fScalars->fHPtSTrig << " (0x"
510 << hex << fScalars->fHPtSTrig << dec << ")" << endl;
511 for (int i = 0; i < 8*4; i++)
512 {
513 cout << "Scaler[" << i << "] : " << fScalars->fScaler[i] << " (0x"
514 << hex << fScalars->fScaler[i] << dec << ")" << endl;
515 }
516 cout << "EOS : " << fScalars->fEOS << " (0x"
517 << hex << fScalars->fEOS << dec << ")" << endl;
518 cout << "Reset : " << fScalars->fReset << " (0x"
519 << hex << fScalars->fReset << dec << ")" << endl;
520 }
521 else
522 {
523 cout << "Scalars == NULL" << endl;
524 }
525}
526
527///////////////////////////////////////////////////////////////////////////////
528
529AliMUONRawStreamTriggerHP::AliDecoderEventHandler::AliDecoderEventHandler() :
530 fRawStream(NULL),
531 fBufferStart(NULL),
532 fDarcHeader(0),
533 fDarcScalars(NULL),
534 fHeaders(),
535 fRegionalsCount(0),
536 fRegionals(NULL),
537 fLocals(NULL),
538 fEndOfLocals(NULL),
539 fCurrentRegional(NULL),
540 fCurrentLocal(NULL),
541 fDarcEoWErrors(0),
542 fGlobalEoWErrors(0),
543 fRegEoWErrors(0),
544 fLocalEoWErrors(0),
545 fWarnings(kTRUE)
546{
547 /// Default constructor
548}
549
550
551AliMUONRawStreamTriggerHP::AliDecoderEventHandler::~AliDecoderEventHandler()
552{
553 /// Default destructor cleans up the allocated memory.
554
555 if (fRegionals != NULL) delete [] fRegionals;
556 if (fLocals != NULL) delete [] fLocals;
557}
558
559
560void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::SetMaxStructs(
561 UInt_t maxRegionals, UInt_t maxLocals
562 )
563{
564 /// Sets the maximum number of structures allowed.
565
566 // Start by clearing the current arrays.
567 if (fRegionals != NULL)
568 {
569 delete [] fRegionals;
570 fRegionals = NULL;
571 }
572 if (fLocals != NULL)
573 {
574 delete [] fLocals;
575 fLocals = NULL;
576 fEndOfLocals = NULL;
577 }
578 fCurrentRegional = NULL;
579 fCurrentLocal = NULL;
580
581 // Allocate new memory.
582 fRegionals = new AliRegionalHeader[maxRegionals];
583 fLocals = new AliLocalStruct[maxRegionals*maxLocals];
584 fEndOfLocals = fLocals;
585}
586
587
588void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewBuffer(
589 const void* buffer, UInt_t /*bufferSize*/
590 )
591{
592 /// This is called by the high performance decoder when a new DDL payload
593 /// is about to be decoded.
594
595 assert( fRawStream != NULL );
596
597 // remember the start of the buffer to be used in OnError.
598 fBufferStart = buffer;
599
600 // Reset error counters.
601 fDarcEoWErrors = 0;
602 fGlobalEoWErrors = 0;
603 fRegEoWErrors = 0;
604 fLocalEoWErrors = 0;
605
606 // Reset the current pointers which will be used to track where we need to
607 // fill fRegionals and fLocals. We have to subtract one space because we
608 // will increment the pointer the first time in the OnNewRegionalStruct
609 // and OnLocalStruct methods.
610 fCurrentRegional = fRegionals-1;
611 fCurrentLocal = fLocals-1;
612 fRegionalsCount = 0;
613}
614
615
616void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnError(
617 ErrorCode error, const void* location
618 )
619{
620 /// This is called by the high performance decoder when a error occurs
621 /// when trying to decode the DDL payload. This indicates corruption in
622 /// the data. This method converts the error code to a descriptive message
623 /// and logs this with the raw reader.
624 /// \param error The error code indicating the problem.
625 /// \param location A pointer to the location within the DDL payload buffer
626 /// being decoded where the problem with the data was found.
627
628 assert( fRawStream != NULL );
629 assert( fRawStream->GetReader() != NULL );
630
631 Char_t* message = NULL;
632 //UInt_t word = 0;
633
634 switch (error)
635 {
636 case kWrongEventType:
637 message = Form("Wrong event type obtained from the Darc header, take the one of CDH");
638 break;
639
640 case kBadEndOfDarc:
641 fDarcEoWErrors++;
642 message = Form(
643 "Wrong end of Darc word %x instead of %x\n",
644 *reinterpret_cast<const UInt_t*>(location),
645 AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::EndOfDarcWord()
646 );
647 fRawStream->GetReader()->AddMajorErrorLog(kDarcEoWErr, message);
648 break;
649
650 case kBadEndOfGlobal:
651 fGlobalEoWErrors++;
652 message = Form(
653 "Wrong end of Global word %x instead of %x\n",
654 *reinterpret_cast<const UInt_t*>(location),
655 AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::EndOfGlobalWord()
656 );
657 fRawStream->GetReader()->AddMajorErrorLog(kGlobalEoWErr, message);
658 break;
659
660 case kBadEndOfRegional:
661 fRegEoWErrors++;
662 message = Form(
663 "Wrong end of Regional word %x instead of %x\n",
664 *reinterpret_cast<const UInt_t*>(location),
665 AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::EndOfRegionalWord()
666 );
667 fRawStream->GetReader()->AddMajorErrorLog(kRegEoWErr, message);
668 break;
669
670 case kBadEndOfLocal:
671 fLocalEoWErrors++;
672 message = Form(
673 "Wrong end of Local word %x instead of %x\n",
674 *reinterpret_cast<const UInt_t*>(location),
675 AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::EndOfLocalWord()
676 );
677 fRawStream->GetReader()->AddMajorErrorLog(kLocalEoWErr, message);
678 break;
679
680 default:
681 message = Form(
682 "%s (At byte %d in DDL.)",
683 ErrorCodeToMessage(error),
684 (unsigned long)location - (unsigned long)fBufferStart + sizeof(AliRawDataHeader)
685 );
686 fRawStream->GetReader()->AddMajorErrorLog(error, message);
687 break;
688 }
689
690 if (fWarnings)
691 {
692 AliWarningGeneral(
693 "AliMUONRawStreamTriggerHP::AliDecoderEventHandler",
694 message
695 );
696 }
697}
698