]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/AliHLTMUONUtils.cxx
Cleanup of documentation and code.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONUtils.cxx
CommitLineData
26a4668d 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
6253e09b 18///
19/// @file AliHLTMUONUtils.cxx
20/// @author Artur Szostak <artursz@iafrica.com>
21/// @date
22/// @brief Implementation of AliHLTMUONUtils utility routines.
23///
26a4668d 24
25#include "AliHLTMUONUtils.h"
b727f838 26#include "AliHLTMUONConstants.h"
c8ec7c7e 27#include "AliHLTMUONTriggerRecordsBlockStruct.h"
28#include "AliHLTMUONTrigRecsDebugBlockStruct.h"
29#include "AliHLTMUONTriggerChannelsBlockStruct.h"
30#include "AliHLTMUONRecHitsBlockStruct.h"
31#include "AliHLTMUONClustersBlockStruct.h"
32#include "AliHLTMUONChannelsBlockStruct.h"
90a74d7a 33#include "AliHLTMUONMansoTracksBlockStruct.h"
34#include "AliHLTMUONMansoCandidatesBlockStruct.h"
35#include "AliHLTMUONSinglesDecisionBlockStruct.h"
b12fe461 36#include "AliHLTMUONPairsDecisionBlockStruct.h"
90a74d7a 37#include <cassert>
26a4668d 38
39
b727f838 40AliHLTUInt32_t AliHLTMUONUtils::PackTriggerRecordFlags(
e6357f88 41 AliHLTMUONParticleSign sign, const bool hitset[4]
b727f838 42 )
26a4668d 43{
6253e09b 44 ///
45 /// This packs the given parameters into the bits of a word appropriate
46 /// for AliHLTMUONTriggerRecordStruct::fFlags.
47 /// @param sign The particle sign.
48 /// @param hitset Flags to indicate if the corresponding fHits[i] elements
49 /// was set/filled.
50 /// @return Returns the 32 bit packed word.
51 ///
52
b727f838 53 AliHLTUInt32_t flags;
54 switch (sign)
55 {
56 case kSignMinus: flags = 0x80000000; break;
57 case kSignPlus: flags = 0x40000000; break;
58 default: flags = 0x00000000; break;
59 }
26a4668d 60
b727f838 61 return flags | (hitset[0] ? 0x1 : 0) | (hitset[1] ? 0x2 : 0)
62 | (hitset[2] ? 0x4 : 0) | (hitset[3] ? 0x8 : 0);
63}
64
65
66void AliHLTMUONUtils::UnpackTriggerRecordFlags(
90a74d7a 67 AliHLTUInt32_t flags, AliHLTMUONParticleSign& sign, bool hitset[4]
b727f838 68 )
69{
6253e09b 70 ///
71 /// This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
72 /// its component fields.
73 /// @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
74 /// @param sign Sets this to the particle sign.
75 /// @param hitset Sets the array elements to indicate if the corresponding
76 /// fHits[i] element was set/filled.
77 ///
78
b727f838 79 AliHLTUInt32_t signbits = flags & 0xC0000000;
80 switch (signbits)
81 {
82 case 0x80000000: sign = kSignMinus; break;
83 case 0x40000000: sign = kSignPlus; break;
84 default: sign = kSignUnknown; break;
85 }
e6357f88 86 hitset[0] = (flags & 0x1) == 0x1;
87 hitset[1] = (flags & 0x2) == 0x2;
88 hitset[2] = (flags & 0x4) == 0x4;
89 hitset[3] = (flags & 0x8) == 0x8;
b727f838 90}
91
92
90a74d7a 93AliHLTUInt32_t AliHLTMUONUtils::PackTrackDecisionBits(bool highPt, bool lowPt)
94{
6253e09b 95 ///
96 /// This packs the given parameters into the bits of a word appropriate
97 /// for AliHLTMUONTrackDecisionStruct::fTriggerBits.
98 /// @param highPt Has the track passed the high pt cut.
99 /// @param lowPt Has the track passed the low pt cut.
100 /// @return Returns the 32 bit packed word.
101 ///
102
90a74d7a 103 return (highPt ? 0x2 : 0) | (lowPt ? 0x1 : 0);
104}
105
106
107void AliHLTMUONUtils::UnpackTrackDecisionBits(
108 AliHLTUInt32_t bits, bool& highPt, bool& lowPt
109 )
110{
6253e09b 111 ///
112 /// This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
113 /// its component fields.
114 /// @param bits The trigger bits from an AliHLTMUONTrackDecisionStruct
115 /// structure.
116 /// @param highPt Sets this to the value of the high pt cut bit.
117 /// @param lowPt Sets this to the value of the low pt cut bit.
118 ///
119
fc310e19 120 lowPt = (bits & 0x1) == 0x1;
121 highPt = (bits & 0x2) == 0x2;
90a74d7a 122}
123
124
125AliHLTUInt32_t AliHLTMUONUtils::PackPairDecisionBits(
126 bool highMass, bool lowMass, bool unlike,
127 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
128 )
129{
6253e09b 130 ///
131 /// This packs the given parameters into the bits of a word appropriate
132 /// for AliHLTMUONPairDecisionStruct::fTriggerBits.
133 ///
134 /// @param highMass Has the track pair passed the high invariant mass cut.
135 /// @param lowMass Has the track pair passed the low invariant mass cut.
136 /// @param unlike Does the track pair have unlike signs.
137 /// @param highPtCount The number of tracks that passed the high pt cut
138 /// in the pair.
139 /// @param lowPtCount The number of tracks that passed the low pt cut
140 /// in the pair.
141 /// @return Returns the 32 bit packed word.
142 ///
143 /// Note: Must have highPtCount + lowPtCount <= 2 and unlike == true if
144 /// highMass or lowMass is true.
145 ///
146
90a74d7a 147 assert( highPtCount + lowPtCount <= 2 );
148 // highMass and lowMass must be false if unlike is false:
149 assert( not unlike ? (highMass == false and lowMass == false) : true );
150
151 return (highMass ? 0x40 : 0) | (lowMass ? 0x20 : 0) | (unlike ? 0x10 : 0)
152 | ((highPtCount & 0x3) << 2) | (lowPtCount & 0x3);
153}
154
155
156void AliHLTMUONUtils::UnpackPairDecisionBits(
157 AliHLTUInt32_t bits, bool& highMass, bool& lowMass, bool& unlike,
158 AliHLTUInt8_t& highPtCount, AliHLTUInt8_t& lowPtCount
159 )
160{
6253e09b 161 ///
162 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
163 /// its component fields.
164 /// @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
165 /// structure.
166 /// @param highMass Sets this to the value of the high invariant mass cut bit.
167 /// @param lowMass Sets this to the value of the low invariant mass cut bit.
168 /// @param unlike Sets this if the pair is unlike sign.
169 /// @param highPtCount Sets this to the high pt count bits.
170 /// @param lowPtCount Sets this to the low pt count bits.
171 ///
172
fc310e19 173 highMass = (bits & 0x40) == 0x40;
174 lowMass = (bits & 0x20) == 0x20;
175 unlike = (bits & 0x10) == 0x10;
90a74d7a 176 highPtCount = (bits & 0xC) >> 2;
177 lowPtCount = bits & 0x3;
178}
179
180
e6357f88 181AliHLTUInt32_t AliHLTMUONUtils::PackSpecBits(
182 const bool ddl[22]
183 )
184{
6253e09b 185 ///
186 /// This packs the given parameters into the 32bit Pub/Sub specification
187 /// word in the data block descriptor.
188 ///
189 /// @param ddl The list of DDLs forming part of the readout. ddl[0]
190 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
191 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
192 /// trigger DDLs 2816 and 2817 respectively.
193 /// @return Returns the 32 bit packed specification word.
194 ///
195
e6357f88 196 // Pack the bits into the following format:
197 // bit: [ 31 - 22 ][ 21 ][ 20 ][ 19 - 0 ]
80606a9f 198 // field: [ reserved, set to zero ][ TRGDDL2817 ][ TRGDDL2816 ][ TRKDDLS ]
e6357f88 199 // Meaning of field acronyms:
200 // TRGDDL2816 - Trigger DDL number 2816.
201 // TRGDDL2817 - Trigger DDL number 2817.
202 // TRKDDLS - Tracking DDL flags where bit 0 will be for DDL number 2560,
203 // bit 1 for DDL no. 2561 etc. up to bit 19 which is for DDL 2579.
204 AliHLTUInt32_t bits = 0;
205 for (int i = 0; i < 22; i++)
206 bits |= (ddl[i] ? 0x1 : 0x0) << i;
207 return bits;
208}
209
210
211void AliHLTMUONUtils::UnpackSpecBits(
212 AliHLTUInt32_t bits, bool ddl[22]
213 )
214{
6253e09b 215 ///
216 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
217 /// its component fields.
218 /// @param bits The Pub/Sub specification word from a data block descriptor.
219 /// @param ddl The output list of DDLs forming part of the readout. ddl[0]
220 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
221 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
222 /// trigger DDLs 2816 and 2817 respectively.
223 ///
224
e6357f88 225 // Perform the inverse operation of PackSpecBits.
226 for (int i = 0; i < 22; i++)
227 ddl[i] = ((bits >> i) & 0x1) == 1;
228}
229
230
86b774d9 231AliHLTInt32_t AliHLTMUONUtils::DDLNumberToEquipId(AliHLTInt32_t ddlNo)
232{
233 ///
234 /// This method converts the DDL number for the muon spectrometer in the
235 /// range [0..21] to the equipment ID number.
236 /// @param ddlNo The DDL number in the range [0..21].
237 /// @return Returns the equipment ID number or -1 if ddlNo was invalid.
238 ///
239
240 if (0 <= ddlNo and ddlNo <= 19)
241 {
242 return 2560 + ddlNo;
243 }
244 else if (20 <= ddlNo and ddlNo <= 21)
245 {
246 return 2816 + (ddlNo - 20);
247 }
248 else
249 {
250 return -1;
251 }
252}
253
254
255AliHLTInt32_t AliHLTMUONUtils::EquipIdToDDLNumber(AliHLTInt32_t id)
256{
257 ///
258 /// This method converts the equipment ID number for a muon spectrometer
259 /// DDL to the DDL number in the range [0..21].
260 /// @param id The equipment ID of the DDL.
261 /// @return Returns the DDL number in the range [0..21] or -1 if the
262 /// equipment ID was invalid.
263 ///
264
265 if (2560 <= id and id <= 2560+19)
266 {
267 return id - 2560;
268 }
269 else if (2816 <= id and id <= 2817)
270 {
271 return id - 2816 + 20;
272 }
273 else
274 {
275 return -1;
276 }
277}
278
279
280AliHLTInt32_t AliHLTMUONUtils::SpecToEquipId(AliHLTUInt32_t spec)
281{
282 ///
283 /// This method converts a 32 bit data block specification for a MUON-HLT
284 /// data block into its corresponding DDL equipment ID number.
285 /// It is assumed that the specification is for a data block comming from
286 /// a single DDL source. If more than one DDL contributed to the data block
287 /// then -1 is returned.
288 /// @param spec The 32 bit specification for a data block.
289 /// @return Returns the equipment ID corresponding to the specification
290 /// or -1 if the specification was invalid.
291 ///
292
293 for (AliHLTInt32_t ddlNo = 0; ddlNo < 20; ddlNo++)
294 {
295 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
296 return ddlNo + 2560;
297 }
298 for (AliHLTInt32_t ddlNo = 20; ddlNo < 22; ddlNo++)
299 {
300 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
301 return ddlNo - 20 + 2816;
302 }
303 return -1;
304}
305
306
307AliHLTUInt32_t AliHLTMUONUtils::EquipIdToSpec(AliHLTInt32_t id)
308{
309 ///
310 /// This method converts a equipment ID number for a DDL into its corresponding
311 /// 32 bit data block specification for the MUON-HLT.
312 /// @param id The equipment ID number of the DDL.
313 /// @return Returns the 32 bit data block specification or 0x0 if the
314 /// equipment ID was invalid.
315 ///
316
317 if (2560 <= id and id <= 2560+19)
318 {
319 return 0x1 << (id - 2560);
320 }
321 else if (2816 <= id and id <= 2817)
322 {
323 return 0x1 << (id - 2816 + 20);
324 }
325 else
326 {
327 return 0x0;
328 }
329}
330
331
332AliHLTInt32_t AliHLTMUONUtils::SpecToDDLNumber(AliHLTUInt32_t spec)
333{
334 ///
335 /// This method converts a 32 bit data block specification for a MUON-HLT
336 /// data block into its corresponding DDL number in the range [0..21].
337 /// It is assumed that the specification is for a data block comming from
338 /// a single DDL source. If more than one DDL contributed to the data block
339 /// then -1 is returned.
340 /// @param spec The 32 bit specification for a data block.
341 /// @return Returns the corresponding DDL number for the specification
342 /// or -1 if the specification was invalid.
343 ///
344
345 for (AliHLTInt32_t ddlNo = 0; ddlNo < 22; ddlNo++)
346 {
347 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
348 return ddlNo;
349 }
350 return -1;
351}
352
353
354AliHLTUInt32_t AliHLTMUONUtils::DDLNumberToSpec(AliHLTInt32_t ddlNo)
355{
356 ///
357 /// This method converts a DDL number in the range [0..21] into its
358 /// corresponding 32 bit data block specification for the MUON-HLT.
359 /// @param ddlNo The equipment ID number of the DDL.
360 /// @return Returns the 32 bit data block specification or 0x0 if the
361 /// DDL number was invalid (out of range).
362 ///
363
364 if (0 <= ddlNo and ddlNo <= 21)
365 {
366 return 0x1 << ddlNo;
367 }
368 else
369 {
370 return 0x0;
371 }
372}
373
374
698c9498 375bool AliHLTMUONUtils::HeaderOk(
376 const AliHLTMUONTriggerRecordsBlockStruct& block,
377 WhyNotValid* reason
378 )
b727f838 379{
6253e09b 380 ///
381 /// Methods used to check if the header information corresponds to the
382 /// supposed type of the data block.
383 /// If the 'reason' parameter is not NULL then these methods will fill the
384 /// memory pointed to by reason with a code describing of why the header
385 /// is not valid, if and only if a problem is found with the data.
386 ///
387
b727f838 388 // The block must have the correct type.
698c9498 389 if (block.fHeader.fType != kTriggerRecordsDataBlock)
390 {
391 if (reason != NULL) *reason = kHeaderContainsWrongType;
392 return false;
393 }
394
90a74d7a 395 // The block's record width must be the correct size.
b727f838 396 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerRecordStruct))
698c9498 397 {
398 if (reason != NULL) *reason = kHeaderContainsWrongRecordWidth;
26a4668d 399 return false;
698c9498 400 }
401
b727f838 402 return true;
403}
26a4668d 404
90a74d7a 405
c8ec7c7e 406bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONTrigRecsDebugBlockStruct& block)
407{
6253e09b 408 ///
409 /// Methods used to check if the header information corresponds to the
410 /// supposed type of the data block.
411 ///
412
c8ec7c7e 413 // The block must have the correct type.
414 if (block.fHeader.fType != kTrigRecsDebugDataBlock) return false;
90a74d7a 415 // The block's record width must be the correct size.
c8ec7c7e 416 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrigRecInfoStruct))
417 return false;
418 return true;
419}
420
90a74d7a 421
c8ec7c7e 422bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONTriggerChannelsBlockStruct& block)
423{
6253e09b 424 ///
425 /// Methods used to check if the header information corresponds to the
426 /// supposed type of the data block.
427 ///
428
c8ec7c7e 429 // The block must have the correct type.
430 if (block.fHeader.fType != kTriggerChannelsDataBlock) return false;
90a74d7a 431 // The block's record width must be the correct size.
c8ec7c7e 432 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerChannelStruct))
433 return false;
434 return true;
435}
436
90a74d7a 437
b727f838 438bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONRecHitsBlockStruct& block)
439{
6253e09b 440 ///
441 /// Methods used to check if the header information corresponds to the
442 /// supposed type of the data block.
443 ///
444
b727f838 445 // The block must have the correct type.
446 if (block.fHeader.fType != kRecHitsDataBlock) return false;
90a74d7a 447 // The block's record width must be the correct size.
b727f838 448 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONRecHitStruct))
26a4668d 449 return false;
b727f838 450 return true;
451}
26a4668d 452
90a74d7a 453
b727f838 454bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONClustersBlockStruct& block)
455{
6253e09b 456 ///
457 /// Methods used to check if the header information corresponds to the
458 /// supposed type of the data block.
459 ///
460
b727f838 461 // The block must have the correct type.
462 if (block.fHeader.fType != kClustersDataBlock) return false;
90a74d7a 463 // The block's record width must be the correct size.
b727f838 464 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONClusterStruct))
465 return false;
466 return true;
467}
26a4668d 468
90a74d7a 469
b727f838 470bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONChannelsBlockStruct& block)
471{
6253e09b 472 ///
473 /// Methods used to check if the header information corresponds to the
474 /// supposed type of the data block.
475 ///
476
b727f838 477 // The block must have the correct type.
478 if (block.fHeader.fType != kChannelsDataBlock) return false;
90a74d7a 479 // The block's record width must be the correct size.
b727f838 480 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONChannelStruct))
26a4668d 481 return false;
b727f838 482 return true;
483}
484
485
90a74d7a 486bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONMansoTracksBlockStruct& block)
487{
6253e09b 488 ///
489 /// Methods used to check if the header information corresponds to the
490 /// supposed type of the data block.
491 ///
492
90a74d7a 493 // The block must have the correct type.
494 if (block.fHeader.fType != kMansoTracksDataBlock) return false;
495 // The block's record width must be the correct size.
496 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoTrackStruct))
497 return false;
498 return true;
499}
500
501
502bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONMansoCandidatesBlockStruct& block)
503{
6253e09b 504 ///
505 /// Methods used to check if the header information corresponds to the
506 /// supposed type of the data block.
507 ///
508
90a74d7a 509 // The block must have the correct type.
510 if (block.fHeader.fType != kMansoCandidatesDataBlock) return false;
511 // The block's record width must be the correct size.
512 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoCandidateStruct))
513 return false;
514 return true;
515}
516
517
518bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONSinglesDecisionBlockStruct& block)
519{
6253e09b 520 ///
521 /// Methods used to check if the header information corresponds to the
522 /// supposed type of the data block.
523 ///
524
90a74d7a 525 // The block must have the correct type.
526 if (block.fHeader.fType != kSinglesDecisionDataBlock) return false;
527 // The block's record width must be the correct size.
528 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrackDecisionStruct))
529 return false;
530 return true;
531}
532
533
534bool AliHLTMUONUtils::HeaderOk(const AliHLTMUONPairsDecisionBlockStruct& block)
535{
6253e09b 536 ///
537 /// Methods used to check if the header information corresponds to the
538 /// supposed type of the data block.
539 ///
540
90a74d7a 541 // The block must have the correct type.
542 if (block.fHeader.fType != kPairsDecisionDataBlock) return false;
543 // The block's record width must be the correct size.
544 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONPairDecisionStruct))
545 return false;
546 return true;
547}
548
549
550bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONTriggerRecordStruct& tr)
551{
6253e09b 552 ///
553 /// Methods used to check more extensively if the integrity of various
554 /// types of data blocks are Ok and returns true in that case.
555 /// These can be slow and should generally only be used for debugging.
556 ///
557
90a74d7a 558 // Make sure that the reserved bits in the fFlags field are set
559 // to zero.
560 if ((tr.fFlags & 0x3FFFFFF0) != 0) return false;
561
562 // Make sure the sign is not invalid.
563 if ((tr.fFlags & 0xC0000000) == 3) return false;
564
565 // Check that fHit[i] is nil if the corresponding bit in the
566 // flags word is zero.
567 const AliHLTMUONRecHitStruct& nilhit
568 = AliHLTMUONConstants::NilRecHitStruct();
569 if ((tr.fFlags & 0x1) == 0 and tr.fHit[0] != nilhit) return false;
570 if ((tr.fFlags & 0x2) == 0 and tr.fHit[1] != nilhit) return false;
571 if ((tr.fFlags & 0x4) == 0 and tr.fHit[2] != nilhit) return false;
572 if ((tr.fFlags & 0x8) == 0 and tr.fHit[3] != nilhit) return false;
573
574 return true;
575}
576
577
b727f838 578bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONTriggerRecordsBlockStruct& block)
579{
6253e09b 580 ///
581 /// Methods used to check more extensively if the integrity of various
582 /// types of data blocks are Ok and returns true in that case.
583 /// These can be slow and should generally only be used for debugging.
584 ///
585
b727f838 586 if (not HeaderOk(block)) return false;
23ad6161 587
588 const AliHLTMUONTriggerRecordStruct* triggerRecord =
589 reinterpret_cast<const AliHLTMUONTriggerRecordStruct*>(&block + 1);
26a4668d 590
b727f838 591 // Check if any ID is duplicated.
592 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
593 {
23ad6161 594 AliHLTInt32_t id = triggerRecord[i].fId;
b727f838 595 for (AliHLTUInt32_t j = i+1; i < block.fHeader.fNrecords; j++)
596 {
23ad6161 597 if (id == triggerRecord[j].fId)
b727f838 598 return false;
599 }
600 }
601
90a74d7a 602 // Check integrity of individual trigger records.
b727f838 603 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
604 {
23ad6161 605 if (not IntegrityOk(triggerRecord[i])) return false;
b727f838 606 }
607
608 return true;
609}
610
90a74d7a 611
c8ec7c7e 612bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONTrigRecsDebugBlockStruct& block)
613{
6253e09b 614 ///
615 /// Methods used to check more extensively if the integrity of various
616 /// types of data blocks are Ok and returns true in that case.
617 /// These can be slow and should generally only be used for debugging.
618 ///
619
c8ec7c7e 620 if (not HeaderOk(block)) return false;
621 return true;
622}
623
90a74d7a 624
c8ec7c7e 625bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONTriggerChannelsBlockStruct& block)
626{
6253e09b 627 ///
628 /// Methods used to check more extensively if the integrity of various
629 /// types of data blocks are Ok and returns true in that case.
630 /// These can be slow and should generally only be used for debugging.
631 ///
632
c8ec7c7e 633 if (not HeaderOk(block)) return false;
634 return true;
635}
b727f838 636
90a74d7a 637
b727f838 638bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONRecHitsBlockStruct& block)
639{
6253e09b 640 ///
641 /// Methods used to check more extensively if the integrity of various
642 /// types of data blocks are Ok and returns true in that case.
643 /// These can be slow and should generally only be used for debugging.
644 ///
645
b727f838 646 if (not HeaderOk(block)) return false;
647 return true;
648}
649
650
651bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONClustersBlockStruct& block)
652{
6253e09b 653 ///
654 /// Methods used to check more extensively if the integrity of various
655 /// types of data blocks are Ok and returns true in that case.
656 /// These can be slow and should generally only be used for debugging.
657 ///
658
b727f838 659 if (not HeaderOk(block)) return false;
b727f838 660
23ad6161 661 const AliHLTMUONClusterStruct* cluster =
662 reinterpret_cast<const AliHLTMUONClusterStruct*>(&block + 1);
663
c8ec7c7e 664 // Check if any ID is duplicated.
665 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
666 {
23ad6161 667 AliHLTInt32_t id = cluster[i].fId;
c8ec7c7e 668 for (AliHLTUInt32_t j = i+1; i < block.fHeader.fNrecords; j++)
669 {
23ad6161 670 if (id == cluster[j].fId)
c8ec7c7e 671 return false;
672 }
673 }
674
b727f838 675 return true;
676}
677
90a74d7a 678
b727f838 679bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONChannelsBlockStruct& block)
680{
6253e09b 681 ///
682 /// Methods used to check more extensively if the integrity of various
683 /// types of data blocks are Ok and returns true in that case.
684 /// These can be slow and should generally only be used for debugging.
685 ///
686
b727f838 687 if (not HeaderOk(block)) return false;
26a4668d 688 return true;
689}
90a74d7a 690
691
692bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONMansoTrackStruct& track)
693{
6253e09b 694 ///
695 /// Methods used to check more extensively if the integrity of various
696 /// types of data blocks are Ok and returns true in that case.
697 /// These can be slow and should generally only be used for debugging.
698 ///
699
90a74d7a 700 // Make sure that the reserved bits in the fFlags field are set
701 // to zero.
702 if ((track.fFlags & 0x3FFFFFF0) != 0) return false;
703
704 // Make sure the sign is not invalid.
705 if ((track.fFlags & 0xC0000000) == 0xC0000000) return false;
706
707 // Check that fHit[i] is nil if the corresponding bit in the
708 // flags word is zero.
709 const AliHLTMUONRecHitStruct& nilhit
710 = AliHLTMUONConstants::NilRecHitStruct();
711 if ((track.fFlags & 0x1) == 0 and track.fHit[0] != nilhit) return false;
712 if ((track.fFlags & 0x2) == 0 and track.fHit[1] != nilhit) return false;
713 if ((track.fFlags & 0x4) == 0 and track.fHit[2] != nilhit) return false;
714 if ((track.fFlags & 0x8) == 0 and track.fHit[3] != nilhit) return false;
715
716 return true;
717}
718
719
720bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONMansoTracksBlockStruct& block)
721{
6253e09b 722 ///
723 /// Methods used to check more extensively if the integrity of various
724 /// types of data blocks are Ok and returns true in that case.
725 /// These can be slow and should generally only be used for debugging.
726 ///
727
90a74d7a 728 if (not HeaderOk(block)) return false;
729
23ad6161 730 const AliHLTMUONMansoTrackStruct* track =
731 reinterpret_cast<const AliHLTMUONMansoTrackStruct*>(&block + 1);
732
90a74d7a 733 // Check if any ID is duplicated.
734 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
735 {
23ad6161 736 AliHLTInt32_t id = track[i].fId;
90a74d7a 737 for (AliHLTUInt32_t j = i+1; i < block.fHeader.fNrecords; j++)
738 {
23ad6161 739 if (id == track[j].fId)
90a74d7a 740 return false;
741 }
742 }
743
744 // Check that the tracks have integrity.
745 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
746 {
23ad6161 747 if (not IntegrityOk(track[i])) return false;
90a74d7a 748 }
749
750 return true;
751}
752
753
754bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONMansoCandidatesBlockStruct& block)
755{
6253e09b 756 ///
757 /// Methods used to check more extensively if the integrity of various
758 /// types of data blocks are Ok and returns true in that case.
759 /// These can be slow and should generally only be used for debugging.
760 ///
761
90a74d7a 762 if (not HeaderOk(block)) return false;
763
23ad6161 764 const AliHLTMUONMansoCandidateStruct* candidate =
765 reinterpret_cast<const AliHLTMUONMansoCandidateStruct*>(&block + 1);
766
90a74d7a 767 // Check that the tracks have integrity.
768 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
769 {
23ad6161 770 if (not IntegrityOk(candidate[i].fTrack)) return false;
90a74d7a 771 }
772
773 return true;
774}
775
776
777bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONTrackDecisionStruct& decision)
778{
6253e09b 779 ///
780 /// Methods used to check more extensively if the integrity of various
781 /// types of data blocks are Ok and returns true in that case.
782 /// These can be slow and should generally only be used for debugging.
783 ///
784
90a74d7a 785 // Make sure that the reserved bits in the fTriggerBits field are set
786 // to zero.
787 if ((decision.fTriggerBits & 0xFFFFFFFC) != 0) return false;
788 return true;
789}
790
791
792bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONSinglesDecisionBlockStruct& block)
793{
6253e09b 794 ///
795 /// Methods used to check more extensively if the integrity of various
796 /// types of data blocks are Ok and returns true in that case.
797 /// These can be slow and should generally only be used for debugging.
798 ///
799
90a74d7a 800 if (not HeaderOk(block)) return false;
23ad6161 801
802 const AliHLTMUONTrackDecisionStruct* decision =
803 reinterpret_cast<const AliHLTMUONTrackDecisionStruct*>(&block + 1);
90a74d7a 804
805 // Check that the trigger bits for each track have integrity.
806 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
807 {
23ad6161 808 if (not IntegrityOk(decision[i])) return false;
90a74d7a 809 }
810
811 return true;
812}
813
814
815bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONPairDecisionStruct& decision)
816{
6253e09b 817 ///
818 /// Methods used to check more extensively if the integrity of various
819 /// types of data blocks are Ok and returns true in that case.
820 /// These can be slow and should generally only be used for debugging.
821 ///
822
90a74d7a 823 // Make sure that the reserved bits in the fTriggerBits field are set
824 // to zero.
825 if ((decision.fTriggerBits & 0xFFFFFF80) != 0) return false;
826
827 // The high mass or low mass bits can only be set if unlike bit is set.
828 if ((decision.fTriggerBits & 0x00000010) == 0
829 and (decision.fTriggerBits & 0x00000060) != 0
830 )
831 return false;
832
833 // Neither the high pt (hipt) or low pt (lopt) count bits can be > 2.
834 // And the sum must not be > 2.
835 AliHLTUInt8_t lowPtCount = (decision.fTriggerBits & 0x00000003);
836 AliHLTUInt8_t highPtCount = (decision.fTriggerBits & 0x0000000C) >> 2;
837 if (lowPtCount + highPtCount > 2) return false;
838
839 return true;
840}
841
842
843bool AliHLTMUONUtils::IntegrityOk(const AliHLTMUONPairsDecisionBlockStruct& block)
844{
6253e09b 845 ///
846 /// Methods used to check more extensively if the integrity of various
847 /// types of data blocks are Ok and returns true in that case.
848 /// These can be slow and should generally only be used for debugging.
849 ///
850
90a74d7a 851 if (not HeaderOk(block)) return false;
852
23ad6161 853 const AliHLTMUONPairDecisionStruct* decision =
854 reinterpret_cast<const AliHLTMUONPairDecisionStruct*>(&block + 1);
855
90a74d7a 856 // Check that the trigger bits for each track pair have integrity.
857 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
858 {
23ad6161 859 if (not IntegrityOk(decision[i])) return false;
90a74d7a 860 }
861
862 return true;
863}