Separating run-dependent mapping data from data, which are not
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTriggerHP.h
CommitLineData
1788245f 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 */
6
7/* $Id$ */
8
9/// \ingroup raw
10/// \class AliMUONRawStreamTriggerHP
11/// \brief Higher performance decoder stream class for reading MUON raw trigger data.
12///
13// This provides a streamer interface to the high performance decoder which
14// is required for AliRoot.
15//
16// Author Artur Szostak <artursz@iafrica.com>
17
18#include "AliMUONVRawStreamTrigger.h"
19#include "AliMUONTriggerDDLDecoder.h"
20#include "TArrayS.h"
21
481d8064 22class AliMUONDDLTrigger;
23
1788245f 24
25class AliMUONRawStreamTriggerHP : public AliMUONVRawStreamTrigger
26{
27public:
28 class AliLocalStruct;
29
30 AliMUONRawStreamTriggerHP();
31 AliMUONRawStreamTriggerHP(AliRawReader* rawReader);
32 virtual ~AliMUONRawStreamTriggerHP();
33
34 /// Initialize iterator
35 virtual void First();
36
37 /// DDL iterator
38 virtual Bool_t NextDDL();
39
40 /// Whether the iteration is finished or not
41 virtual Bool_t IsDone() const;
42
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() { };
46
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);
52
481d8064 53 /// Construct and return a pointer to the DDL payload object.
54 virtual AliMUONDDLTrigger* GetDDLTrigger() const;
55
1788245f 56 /// Returns the next local trigger structure.
57 const AliLocalStruct* Next();
58
59 /// Return maximum number of DDLs.
60 virtual Int_t GetMaxDDL() const { return fgkMaxDDL; }
61
62 /// Return maximum number of regional cards in the DDL.
63 virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.RegionalsDecoded(); }
64
65 /// Return maximum allowed number of regional cards in the DDL.
66 virtual Int_t GetMaxRegAllowed() const { return (Int_t) fDecoder.MaxRegionals(); }
67
68 /// Set the maximum allowed number of regional cards in the DDL.
69 virtual void SetMaxRegAllowed(Int_t reg);
70
71 /// Return maximum number of local cards in the DDL.
72 virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
73
74 /// Sets the maximum number of local cards in the DDL.
75 virtual void SetMaxLoc(Int_t loc);
76
77 /// Return number of the current DDL being handled.
78 virtual Int_t GetDDL() const { return fDDL - 1; }
79
80 /// check error/Warning presence
81 virtual Bool_t IsErrorMessage() const { return fHadError; }
82
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); }
87
88 /// Get number of end of DARC word errors.
89 UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
90
91 /// Get number of end of Global word errors.
92 UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
93
94 /// Get number of end of regional word errors.
95 UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
96
97 /// Get number of end of local word errors.
98 UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
99
100 /// Returns the "try to recover from errors" flag.
101 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
102
103 /// Sets the "try to recover from errors" flag.
104 /// i.e. should the decoder try to recover from errors found in the
105 /// payload headers.
106 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
107
108 /// Light weight interface class to the DARC and global header data.
109 class AliHeader
110 {
111 public:
112 /// Default constructor.
113 AliHeader(
114 UInt_t darcHeader = 0,
115 const AliMUONDarcScalarsStruct* darcScalars = NULL,
116 const AliMUONGlobalHeaderStruct* globalHeader = NULL,
117 const AliMUONGlobalScalarsStruct* globalScalars = NULL
118 ) :
119 fDarcHeader(darcHeader), fDarcScalars(darcScalars),
120 fGlobalHeader(globalHeader), fGlobalScalars(globalScalars)
121 {
122 }
123
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)
128 {
129 }
130
131 /// Implement shallow copying in the assignment operator.
132 AliHeader& operator = (const AliHeader& object)
133 {
134 memcpy(this, &object, sizeof(AliHeader));
135 return *this;
136 }
137
138 /// Default destructor.
139 ~AliHeader() {};
140
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);}
149
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;}
154 /// Return Darc type
155 UChar_t GetDarcType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcType(GetDarcHeader());}
156 /// Return serial number
157 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcSerialNb(GetDarcHeader());}
158 /// Return version
159 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVersion(GetDarcHeader());}
160 /// Return VME trig
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());}
166 /// Return DAQ flag
167 Bool_t GetDAQFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcDAQFlag(GetDarcHeader());}
168 /// Return reg pattern
169 UChar_t GetRegPattern() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcRegPattern(GetDarcHeader());}
170
171 // DARC get methods
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;}
186
187 // global get methods
188 /// Return global L0
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;}
198
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();}
203
204 /// Return the DARC header's raw data.
205 UInt_t GetDarcHeader() const {return fDarcHeader;}
206
207 /// Return the DARC scalars raw data or NULL if none exist.
208 const AliMUONDarcScalarsStruct* GetDarcScalars() const {return fDarcScalars;}
209
210 /// Return the global header's raw data.
211 const AliMUONGlobalHeaderStruct* GetGlobalHeader() const {return fGlobalHeader;}
212
213 /// Return the global scalars raw data or NULL if none exist.
214 const AliMUONGlobalScalarsStruct* GetGlobalScalars() const {return fGlobalScalars;}
215
216 /// Print the contents of the headers to screen.
217 void Print() const;
218
219 private:
220
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.
225 };
226
227 /// Light weight interface class to the regional card header data.
228 class AliRegionalHeader
229 {
230 public:
231 /// Default constructor.
232 AliRegionalHeader(
233 const AliLocalStruct* localsArray = NULL,
234 const AliMUONRegionalHeaderStruct* header = NULL,
235 const AliMUONRegionalScalarsStruct* scalars = NULL
236 ) :
237 fNext(NULL), fLocalsCount(0), fFirstLocal(localsArray),
238 fHeader(header), fScalars(scalars)
239 {
240 }
241
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),
246 fScalars(o.fScalars)
247 {
248 }
249
250 /// Implement shallow copying in the assignment operator.
251 AliRegionalHeader& operator = (const AliRegionalHeader& object)
252 {
253 memcpy(this, &object, sizeof(AliRegionalHeader));
254 return *this;
255 }
256
257 /// Default destructor.
258 ~AliRegionalHeader() {};
259
260 /// Return darc word
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];}
266 /// Return L0
267 UShort_t GetL0() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0(fHeader);}
268 /// Return mask
269 UShort_t GetMask() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalMask(fHeader);}
270
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);}
275 /// Return ResetNb
276 UChar_t GetResetNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalResetNb(fHeader);}
277 /// Return SerialNb
278 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalSerialNb(fHeader);}
279 /// Return Id
280 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalId(fHeader);}
281 /// Return Version
282 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalVersion(fHeader);}
283 /// Return Output
284 UChar_t GetOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalOutput(fHeader);}
285
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
288 /// Return ErrorBits
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);}
304 /// Return L1Status
305 Bool_t GetL1Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL1Status(fHeader);}
306 /// Return L0Status
307 Bool_t GetL0Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0Status(fHeader);}
308 /// Return EventInRam
309 UChar_t GetEventInRam() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalEventInRam(fHeader);}
310 /// Return Busy
311 UChar_t GetBusy() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalBusy(fHeader);}
312
313 // scalar methods
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;}
320
321 /// Return raw data of regional header.
322 const AliMUONRegionalHeaderStruct* GetHeader() const { return fHeader; }
323
324 /// Return the raw data of the regional scalars or NULL if none exist.
325 const AliMUONRegionalScalarsStruct* GetScalars() const { return fScalars; }
326
327 /// Return the next regional structure header.
328 const AliRegionalHeader* Next() const { return fNext; }
329
330 /// Returns the first AliLocalStruct class in this regional structure.
331 const AliLocalStruct* GetFirstLocalStruct() const { return fFirstLocal; }
332
333 /// Returns the number of local trigger structures within this regional structure.
334 UInt_t GetLocalStructCount() const { return fLocalsCount; }
335
336 /// Return the i'th local trigger structure in this regional structure.
337 const AliLocalStruct* GetLocalStruct(UInt_t i) const
338 {
339 return i < fLocalsCount ? GetFirstLocalStruct() + i : NULL;
340 }
341
342 /// Sets the next regional structure header.
343 void SetNext(const AliRegionalHeader* next) { fNext = next; }
344
345 /// Increments the local trigger structure count.
346 void IncLocalStructCount() { fLocalsCount++; };
347
348 /// Print the contents of the regional header and scalars to screen.
349 void Print() const;
350
351 private:
352
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.
358 };
359
360 /// Light weight interface class to the local trigger card data.
361 class AliLocalStruct
362 {
363 public:
364 /// Default constructor.
365 AliLocalStruct(
366 const AliRegionalHeader* regionalHeader = NULL,
367 const AliMUONLocalInfoStruct* localStruct = NULL,
368 const AliMUONLocalScalarsStruct* scalars = NULL
369 ) :
370 fRegional(regionalHeader), fNext(NULL),
371 fLocalStruct(localStruct), fScalars(scalars)
372 {
373 }
374
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)
379 {
380 }
381
382 /// Implement shallow copying in the assignment operator.
383 AliLocalStruct& operator = (const AliLocalStruct& object)
384 {
385 memcpy(this, &object, sizeof(AliLocalStruct));
386 return *this;
387 }
388
389 /// Default destructor.
390 ~AliLocalStruct() {};
391
392 /// Return local data
393 UInt_t GetData(Int_t n) const
394 {
395 assert(n < 5);
396 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
397 }
398
399 /// Return X2
400 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
401 /// Return X1
402 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
403 /// Return X4
404 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
405 /// Return X3
406 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
407
408 /// Return Y2
409 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
410 /// Return Y1
411 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
412 /// Return Y4
413 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
414 /// Return Y3
415 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
416
417 /// return X pattern array
418 void GetXPattern(TArrayS& array) const
419 {
420 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
421 array.Set(4, vec);
422 }
423
424 /// return Y pattern array
425 void GetYPattern(TArrayS& array) const
426 {
427 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
428 array.Set(4, vec);
429 }
430
431 /// Return Id
432 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
433 /// Return Dec
434 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
435 /// Return TrigY
436 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
437 /// Return TriggerY
438 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
439 /// Return Upos
440 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
441 /// Get Sign of X deviation
442 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
443 /// Get X deviation
444 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
445 /// Return TriggerX
446 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
447 /// Return Xpos
448 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
449 /// Return LPT
450 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
451 /// Return HPT
452 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
453
454 // Scaler methods
455 /// Return local L0
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;}
461
462 /// Return switch
463 UShort_t GetSwitch() const
464 {
465 return (fScalars != NULL) ?
466 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
467 }
468
469 /// Return ComptXY
470 UChar_t GetComptXY() const
471 {
472 return (fScalars != NULL) ?
473 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
474 }
475
476 /// Return XY1
477 UShort_t GetXY1(Int_t n) const
478 {
479 return (fScalars != NULL) ?
480 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
481 }
482
483 /// Return XY2
484 UShort_t GetXY2(Int_t n) const
485 {
486 return (fScalars != NULL) ?
487 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
488 }
489
490 /// Return XY3
491 UShort_t GetXY3(Int_t n) const
492 {
493 return (fScalars != NULL) ?
494 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
495 }
496
497 /// Return XY4
498 UShort_t GetXY4(Int_t n) const
499 {
500 return (fScalars != NULL) ?
501 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
502 }
503
504 /// Return raw data of the local trigger structure.
505 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
506
507 /// Return raw data of the local trigger scalars.
508 /// Could be NULL if no scalars present.
509 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
510
511 /// Return the parent regional header.
512 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
513
514 /// Return the next local trigger structure.
515 const AliLocalStruct* Next() const { return fNext; }
516
517 /// Sets the next local trigger structure.
518 void SetNext(const AliLocalStruct* next) { fNext = next; }
519
520 /// Print the contents of the local trigger structure and contents to screen.
521 void Print() const;
522
523 private:
524
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.
529 };
530
531 /// Returns the DARC and global headers plus scalars if they exist.
532 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
533
534 /// Return the number of regional structures in the DDL payload.
535 UInt_t GetRegionalHeaderCount() const
536 {
537 return fDecoder.GetHandler().RegionalHeaderCount();
538 }
539
540 /// Return the first regional structure header.
541 const AliRegionalHeader* GetFirstRegionalHeader() const
542 {
543 return fDecoder.GetHandler().RegionalHeader(0);
544 }
545
546 /// Return the i'th regional header or NULL if not found.
547 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
548 {
549 return fDecoder.GetHandler().RegionalHeader(i);
550 }
551
552 /// Returns the number of local trigger structures for the given
553 /// regional structure number.
554 UInt_t GetLocalStructCount(UInt_t reg) const
555 {
556 const AliRegionalHeader* r = GetRegionalHeader(reg);
557 return r != NULL ? r->GetLocalStructCount() : 0;
558 }
559
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
563 {
564 const AliRegionalHeader* r = GetRegionalHeader(reg);
565 return r != NULL ? r->GetLocalStruct(i) : NULL;
566 }
567
568 /// Returns the current local struct being decoded or NULL if none found.
569 const AliLocalStruct* CurrentLocalStruct() const
570 {
571 return (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
572 fCurrentLocalStruct : NULL;
573 }
574
575 /// Returns the current regional structure being decoded
576 /// or NULL if none found.
577 const AliRegionalHeader* CurrentRegionalHeader() const
578 {
579 const AliLocalStruct* local = CurrentLocalStruct();
580 return (local != NULL) ? local->GetRegionalHeader() : NULL;
581 }
582
583private:
584 /// Not implemented
585 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
586 /// Not implemented
587 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
588
589
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
596 {
597 public:
598
599 /// Default constructor.
600 AliDecoderEventHandler();
601 /// Default destructor.
602 virtual ~AliDecoderEventHandler();
603
604 /// Sets the internal arrays based on the maximum number of structures allowed.
605 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
606
607 /// Sets the raw stream object which should be the parent of this class.
608 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
609
610 /// Returns the decoded DARC and global headers (and scalars if they exist).
611 const AliHeader* GetHeaders() const { return &fHeaders; }
612
613 /// Returns the number of regional headers.
614 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
615
616 /// Return the i'th regional structure header.
617 const AliRegionalHeader* RegionalHeader(UInt_t i) const
618 {
619 return i < fRegionalsCount ? &fRegionals[i] : NULL;
620 }
621
622 /// Return the first local structure decoded.
623 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
624
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; }
628
629 /// Get number of end of DARC word errors.
630 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
631
632 /// Get number of end of Global word errors.
633 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
634
635 /// Get number of end of regional word errors.
636 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
637
638 /// Get number of end of local word errors.
639 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
640
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; }
645
646 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
647
648 /// New buffer handler.
649 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
650
651 /// End of buffer handler marks the end of local trigger structures.
652 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
653 {
654 fEndOfLocals = fCurrentLocal+1;
655 }
656
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*/)
661 {
662 fDarcHeader = header;
663 fDarcScalars = scalars;
664 }
665
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*/)
670 {
671 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
672 }
673
674 /// Handler for new regional card structures.
675 void OnNewRegionalStruct(const AliMUONRegionalHeaderStruct* header,
676 const AliMUONRegionalScalarsStruct* scalars,
677 const void* data);
678
679 /// Handler for new local card structures.
680 void OnLocalStruct(const AliMUONLocalInfoStruct* localStruct,
681 const AliMUONLocalScalarsStruct* scalars);
682
683 /// Error handler.
684 void OnError(ErrorCode error, const void* location);
685
686 private:
687
688 // Do not allow copying of this class.
689 /// Not implemented
690 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
691 /// Not implemented
692 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
693
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.
710 };
711
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* fCurrentLocalStruct; //!< 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.
481d8064 719 mutable AliMUONDDLTrigger* fDDLObject; //!< Temporary DDL object used by GetDDLTrigger() for caching.
1788245f 720
721 static const Int_t fgkMaxDDL; //!< Maximum number of DDLs
722
723 ClassDef(AliMUONRawStreamTriggerHP, 0) // Higher performance decoder class for MUON trigger rawdata.
724};
725
726////////////////////////////////////////////////////////////////////////////////
727
728inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerHP::Next()
729{
730 /// Iterates through all the local trigger structures for the event.
731 /// When no more local triggers are found then NULL is returned.
732
733 do {
734 if (fCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
735 return fCurrentLocalStruct++;
736 } while (NextDDL());
737 return NULL;
738}
739
740
741inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStruct(
742 const AliMUONRegionalHeaderStruct* header,
743 const AliMUONRegionalScalarsStruct* scalars,
744 const void* /*data*/
745 )
746{
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.
750
751 assert( header != NULL );
752 assert( fCurrentRegional != NULL );
753 assert( fRegionalsCount < (UInt_t)fRawStream->GetMaxReg() );
754
755 // Link the previous regional structure unless it is the first one.
756 if (fRegionalsCount > 0)
757 {
758 fCurrentRegional->SetNext(fCurrentRegional+1);
759 }
760
761 fCurrentRegional++;
762 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
763 fRegionalsCount++;
764}
765
766
767inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStruct(
768 const AliMUONLocalInfoStruct* localStruct,
769 const AliMUONLocalScalarsStruct* scalars
770 )
771{
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.
777
778 assert( localStruct != NULL );
779 assert( fCurrentLocal != NULL );
780 assert( fCurrentRegional != NULL );
781 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
782
783 // Link the previous local structure unless it is the first one.
784 if (fCurrentRegional->GetLocalStructCount() > 0)
785 {
786 fCurrentLocal->SetNext(fCurrentLocal+1);
787 }
788
789 fCurrentLocal++;
790 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
791 fCurrentRegional->IncLocalStructCount();
792}
793
794#endif // ALIMUONRAWSTREAMTRIGGERHP_H