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.RegionalsDecoded(); }
65 /// Return maximum allowed number of regional cards in the DDL.
66 virtual Int_t GetMaxRegAllowed() const { return (Int_t) fDecoder.MaxRegionals(); }
68 /// Set the maximum allowed number of regional cards in the DDL.
69 virtual void SetMaxRegAllowed(Int_t reg);
71 /// Return maximum number of local cards in the DDL.
72 virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
74 /// Sets the maximum number of local cards in the DDL.
75 virtual void SetMaxLoc(Int_t loc);
77 /// Return number of the current DDL being handled.
78 virtual Int_t GetDDL() const { return fDDL - 1; }
80 /// check error/Warning presence
81 virtual Bool_t IsErrorMessage() const { return fHadError; }
83 /// Set warnings flag to disable warnings on data errors.
84 virtual void DisableWarnings() { fDecoder.GetHandler().Warnings(kFALSE); }
85 /// Set warnings flag to enable warnings on data errors.
86 virtual void EnableWarnings() { fDecoder.GetHandler().Warnings(kTRUE); }
88 /// Get number of end of DARC word errors.
89 UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
91 /// Get number of end of Global word errors.
92 UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
94 /// Get number of end of regional word errors.
95 UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
97 /// Get number of end of local word errors.
98 UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
100 /// Returns the "try to recover from errors" flag.
101 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
103 /// Sets the "try to recover from errors" flag.
104 /// i.e. should the decoder try to recover from errors found in the
106 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
108 /// Light weight interface class to the DARC and global header data.
112 /// Default constructor.
114 UInt_t darcHeader = 0,
115 const AliMUONDarcScalarsStruct* darcScalars = NULL,
116 const AliMUONGlobalHeaderStruct* globalHeader = NULL,
117 const AliMUONGlobalScalarsStruct* globalScalars = NULL
119 fDarcHeader(darcHeader), fDarcScalars(darcScalars),
120 fGlobalHeader(globalHeader), fGlobalScalars(globalScalars)
124 /// Implement shallow copying in the copy constructor.
125 AliHeader(const AliHeader& o) :
126 fDarcHeader(o.fDarcHeader), fDarcScalars(o.fDarcScalars),
127 fGlobalHeader(o.fGlobalHeader), fGlobalScalars(o.fGlobalScalars)
131 /// Implement shallow copying in the assignment operator.
132 AliHeader& operator = (const AliHeader& object)
134 memcpy(this, &object, sizeof(AliHeader));
138 /// Default destructor.
141 /// Return first word
142 UInt_t GetWord() const {return GetDarcHeader();}
143 /// Return global input
144 Int_t GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
145 /// Return global output
146 UChar_t GetGlobalOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalOutput(fGlobalHeader);}
147 /// Return global config
148 UShort_t GetGlobalConfig() const {return AliMUONTriggerDDLDecoderEventHandler::GetGlobalConfig(fGlobalHeader);}
150 /// Return event type
151 UChar_t GetEventType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcEventType(GetDarcHeader());}
152 /// Returns true if this was a physics event.
153 Bool_t IsPhysicsEvent() const {return GetEventType() == 0x1;}
155 UChar_t GetDarcType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcType(GetDarcHeader());}
156 /// Return serial number
157 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcSerialNb(GetDarcHeader());}
159 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVersion(GetDarcHeader());}
161 Bool_t GetVMETrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVMETrig(GetDarcHeader());}
162 /// Return global flag
163 Bool_t GetGlobalFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcGlobalFlag(GetDarcHeader());}
164 /// Return CPT trigger
165 Bool_t GetCTPTrig() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcCTPTrig(GetDarcHeader());}
167 Bool_t GetDAQFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcDAQFlag(GetDarcHeader());}
168 /// Return reg pattern
169 UChar_t GetRegPattern() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcRegPattern(GetDarcHeader());}
172 /// Return DARC L0 received and used
173 UInt_t GetDarcL0R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL0R : 0;}
174 /// Return DARC L1 physics
175 UInt_t GetDarcL1P() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1P : 0;}
176 /// Return DARC L1 software
177 UInt_t GetDarcL1S() const {return (fDarcScalars != NULL) ? fDarcScalars->fL1S : 0;}
178 /// Return DARC L2 accept
179 UInt_t GetDarcL2A() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2A : 0;}
180 /// Return DARC L2 reject
181 UInt_t GetDarcL2R() const {return (fDarcScalars != NULL) ? fDarcScalars->fL2R : 0;}
182 /// Return DARC clock
183 UInt_t GetDarcClock() const {return (fDarcScalars != NULL) ? fDarcScalars->fClk : 0;}
184 /// Return DARC hold (dead time)
185 UInt_t GetDarcHold() const {return (fDarcScalars != NULL) ? fDarcScalars->fHold : 0;}
187 // global get methods
189 UInt_t GetGlobalL0() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fL0 : 0;}
190 /// Return global clock
191 UInt_t GetGlobalClock() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fClk : 0;}
192 /// Return global scalars or NULL if none exist.
193 const UInt_t* GetGlobalScaler() const {return (fGlobalScalars != NULL) ? &fGlobalScalars->fScaler[0] : NULL;}
194 /// Return global hold (dead time)
195 UInt_t GetGlobalHold() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fHold : 0;}
196 /// Return global spare
197 UInt_t GetGlobalSpare() const {return (fGlobalScalars != NULL) ? fGlobalScalars->fSpare : 0;}
199 /// Return true if type for DARC is default.
200 Bool_t DarcIsDefaultType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcDefaultType();}
201 /// Return true if type for DARC is Vadorh.
202 Bool_t DarcIsVadohrType() const {return GetDarcType() == AliMUONTriggerDDLDecoder<AliMUONTriggerDDLDecoderEventHandler>::DarcVadorhType();}
204 /// Return the DARC header's raw data.
205 UInt_t GetDarcHeader() const {return fDarcHeader;}
207 /// Return the DARC scalars raw data or NULL if none exist.
208 const AliMUONDarcScalarsStruct* GetDarcScalars() const {return fDarcScalars;}
210 /// Return the global header's raw data.
211 const AliMUONGlobalHeaderStruct* GetGlobalHeader() const {return fGlobalHeader;}
213 /// Return the global scalars raw data or NULL if none exist.
214 const AliMUONGlobalScalarsStruct* GetGlobalScalars() const {return fGlobalScalars;}
216 /// Print the contents of the headers to screen.
221 UInt_t fDarcHeader; ///< Pointer to DARC header in DDL payload.
222 const AliMUONDarcScalarsStruct* fDarcScalars; ///< Pointer to DARC scalars in DDL payload.
223 const AliMUONGlobalHeaderStruct* fGlobalHeader; ///< Pointer to global header in DDL payload.
224 const AliMUONGlobalScalarsStruct* fGlobalScalars; ///< Pointer to global scalars in DDL payload.
227 /// Light weight interface class to the regional card header data.
228 class AliRegionalHeader
231 /// Default constructor.
233 const AliLocalStruct* localsArray = NULL,
234 const AliMUONRegionalHeaderStruct* header = NULL,
235 const AliMUONRegionalScalarsStruct* scalars = NULL
237 fNext(NULL), fLocalsCount(0), fFirstLocal(localsArray),
238 fHeader(header), fScalars(scalars)
242 /// Implement shallow copying in the copy constructor.
243 AliRegionalHeader(const AliRegionalHeader& o) :
244 fNext(o.fNext), fLocalsCount(o.fLocalsCount),
245 fFirstLocal(o.fFirstLocal), fHeader(o.fHeader),
250 /// Implement shallow copying in the assignment operator.
251 AliRegionalHeader& operator = (const AliRegionalHeader& object)
253 memcpy(this, &object, sizeof(AliRegionalHeader));
257 /// Default destructor.
258 ~AliRegionalHeader() {};
261 UInt_t GetDarcWord() const {return fHeader->fDarcWord;}
262 /// Return first reg word
263 UInt_t GetWord() const {return fHeader->fWord;}
264 /// Return regional input
265 UInt_t GetInput(Int_t n) const {assert(n < 2); return fHeader->fInput[n];}
267 UShort_t GetL0() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0(fHeader);}
269 UShort_t GetMask() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalMask(fHeader);}
271 //word: phys type:1, reset: 6, serialNb:5, Id:4, version: 8, regional output:8
272 //true for phys, false for soft
273 /// Return RegPhysFlag
274 Bool_t GetRegPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPhysFlag(fHeader);}
276 UChar_t GetResetNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalResetNb(fHeader);}
278 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalSerialNb(fHeader);}
280 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalId(fHeader);}
282 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalVersion(fHeader);}
284 UChar_t GetOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalOutput(fHeader);}
286 //Darc Status: error:10, #fpag:3, MBZ:3, phys type:1, present:1, not_full:1
287 // not_empty:1, L2Rej:1, L2Acc:1, L1:1, L0:1, #evt:4, busy:4
289 UShort_t GetErrorBits() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalErrorBits(fHeader);}
290 /// Return FPGANumber
291 UChar_t GetFPGANumber() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalFPGANumber(fHeader);}
292 /// Return DarcPhysFlag
293 Bool_t GetDarcPhysFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalDarcPhysFlag(fHeader);}
294 /// Return PresentFlag
295 Bool_t GetPresentFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalPresentFlag(fHeader);}
296 /// Return RamNotFullFlag
297 Bool_t GetRamNotFullFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotFullFlag(fHeader);}
298 /// Return RamNotEmptyFlag
299 Bool_t GetRamNotEmptyFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalRamNotEmptyFlag(fHeader);}
300 /// Return L2RejStatus
301 Bool_t GetL2RejStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2RejStatus(fHeader);}
302 /// Return L2AccStatus
303 Bool_t GetL2AccStatus() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL2AccStatus(fHeader);}
305 Bool_t GetL1Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL1Status(fHeader);}
307 Bool_t GetL0Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0Status(fHeader);}
308 /// Return EventInRam
309 UChar_t GetEventInRam() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalEventInRam(fHeader);}
311 UChar_t GetBusy() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalBusy(fHeader);}
314 /// Return regional clock
315 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
316 /// Return regional ouput
317 const UInt_t* GetScaler() const {return (fScalars != NULL) ? &fScalars->fScaler[0] : NULL;}
318 /// Return regional hold (dead time)
319 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
321 /// Return raw data of regional header.
322 const AliMUONRegionalHeaderStruct* GetHeader() const { return fHeader; }
324 /// Return the raw data of the regional scalars or NULL if none exist.
325 const AliMUONRegionalScalarsStruct* GetScalars() const { return fScalars; }
327 /// Return the next regional structure header.
328 const AliRegionalHeader* Next() const { return fNext; }
330 /// Returns the first AliLocalStruct class in this regional structure.
331 const AliLocalStruct* GetFirstLocalStruct() const { return fFirstLocal; }
333 /// Returns the number of local trigger structures within this regional structure.
334 UInt_t GetLocalStructCount() const { return fLocalsCount; }
336 /// Return the i'th local trigger structure in this regional structure.
337 const AliLocalStruct* GetLocalStruct(UInt_t i) const
339 return i < fLocalsCount ? GetFirstLocalStruct() + i : NULL;
342 /// Sets the next regional structure header.
343 void SetNext(const AliRegionalHeader* next) { fNext = next; }
345 /// Increments the local trigger structure count.
346 void IncLocalStructCount() { fLocalsCount++; };
348 /// Print the contents of the regional header and scalars to screen.
353 const AliRegionalHeader* fNext; ///< Pointer to next regional header.
354 UInt_t fLocalsCount; ///< The number of AliLocalStruct objects found in the array pointed to by fFirstLocal.
355 const AliLocalStruct* fFirstLocal; ///< The first local trigger structure of this regional structure.
356 const AliMUONRegionalHeaderStruct* fHeader; ///< Pointer to the regional header in the DDL payload.
357 const AliMUONRegionalScalarsStruct* fScalars; ///< Pointer to the regional scalars in the DDL payload.
360 /// Light weight interface class to the local trigger card data.
364 /// Default constructor.
366 const AliRegionalHeader* regionalHeader = NULL,
367 const AliMUONLocalInfoStruct* localStruct = NULL,
368 const AliMUONLocalScalarsStruct* scalars = NULL
370 fRegional(regionalHeader), fNext(NULL),
371 fLocalStruct(localStruct), fScalars(scalars)
375 /// Implement shallow copying in the copy constructor.
376 AliLocalStruct(const AliLocalStruct& o) :
377 fRegional(o.fRegional), fNext(o.fNext),
378 fLocalStruct(o.fLocalStruct), fScalars(o.fScalars)
382 /// Implement shallow copying in the assignment operator.
383 AliLocalStruct& operator = (const AliLocalStruct& object)
385 memcpy(this, &object, sizeof(AliLocalStruct));
389 /// Default destructor.
390 ~AliLocalStruct() {};
392 /// Return local data
393 UInt_t GetData(Int_t n) const
396 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
400 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
402 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
404 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
406 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
409 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
411 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
413 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
415 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
417 /// return X pattern array
418 void GetXPattern(TArrayS& array) const
420 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
424 /// return Y pattern array
425 void GetYPattern(TArrayS& array) const
427 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
432 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
434 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
436 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
438 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
440 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
441 /// Get Sign of X deviation
442 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
444 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
446 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
448 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
450 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
452 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
456 UInt_t GetL0() const {return (fScalars != NULL) ? fScalars->fL0 : 0;}
457 /// Return local hold (dead time)
458 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
459 /// Return local clock
460 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
463 UShort_t GetSwitch() const
465 return (fScalars != NULL) ?
466 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
470 UChar_t GetComptXY() const
472 return (fScalars != NULL) ?
473 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
477 UShort_t GetXY1(Int_t n) const
479 return (fScalars != NULL) ?
480 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
484 UShort_t GetXY2(Int_t n) const
486 return (fScalars != NULL) ?
487 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
491 UShort_t GetXY3(Int_t n) const
493 return (fScalars != NULL) ?
494 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
498 UShort_t GetXY4(Int_t n) const
500 return (fScalars != NULL) ?
501 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
504 /// Return raw data of the local trigger structure.
505 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
507 /// Return raw data of the local trigger scalars.
508 /// Could be NULL if no scalars present.
509 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
511 /// Return the parent regional header.
512 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
514 /// Return the next local trigger structure.
515 const AliLocalStruct* Next() const { return fNext; }
517 /// Sets the next local trigger structure.
518 void SetNext(const AliLocalStruct* next) { fNext = next; }
520 /// Print the contents of the local trigger structure and contents to screen.
525 const AliRegionalHeader* fRegional; ///< The regional structure this local trigger structure belongs to.
526 const AliLocalStruct* fNext; ///< Next local structure object in the regional structure.
527 const AliMUONLocalInfoStruct* fLocalStruct; ///< Pointer to the local trigger structure data in the DDL payload.
528 const AliMUONLocalScalarsStruct* fScalars; ///< Pointer to the local trigger scalars data in the DDL payload.
531 /// Returns the DARC and global headers plus scalars if they exist.
532 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
534 /// Return the number of regional structures in the DDL payload.
535 UInt_t GetRegionalHeaderCount() const
537 return fDecoder.GetHandler().RegionalHeaderCount();
540 /// Return the first regional structure header.
541 const AliRegionalHeader* GetFirstRegionalHeader() const
543 return fDecoder.GetHandler().RegionalHeader(0);
546 /// Return the i'th regional header or NULL if not found.
547 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
549 return fDecoder.GetHandler().RegionalHeader(i);
552 /// Returns the number of local trigger structures for the given
553 /// regional structure number.
554 UInt_t GetLocalStructCount(UInt_t reg) const
556 const AliRegionalHeader* r = GetRegionalHeader(reg);
557 return r != NULL ? r->GetLocalStructCount() : 0;
560 /// Returns the i'th local trigger structure for the given regional
561 /// structure number or NULL if not found.
562 const AliLocalStruct* GetLocalStruct(UInt_t reg, UInt_t i) const
564 const AliRegionalHeader* r = GetRegionalHeader(reg);
565 return r != NULL ? r->GetLocalStruct(i) : NULL;
568 /// Returns the current local struct being decoded or NULL if none found.
569 const AliLocalStruct* CurrentLocalStruct() const
571 return (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
572 fkCurrentLocalStruct : NULL;
575 /// Returns the current regional structure being decoded
576 /// or NULL if none found.
577 const AliRegionalHeader* CurrentRegionalHeader() const
579 const AliLocalStruct* local = CurrentLocalStruct();
580 return (local != NULL) ? local->GetRegionalHeader() : NULL;
585 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
587 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
590 /// This is the custom event handler (callback interface) class which
591 /// unpacks raw data words and fills an internal buffer with decoded digits
592 /// as they are decoded by the high performance decoder.
593 /// Any errors are logged to the parent AliMUONVRawStreamTrigger, so one
594 /// must set this pointer appropriately before decoding and DDL payload.
595 class AliDecoderEventHandler : public AliMUONTriggerDDLDecoderEventHandler
599 /// Default constructor.
600 AliDecoderEventHandler();
601 /// Default destructor.
602 virtual ~AliDecoderEventHandler();
604 /// Sets the internal arrays based on the maximum number of structures allowed.
605 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
607 /// Sets the raw stream object which should be the parent of this class.
608 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
610 /// Returns the decoded DARC and global headers (and scalars if they exist).
611 const AliHeader* GetHeaders() const { return &fHeaders; }
613 /// Returns the number of regional headers.
614 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
616 /// Return the i'th regional structure header.
617 const AliRegionalHeader* RegionalHeader(UInt_t i) const
619 return i < fRegionalsCount ? &fRegionals[i] : NULL;
622 /// Return the first local structure decoded.
623 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
625 /// Returns the marker to the end of local structures.
626 /// i.e. one position past the last local structure in fLocals.
627 const AliLocalStruct* EndOfLocalStructs() const { return fEndOfLocals; }
629 /// Get number of end of DARC word errors.
630 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
632 /// Get number of end of Global word errors.
633 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
635 /// Get number of end of regional word errors.
636 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
638 /// Get number of end of local word errors.
639 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
641 /// Returns the warnings flag.
642 Bool_t Warnings() const { return fWarnings; }
643 /// Sets the warnings flag.
644 void Warnings(Bool_t value) { fWarnings = value; }
646 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
648 /// New buffer handler.
649 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
651 /// End of buffer handler marks the end of local trigger structures.
652 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
654 fEndOfLocals = fCurrentLocal+1;
657 /// Handler for the DARC header which just remembers the pointers for later.
658 void OnDarcHeader(UInt_t header,
659 const AliMUONDarcScalarsStruct* scalars,
660 const void* /*data*/)
662 fDarcHeader = header;
663 fDarcScalars = scalars;
666 /// Handler for the global header which stores the pointer to the headers.
667 void OnGlobalHeader(const AliMUONGlobalHeaderStruct* header,
668 const AliMUONGlobalScalarsStruct* scalars,
669 const void* /*data*/)
671 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
674 /// Handler for new regional card structures.
675 void OnNewRegionalStruct(const AliMUONRegionalHeaderStruct* header,
676 const AliMUONRegionalScalarsStruct* scalars,
679 /// Handler for new local card structures.
680 void OnLocalStruct(const AliMUONLocalInfoStruct* localStruct,
681 const AliMUONLocalScalarsStruct* scalars);
684 void OnError(ErrorCode error, const void* location);
688 // Do not allow copying of this class.
690 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
692 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
694 AliMUONVRawStreamTrigger* fRawStream; //!< Pointer to the parent raw stream object.
695 const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer.
696 UInt_t fDarcHeader; //!< Currently decoded DARC header.
697 const AliMUONDarcScalarsStruct* fDarcScalars; //!< Currently decoded DARC scalars.
698 AliHeader fHeaders; //!< Headers of the DDL payload.
699 UInt_t fRegionalsCount; //!< Number of regional headers filled in fRegionals.
700 AliRegionalHeader* fRegionals; //!< Array of regional headers. [0..fMaxRegionals-1]
701 AliLocalStruct* fLocals; //!< Array of decoded local structured. [0..fMaxRegionals*fMaxLocals-1]
702 AliLocalStruct* fEndOfLocals; //!< Marker indicating the position just passed the last filled element in fLocals.
703 AliRegionalHeader* fCurrentRegional; //!< Current regional header position.
704 AliLocalStruct* fCurrentLocal; //!< Current local trigger structure.
705 UInt_t fDarcEoWErrors; //!< Number of end of DARC word errors.
706 UInt_t fGlobalEoWErrors; //!< Number of end of global word errors.
707 UInt_t fRegEoWErrors; //!< Number of end of regional word errors.
708 UInt_t fLocalEoWErrors; //!< Number of end of local word errors.
709 Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors.
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::OnNewRegionalStruct(
742 const AliMUONRegionalHeaderStruct* header,
743 const AliMUONRegionalScalarsStruct* scalars,
747 /// New regional structure handler is called by the decoder whenever a
748 /// new regional header is found. We just mark the header and increment
749 /// the appropriate counters.
751 assert( header != NULL );
752 assert( fCurrentRegional != NULL );
753 assert( fRegionalsCount < (UInt_t)fRawStream->GetMaxReg() );
755 // Link the previous regional structure unless it is the first one.
756 if (fRegionalsCount > 0)
758 fCurrentRegional->SetNext(fCurrentRegional+1);
762 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
767 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
768 const AliMUONLocalInfoStruct* localStruct,
769 const AliMUONLocalScalarsStruct* scalars
772 /// New local trigger structure handler.
773 /// This is called by the high performance decoder when a new local trigger
774 /// structure is found within the DDL payload.
775 /// We mark the location of the structure in the DDL paytload and increment
776 /// appropriate counters.
778 assert( localStruct != NULL );
779 assert( fCurrentLocal != NULL );
780 assert( fCurrentRegional != NULL );
781 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
783 // Link the previous local structure unless it is the first one.
784 if (fCurrentRegional->GetLocalStructCount() > 0)
786 fCurrentLocal->SetNext(fCurrentLocal+1);
790 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
791 fCurrentRegional->IncLocalStructCount();
794 #endif // ALIMUONRAWSTREAMTRIGGERHP_H