]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONRawStreamTriggerHP.h
Some leftover changes (Jean-Luc C.)
[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.
50a1db76 63 virtual Int_t GetMaxReg() const { return (Int_t) fDecoder.MaxRegionals(); }
1788245f 64
50a1db76 65 /// Set the maximum number of regional cards in the DDL.
66 virtual void SetMaxReg(Int_t reg);
1788245f 67
68 /// Return maximum number of local cards in the DDL.
69 virtual Int_t GetMaxLoc() const { return (Int_t) fDecoder.MaxLocals(); }
70
71 /// Sets the maximum number of local cards in the DDL.
72 virtual void SetMaxLoc(Int_t loc);
73
74 /// Return number of the current DDL being handled.
75 virtual Int_t GetDDL() const { return fDDL - 1; }
76
77 /// check error/Warning presence
78 virtual Bool_t IsErrorMessage() const { return fHadError; }
79
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); }
84
85 /// Get number of end of DARC word errors.
86 UInt_t GetDarcEoWErrors() const {return fDecoder.GetHandler().GetDarcEoWErrors();}
87
88 /// Get number of end of Global word errors.
89 UInt_t GetGlobalEoWErrors() const {return fDecoder.GetHandler().GetGlobalEoWErrors();}
90
91 /// Get number of end of regional word errors.
92 UInt_t GetRegEoWErrors() const {return fDecoder.GetHandler().GetRegEoWErrors();}
93
94 /// Get number of end of local word errors.
95 UInt_t GetLocalEoWErrors() const {return fDecoder.GetHandler().GetLocalEoWErrors();}
96
97 /// Returns the "try to recover from errors" flag.
98 Bool_t TryRecover() const { return Bool_t(fDecoder.TryRecover()); }
99
100 /// Sets the "try to recover from errors" flag.
101 /// i.e. should the decoder try to recover from errors found in the
102 /// payload headers.
103 void TryRecover(Bool_t value) { fDecoder.TryRecover(bool(value)); }
104
105 /// Light weight interface class to the DARC and global header data.
106 class AliHeader
107 {
108 public:
109 /// Default constructor.
110 AliHeader(
111 UInt_t darcHeader = 0,
112 const AliMUONDarcScalarsStruct* darcScalars = NULL,
113 const AliMUONGlobalHeaderStruct* globalHeader = NULL,
114 const AliMUONGlobalScalarsStruct* globalScalars = NULL
115 ) :
116 fDarcHeader(darcHeader), fDarcScalars(darcScalars),
117 fGlobalHeader(globalHeader), fGlobalScalars(globalScalars)
118 {
119 }
120
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)
125 {
126 }
127
128 /// Implement shallow copying in the assignment operator.
129 AliHeader& operator = (const AliHeader& object)
130 {
131 memcpy(this, &object, sizeof(AliHeader));
132 return *this;
133 }
134
135 /// Default destructor.
136 ~AliHeader() {};
137
138 /// Return first word
139 UInt_t GetWord() const {return GetDarcHeader();}
140 /// Return global input
a90f8830 141 UInt_t GetGlobalInput(Int_t n) const {return fGlobalHeader->fInput[n];}
1788245f 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);}
146
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;}
151 /// Return Darc type
152 UChar_t GetDarcType() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcType(GetDarcHeader());}
153 /// Return serial number
154 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcSerialNb(GetDarcHeader());}
155 /// Return version
156 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcVersion(GetDarcHeader());}
157 /// Return VME trig
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());}
163 /// Return DAQ flag
164 Bool_t GetDAQFlag() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcDAQFlag(GetDarcHeader());}
165 /// Return reg pattern
166 UChar_t GetRegPattern() const {return AliMUONTriggerDDLDecoderEventHandler::GetDarcRegPattern(GetDarcHeader());}
167
168 // DARC get methods
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;}
183
184 // global get methods
185 /// Return global L0
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;}
195
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();}
200
201 /// Return the DARC header's raw data.
202 UInt_t GetDarcHeader() const {return fDarcHeader;}
203
204 /// Return the DARC scalars raw data or NULL if none exist.
205 const AliMUONDarcScalarsStruct* GetDarcScalars() const {return fDarcScalars;}
206
207 /// Return the global header's raw data.
208 const AliMUONGlobalHeaderStruct* GetGlobalHeader() const {return fGlobalHeader;}
209
210 /// Return the global scalars raw data or NULL if none exist.
211 const AliMUONGlobalScalarsStruct* GetGlobalScalars() const {return fGlobalScalars;}
212
213 /// Print the contents of the headers to screen.
214 void Print() const;
215
216 private:
217
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.
222 };
223
224 /// Light weight interface class to the regional card header data.
225 class AliRegionalHeader
226 {
227 public:
228 /// Default constructor.
229 AliRegionalHeader(
230 const AliLocalStruct* localsArray = NULL,
231 const AliMUONRegionalHeaderStruct* header = NULL,
232 const AliMUONRegionalScalarsStruct* scalars = NULL
233 ) :
234 fNext(NULL), fLocalsCount(0), fFirstLocal(localsArray),
235 fHeader(header), fScalars(scalars)
236 {
237 }
238
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),
243 fScalars(o.fScalars)
244 {
245 }
246
247 /// Implement shallow copying in the assignment operator.
248 AliRegionalHeader& operator = (const AliRegionalHeader& object)
249 {
250 memcpy(this, &object, sizeof(AliRegionalHeader));
251 return *this;
252 }
253
254 /// Default destructor.
255 ~AliRegionalHeader() {};
256
257 /// Return darc word
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];}
263 /// Return L0
264 UShort_t GetL0() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0(fHeader);}
265 /// Return mask
266 UShort_t GetMask() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalMask(fHeader);}
267
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);}
272 /// Return ResetNb
273 UChar_t GetResetNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalResetNb(fHeader);}
274 /// Return SerialNb
275 UChar_t GetSerialNb() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalSerialNb(fHeader);}
276 /// Return Id
277 UChar_t GetId() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalId(fHeader);}
278 /// Return Version
279 UChar_t GetVersion() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalVersion(fHeader);}
280 /// Return Output
281 UChar_t GetOutput() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalOutput(fHeader);}
282
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
285 /// Return ErrorBits
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);}
301 /// Return L1Status
302 Bool_t GetL1Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL1Status(fHeader);}
303 /// Return L0Status
304 Bool_t GetL0Status() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalL0Status(fHeader);}
305 /// Return EventInRam
306 UChar_t GetEventInRam() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalEventInRam(fHeader);}
307 /// Return Busy
308 UChar_t GetBusy() const {return AliMUONTriggerDDLDecoderEventHandler::GetRegionalBusy(fHeader);}
309
310 // scalar methods
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;}
317
318 /// Return raw data of regional header.
319 const AliMUONRegionalHeaderStruct* GetHeader() const { return fHeader; }
320
321 /// Return the raw data of the regional scalars or NULL if none exist.
322 const AliMUONRegionalScalarsStruct* GetScalars() const { return fScalars; }
323
324 /// Return the next regional structure header.
325 const AliRegionalHeader* Next() const { return fNext; }
326
327 /// Returns the first AliLocalStruct class in this regional structure.
328 const AliLocalStruct* GetFirstLocalStruct() const { return fFirstLocal; }
329
330 /// Returns the number of local trigger structures within this regional structure.
331 UInt_t GetLocalStructCount() const { return fLocalsCount; }
332
333 /// Return the i'th local trigger structure in this regional structure.
334 const AliLocalStruct* GetLocalStruct(UInt_t i) const
335 {
336 return i < fLocalsCount ? GetFirstLocalStruct() + i : NULL;
337 }
338
339 /// Sets the next regional structure header.
340 void SetNext(const AliRegionalHeader* next) { fNext = next; }
341
342 /// Increments the local trigger structure count.
343 void IncLocalStructCount() { fLocalsCount++; };
344
345 /// Print the contents of the regional header and scalars to screen.
346 void Print() const;
347
348 private:
349
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.
355 };
356
357 /// Light weight interface class to the local trigger card data.
358 class AliLocalStruct
359 {
360 public:
361 /// Default constructor.
362 AliLocalStruct(
363 const AliRegionalHeader* regionalHeader = NULL,
364 const AliMUONLocalInfoStruct* localStruct = NULL,
365 const AliMUONLocalScalarsStruct* scalars = NULL
366 ) :
367 fRegional(regionalHeader), fNext(NULL),
b385ced2 368 fLocalStruct(localStruct), fScalars(scalars),
369 fCalculatedId(0)
1788245f 370 {
371 }
372
373 /// Implement shallow copying in the copy constructor.
374 AliLocalStruct(const AliLocalStruct& o) :
375 fRegional(o.fRegional), fNext(o.fNext),
b385ced2 376 fLocalStruct(o.fLocalStruct), fScalars(o.fScalars),
377 fCalculatedId(o.fCalculatedId)
1788245f 378 {
379 }
380
381 /// Implement shallow copying in the assignment operator.
382 AliLocalStruct& operator = (const AliLocalStruct& object)
383 {
384 memcpy(this, &object, sizeof(AliLocalStruct));
385 return *this;
386 }
387
388 /// Default destructor.
389 ~AliLocalStruct() {};
390
391 /// Return local data
392 UInt_t GetData(Int_t n) const
393 {
394 assert(n < 5);
395 return (reinterpret_cast<const UInt_t*>(fLocalStruct))[n];
396 }
397
398 /// Return X2
399 UShort_t GetX2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX2(fLocalStruct);}
400 /// Return X1
401 UShort_t GetX1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX1(fLocalStruct);}
402 /// Return X4
403 UShort_t GetX4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX4(fLocalStruct);}
404 /// Return X3
405 UShort_t GetX3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalX3(fLocalStruct);}
406
407 /// Return Y2
408 UShort_t GetY2() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY2(fLocalStruct);}
409 /// Return Y1
410 UShort_t GetY1() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY1(fLocalStruct);}
411 /// Return Y4
412 UShort_t GetY4() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY4(fLocalStruct);}
413 /// Return Y3
414 UShort_t GetY3() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalY3(fLocalStruct);}
415
416 /// return X pattern array
417 void GetXPattern(TArrayS& array) const
418 {
419 Short_t vec[4] = {GetX1(), GetX2(), GetX3(), GetX4()};
420 array.Set(4, vec);
421 }
422
423 /// return Y pattern array
424 void GetYPattern(TArrayS& array) const
425 {
426 Short_t vec[4] = {GetY1(), GetY2(), GetY3(), GetY4()};
427 array.Set(4, vec);
428 }
429
430 /// Return Id
b385ced2 431 UChar_t GetId() const {return fgOverrideId ? fCalculatedId : AliMUONTriggerDDLDecoderEventHandler::GetLocalId(fLocalStruct);}
1788245f 432 /// Return Dec
433 UChar_t GetDec() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalDec(fLocalStruct);}
434 /// Return TrigY
435 Bool_t GetTrigY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTrigY(fLocalStruct);}
436 /// Return TriggerY
437 Bool_t GetTriggerY() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerY(fLocalStruct);}
438 /// Return Upos
439 UChar_t GetYPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalYPos(fLocalStruct);}
440 /// Get Sign of X deviation
441 Bool_t GetSXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalSXDev(fLocalStruct);}
442 /// Get X deviation
443 UChar_t GetXDev() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXDev(fLocalStruct);}
444 /// Return TriggerX
445 Bool_t GetTriggerX() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalTriggerX(fLocalStruct);}
446 /// Return Xpos
447 UChar_t GetXPos() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalXPos(fLocalStruct);}
448 /// Return LPT
449 UChar_t GetLpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalLpt(fLocalStruct);}
450 /// Return HPT
451 UChar_t GetHpt() const {return AliMUONTriggerDDLDecoderEventHandler::GetLocalHpt(fLocalStruct);}
452
453 // Scaler methods
454 /// Return local L0
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;}
460
461 /// Return switch
462 UShort_t GetSwitch() const
463 {
464 return (fScalars != NULL) ?
465 AliMUONTriggerDDLDecoderEventHandler::GetLocalSwitch(fScalars) : 0;
466 }
467
468 /// Return ComptXY
469 UChar_t GetComptXY() const
470 {
471 return (fScalars != NULL) ?
472 AliMUONTriggerDDLDecoderEventHandler::GetLocalComptXY(fScalars) : 0;
473 }
474
475 /// Return XY1
476 UShort_t GetXY1(Int_t n) const
477 {
478 return (fScalars != NULL) ?
479 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY1(fScalars, n) : 0;
480 }
481
482 /// Return XY2
483 UShort_t GetXY2(Int_t n) const
484 {
485 return (fScalars != NULL) ?
486 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY2(fScalars, n) : 0;
487 }
488
489 /// Return XY3
490 UShort_t GetXY3(Int_t n) const
491 {
492 return (fScalars != NULL) ?
493 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY3(fScalars, n) : 0;
494 }
495
496 /// Return XY4
497 UShort_t GetXY4(Int_t n) const
498 {
499 return (fScalars != NULL) ?
500 AliMUONTriggerDDLDecoderEventHandler::GetLocalXY4(fScalars, n) : 0;
501 }
502
503 /// Return raw data of the local trigger structure.
504 const AliMUONLocalInfoStruct* GetData() const {return fLocalStruct;}
505
506 /// Return raw data of the local trigger scalars.
507 /// Could be NULL if no scalars present.
508 const AliMUONLocalScalarsStruct* GetScalars() const {return fScalars;}
509
510 /// Return the parent regional header.
511 const AliRegionalHeader* GetRegionalHeader() const { return fRegional; }
512
513 /// Return the next local trigger structure.
514 const AliLocalStruct* Next() const { return fNext; }
515
516 /// Sets the next local trigger structure.
517 void SetNext(const AliLocalStruct* next) { fNext = next; }
b385ced2 518
519 /// Sets the calculated ID value to be returned by GetId if fgOverrideId is true.
520 void SetCalculatedId(UChar_t id) { fCalculatedId = id; }
1788245f 521
522 /// Print the contents of the local trigger structure and contents to screen.
523 void Print() const;
b385ced2 524
525 /// Returns the override flag indicating if the GetId method should return the calculated Id value or not.
526 static bool GetOverrideIdFlag() { return fgOverrideId; }
527
528 /// Sets the override flag to control what value the GetId method returns.
529 static void SetOverrideIdFlag(bool value) { fgOverrideId = value; }
1788245f 530
531 private:
532
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.
b385ced2 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.
1788245f 539 };
540
541 /// Returns the DARC and global headers plus scalars if they exist.
542 const AliHeader* GetHeaders() const { return fDecoder.GetHandler().GetHeaders(); }
543
544 /// Return the number of regional structures in the DDL payload.
545 UInt_t GetRegionalHeaderCount() const
546 {
547 return fDecoder.GetHandler().RegionalHeaderCount();
548 }
549
550 /// Return the first regional structure header.
551 const AliRegionalHeader* GetFirstRegionalHeader() const
552 {
553 return fDecoder.GetHandler().RegionalHeader(0);
554 }
555
556 /// Return the i'th regional header or NULL if not found.
557 const AliRegionalHeader* GetRegionalHeader(UInt_t i) const
558 {
559 return fDecoder.GetHandler().RegionalHeader(i);
560 }
561
562 /// Returns the number of local trigger structures for the given
563 /// regional structure number.
564 UInt_t GetLocalStructCount(UInt_t reg) const
565 {
566 const AliRegionalHeader* r = GetRegionalHeader(reg);
567 return r != NULL ? r->GetLocalStructCount() : 0;
568 }
569
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
573 {
574 const AliRegionalHeader* r = GetRegionalHeader(reg);
575 return r != NULL ? r->GetLocalStruct(i) : NULL;
576 }
577
578 /// Returns the current local struct being decoded or NULL if none found.
579 const AliLocalStruct* CurrentLocalStruct() const
580 {
586dda01 581 return (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs()) ?
582 fkCurrentLocalStruct : NULL;
1788245f 583 }
584
585 /// Returns the current regional structure being decoded
586 /// or NULL if none found.
587 const AliRegionalHeader* CurrentRegionalHeader() const
588 {
589 const AliLocalStruct* local = CurrentLocalStruct();
590 return (local != NULL) ? local->GetRegionalHeader() : NULL;
591 }
592
593private:
594 /// Not implemented
595 AliMUONRawStreamTriggerHP(const AliMUONRawStreamTriggerHP& stream);
596 /// Not implemented
597 AliMUONRawStreamTriggerHP& operator = (const AliMUONRawStreamTriggerHP& stream);
598
599
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
606 {
607 public:
608
609 /// Default constructor.
610 AliDecoderEventHandler();
611 /// Default destructor.
612 virtual ~AliDecoderEventHandler();
613
614 /// Sets the internal arrays based on the maximum number of structures allowed.
615 void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals);
616
617 /// Sets the raw stream object which should be the parent of this class.
618 void SetRawStream(AliMUONVRawStreamTrigger* rawStream) { fRawStream = rawStream; }
619
620 /// Returns the decoded DARC and global headers (and scalars if they exist).
621 const AliHeader* GetHeaders() const { return &fHeaders; }
622
623 /// Returns the number of regional headers.
624 UInt_t RegionalHeaderCount() const { return fRegionalsCount; }
625
626 /// Return the i'th regional structure header.
627 const AliRegionalHeader* RegionalHeader(UInt_t i) const
628 {
629 return i < fRegionalsCount ? &fRegionals[i] : NULL;
630 }
631
632 /// Return the first local structure decoded.
633 const AliLocalStruct* FirstLocalStruct() const { return fLocals; }
634
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; }
638
639 /// Get number of end of DARC word errors.
640 UInt_t GetDarcEoWErrors() const {return fDarcEoWErrors;}
641
642 /// Get number of end of Global word errors.
643 UInt_t GetGlobalEoWErrors() const {return fGlobalEoWErrors;}
644
645 /// Get number of end of regional word errors.
646 UInt_t GetRegEoWErrors() const {return fRegEoWErrors;}
647
648 /// Get number of end of local word errors.
649 UInt_t GetLocalEoWErrors() const {return fLocalEoWErrors;}
650
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; }
655
656 // The following methods are inherited from AliMUONTriggerDDLDecoderEventHandler:
657
658 /// New buffer handler.
659 void OnNewBuffer(const void* buffer, UInt_t bufferSize);
660
661 /// End of buffer handler marks the end of local trigger structures.
662 void OnEndOfBuffer(const void* /*buffer*/, UInt_t /*bufferSize*/)
663 {
664 fEndOfLocals = fCurrentLocal+1;
665 }
666
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*/)
671 {
672 fDarcHeader = header;
673 fDarcScalars = scalars;
674 }
675
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*/)
680 {
681 fHeaders = AliHeader(fDarcHeader, fDarcScalars, header, scalars);
682 }
683
684 /// Handler for new regional card structures.
50a1db76 685 void OnNewRegionalStructV2(UInt_t iReg,
686 const AliMUONRegionalHeaderStruct* header,
687 const AliMUONRegionalScalarsStruct* scalars,
688 const void* data);
1788245f 689
690 /// Handler for new local card structures.
b385ced2 691 void OnLocalStructV2(UInt_t iLoc,
692 const AliMUONLocalInfoStruct* localStruct,
693 const AliMUONLocalScalarsStruct* scalars);
1788245f 694
695 /// Error handler.
696 void OnError(ErrorCode error, const void* location);
697
698 private:
699
700 // Do not allow copying of this class.
701 /// Not implemented
702 AliDecoderEventHandler(const AliDecoderEventHandler& /*obj*/);
703 /// Not implemented
704 AliDecoderEventHandler& operator = (const AliDecoderEventHandler& /*obj*/);
705
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.
50a1db76 722
723 static const AliMUONRegionalHeaderStruct fgkEmptyHeader; //!< Empty header for skipped regional structures.
1788245f 724 };
725
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.
586dda01 730 const AliLocalStruct* fkCurrentLocalStruct; //!< The current local trigger structure being handled by Next().
1788245f 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.
481d8064 733 mutable AliMUONDDLTrigger* fDDLObject; //!< Temporary DDL object used by GetDDLTrigger() for caching.
1788245f 734
735 static const Int_t fgkMaxDDL; //!< Maximum number of DDLs
736
737 ClassDef(AliMUONRawStreamTriggerHP, 0) // Higher performance decoder class for MUON trigger rawdata.
738};
739
740////////////////////////////////////////////////////////////////////////////////
741
742inline const AliMUONRawStreamTriggerHP::AliLocalStruct* AliMUONRawStreamTriggerHP::Next()
743{
744 /// Iterates through all the local trigger structures for the event.
745 /// When no more local triggers are found then NULL is returned.
746
747 do {
586dda01 748 if (fkCurrentLocalStruct != fDecoder.GetHandler().EndOfLocalStructs())
749 return fkCurrentLocalStruct++;
1788245f 750 } while (NextDDL());
751 return NULL;
752}
753
754
50a1db76 755inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnNewRegionalStructV2(
756 UInt_t iReg,
1788245f 757 const AliMUONRegionalHeaderStruct* header,
758 const AliMUONRegionalScalarsStruct* scalars,
759 const void* /*data*/
760 )
761{
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.
765
766 assert( header != NULL );
50a1db76 767 assert( iReg < fRegionalsCount );
1788245f 768
50a1db76 769 fCurrentRegional = fRegionals+iReg;
770 *fCurrentRegional = AliRegionalHeader(fCurrentLocal+1, header, scalars);
771
772 // Link to the next regional structure unless this is the last one.
773 if (iReg+1 < fRegionalsCount)
1788245f 774 {
775 fCurrentRegional->SetNext(fCurrentRegional+1);
776 }
1788245f 777}
778
779
b385ced2 780inline void AliMUONRawStreamTriggerHP::AliDecoderEventHandler::OnLocalStructV2(
781 UInt_t iLoc,
1788245f 782 const AliMUONLocalInfoStruct* localStruct,
783 const AliMUONLocalScalarsStruct* scalars
784 )
785{
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.
791
792 assert( localStruct != NULL );
793 assert( fCurrentLocal != NULL );
794 assert( fCurrentRegional != NULL );
795 assert( fCurrentRegional->GetLocalStructCount() < (UInt_t)fRawStream->GetMaxLoc() );
796
797 // Link the previous local structure unless it is the first one.
798 if (fCurrentRegional->GetLocalStructCount() > 0)
799 {
800 fCurrentLocal->SetNext(fCurrentLocal+1);
801 }
802
803 fCurrentLocal++;
804 *fCurrentLocal = AliLocalStruct(fCurrentRegional, localStruct, scalars);
b385ced2 805 fCurrentLocal->SetCalculatedId(iLoc);
1788245f 806 fCurrentRegional->IncLocalStructCount();
807}
808
809#endif // ALIMUONRAWSTREAMTRIGGERHP_H