1 #ifndef ALIMUONRAWSTREAMTRIGGERHP_H
2 #define ALIMUONRAWSTREAMTRIGGERHP_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 */
10 /// \class AliMUONRawStreamTriggerHP
11 /// \brief Higher performance decoder stream class for reading MUON raw trigger data.
13 // This provides a streamer interface to the high performance decoder which
14 // is required for AliRoot.
16 // Author Artur Szostak <artursz@iafrica.com>
18 #include "AliMUONVRawStreamTrigger.h"
19 #include "AliMUONTriggerDDLDecoder.h"
23 class AliMUONRawStreamTriggerHP : public AliMUONVRawStreamTrigger
28 AliMUONRawStreamTriggerHP();
29 AliMUONRawStreamTriggerHP(AliRawReader* rawReader);
30 virtual ~AliMUONRawStreamTriggerHP();
32 /// Initialize iterator
36 virtual Bool_t NextDDL();
38 /// Whether the iteration is finished or not
39 virtual Bool_t IsDone() const;
41 /// Nothing is actually done in the AddErrorMessage method because we log
42 /// the error messages as we find them in AliDecoderEventHandler::OnError().
43 virtual void AddErrorMessage() { };
45 /// Advance one step in the iteration. Returns false if finished.
46 virtual Bool_t Next(UChar_t& id, UChar_t& dec, Bool_t& trigY,
47 UChar_t& yPos, UChar_t& sXDev, UChar_t& xDev,
48 UChar_t& xPos, Bool_t& triggerY, Bool_t& triggerX,
49 TArrayS& xPattern, TArrayS& yPattern);
51 /// Returns the next local trigger structure.
52 const AliLocalStruct* Next();
54 /// Return maximum number of DDLs.
55 virtual Int_t GetMaxDDL() const { return fgkMaxDDL; }
57 /// Return maximum number of regional cards in the DDL.
58 virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.RegionalsDecoded(); }
60 /// Return maximum allowed number of regional cards in the DDL.
61 virtual Int_t GetMaxRegAllowed() const { return (Int_t) fDecoder.MaxRegionals(); }
63 /// Set the maximum allowed number of regional cards in the DDL.
64 virtual void SetMaxRegAllowed(Int_t reg);
66 /// Return maximum number of local cards in the DDL.
67 virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
69 /// Sets the maximum number of local cards in the DDL.
70 virtual void SetMaxLoc(Int_t loc);
72 /// Return number of the current DDL being handled.
73 virtual Int_t GetDDL() const { return fDDL - 1; }
75 /// check error/Warning presence
76 virtual Bool_t IsErrorMessage() const { return fHadError; }
78 /// Set warnings flag to disable warnings on data errors.
79 virtual void DisableWarnings() { fDecoder.GetHandler().Warnings(kFALSE); }
80 /// Set warnings flag to enable warnings on data errors.
81 virtual void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); }
83 /// Get number of end of DARC word errors.
84 UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
86 /// Get number of end of Global word errors.
87 UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
89 /// Get number of end of regional word errors.
90 UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
92 /// Get number of end of local word errors.
93 UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
95 /// Returns the "try to recover from errors" flag.
96 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
98 /// Sets the "try to recover from errors" flag.
99 /// i.e. should the decoder try to recover from errors found in the
101 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
103 /// Light weight interface class to the DARC and global header data.
107 /// Default constructor.
109 UInt_t darcHeader = 0,
110 const AliMUONDarcScalarsStruct* darcScalars = NULL,
111 const AliMUONGlobalHeaderStruct* globalHeader = NULL,
112 const AliMUONGlobalScalarsStruct* globalScalars = NULL
114 fDarcHeader(darcHeader), fDarcScalars(darcScalars),
115 fGlobalHeader(globalHeader), fGlobalScalars(globalScalars)
119 /// Implement shallow copying in the copy constructor.
120 AliHeader(const AliHeader& o) :
121 fDarcHeader(o.fDarcHeader), fDarcScalars(o.fDarcScalars),
122 fGlobalHeader(o.fGlobalHeader), fGlobalScalars(o.fGlobalScalars)
126 /// Implement shallow copying in the assignment operator.
127 AliHeader& operator = (const AliHeader& object)
129 memcpy(this, &object, sizeof(AliHeader));
133 /// Default destructor.
136 /// Return first word
137 UInt_t GetWord() const {return GetDarcHeader();}
138 /// Return global input
139 Int_t GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
140 /// Return global output
141 UChar_t GetGlobalOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalOutput(fGlobalHeader);}
142 /// Return global config
143 UShort_t GetGlobalConfig() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalConfig(fGlobalHeader);}
145 /// Return event type
146 UChar_t GetEventType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcEventType(GetDarcHeader());}
147 /// Returns true if this was a physics event.
148 Bool_t IsPhysicsEvent() const {return GetEventType() == 0x1;}
150 UChar_t GetDarcType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcType(GetDarcHeader());}
151 /// Return serial number
152 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcSerialNb(GetDarcHeader());}
154 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVersion(GetDarcHeader());}
156 Bool_t GetVMETrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVMETrig(GetDarcHeader());}
157 /// Return global flag
158 Bool_t GetGlobalFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcGlobalFlag(GetDarcHeader());}
159 /// Return CPT trigger
160 Bool_t GetCTPTrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcCTPTrig(GetDarcHeader());}
162 Bool_t GetDAQFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcDAQFlag(GetDarcHeader());}
163 /// Return reg pattern
164 UChar_t GetRegPattern() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcRegPattern(GetDarcHeader());}
167 /// Return DARC L0 received and used
168 UInt_t GetDarcL0R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL0R : 0;}
169 /// Return DARC L1 physics
170 UInt_t GetDarcL1P() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1P : 0;}
171 /// Return DARC L1 software
172 UInt_t GetDarcL1S() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1S : 0;}
173 /// Return DARC L2 accept
174 UInt_t GetDarcL2A() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2A : 0;}
175 /// Return DARC L2 reject
176 UInt_t GetDarcL2R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2R : 0;}
177 /// Return DARC clock
178 UInt_t GetDarcClock() const {return (fDarcScalars != NULL) ? fDarcScalars->fClk : 0;}
179 /// Return DARC hold (dead time)
180 UInt_t GetDarcHold() const {return (fDarcScalars != NULL) ? fDarcScalars->fHold : 0;}
182 // global get methods
184 UInt_t GetGlobalL0() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fL0 : 0;}
185 /// Return global clock
186 UInt_t GetGlobalClock() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fClk : 0;}
187 /// Return global scalars or NULL if none exist.
188 const UInt_t* GetGlobalScaler() const {return (fGlobalScalars != NULL) ? &fGlobalScalars->fScaler[0] : NULL;}
189 /// Return global hold (dead time)
190 UInt_t GetGlobalHold() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fHold : 0;}
191 /// Return global spare
192 UInt_t GetGlobalSpare() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fSpare : 0;}
194 /// Return true if type for DARC is default.
195 Bool_t DarcIsDefaultType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcDefaultType();}
196 /// Return true if type for DARC is Vadorh.
197 Bool_t DarcIsVadohrType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcVadorhType();}
199 /// Return the DARC header's raw data.
200 UInt_t GetDarcHeader() const {return fDarcHeader;}
202 /// Return the DARC scalars raw data or NULL if none exist.
203 const AliMUONDarcScalarsStruct* GetDarcScalars() const {return fDarcScalars;}
205 /// Return the global header's raw data.
206 const AliMUONGlobalHeaderStruct* GetGlobalHeader() const {return fGlobalHeader;}
208 /// Return the global scalars raw data or NULL if none exist.
209 const AliMUONGlobalScalarsStruct* GetGlobalScalars() const {return fGlobalScalars;}
211 /// Print the contents of the headers to screen.
216 UInt_t fDarcHeader; ///< Pointer to DARC header in DDL payload.
217 const AliMUONDarcScalarsStruct* fDarcScalars; ///< Pointer to DARC scalars in DDL payload.
218 const AliMUONGlobalHeaderStruct* fGlobalHeader; ///< Pointer to global header in DDL payload.
219 const AliMUONGlobalScalarsStruct* fGlobalScalars; ///< Pointer to global scalars in DDL payload.
222 /// Light weight interface class to the regional card header data.
223 class AliRegionalHeader
226 /// Default constructor.
228 const AliLocalStruct* localsArray = NULL,
229 const AliMUONRegionalHeaderStruct* header = NULL,
230 const AliMUONRegionalScalarsStruct* scalars = NULL
232 fNext(NULL), fLocalsCount(0), fFirstLocal(localsArray),
233 fHeader(header), fScalars(scalars)
237 /// Implement shallow copying in the copy constructor.
238 AliRegionalHeader(const AliRegionalHeader& o) :
239 fNext(o.fNext), fLocalsCount(o.fLocalsCount),
240 fFirstLocal(o.fFirstLocal), fHeader(o.fHeader),
245 /// Implement shallow copying in the assignment operator.
246 AliRegionalHeader& operator = (const AliRegionalHeader& object)
248 memcpy(this, &object, sizeof(AliRegionalHeader));
252 /// Default destructor.
253 ~AliRegionalHeader() {};
256 UInt_t GetDarcWord() const {return fHeader->fDarcWord;}
257 /// Return first reg word
258 UInt_t GetWord() const {return fHeader->fWord;}
259 /// Return regional input
260 UInt_t GetInput(Int_t n) const {assert(n < 2); return fHeader->fInput[n];}
262 UShort_t GetL0() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0(fHeader);}
264 UShort_t GetMask() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalMask(fHeader);}
266 //word: phys type:1, reset: 6, serialNb:5, Id:4, version: 8, regional output:8
267 //true for phys, false for soft
268 /// Return RegPhysFlag
269 Bool_t GetRegPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPhysFlag(fHeader);}
271 UChar_t GetResetNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalResetNb(fHeader);}
273 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalSerialNb(fHeader);}
275 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalId(fHeader);}
277 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalVersion(fHeader);}
279 UChar_t GetOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalOutput(fHeader);}
281 //Darc Status: error:10, #fpag:3, MBZ:3, phys type:1, present:1, not_full:1
282 // not_empty:1, L2Rej:1, L2Acc:1, L1:1, L0:1, #evt:4, busy:4
284 UShort_t GetErrorBits() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalErrorBits(fHeader);}
285 /// Return FPGANumber
286 UChar_t GetFPGANumber() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalFPGANumber(fHeader);}
287 /// Return DarcPhysFlag
288 Bool_t GetDarcPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalDarcPhysFlag(fHeader);}
289 /// Return PresentFlag
290 Bool_t GetPresentFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPresentFlag(fHeader);}
291 /// Return RamNotFullFlag
292 Bool_t GetRamNotFullFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotFullFlag(fHeader);}
293 /// Return RamNotEmptyFlag
294 Bool_t GetRamNotEmptyFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotEmptyFlag(fHeader);}
295 /// Return L2RejStatus
296 Bool_t GetL2RejStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2RejStatus(fHeader);}
297 /// Return L2AccStatus
298 Bool_t GetL2AccStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2AccStatus(fHeader);}
300 Bool_t GetL1Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL1Status(fHeader);}
302 Bool_t GetL0Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0Status(fHeader);}
303 /// Return EventInRam
304 UChar_t GetEventInRam() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalEventInRam(fHeader);}
306 UChar_t GetBusy() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalBusy(fHeader);}
309 /// Return regional clock
310 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
311 /// Return regional ouput
312 const UInt_t* GetScaler() const {return (fScalars != NULL) ? &fScalars->fScaler[0] : NULL;}
313 /// Return regional hold (dead time)
314 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
316 /// Return raw data of regional header.
317 const AliMUONRegionalHeaderStruct* GetHeader() const { return fHeader; }
319 /// Return the raw data of the regional scalars or NULL if none exist.
320 const AliMUONRegionalScalarsStruct* GetScalars() const { return fScalars; }
322 /// Return the next regional structure header.
323 const AliRegionalHeader* Next() const { return fNext; }
325 /// Returns the first AliLocalStruct class in this regional structure.
326 const AliLocalStruct* GetFirstLocalStruct() const { return fFirstLocal; }
328 /// Returns the number of local trigger structures within this regional structure.
329 UInt_t GetLocalStructCount() const { return fLocalsCount; }
331 /// Return the i'th local trigger structure in this regional structure.
332 const AliLocalStruct* GetLocalStruct(UInt_t i) const
334 return i < fLocalsCount ? GetFirstLocalStruct() + i : NULL;
337 /// Sets the next regional structure header.
338 void SetNext(const AliRegionalHeader* next) { fNext = next; }
340 /// Increments the local trigger structure count.
341 void IncLocalStructCount() { fLocalsCount++; };
343 /// Print the contents of the regional header and scalars to screen.
348 const AliRegionalHeader* fNext; ///< Pointer to next regional header.
349 UInt_t fLocalsCount; ///< The number of AliLocalStruct objects found in the array pointed to by fFirstLocal.
350 const AliLocalStruct* fFirstLocal; ///< The first local trigger structure of this regional structure.
351 const AliMUONRegionalHeaderStruct* fHeader; ///< Pointer to the regional header in the DDL payload.
352 const AliMUONRegionalScalarsStruct* fScalars; ///< Pointer to the regional scalars in the DDL payload.
355 /// Light weight interface class to the local trigger card data.
359 /// Default constructor.
361 const AliRegionalHeader* regionalHeader = NULL,
362 const AliMUONLocalInfoStruct* localStruct = NULL,
363 const AliMUONLocalScalarsStruct* scalars = NULL
365 fRegional(regionalHeader), fNext(NULL),
366 fLocalStruct(localStruct), fScalars(scalars)
370 /// Implement shallow copying in the copy constructor.
371 AliLocalStruct(const AliLocalStruct& o) :
372 fRegional(o.fRegional), fNext(o.fNext),
373 fLocalStruct(o.fLocalStruct), fScalars(o.fScalars)
377 /// Implement shallow copying in the assignment operator.
378 AliLocalStruct& operator = (const AliLocalStruct& object)
380 memcpy(this, &object, sizeof(AliLocalStruct));
384 /// Default destructor.
385 ~AliLocalStruct() {};
387 /// Return local data
388 UInt_t GetData(Int_t n) const
391 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
395 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
397 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
399 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
401 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
404 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
406 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
408 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
410 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
412 /// return X pattern array
413 void GetXPattern(TArrayS& array) const
415 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
419 /// return Y pattern array
420 void GetYPattern(TArrayS& array) const
422 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
427 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
429 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
431 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
433 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
435 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
436 /// Get Sign of X deviation
437 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
439 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
441 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
443 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
445 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
447 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
451 UInt_t GetL0() const {return (fScalars != NULL) ? fScalars->fL0 : 0;}
452 /// Return local hold (dead time)
453 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
454 /// Return local clock
455 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
458 UShort_t GetSwitch() const
460 return (fScalars != NULL) ?
461 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
465 UChar_t GetComptXY() const
467 return (fScalars != NULL) ?
468 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
472 UShort_t GetXY1(Int_t n) const
474 return (fScalars != NULL) ?
475 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
479 UShort_t GetXY2(Int_t n) const
481 return (fScalars != NULL) ?
482 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
486 UShort_t GetXY3(Int_t n) const
488 return (fScalars != NULL) ?
489 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
493 UShort_t GetXY4(Int_t n) const
495 return (fScalars != NULL) ?
496 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
499 /// Return raw data of the local trigger structure.
500 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
502 /// Return raw data of the local trigger scalars.
503 /// Could be NULL if no scalars present.
504 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
506 /// Return the parent regional header.
507 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
509 /// Return the next local trigger structure.
510 const AliLocalStruct* Next() const { return fNext; }
512 /// Sets the next local trigger structure.
513 void SetNext(const AliLocalStruct* next) { fNext = next; }
515 /// Print the contents of the local trigger structure and contents to screen.
520 const AliRegionalHeader* fRegional; ///< The regional structure this local trigger structure belongs to.
521 const AliLocalStruct* fNext; ///< Next local structure object in the regional structure.
522 const AliMUONLocalInfoStruct* fLocalStruct; ///< Pointer to the local trigger structure data in the DDL payload.
523 const AliMUONLocalScalarsStruct* fScalars; ///< Pointer to the local trigger scalars data in the DDL payload.
526 /// Returns the DARC and global headers plus scalars if they exist.
527 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
529 /// Return the number of regional structures in the DDL payload.
530 UInt_t GetRegionalHeaderCount() const
532 return fDecoder.GetHandler().RegionalHeaderCount();
535 /// Return the first regional structure header.
536 const AliRegionalHeader* GetFirstRegionalHeader() const
538 return fDecoder.GetHandler().RegionalHeader(0);
541 /// Return the i'th regional header or NULL if not found.
542 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
544 return fDecoder.GetHandler().RegionalHeader(i);
547 /// Returns the number of local trigger structures for the given
548 /// regional structure number.
549 UInt_t GetLocalStructCount(UInt_t reg) const
551 const AliRegionalHeader* r = GetRegionalHeader(reg);
552 return r != NULL ? r->GetLocalStructCount() : 0;
555 /// Returns the i'th local trigger structure for the given regional
556 /// structure number or NULL if not found.
557 const AliLocalStruct* GetLocalStruct(UInt_t reg, UInt_t i) const
559 const AliRegionalHeader* r = GetRegionalHeader(reg);
560 return r != NULL ? r->GetLocalStruct(i) : NULL;
563 /// Returns the current local struct being decoded or NULL if none found.
564 const AliLocalStruct* CurrentLocalStruct() const
566 return (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
567 fCurrentLocalStruct : NULL;
570 /// Returns the current regional structure being decoded
571 /// or NULL if none found.
572 const AliRegionalHeader* CurrentRegionalHeader() const
574 const AliLocalStruct* local = CurrentLocalStruct();
575 return (local != NULL) ? local->GetRegionalHeader() : NULL;
580 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
582 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
585 /// This is the custom event handler (callback interface) class which
586 /// unpacks raw data words and fills an internal buffer with decoded digits
587 /// as they are decoded by the high performance decoder.
588 /// Any errors are logged to the parent AliMUONVRawStreamTrigger, so one
589 /// must set this pointer appropriately before decoding and DDL payload.
590 class AliDecoderEventHandler : public AliMUONTriggerDDLDecoderEventHandler
594 /// Default constructor.
595 AliDecoderEventHandler();
596 /// Default destructor.
597 virtual ~AliDecoderEventHandler();
599 /// Sets the internal arrays based on the maximum number of structures allowed.
600 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
602 /// Sets the raw stream object which should be the parent of this class.
603 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
605 /// Returns the decoded DARC and global headers (and scalars if they exist).
606 const AliHeader* GetHeaders() const { return &fHeaders; }
608 /// Returns the number of regional headers.
609 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
611 /// Return the i'th regional structure header.
612 const AliRegionalHeader* RegionalHeader(UInt_t i) const
614 return i < fRegionalsCount ? &fRegionals[i] : NULL;
617 /// Return the first local structure decoded.
618 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
620 /// Returns the marker to the end of local structures.
621 /// i.e. one position past the last local structure in fLocals.
622 const AliLocalStruct* EndOfLocalStructs() const { return fEndOfLocals; }
624 /// Get number of end of DARC word errors.
625 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
627 /// Get number of end of Global word errors.
628 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
630 /// Get number of end of regional word errors.
631 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
633 /// Get number of end of local word errors.
634 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
636 /// Returns the warnings flag.
637 Bool_t Warnings() const { return fWarnings; }
638 /// Sets the warnings flag.
639 void Warnings(Bool_t value) { fWarnings = value; }
641 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
643 /// New buffer handler.
644 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
646 /// End of buffer handler marks the end of local trigger structures.
647 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
649 fEndOfLocals = fCurrentLocal+1;
652 /// Handler for the DARC header which just remembers the pointers for later.
653 void OnDarcHeader(UInt_t header,
654 const AliMUONDarcScalarsStruct* scalars,
655 const void* /*data*/)
657 fDarcHeader = header;
658 fDarcScalars = scalars;
661 /// Handler for the global header which stores the pointer to the headers.
662 void OnGlobalHeader(const AliMUONGlobalHeaderStruct* header,
663 const AliMUONGlobalScalarsStruct* scalars,
664 const void* /*data*/)
666 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
669 /// Handler for new regional card structures.
670 void OnNewRegionalStruct(const AliMUONRegionalHeaderStruct* header,
671 const AliMUONRegionalScalarsStruct* scalars,
674 /// Handler for new local card structures.
675 void OnLocalStruct(const AliMUONLocalInfoStruct* localStruct,
676 const AliMUONLocalScalarsStruct* scalars);
679 void OnError(ErrorCode error, const void* location);
683 // Do not allow copying of this class.
685 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
687 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
689 AliMUONVRawStreamTrigger* fRawStream; //!< Pointer to the parent raw stream object.
690 const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer.
691 UInt_t fDarcHeader; //!< Currently decoded DARC header.
692 const AliMUONDarcScalarsStruct* fDarcScalars; //!< Currently decoded DARC scalars.
693 AliHeader fHeaders; //!< Headers of the DDL payload.
694 UInt_t fRegionalsCount; //!< Number of regional headers filled in fRegionals.
695 AliRegionalHeader* fRegionals; //!< Array of regional headers. [0..fMaxRegionals-1]
696 AliLocalStruct* fLocals; //!< Array of decoded local structured. [0..fMaxRegionals*fMaxLocals-1]
697 AliLocalStruct* fEndOfLocals; //!< Marker indicating the position just passed the last filled element in fLocals.
698 AliRegionalHeader* fCurrentRegional; //!< Current regional header position.
699 AliLocalStruct* fCurrentLocal; //!< Current local trigger structure.
700 UInt_t fDarcEoWErrors; //!< Number of end of DARC word errors.
701 UInt_t fGlobalEoWErrors; //!< Number of end of global word errors.
702 UInt_t fRegEoWErrors; //!< Number of end of regional word errors.
703 UInt_t fLocalEoWErrors; //!< Number of end of local word errors.
704 Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors.
707 AliMUONTriggerDDLDecoder<AliDecoderEventHandler> fDecoder; //!< The decoder for the DDL payload.
708 Int_t fDDL; //!< The current DDL number being handled.
709 Int_t fBufferSize; //!< This is the buffer size in bytes of fBuffer.
710 UChar_t* fBuffer; //!< This is the buffer in which we store the DDL payload read from AliRawReader.
711 const AliLocalStruct* fCurrentLocalStruct; //!< The current local trigger structure being handled by Next().
712 Bool_t fHadError; //!< Flag indicating if there was a decoding error or not.
713 Bool_t fDone; //!< Flag indicating if the iteration is done or not.
715 static const Int_t fgkMaxDDL; //!< Maximum number of DDLs
717 ClassDef(AliMUONRawStreamTriggerHP, 0) // Higher performance decoder class for MUON trigger rawdata.
720 ////////////////////////////////////////////////////////////////////////////////
722 inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerHP::Next()
724 /// Iterates through all the local trigger structures for the event.
725 /// When no more local triggers are found then NULL is returned.
728 if (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
729 return fCurrentLocalStruct++;
735 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStruct(
736 const AliMUONRegionalHeaderStruct* header,
737 const AliMUONRegionalScalarsStruct* scalars,
741 /// New regional structure handler is called by the decoder whenever a
742 /// new regional header is found. We just mark the header and increment
743 /// the appropriate counters.
745 assert( header != NULL );
746 assert( fCurrentRegional != NULL );
747 assert( fRegionalsCount < (UInt_t)fRawStream->GetMaxReg() );
749 // Link the previous regional structure unless it is the first one.
750 if (fRegionalsCount > 0)
752 fCurrentRegional->SetNext(fCurrentRegional+1);
756 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
761 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
762 const AliMUONLocalInfoStruct* localStruct,
763 const AliMUONLocalScalarsStruct* scalars
766 /// New local trigger structure handler.
767 /// This is called by the high performance decoder when a new local trigger
768 /// structure is found within the DDL payload.
769 /// We mark the location of the structure in the DDL paytload and increment
770 /// appropriate counters.
772 assert( localStruct != NULL );
773 assert( fCurrentLocal != NULL );
774 assert( fCurrentRegional != NULL );
775 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
777 // Link the previous local structure unless it is the first one.
778 if (fCurrentRegional->GetLocalStructCount() > 0)
780 fCurrentLocal->SetNext(fCurrentLocal+1);
784 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
785 fCurrentRegional->IncLocalStructCount();
788 #endif // ALIMUONRAWSTREAMTRIGGERHP_H