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"
22 class AliMUONDDLTrigger;
25 class AliMUONRawStreamTriggerHP : public AliMUONVRawStreamTrigger
30 AliMUONRawStreamTriggerHP();
31 AliMUONRawStreamTriggerHP(AliRawReader* rawReader);
32 virtual ~AliMUONRawStreamTriggerHP();
34 /// Initialize iterator
38 virtual Bool_t NextDDL();
40 /// Whether the iteration is finished or not
41 virtual Bool_t IsDone() const;
43 /// Nothing is actually done in the AddErrorMessage method because we log
44 /// the error messages as we find them in AliDecoderEventHandler::OnError().
45 virtual void AddErrorMessage() { };
47 /// Advance one step in the iteration. Returns false if finished.
48 virtual Bool_t Next(UChar_t& id, UChar_t& dec, Bool_t& trigY,
49 UChar_t& yPos, UChar_t& sXDev, UChar_t& xDev,
50 UChar_t& xPos, Bool_t& triggerY, Bool_t& triggerX,
51 TArrayS& xPattern, TArrayS& yPattern);
53 /// Construct and return a pointer to the DDL payload object.
54 virtual AliMUONDDLTrigger* GetDDLTrigger() const;
56 /// Returns the next local trigger structure.
57 const AliLocalStruct* Next();
59 /// Return maximum number of DDLs.
60 virtual Int_t GetMaxDDL() const { return fgkMaxDDL; }
62 /// Return maximum number of regional cards in the DDL.
63 virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.MaxRegionals(); }
65 /// Set the maximum number of regional cards in the DDL.
66 virtual void SetMaxReg(Int_t reg);
68 /// Return maximum number of local cards in the DDL.
69 virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
71 /// Sets the maximum number of local cards in the DDL.
72 virtual void SetMaxLoc(Int_t loc);
74 /// Return number of the current DDL being handled.
75 virtual Int_t GetDDL() const { return fDDL - 1; }
77 /// check error/Warning presence
78 virtual Bool_t IsErrorMessage() const { return fHadError; }
80 /// Set warnings flag to disable warnings on data errors.
81 virtual void DisableWarnings() { fDecoder.GetHandler().Warnings(kFALSE); }
82 /// Set warnings flag to enable warnings on data errors.
83 virtual void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); }
85 /// Get number of end of DARC word errors.
86 UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
88 /// Get number of end of Global word errors.
89 UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
91 /// Get number of end of regional word errors.
92 UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
94 /// Get number of end of local word errors.
95 UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
97 /// Returns the "try to recover from errors" flag.
98 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
100 /// Sets the "try to recover from errors" flag.
101 /// i.e. should the decoder try to recover from errors found in the
103 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
105 /// Light weight interface class to the DARC and global header data.
109 /// Default constructor.
111 UInt_t darcHeader = 0,
112 const AliMUONDarcScalarsStruct* darcScalars = NULL,
113 const AliMUONGlobalHeaderStruct* globalHeader = NULL,
114 const AliMUONGlobalScalarsStruct* globalScalars = NULL
116 fDarcHeader(darcHeader), fDarcScalars(darcScalars),
117 fGlobalHeader(globalHeader), fGlobalScalars(globalScalars)
121 /// Implement shallow copying in the copy constructor.
122 AliHeader(const AliHeader& o) :
123 fDarcHeader(o.fDarcHeader), fDarcScalars(o.fDarcScalars),
124 fGlobalHeader(o.fGlobalHeader), fGlobalScalars(o.fGlobalScalars)
128 /// Implement shallow copying in the assignment operator.
129 AliHeader& operator = (const AliHeader& object)
131 memcpy(this, &object, sizeof(AliHeader));
135 /// Default destructor.
138 /// Return first word
139 UInt_t GetWord() const {return GetDarcHeader();}
140 /// Return global input
141 UInt_t GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
142 /// Return global output
143 UChar_t GetGlobalOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalOutput(fGlobalHeader);}
144 /// Return global config
145 UShort_t GetGlobalConfig() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalConfig(fGlobalHeader);}
147 /// Return event type
148 UChar_t GetEventType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcEventType(GetDarcHeader());}
149 /// Returns true if this was a physics event.
150 Bool_t IsPhysicsEvent() const {return GetEventType() == 0x1;}
152 UChar_t GetDarcType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcType(GetDarcHeader());}
153 /// Return serial number
154 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcSerialNb(GetDarcHeader());}
156 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVersion(GetDarcHeader());}
158 Bool_t GetVMETrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVMETrig(GetDarcHeader());}
159 /// Return global flag
160 Bool_t GetGlobalFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcGlobalFlag(GetDarcHeader());}
161 /// Return CPT trigger
162 Bool_t GetCTPTrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcCTPTrig(GetDarcHeader());}
164 Bool_t GetDAQFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcDAQFlag(GetDarcHeader());}
165 /// Return reg pattern
166 UChar_t GetRegPattern() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcRegPattern(GetDarcHeader());}
169 /// Return DARC L0 received and used
170 UInt_t GetDarcL0R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL0R : 0;}
171 /// Return DARC L1 physics
172 UInt_t GetDarcL1P() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1P : 0;}
173 /// Return DARC L1 software
174 UInt_t GetDarcL1S() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1S : 0;}
175 /// Return DARC L2 accept
176 UInt_t GetDarcL2A() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2A : 0;}
177 /// Return DARC L2 reject
178 UInt_t GetDarcL2R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2R : 0;}
179 /// Return DARC clock
180 UInt_t GetDarcClock() const {return (fDarcScalars != NULL) ? fDarcScalars->fClk : 0;}
181 /// Return DARC hold (dead time)
182 UInt_t GetDarcHold() const {return (fDarcScalars != NULL) ? fDarcScalars->fHold : 0;}
184 // global get methods
186 UInt_t GetGlobalL0() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fL0 : 0;}
187 /// Return global clock
188 UInt_t GetGlobalClock() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fClk : 0;}
189 /// Return global scalars or NULL if none exist.
190 const UInt_t* GetGlobalScaler() const {return (fGlobalScalars != NULL) ? &fGlobalScalars->fScaler[0] : NULL;}
191 /// Return global hold (dead time)
192 UInt_t GetGlobalHold() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fHold : 0;}
193 /// Return global spare
194 UInt_t GetGlobalSpare() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fSpare : 0;}
196 /// Return true if type for DARC is default.
197 Bool_t DarcIsDefaultType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcDefaultType();}
198 /// Return true if type for DARC is Vadorh.
199 Bool_t DarcIsVadohrType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcVadorhType();}
201 /// Return the DARC header's raw data.
202 UInt_t GetDarcHeader() const {return fDarcHeader;}
204 /// Return the DARC scalars raw data or NULL if none exist.
205 const AliMUONDarcScalarsStruct* GetDarcScalars() const {return fDarcScalars;}
207 /// Return the global header's raw data.
208 const AliMUONGlobalHeaderStruct* GetGlobalHeader() const {return fGlobalHeader;}
210 /// Return the global scalars raw data or NULL if none exist.
211 const AliMUONGlobalScalarsStruct* GetGlobalScalars() const {return fGlobalScalars;}
213 /// Print the contents of the headers to screen.
218 UInt_t fDarcHeader; ///< Pointer to DARC header in DDL payload.
219 const AliMUONDarcScalarsStruct* fDarcScalars; ///< Pointer to DARC scalars in DDL payload.
220 const AliMUONGlobalHeaderStruct* fGlobalHeader; ///< Pointer to global header in DDL payload.
221 const AliMUONGlobalScalarsStruct* fGlobalScalars; ///< Pointer to global scalars in DDL payload.
224 /// Light weight interface class to the regional card header data.
225 class AliRegionalHeader
228 /// Default constructor.
230 const AliLocalStruct* localsArray = NULL,
231 const AliMUONRegionalHeaderStruct* header = NULL,
232 const AliMUONRegionalScalarsStruct* scalars = NULL
234 fNext(NULL), fLocalsCount(0), fFirstLocal(localsArray),
235 fHeader(header), fScalars(scalars)
239 /// Implement shallow copying in the copy constructor.
240 AliRegionalHeader(const AliRegionalHeader& o) :
241 fNext(o.fNext), fLocalsCount(o.fLocalsCount),
242 fFirstLocal(o.fFirstLocal), fHeader(o.fHeader),
247 /// Implement shallow copying in the assignment operator.
248 AliRegionalHeader& operator = (const AliRegionalHeader& object)
250 memcpy(this, &object, sizeof(AliRegionalHeader));
254 /// Default destructor.
255 ~AliRegionalHeader() {};
258 UInt_t GetDarcWord() const {return fHeader->fDarcWord;}
259 /// Return first reg word
260 UInt_t GetWord() const {return fHeader->fWord;}
261 /// Return regional input
262 UInt_t GetInput(Int_t n) const {assert(n < 2); return fHeader->fInput[n];}
264 UShort_t GetL0() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0(fHeader);}
266 UShort_t GetMask() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalMask(fHeader);}
268 //word: phys type:1, reset: 6, serialNb:5, Id:4, version: 8, regional output:8
269 //true for phys, false for soft
270 /// Return RegPhysFlag
271 Bool_t GetRegPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPhysFlag(fHeader);}
273 UChar_t GetResetNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalResetNb(fHeader);}
275 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalSerialNb(fHeader);}
277 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalId(fHeader);}
279 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalVersion(fHeader);}
281 UChar_t GetOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalOutput(fHeader);}
283 //Darc Status: error:10, #fpag:3, MBZ:3, phys type:1, present:1, not_full:1
284 // not_empty:1, L2Rej:1, L2Acc:1, L1:1, L0:1, #evt:4, busy:4
286 UShort_t GetErrorBits() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalErrorBits(fHeader);}
287 /// Return FPGANumber
288 UChar_t GetFPGANumber() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalFPGANumber(fHeader);}
289 /// Return DarcPhysFlag
290 Bool_t GetDarcPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalDarcPhysFlag(fHeader);}
291 /// Return PresentFlag
292 Bool_t GetPresentFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPresentFlag(fHeader);}
293 /// Return RamNotFullFlag
294 Bool_t GetRamNotFullFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotFullFlag(fHeader);}
295 /// Return RamNotEmptyFlag
296 Bool_t GetRamNotEmptyFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotEmptyFlag(fHeader);}
297 /// Return L2RejStatus
298 Bool_t GetL2RejStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2RejStatus(fHeader);}
299 /// Return L2AccStatus
300 Bool_t GetL2AccStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2AccStatus(fHeader);}
302 Bool_t GetL1Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL1Status(fHeader);}
304 Bool_t GetL0Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0Status(fHeader);}
305 /// Return EventInRam
306 UChar_t GetEventInRam() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalEventInRam(fHeader);}
308 UChar_t GetBusy() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalBusy(fHeader);}
311 /// Return regional clock
312 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
313 /// Return regional ouput
314 const UInt_t* GetScaler() const {return (fScalars != NULL) ? &fScalars->fScaler[0] : NULL;}
315 /// Return regional hold (dead time)
316 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
318 /// Return raw data of regional header.
319 const AliMUONRegionalHeaderStruct* GetHeader() const { return fHeader; }
321 /// Return the raw data of the regional scalars or NULL if none exist.
322 const AliMUONRegionalScalarsStruct* GetScalars() const { return fScalars; }
324 /// Return the next regional structure header.
325 const AliRegionalHeader* Next() const { return fNext; }
327 /// Returns the first AliLocalStruct class in this regional structure.
328 const AliLocalStruct* GetFirstLocalStruct() const { return fFirstLocal; }
330 /// Returns the number of local trigger structures within this regional structure.
331 UInt_t GetLocalStructCount() const { return fLocalsCount; }
333 /// Return the i'th local trigger structure in this regional structure.
334 const AliLocalStruct* GetLocalStruct(UInt_t i) const
336 return i < fLocalsCount ? GetFirstLocalStruct() + i : NULL;
339 /// Sets the next regional structure header.
340 void SetNext(const AliRegionalHeader* next) { fNext = next; }
342 /// Increments the local trigger structure count.
343 void IncLocalStructCount() { fLocalsCount++; };
345 /// Print the contents of the regional header and scalars to screen.
350 const AliRegionalHeader* fNext; ///< Pointer to next regional header.
351 UInt_t fLocalsCount; ///< The number of AliLocalStruct objects found in the array pointed to by fFirstLocal.
352 const AliLocalStruct* fFirstLocal; ///< The first local trigger structure of this regional structure.
353 const AliMUONRegionalHeaderStruct* fHeader; ///< Pointer to the regional header in the DDL payload.
354 const AliMUONRegionalScalarsStruct* fScalars; ///< Pointer to the regional scalars in the DDL payload.
357 /// Light weight interface class to the local trigger card data.
361 /// Default constructor.
363 const AliRegionalHeader* regionalHeader = NULL,
364 const AliMUONLocalInfoStruct* localStruct = NULL,
365 const AliMUONLocalScalarsStruct* scalars = NULL
367 fRegional(regionalHeader), fNext(NULL),
368 fLocalStruct(localStruct), fScalars(scalars)
372 /// Implement shallow copying in the copy constructor.
373 AliLocalStruct(const AliLocalStruct& o) :
374 fRegional(o.fRegional), fNext(o.fNext),
375 fLocalStruct(o.fLocalStruct), fScalars(o.fScalars)
379 /// Implement shallow copying in the assignment operator.
380 AliLocalStruct& operator = (const AliLocalStruct& object)
382 memcpy(this, &object, sizeof(AliLocalStruct));
386 /// Default destructor.
387 ~AliLocalStruct() {};
389 /// Return local data
390 UInt_t GetData(Int_t n) const
393 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
397 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
399 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
401 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
403 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
406 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
408 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
410 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
412 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
414 /// return X pattern array
415 void GetXPattern(TArrayS& array) const
417 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
421 /// return Y pattern array
422 void GetYPattern(TArrayS& array) const
424 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
429 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
431 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
433 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
435 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
437 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
438 /// Get Sign of X deviation
439 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
441 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
443 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
445 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
447 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
449 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
453 UInt_t GetL0() const {return (fScalars != NULL) ? fScalars->fL0 : 0;}
454 /// Return local hold (dead time)
455 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
456 /// Return local clock
457 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
460 UShort_t GetSwitch() const
462 return (fScalars != NULL) ?
463 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
467 UChar_t GetComptXY() const
469 return (fScalars != NULL) ?
470 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
474 UShort_t GetXY1(Int_t n) const
476 return (fScalars != NULL) ?
477 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
481 UShort_t GetXY2(Int_t n) const
483 return (fScalars != NULL) ?
484 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
488 UShort_t GetXY3(Int_t n) const
490 return (fScalars != NULL) ?
491 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
495 UShort_t GetXY4(Int_t n) const
497 return (fScalars != NULL) ?
498 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
501 /// Return raw data of the local trigger structure.
502 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
504 /// Return raw data of the local trigger scalars.
505 /// Could be NULL if no scalars present.
506 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
508 /// Return the parent regional header.
509 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
511 /// Return the next local trigger structure.
512 const AliLocalStruct* Next() const { return fNext; }
514 /// Sets the next local trigger structure.
515 void SetNext(const AliLocalStruct* next) { fNext = next; }
517 /// Print the contents of the local trigger structure and contents to screen.
522 const AliRegionalHeader* fRegional; ///< The regional structure this local trigger structure belongs to.
523 const AliLocalStruct* fNext; ///< Next local structure object in the regional structure.
524 const AliMUONLocalInfoStruct* fLocalStruct; ///< Pointer to the local trigger structure data in the DDL payload.
525 const AliMUONLocalScalarsStruct* fScalars; ///< Pointer to the local trigger scalars data in the DDL payload.
528 /// Returns the DARC and global headers plus scalars if they exist.
529 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
531 /// Return the number of regional structures in the DDL payload.
532 UInt_t GetRegionalHeaderCount() const
534 return fDecoder.GetHandler().RegionalHeaderCount();
537 /// Return the first regional structure header.
538 const AliRegionalHeader* GetFirstRegionalHeader() const
540 return fDecoder.GetHandler().RegionalHeader(0);
543 /// Return the i'th regional header or NULL if not found.
544 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
546 return fDecoder.GetHandler().RegionalHeader(i);
549 /// Returns the number of local trigger structures for the given
550 /// regional structure number.
551 UInt_t GetLocalStructCount(UInt_t reg) const
553 const AliRegionalHeader* r = GetRegionalHeader(reg);
554 return r != NULL ? r->GetLocalStructCount() : 0;
557 /// Returns the i'th local trigger structure for the given regional
558 /// structure number or NULL if not found.
559 const AliLocalStruct* GetLocalStruct(UInt_t reg, UInt_t i) const
561 const AliRegionalHeader* r = GetRegionalHeader(reg);
562 return r != NULL ? r->GetLocalStruct(i) : NULL;
565 /// Returns the current local struct being decoded or NULL if none found.
566 const AliLocalStruct* CurrentLocalStruct() const
568 return (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
569 fkCurrentLocalStruct : NULL;
572 /// Returns the current regional structure being decoded
573 /// or NULL if none found.
574 const AliRegionalHeader* CurrentRegionalHeader() const
576 const AliLocalStruct* local = CurrentLocalStruct();
577 return (local != NULL) ? local->GetRegionalHeader() : NULL;
582 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
584 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
587 /// This is the custom event handler (callback interface) class which
588 /// unpacks raw data words and fills an internal buffer with decoded digits
589 /// as they are decoded by the high performance decoder.
590 /// Any errors are logged to the parent AliMUONVRawStreamTrigger, so one
591 /// must set this pointer appropriately before decoding and DDL payload.
592 class AliDecoderEventHandler : public AliMUONTriggerDDLDecoderEventHandler
596 /// Default constructor.
597 AliDecoderEventHandler();
598 /// Default destructor.
599 virtual ~AliDecoderEventHandler();
601 /// Sets the internal arrays based on the maximum number of structures allowed.
602 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
604 /// Sets the raw stream object which should be the parent of this class.
605 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
607 /// Returns the decoded DARC and global headers (and scalars if they exist).
608 const AliHeader* GetHeaders() const { return &fHeaders; }
610 /// Returns the number of regional headers.
611 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
613 /// Return the i'th regional structure header.
614 const AliRegionalHeader* RegionalHeader(UInt_t i) const
616 return i < fRegionalsCount ? &fRegionals[i] : NULL;
619 /// Return the first local structure decoded.
620 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
622 /// Returns the marker to the end of local structures.
623 /// i.e. one position past the last local structure in fLocals.
624 const AliLocalStruct* EndOfLocalStructs() const { return fEndOfLocals; }
626 /// Get number of end of DARC word errors.
627 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
629 /// Get number of end of Global word errors.
630 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
632 /// Get number of end of regional word errors.
633 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
635 /// Get number of end of local word errors.
636 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
638 /// Returns the warnings flag.
639 Bool_t Warnings() const { return fWarnings; }
640 /// Sets the warnings flag.
641 void Warnings(Bool_t value) { fWarnings = value; }
643 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
645 /// New buffer handler.
646 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
648 /// End of buffer handler marks the end of local trigger structures.
649 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
651 fEndOfLocals = fCurrentLocal+1;
654 /// Handler for the DARC header which just remembers the pointers for later.
655 void OnDarcHeader(UInt_t header,
656 const AliMUONDarcScalarsStruct* scalars,
657 const void* /*data*/)
659 fDarcHeader = header;
660 fDarcScalars = scalars;
663 /// Handler for the global header which stores the pointer to the headers.
664 void OnGlobalHeader(const AliMUONGlobalHeaderStruct* header,
665 const AliMUONGlobalScalarsStruct* scalars,
666 const void* /*data*/)
668 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
671 /// Handler for new regional card structures.
672 void OnNewRegionalStructV2(UInt_t iReg,
673 const AliMUONRegionalHeaderStruct* header,
674 const AliMUONRegionalScalarsStruct* scalars,
677 /// Handler for new local card structures.
678 void OnLocalStruct(const AliMUONLocalInfoStruct* localStruct,
679 const AliMUONLocalScalarsStruct* scalars);
682 void OnError(ErrorCode error, const void* location);
686 // Do not allow copying of this class.
688 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
690 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
692 AliMUONVRawStreamTrigger* fRawStream; //!< Pointer to the parent raw stream object.
693 const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer.
694 UInt_t fDarcHeader; //!< Currently decoded DARC header.
695 const AliMUONDarcScalarsStruct* fDarcScalars; //!< Currently decoded DARC scalars.
696 AliHeader fHeaders; //!< Headers of the DDL payload.
697 UInt_t fRegionalsCount; //!< Number of regional headers filled in fRegionals.
698 AliRegionalHeader* fRegionals; //!< Array of regional headers. [0..fMaxRegionals-1]
699 AliLocalStruct* fLocals; //!< Array of decoded local structured. [0..fMaxRegionals*fMaxLocals-1]
700 AliLocalStruct* fEndOfLocals; //!< Marker indicating the position just passed the last filled element in fLocals.
701 AliRegionalHeader* fCurrentRegional; //!< Current regional header position.
702 AliLocalStruct* fCurrentLocal; //!< Current local trigger structure.
703 UInt_t fDarcEoWErrors; //!< Number of end of DARC word errors.
704 UInt_t fGlobalEoWErrors; //!< Number of end of global word errors.
705 UInt_t fRegEoWErrors; //!< Number of end of regional word errors.
706 UInt_t fLocalEoWErrors; //!< Number of end of local word errors.
707 Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors.
709 static const AliMUONRegionalHeaderStruct fgkEmptyHeader; //!< Empty header for skipped regional structures.
712 AliMUONTriggerDDLDecoder<AliDecoderEventHandler> fDecoder; //!< The decoder for the DDL payload.
713 Int_t fDDL; //!< The current DDL number being handled.
714 Int_t fBufferSize; //!< This is the buffer size in bytes of fBuffer.
715 UChar_t* fBuffer; //!< This is the buffer in which we store the DDL payload read from AliRawReader.
716 const AliLocalStruct* fkCurrentLocalStruct; //!< The current local trigger structure being handled by Next().
717 Bool_t fHadError; //!< Flag indicating if there was a decoding error or not.
718 Bool_t fDone; //!< Flag indicating if the iteration is done or not.
719 mutable AliMUONDDLTrigger* fDDLObject; //!< Temporary DDL object used by GetDDLTrigger() for caching.
721 static const Int_t fgkMaxDDL; //!< Maximum number of DDLs
723 ClassDef(AliMUONRawStreamTriggerHP, 0) // Higher performance decoder class for MUON trigger rawdata.
726 ////////////////////////////////////////////////////////////////////////////////
728 inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerHP::Next()
730 /// Iterates through all the local trigger structures for the event.
731 /// When no more local triggers are found then NULL is returned.
734 if (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
735 return fkCurrentLocalStruct++;
741 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStructV2(
743 const AliMUONRegionalHeaderStruct* header,
744 const AliMUONRegionalScalarsStruct* scalars,
748 /// New regional structure handler is called by the decoder whenever a
749 /// new regional header is found. We just mark the header and increment
750 /// the appropriate counters.
752 assert( header != NULL );
753 assert( iReg < fRegionalsCount );
755 fCurrentRegional = fRegionals+iReg;
756 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
758 // Link to the next regional structure unless this is the last one.
759 if (iReg+1 < fRegionalsCount)
761 fCurrentRegional->SetNext(fCurrentRegional+1);
766 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
767 const AliMUONLocalInfoStruct* localStruct,
768 const AliMUONLocalScalarsStruct* scalars
771 /// New local trigger structure handler.
772 /// This is called by the high performance decoder when a new local trigger
773 /// structure is found within the DDL payload.
774 /// We mark the location of the structure in the DDL paytload and increment
775 /// appropriate counters.
777 assert( localStruct != NULL );
778 assert( fCurrentLocal != NULL );
779 assert( fCurrentRegional != NULL );
780 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
782 // Link the previous local structure unless it is the first one.
783 if (fCurrentRegional->GetLocalStructCount() > 0)
785 fCurrentLocal->SetNext(fCurrentLocal+1);
789 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
790 fCurrentRegional->IncLocalStructCount();
793 #endif // ALIMUONRAWSTREAMTRIGGERHP_H