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),
373 /// Implement shallow copying in the copy constructor.
374 AliLocalStruct(const AliLocalStruct& o) :
375 fRegional(o.fRegional), fNext(o.fNext),
376 fLocalStruct(o.fLocalStruct), fScalars(o.fScalars),
377 fCalculatedId(o.fCalculatedId)
381 /// Implement shallow copying in the assignment operator.
382 AliLocalStruct& operator = (const AliLocalStruct& object)
384 memcpy(this, &object, sizeof(AliLocalStruct));
388 /// Default destructor.
389 ~AliLocalStruct() {};
391 /// Return local data
392 UInt_t GetData(Int_t n) const
395 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
399 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
401 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
403 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
405 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
408 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
410 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
412 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
414 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
416 /// return X pattern array
417 void GetXPattern(TArrayS& array) const
419 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
423 /// return Y pattern array
424 void GetYPattern(TArrayS& array) const
426 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
431 UChar_t GetId() const {return fgOverrideId ? fCalculatedId : AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
433 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
435 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
437 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
439 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
440 /// Get Sign of X deviation
441 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
443 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
445 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
447 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
449 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
451 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
455 UInt_t GetL0() const {return (fScalars != NULL) ? fScalars->fL0 : 0;}
456 /// Return local hold (dead time)
457 UInt_t GetHold() const {return (fScalars != NULL) ? fScalars->fHold : 0;}
458 /// Return local clock
459 UInt_t GetClock() const {return (fScalars != NULL) ? fScalars->fClk : 0;}
462 UShort_t GetSwitch() const
464 return (fScalars != NULL) ?
465 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
469 UChar_t GetComptXY() const
471 return (fScalars != NULL) ?
472 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
476 UShort_t GetXY1(Int_t n) const
478 return (fScalars != NULL) ?
479 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
483 UShort_t GetXY2(Int_t n) const
485 return (fScalars != NULL) ?
486 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
490 UShort_t GetXY3(Int_t n) const
492 return (fScalars != NULL) ?
493 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
497 UShort_t GetXY4(Int_t n) const
499 return (fScalars != NULL) ?
500 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
503 /// Return raw data of the local trigger structure.
504 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
506 /// Return raw data of the local trigger scalars.
507 /// Could be NULL if no scalars present.
508 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
510 /// Return the parent regional header.
511 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
513 /// Return the next local trigger structure.
514 const AliLocalStruct* Next() const { return fNext; }
516 /// Sets the next local trigger structure.
517 void SetNext(const AliLocalStruct* next) { fNext = next; }
519 /// Sets the calculated ID value to be returned by GetId if fgOverrideId is true.
520 void SetCalculatedId(UChar_t id) { fCalculatedId = id; }
522 /// Print the contents of the local trigger structure and contents to screen.
525 /// Returns the override flag indicating if the GetId method should return the calculated Id value or not.
526 static bool GetOverrideIdFlag() { return fgOverrideId; }
528 /// Sets the override flag to control what value the GetId method returns.
529 static void SetOverrideIdFlag(bool value) { fgOverrideId = value; }
533 const AliRegionalHeader* fRegional; ///< The regional structure this local trigger structure belongs to.
534 const AliLocalStruct* fNext; ///< Next local structure object in the regional structure.
535 const AliMUONLocalInfoStruct* fLocalStruct; ///< Pointer to the local trigger structure data in the DDL payload.
536 const AliMUONLocalScalarsStruct* fScalars; ///< Pointer to the local trigger scalars data in the DDL payload.
537 UChar_t fCalculatedId; ///< Calculated ID value returned by GetId() if fgOverrideId == true.
538 static bool fgOverrideId; //!< Flag indicating if we should return a calculated number in the GetId method.
541 /// Returns the DARC and global headers plus scalars if they exist.
542 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
544 /// Return the number of regional structures in the DDL payload.
545 UInt_t GetRegionalHeaderCount() const
547 return fDecoder.GetHandler().RegionalHeaderCount();
550 /// Return the first regional structure header.
551 const AliRegionalHeader* GetFirstRegionalHeader() const
553 return fDecoder.GetHandler().RegionalHeader(0);
556 /// Return the i'th regional header or NULL if not found.
557 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
559 return fDecoder.GetHandler().RegionalHeader(i);
562 /// Returns the number of local trigger structures for the given
563 /// regional structure number.
564 UInt_t GetLocalStructCount(UInt_t reg) const
566 const AliRegionalHeader* r = GetRegionalHeader(reg);
567 return r != NULL ? r->GetLocalStructCount() : 0;
570 /// Returns the i'th local trigger structure for the given regional
571 /// structure number or NULL if not found.
572 const AliLocalStruct* GetLocalStruct(UInt_t reg, UInt_t i) const
574 const AliRegionalHeader* r = GetRegionalHeader(reg);
575 return r != NULL ? r->GetLocalStruct(i) : NULL;
578 /// Returns the current local struct being decoded or NULL if none found.
579 const AliLocalStruct* CurrentLocalStruct() const
581 return (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
582 fkCurrentLocalStruct : NULL;
585 /// Returns the current regional structure being decoded
586 /// or NULL if none found.
587 const AliRegionalHeader* CurrentRegionalHeader() const
589 const AliLocalStruct* local = CurrentLocalStruct();
590 return (local != NULL) ? local->GetRegionalHeader() : NULL;
595 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
597 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
600 /// This is the custom event handler (callback interface) class which
601 /// unpacks raw data words and fills an internal buffer with decoded digits
602 /// as they are decoded by the high performance decoder.
603 /// Any errors are logged to the parent AliMUONVRawStreamTrigger, so one
604 /// must set this pointer appropriately before decoding and DDL payload.
605 class AliDecoderEventHandler : public AliMUONTriggerDDLDecoderEventHandler
609 /// Default constructor.
610 AliDecoderEventHandler();
611 /// Default destructor.
612 virtual ~AliDecoderEventHandler();
614 /// Sets the internal arrays based on the maximum number of structures allowed.
615 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
617 /// Sets the raw stream object which should be the parent of this class.
618 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
620 /// Returns the decoded DARC and global headers (and scalars if they exist).
621 const AliHeader* GetHeaders() const { return &fHeaders; }
623 /// Returns the number of regional headers.
624 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
626 /// Return the i'th regional structure header.
627 const AliRegionalHeader* RegionalHeader(UInt_t i) const
629 return i < fRegionalsCount ? &fRegionals[i] : NULL;
632 /// Return the first local structure decoded.
633 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
635 /// Returns the marker to the end of local structures.
636 /// i.e. one position past the last local structure in fLocals.
637 const AliLocalStruct* EndOfLocalStructs() const { return fEndOfLocals; }
639 /// Get number of end of DARC word errors.
640 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
642 /// Get number of end of Global word errors.
643 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
645 /// Get number of end of regional word errors.
646 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
648 /// Get number of end of local word errors.
649 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
651 /// Returns the warnings flag.
652 Bool_t Warnings() const { return fWarnings; }
653 /// Sets the warnings flag.
654 void Warnings(Bool_t value) { fWarnings = value; }
656 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
658 /// New buffer handler.
659 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
661 /// End of buffer handler marks the end of local trigger structures.
662 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
664 fEndOfLocals = fCurrentLocal+1;
667 /// Handler for the DARC header which just remembers the pointers for later.
668 void OnDarcHeader(UInt_t header,
669 const AliMUONDarcScalarsStruct* scalars,
670 const void* /*data*/)
672 fDarcHeader = header;
673 fDarcScalars = scalars;
676 /// Handler for the global header which stores the pointer to the headers.
677 void OnGlobalHeader(const AliMUONGlobalHeaderStruct* header,
678 const AliMUONGlobalScalarsStruct* scalars,
679 const void* /*data*/)
681 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
684 /// Handler for new regional card structures.
685 void OnNewRegionalStructV2(UInt_t iReg,
686 const AliMUONRegionalHeaderStruct* header,
687 const AliMUONRegionalScalarsStruct* scalars,
690 /// Handler for new local card structures.
691 void OnLocalStructV2(UInt_t iLoc,
692 const AliMUONLocalInfoStruct* localStruct,
693 const AliMUONLocalScalarsStruct* scalars);
696 void OnError(ErrorCode error, const void* location);
700 // Do not allow copying of this class.
702 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
704 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
706 AliMUONVRawStreamTrigger* fRawStream; //!< Pointer to the parent raw stream object.
707 const void* fBufferStart; //!< Pointer to the start of the current DDL payload buffer.
708 UInt_t fDarcHeader; //!< Currently decoded DARC header.
709 const AliMUONDarcScalarsStruct* fDarcScalars; //!< Currently decoded DARC scalars.
710 AliHeader fHeaders; //!< Headers of the DDL payload.
711 UInt_t fRegionalsCount; //!< Number of regional headers filled in fRegionals.
712 AliRegionalHeader* fRegionals; //!< Array of regional headers. [0..fMaxRegionals-1]
713 AliLocalStruct* fLocals; //!< Array of decoded local structured. [0..fMaxRegionals*fMaxLocals-1]
714 AliLocalStruct* fEndOfLocals; //!< Marker indicating the position just passed the last filled element in fLocals.
715 AliRegionalHeader* fCurrentRegional; //!< Current regional header position.
716 AliLocalStruct* fCurrentLocal; //!< Current local trigger structure.
717 UInt_t fDarcEoWErrors; //!< Number of end of DARC word errors.
718 UInt_t fGlobalEoWErrors; //!< Number of end of global word errors.
719 UInt_t fRegEoWErrors; //!< Number of end of regional word errors.
720 UInt_t fLocalEoWErrors; //!< Number of end of local word errors.
721 Bool_t fWarnings; //!< Flag indicating if we should generate a warning for errors.
723 static const AliMUONRegionalHeaderStruct fgkEmptyHeader; //!< Empty header for skipped regional structures.
726 AliMUONTriggerDDLDecoder<AliDecoderEventHandler> fDecoder; //!< The decoder for the DDL payload.
727 Int_t fDDL; //!< The current DDL number being handled.
728 Int_t fBufferSize; //!< This is the buffer size in bytes of fBuffer.
729 UChar_t* fBuffer; //!< This is the buffer in which we store the DDL payload read from AliRawReader.
730 const AliLocalStruct* fkCurrentLocalStruct; //!< The current local trigger structure being handled by Next().
731 Bool_t fHadError; //!< Flag indicating if there was a decoding error or not.
732 Bool_t fDone; //!< Flag indicating if the iteration is done or not.
733 mutable AliMUONDDLTrigger* fDDLObject; //!< Temporary DDL object used by GetDDLTrigger() for caching.
735 static const Int_t fgkMaxDDL; //!< Maximum number of DDLs
737 ClassDef(AliMUONRawStreamTriggerHP, 0) // Higher performance decoder class for MUON trigger rawdata.
740 ////////////////////////////////////////////////////////////////////////////////
742 inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerHP::Next()
744 /// Iterates through all the local trigger structures for the event.
745 /// When no more local triggers are found then NULL is returned.
748 if (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
749 return fkCurrentLocalStruct++;
755 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStructV2(
757 const AliMUONRegionalHeaderStruct* header,
758 const AliMUONRegionalScalarsStruct* scalars,
762 /// New regional structure handler is called by the decoder whenever a
763 /// new regional header is found. We just mark the header and increment
764 /// the appropriate counters.
766 assert( header != NULL );
767 assert( iReg < fRegionalsCount );
769 fCurrentRegional = fRegionals+iReg;
770 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
772 // Link to the next regional structure unless this is the last one.
773 if (iReg+1 < fRegionalsCount)
775 fCurrentRegional->SetNext(fCurrentRegional+1);
780 inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStructV2(
782 const AliMUONLocalInfoStruct* localStruct,
783 const AliMUONLocalScalarsStruct* scalars
786 /// New local trigger structure handler.
787 /// This is called by the high performance decoder when a new local trigger
788 /// structure is found within the DDL payload.
789 /// We mark the location of the structure in the DDL paytload and increment
790 /// appropriate counters.
792 assert( localStruct != NULL );
793 assert( fCurrentLocal != NULL );
794 assert( fCurrentRegional != NULL );
795 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
797 // Link the previous local structure unless it is the first one.
798 if (fCurrentRegional->GetLocalStructCount() > 0)
800 fCurrentLocal->SetNext(fCurrentLocal+1);
804 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
805 fCurrentLocal->SetCalculatedId(iLoc);
806 fCurrentRegional->IncLocalStructCount();
809 #endif // ALIMUONRAWSTREAMTRIGGERHP_H