1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /// @file AliHLTMUONUtils.cxx
20 /// @author Artur Szostak <artursz@iafrica.com>
22 /// @brief Implementation of AliHLTMUONUtils utility routines.
25 #include "AliHLTMUONUtils.h"
26 #include "AliHLTMUONConstants.h"
27 #include "AliHLTMUONTriggerRecordsBlockStruct.h"
28 #include "AliHLTMUONTrigRecsDebugBlockStruct.h"
29 #include "AliHLTMUONTriggerChannelsBlockStruct.h"
30 #include "AliHLTMUONRecHitsBlockStruct.h"
31 #include "AliHLTMUONClustersBlockStruct.h"
32 #include "AliHLTMUONChannelsBlockStruct.h"
33 #include "AliHLTMUONMansoTracksBlockStruct.h"
34 #include "AliHLTMUONMansoCandidatesBlockStruct.h"
35 #include "AliHLTMUONSinglesDecisionBlockStruct.h"
36 #include "AliHLTMUONPairsDecisionBlockStruct.h"
37 #include "AliMUONTrackerDDLDecoderEventHandler.h"
43 AliHLTUInt32_t AliHLTMUONUtils::PackTriggerRecordFlags(
44 AliHLTMUONParticleSign sign, const bool hitset[4]
48 /// This packs the given parameters into the bits of a word appropriate
49 /// for AliHLTMUONTriggerRecordStruct::fFlags.
50 /// @param sign The particle sign.
51 /// @param hitset Flags to indicate if the corresponding fHits[i] elements
53 /// @return Returns the 32 bit packed word.
59 case kSignMinus: flags = 0x80000000; break;
60 case kSignPlus: flags = 0x40000000; break;
61 default: flags = 0x00000000; break;
64 return flags | (hitset[0] ? 0x1 : 0) | (hitset[1] ? 0x2 : 0)
65 | (hitset[2] ? 0x4 : 0) | (hitset[3] ? 0x8 : 0);
69 void AliHLTMUONUtils::UnpackTriggerRecordFlags(
70 AliHLTUInt32_t flags, AliHLTMUONParticleSign& sign, bool hitset[4]
74 /// This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
75 /// its component fields.
76 /// @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
77 /// @param sign Sets this to the particle sign.
78 /// @param hitset Sets the array elements to indicate if the corresponding
79 /// fHits[i] element was set/filled.
82 AliHLTUInt32_t signbits = flags & 0xC0000000;
85 case 0x80000000: sign = kSignMinus; break;
86 case 0x40000000: sign = kSignPlus; break;
87 default: sign = kSignUnknown; break;
89 hitset[0] = (flags & 0x1) == 0x1;
90 hitset[1] = (flags & 0x2) == 0x2;
91 hitset[2] = (flags & 0x4) == 0x4;
92 hitset[3] = (flags & 0x8) == 0x8;
96 AliHLTUInt32_t AliHLTMUONUtils::PackTrackDecisionBits(bool highPt, bool lowPt)
99 /// This packs the given parameters into the bits of a word appropriate
100 /// for AliHLTMUONTrackDecisionStruct::fTriggerBits.
101 /// @param highPt Has the track passed the high pt cut.
102 /// @param lowPt Has the track passed the low pt cut.
103 /// @return Returns the 32 bit packed word.
106 return (highPt ? 0x2 : 0) | (lowPt ? 0x1 : 0);
110 void AliHLTMUONUtils::UnpackTrackDecisionBits(
111 AliHLTUInt32_t bits, bool& highPt, bool& lowPt
115 /// This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
116 /// its component fields.
117 /// @param bits The trigger bits from an AliHLTMUONTrackDecisionStruct
119 /// @param highPt Sets this to the value of the high pt cut bit.
120 /// @param lowPt Sets this to the value of the low pt cut bit.
123 lowPt = (bits & 0x1) == 0x1;
124 highPt = (bits & 0x2) == 0x2;
128 AliHLTUInt32_t AliHLTMUONUtils::PackPairDecisionBits(
129 bool highMass, bool lowMass, bool unlike,
130 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
134 /// This packs the given parameters into the bits of a word appropriate
135 /// for AliHLTMUONPairDecisionStruct::fTriggerBits.
137 /// @param highMass Has the track pair passed the high invariant mass cut.
138 /// @param lowMass Has the track pair passed the low invariant mass cut.
139 /// @param unlike Does the track pair have unlike signs.
140 /// @param highPtCount The number of tracks that passed the high pt cut
142 /// @param lowPtCount The number of tracks that passed the low pt cut
144 /// @return Returns the 32 bit packed word.
146 /// Note: Must have highPtCount + lowPtCount <= 2 and unlike == true if
147 /// highMass or lowMass is true.
150 assert( highPtCount + lowPtCount <= 2 );
151 // highMass and lowMass must be false if unlike is false:
152 assert( not unlike ? (highMass == false and lowMass == false) : true );
154 return (highMass ? 0x40 : 0) | (lowMass ? 0x20 : 0) | (unlike ? 0x10 : 0)
155 | ((highPtCount & 0x3) << 2) | (lowPtCount & 0x3);
159 void AliHLTMUONUtils::UnpackPairDecisionBits(
160 AliHLTUInt32_t bits, bool& highMass, bool& lowMass, bool& unlike,
161 AliHLTUInt8_t& highPtCount, AliHLTUInt8_t& lowPtCount
165 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
166 /// its component fields.
167 /// @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
169 /// @param highMass Sets this to the value of the high invariant mass cut bit.
170 /// @param lowMass Sets this to the value of the low invariant mass cut bit.
171 /// @param unlike Sets this if the pair is unlike sign.
172 /// @param highPtCount Sets this to the high pt count bits.
173 /// @param lowPtCount Sets this to the low pt count bits.
176 highMass = (bits & 0x40) == 0x40;
177 lowMass = (bits & 0x20) == 0x20;
178 unlike = (bits & 0x10) == 0x10;
179 highPtCount = (bits & 0xC) >> 2;
180 lowPtCount = bits & 0x3;
184 AliHLTUInt32_t AliHLTMUONUtils::PackSpecBits(
189 /// This packs the given parameters into the 32bit Pub/Sub specification
190 /// word in the data block descriptor.
192 /// @param ddl The list of DDLs forming part of the readout. ddl[0]
193 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
194 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
195 /// trigger DDLs 2816 and 2817 respectively.
196 /// @return Returns the 32 bit packed specification word.
199 // Pack the bits into the following format:
200 // bit: [ 31 - 22 ][ 21 ][ 20 ][ 19 - 0 ]
201 // field: [ reserved, set to zero ][ TRGDDL2817 ][ TRGDDL2816 ][ TRKDDLS ]
202 // Meaning of field acronyms:
203 // TRGDDL2816 - Trigger DDL number 2816.
204 // TRGDDL2817 - Trigger DDL number 2817.
205 // TRKDDLS - Tracking DDL flags where bit 0 will be for DDL number 2560,
206 // bit 1 for DDL no. 2561 etc. up to bit 19 which is for DDL 2579.
207 AliHLTUInt32_t bits = 0;
208 for (int i = 0; i < 22; i++)
209 bits |= (ddl[i] ? 0x1 : 0x0) << i;
214 void AliHLTMUONUtils::UnpackSpecBits(
215 AliHLTUInt32_t bits, bool ddl[22]
219 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
220 /// its component fields.
221 /// @param bits The Pub/Sub specification word from a data block descriptor.
222 /// @param ddl The output list of DDLs forming part of the readout. ddl[0]
223 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
224 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
225 /// trigger DDLs 2816 and 2817 respectively.
228 // Perform the inverse operation of PackSpecBits.
229 for (int i = 0; i < 22; i++)
230 ddl[i] = ((bits >> i) & 0x1) == 1;
234 AliHLTInt32_t AliHLTMUONUtils::DDLNumberToEquipId(AliHLTInt32_t ddlNo)
237 /// This method converts the DDL number for the muon spectrometer in the
238 /// range [0..21] to the equipment ID number.
239 /// @param ddlNo The DDL number in the range [0..21].
240 /// @return Returns the equipment ID number or -1 if ddlNo was invalid.
243 if (0 <= ddlNo and ddlNo <= 19)
247 else if (20 <= ddlNo and ddlNo <= 21)
249 return 2816 + (ddlNo - 20);
258 AliHLTInt32_t AliHLTMUONUtils::EquipIdToDDLNumber(AliHLTInt32_t id)
261 /// This method converts the equipment ID number for a muon spectrometer
262 /// DDL to the DDL number in the range [0..21].
263 /// @param id The equipment ID of the DDL.
264 /// @return Returns the DDL number in the range [0..21] or -1 if the
265 /// equipment ID was invalid.
268 if (2560 <= id and id <= 2560+19)
272 else if (2816 <= id and id <= 2817)
274 return id - 2816 + 20;
283 AliHLTInt32_t AliHLTMUONUtils::SpecToEquipId(AliHLTUInt32_t spec)
286 /// This method converts a 32 bit data block specification for a MUON-HLT
287 /// data block into its corresponding DDL equipment ID number.
288 /// It is assumed that the specification is for a data block comming from
289 /// a single DDL source. If more than one DDL contributed to the data block
290 /// then -1 is returned.
291 /// @param spec The 32 bit specification for a data block.
292 /// @return Returns the equipment ID corresponding to the specification
293 /// or -1 if the specification was invalid.
296 for (AliHLTInt32_t ddlNo = 0; ddlNo < 20; ddlNo++)
298 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
301 for (AliHLTInt32_t ddlNo = 20; ddlNo < 22; ddlNo++)
303 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
304 return ddlNo - 20 + 2816;
310 AliHLTUInt32_t AliHLTMUONUtils::EquipIdToSpec(AliHLTInt32_t id)
313 /// This method converts a equipment ID number for a DDL into its corresponding
314 /// 32 bit data block specification for the MUON-HLT.
315 /// @param id The equipment ID number of the DDL.
316 /// @return Returns the 32 bit data block specification or 0x0 if the
317 /// equipment ID was invalid.
320 if (2560 <= id and id <= 2560+19)
322 return 0x1 << (id - 2560);
324 else if (2816 <= id and id <= 2817)
326 return 0x1 << (id - 2816 + 20);
335 AliHLTInt32_t AliHLTMUONUtils::SpecToDDLNumber(AliHLTUInt32_t spec)
338 /// This method converts a 32 bit data block specification for a MUON-HLT
339 /// data block into its corresponding DDL number in the range [0..21].
340 /// It is assumed that the specification is for a data block comming from
341 /// a single DDL source. If more than one DDL contributed to the data block
342 /// then -1 is returned.
343 /// @param spec The 32 bit specification for a data block.
344 /// @return Returns the corresponding DDL number for the specification
345 /// or -1 if the specification was invalid.
348 for (AliHLTInt32_t ddlNo = 0; ddlNo < 22; ddlNo++)
350 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
357 AliHLTUInt32_t AliHLTMUONUtils::DDLNumberToSpec(AliHLTInt32_t ddlNo)
360 /// This method converts a DDL number in the range [0..21] into its
361 /// corresponding 32 bit data block specification for the MUON-HLT.
362 /// @param ddlNo The equipment ID number of the DDL.
363 /// @return Returns the 32 bit data block specification or 0x0 if the
364 /// DDL number was invalid (out of range).
367 if (0 <= ddlNo and ddlNo <= 21)
378 AliHLTMUONDataBlockType AliHLTMUONUtils::ParseCommandLineTypeString(const char* type)
380 /// Parses the string containing the type name of a dHLT data block and
381 /// returns the corresponding AliHLTMUONDataBlockType value.
382 /// \param type The string containing the type name.
383 /// \returns The data block type or kUnknownDataBlock if the type name
386 if (strcmp(type, "trigrecs") == 0)
388 return kTriggerRecordsDataBlock;
390 else if (strcmp(type, "trigrecsdebug") == 0)
392 return kTrigRecsDebugDataBlock;
394 else if (strcmp(type, "trigchannels") == 0)
396 return kTriggerChannelsDataBlock;
398 else if (strcmp(type, "rechits") == 0)
400 return kRecHitsDataBlock;
402 else if (strcmp(type,"channels") == 0)
404 return kChannelsDataBlock;
406 else if (strcmp(type,"clusters") == 0)
408 return kClustersDataBlock;
410 else if (strcmp(type, "mansotracks") == 0)
412 return kMansoTracksDataBlock;
414 else if (strcmp(type, "mansocandidates") == 0)
416 return kMansoCandidatesDataBlock;
418 else if (strcmp(type, "singlesdecision") == 0)
420 return kSinglesDecisionDataBlock;
422 else if (strcmp(type, "pairsdecision") == 0)
424 return kPairsDecisionDataBlock;
427 return kUnknownDataBlock;
431 const char* AliHLTMUONUtils::DataBlockTypeToString(AliHLTMUONDataBlockType type)
433 /// Converts a type ID to a type string compatible with
436 static char str[kAliHLTComponentDataTypefIDsize+1];
437 AliHLTComponentDataType t;
440 case kTriggerRecordsDataBlock:
441 t = AliHLTMUONConstants::TriggerRecordsBlockDataType();
443 case kTrigRecsDebugDataBlock:
444 t = AliHLTMUONConstants::TrigRecsDebugBlockDataType();
446 case kTriggerChannelsDataBlock:
447 t = AliHLTMUONConstants::TriggerChannelBlockDataType();
449 case kRecHitsDataBlock:
450 t = AliHLTMUONConstants::RecHitsBlockDataType();
452 case kClustersDataBlock:
453 t = AliHLTMUONConstants::ClusterBlockDataType();
455 case kChannelsDataBlock:
456 t = AliHLTMUONConstants::ChannelBlockDataType();
458 case kMansoTracksDataBlock:
459 t = AliHLTMUONConstants::MansoTracksBlockDataType();
461 case kMansoCandidatesDataBlock:
462 t = AliHLTMUONConstants::MansoCandidatesBlockDataType();
464 case kSinglesDecisionDataBlock:
465 t = AliHLTMUONConstants::SinglesDecisionBlockDataType();
467 case kPairsDecisionDataBlock:
468 t = AliHLTMUONConstants::PairsDecisionBlockDataType();
473 memcpy(&str, &t.fID, kAliHLTComponentDataTypefIDsize);
474 // Must insert the NULL character to make this an ANSI C string.
475 str[kAliHLTComponentDataTypefIDsize] = '\0';
480 const char* AliHLTMUONUtils::FailureReasonToString(WhyNotValid reason)
482 /// This method converts the WhyNotValid enumeration to a string representation.
486 case kNoReason: return "kNoReason";
487 case kHeaderContainsWrongType: return "kHeaderContainsWrongType";
488 case kHeaderContainsWrongRecordWidth: return "kHeaderContainsWrongRecordWidth";
489 case kInvalidIdValue: return "kInvalidIdValue";
490 case kInvalidTriggerIdValue: return "kInvalidTriggerIdValue";
491 case kInvalidTrackIdValue: return "kInvalidTrackIdValue";
492 case kReservedBitsNotZero: return "kReservedBitsNotZero";
493 case kParticleSignBitsNotValid: return "kParticleSignBitsNotValid";
494 case kHitNotMarkedAsNil: return "kHitNotMarkedAsNil";
495 case kInvalidDetElementNumber: return "kInvalidDetElementNumber";
496 case kHitIsNil: return "kHitIsNil";
497 case kInvalidChannelCount: return "kInvalidChannelCount";
498 case kInvalidBusPatchId: return "kInvalidBusPatchId";
499 case kInvalidManuId: return "kInvalidManuId";
500 case kInvalidChannelAddress: return "kInvalidChannelAddress";
501 case kInvalidSignal: return "kInvalidSignal";
502 case kDataWordDifferent: return "kDataWordDifferent";
503 case kChiSquareInvalid: return "kChiSquareInvalid";
504 case kMomentumVectorNotZero: return "kMomentumVectorNotZero";
505 case kRoiRadiusInvalid: return "kRoiRadiusInvalid";
506 case kHitNotWithinRoi: return "kHitNotWithinRoi";
507 case kPtValueNotValid: return "kPtValueNotValid";
508 case kPairTrackIdsAreIdentical: return "kPairTrackIdsAreIdentical";
509 case kMassValueNotValid: return "kMassValueNotValid";
510 case kLowPtCountInvalid: return "kLowPtCountInvalid";
511 case kHighPtCountInvalid: return "kHighPtCountInvalid";
512 case kFoundDuplicateIDs: return "kFoundDuplicateIDs";
513 case kFoundDuplicateHits: return "kFoundDuplicateHits";
514 case kFoundDuplicateTriggers: return "kFoundDuplicateTriggers";
515 default: return "INVALID";
520 const char* AliHLTMUONUtils::FailureReasonToMessage(WhyNotValid reason)
522 /// This method returns a string containing a user readable message explaining
523 /// the reason for failure described by the WhyNotValid enumeration.
528 return "There was no problem with the data block.";
529 case kHeaderContainsWrongType:
530 return "The common data header contains an incorrect type"
532 case kHeaderContainsWrongRecordWidth:
533 return "The common data header contains an incorrect data"
535 case kInvalidIdValue:
536 return "The structure identifier does not have a valid value.";
537 case kInvalidTriggerIdValue:
538 return "The trigger structure identifier does not have a valid"
540 case kInvalidTrackIdValue:
541 return "The track structure identifier does not have a valid"
543 case kReservedBitsNotZero:
544 return "Reserved bits have not been set to zero.";
545 case kParticleSignBitsNotValid:
546 return "The particle sign bits are not a valid value.";
547 case kHitNotMarkedAsNil:
548 return "A hit was marked as not found, but the corresponding hit"
549 " structure was not set to nil.";
550 case kInvalidDetElementNumber:
551 return "An invalid detector element ID was found.";
553 return "The hit cannot be set to a nil value.";
554 case kInvalidChannelCount:
555 return "The number of channels indicated is zero or outside"
557 case kInvalidBusPatchId:
558 return "The bus patch identifier is outside the valid range.";
560 return "The MANU identifier is outside the valid range.";
561 case kInvalidChannelAddress:
562 return "The MANU channel address is outside the valid range.";
564 return "The ADC signal value is outside the valid range.";
565 case kDataWordDifferent:
566 return "The raw data word is different from the unpacked values.";
567 case kChiSquareInvalid:
568 return "The chi squared value must be a positive value or -1"
569 " indicating a fitting error.";
570 case kMomentumVectorNotZero:
571 return "The chi sqaured value is set to -1 indicating momentum"
572 " was not fitted, but the momentum vector was not zero.";
573 case kRoiRadiusInvalid:
574 return "The region of interest radius is invalid.";
575 case kHitNotWithinRoi:
576 return "A tracks hit is not within the corresponding region"
578 case kPtValueNotValid:
579 return "The pT value is not positive, nor -1 indicating an"
581 case kPairTrackIdsAreIdentical:
582 return "The track identifiers of the track pair are identical.";
583 case kMassValueNotValid:
584 return "The invariant mass value is not positive, nor -1"
585 " indicating an invalid value.";
586 case kLowPtCountInvalid:
587 return "The low pT trigger count is greater than 2,"
588 " which is invalid.";
589 case kHighPtCountInvalid:
590 return "The high pT trigger count is greater than 2,"
591 " which is invalid.";
592 case kFoundDuplicateIDs:
593 return "Found duplicate data record identifiers, but they"
594 " should all be unique.";
595 case kFoundDuplicateHits:
596 return "Found duplicate hit structures, but they should all"
598 case kFoundDuplicateTriggers:
599 return "Found duplicate trigger decisions.";
601 return "UNKNOWN REASON CODE";
606 bool AliHLTMUONUtils::RecordNumberWasSet(WhyNotValid reason)
608 /// Returns true if the \em recordNum in the corresponding IntegrityOk method
609 /// would have been set, if it returned false and a reason was set.
610 /// This helper method makes it easy to test if the \em recordNum parameter
611 /// is filled with a valid value or not.
612 /// \param reason The reason code as returned by the IntegrityOk method.
613 /// \returns true if the \em recordNum parameter was set for the given
618 case kInvalidIdValue:
619 case kInvalidTriggerIdValue:
620 case kInvalidTrackIdValue:
621 case kReservedBitsNotZero:
622 case kParticleSignBitsNotValid:
623 case kHitNotMarkedAsNil:
624 case kInvalidDetElementNumber:
626 case kInvalidChannelCount:
627 case kInvalidBusPatchId:
629 case kInvalidChannelAddress:
631 case kDataWordDifferent:
632 case kChiSquareInvalid:
633 case kPtValueNotValid:
634 case kPairTrackIdsAreIdentical:
635 case kMassValueNotValid:
636 case kLowPtCountInvalid:
637 case kHighPtCountInvalid:
639 default: return false;
644 bool AliHLTMUONUtils::HeaderOk(
645 const AliHLTMUONTriggerRecordsBlockStruct& block,
646 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
649 /// Method used to check if the header information corresponds to the
650 /// supposed type of the raw dHLT data block.
651 /// [in] \param block The data block to check.
652 /// [out] \param reason If this is not NULL, then it is assumed to point
653 /// to an array of at least 'reasonCount' number of elements. It will
654 /// be filled with the reason codes describing why the header is not
656 /// [in/out] \param reasonCount This should initially specify the size of
657 /// the array pointed to by 'reason'. It will be filled with the number
658 /// of items actually filled into the reason array upon exit from this
660 /// \returns true if there is no problem with the header and false otherwise.
662 AliHLTUInt32_t maxCount = reasonCount;
666 // The block must have the correct type.
667 if (block.fHeader.fType != kTriggerRecordsDataBlock)
669 if (reason != NULL and reasonCount < maxCount)
671 reason[reasonCount] = kHeaderContainsWrongType;
677 // The block's record width must be the correct size.
678 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerRecordStruct))
680 if (reason != NULL and reasonCount < maxCount)
682 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
692 bool AliHLTMUONUtils::HeaderOk(
693 const AliHLTMUONTrigRecsDebugBlockStruct& block,
694 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
697 /// Method used to check if the header information corresponds to the
698 /// supposed type of the raw dHLT data block.
699 /// [in] \param block The data block to check.
700 /// [out] \param reason If this is not NULL, then it is assumed to point
701 /// to an array of at least 'reasonCount' number of elements. It will
702 /// be filled with the reason codes describing why the header is not
704 /// [in/out] \param reasonCount This should initially specify the size of
705 /// the array pointed to by 'reason'. It will be filled with the number
706 /// of items actually filled into the reason array upon exit from this
708 /// \returns true if there is no problem with the header and false otherwise.
710 AliHLTUInt32_t maxCount = reasonCount;
714 // The block must have the correct type.
715 if (block.fHeader.fType != kTrigRecsDebugDataBlock)
717 if (reason != NULL and reasonCount < maxCount)
719 reason[reasonCount] = kHeaderContainsWrongType;
725 // The block's record width must be the correct size.
726 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrigRecInfoStruct))
728 if (reason != NULL and reasonCount < maxCount)
730 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
740 bool AliHLTMUONUtils::HeaderOk(
741 const AliHLTMUONTriggerChannelsBlockStruct& block,
745 /// Method used to check if the header information corresponds to the
746 /// supposed type of the raw dHLT data block.
747 /// [in] \param block The data block to check.
748 /// [out] \param reason If this is not NULL, then it will be filled with
749 /// the reason code describing why the header is not valid, if and
750 /// only if a problem is found with the data.
751 /// \returns true if there is no problem with the header and false otherwise.
753 // The block must have the correct type.
754 if (block.fHeader.fType != kTriggerChannelsDataBlock)
756 if (reason != NULL) *reason = kHeaderContainsWrongType;
760 // The block's record width must be the correct size.
761 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerChannelStruct))
763 if (reason != NULL) *reason = kHeaderContainsWrongRecordWidth;
771 bool AliHLTMUONUtils::HeaderOk(
772 const AliHLTMUONRecHitsBlockStruct& block,
773 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
776 /// Method used to check if the header information corresponds to the
777 /// supposed type of the raw dHLT data block.
778 /// [in] \param block The data block to check.
779 /// [out] \param reason If this is not NULL, then it is assumed to point
780 /// to an array of at least 'reasonCount' number of elements. It will
781 /// be filled with the reason codes describing why the header is not
783 /// [in/out] \param reasonCount This should initially specify the size of
784 /// the array pointed to by 'reason'. It will be filled with the number
785 /// of items actually filled into the reason array upon exit from this
787 /// \returns true if there is no problem with the header and false otherwise.
789 AliHLTUInt32_t maxCount = reasonCount;
793 // The block must have the correct type.
794 if (block.fHeader.fType != kRecHitsDataBlock)
796 if (reason != NULL and reasonCount < maxCount)
798 reason[reasonCount] = kHeaderContainsWrongType;
804 // The block's record width must be the correct size.
805 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONRecHitStruct))
807 if (reason != NULL and reasonCount < maxCount)
809 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
819 bool AliHLTMUONUtils::HeaderOk(
820 const AliHLTMUONClustersBlockStruct& block,
821 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
824 /// Method used to check if the header information corresponds to the
825 /// supposed type of the raw dHLT data block.
826 /// [in] \param block The data block to check.
827 /// [out] \param reason If this is not NULL, then it is assumed to point
828 /// to an array of at least 'reasonCount' number of elements. It will
829 /// be filled with the reason codes describing why the header is not
831 /// [in/out] \param reasonCount This should initially specify the size of
832 /// the array pointed to by 'reason'. It will be filled with the number
833 /// of items actually filled into the reason array upon exit from this
835 /// \returns true if there is no problem with the header and false otherwise.
837 AliHLTUInt32_t maxCount = reasonCount;
841 // The block must have the correct type.
842 if (block.fHeader.fType != kClustersDataBlock)
844 if (reason != NULL and reasonCount < maxCount)
846 reason[reasonCount] = kHeaderContainsWrongType;
852 // The block's record width must be the correct size.
853 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONClusterStruct))
855 if (reason != NULL and reasonCount < maxCount)
857 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
867 bool AliHLTMUONUtils::HeaderOk(
868 const AliHLTMUONChannelsBlockStruct& block,
869 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
872 /// Method used to check if the header information corresponds to the
873 /// supposed type of the raw dHLT data block.
874 /// [in] \param block The data block to check.
875 /// [out] \param reason If this is not NULL, then it is assumed to point
876 /// to an array of at least 'reasonCount' number of elements. It will
877 /// be filled with the reason codes describing why the header is not
879 /// [in/out] \param reasonCount This should initially specify the size of
880 /// the array pointed to by 'reason'. It will be filled with the number
881 /// of items actually filled into the reason array upon exit from this
883 /// \returns true if there is no problem with the header and false otherwise.
885 AliHLTUInt32_t maxCount = reasonCount;
889 // The block must have the correct type.
890 if (block.fHeader.fType != kChannelsDataBlock)
892 if (reason != NULL and reasonCount < maxCount)
894 reason[reasonCount] = kHeaderContainsWrongType;
900 // The block's record width must be the correct size.
901 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONChannelStruct))
903 if (reason != NULL and reasonCount < maxCount)
905 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
915 bool AliHLTMUONUtils::HeaderOk(
916 const AliHLTMUONMansoTracksBlockStruct& block,
917 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
920 /// Method used to check if the header information corresponds to the
921 /// supposed type of the raw dHLT data block.
922 /// [in] \param block The data block to check.
923 /// [out] \param reason If this is not NULL, then it is assumed to point
924 /// to an array of at least 'reasonCount' number of elements. It will
925 /// be filled with the reason codes describing why the header is not
927 /// [in/out] \param reasonCount This should initially specify the size of
928 /// the array pointed to by 'reason'. It will be filled with the number
929 /// of items actually filled into the reason array upon exit from this
931 /// \returns true if there is no problem with the header and false otherwise.
933 AliHLTUInt32_t maxCount = reasonCount;
937 // The block must have the correct type.
938 if (block.fHeader.fType != kMansoTracksDataBlock)
940 if (reason != NULL and reasonCount < maxCount)
942 reason[reasonCount] = kHeaderContainsWrongType;
948 // The block's record width must be the correct size.
949 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoTrackStruct))
951 if (reason != NULL and reasonCount < maxCount)
953 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
963 bool AliHLTMUONUtils::HeaderOk(
964 const AliHLTMUONMansoCandidatesBlockStruct& block,
965 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
968 /// Method used to check if the header information corresponds to the
969 /// supposed type of the raw dHLT data block.
970 /// [in] \param block The data block to check.
971 /// [out] \param reason If this is not NULL, then it is assumed to point
972 /// to an array of at least 'reasonCount' number of elements. It will
973 /// be filled with the reason codes describing why the header is not
975 /// [in/out] \param reasonCount This should initially specify the size of
976 /// the array pointed to by 'reason'. It will be filled with the number
977 /// of items actually filled into the reason array upon exit from this
979 /// \returns true if there is no problem with the header and false otherwise.
981 AliHLTUInt32_t maxCount = reasonCount;
985 // The block must have the correct type.
986 if (block.fHeader.fType != kMansoCandidatesDataBlock)
988 if (reason != NULL and reasonCount < maxCount)
990 reason[reasonCount] = kHeaderContainsWrongType;
996 // The block's record width must be the correct size.
997 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoCandidateStruct))
999 if (reason != NULL and reasonCount < maxCount)
1001 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1011 bool AliHLTMUONUtils::HeaderOk(
1012 const AliHLTMUONSinglesDecisionBlockStruct& block,
1013 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1016 /// Method used to check if the header information corresponds to the
1017 /// supposed type of the raw dHLT data block.
1018 /// [in] \param block The data block to check.
1019 /// [out] \param reason If this is not NULL, then it is assumed to point
1020 /// to an array of at least 'reasonCount' number of elements. It will
1021 /// be filled with the reason codes describing why the header is not
1023 /// [in/out] \param reasonCount This should initially specify the size of
1024 /// the array pointed to by 'reason'. It will be filled with the number
1025 /// of items actually filled into the reason array upon exit from this
1027 /// \returns true if there is no problem with the header and false otherwise.
1029 AliHLTUInt32_t maxCount = reasonCount;
1033 // The block must have the correct type.
1034 if (block.fHeader.fType != kSinglesDecisionDataBlock)
1036 if (reason != NULL and reasonCount < maxCount)
1038 reason[reasonCount] = kHeaderContainsWrongType;
1044 // The block's record width must be the correct size.
1045 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrackDecisionStruct))
1047 if (reason != NULL and reasonCount < maxCount)
1049 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1059 bool AliHLTMUONUtils::HeaderOk(
1060 const AliHLTMUONPairsDecisionBlockStruct& block,
1061 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1064 /// Method used to check if the header information corresponds to the
1065 /// supposed type of the raw dHLT data block.
1066 /// [in] \param block The data block to check.
1067 /// [out] \param reason If this is not NULL, then it is assumed to point
1068 /// to an array of at least 'reasonCount' number of elements. It will
1069 /// be filled with the reason codes describing why the header is not
1071 /// [in/out] \param reasonCount This should initially specify the size of
1072 /// the array pointed to by 'reason'. It will be filled with the number
1073 /// of items actually filled into the reason array upon exit from this
1075 /// \returns true if there is no problem with the header and false otherwise.
1077 AliHLTUInt32_t maxCount = reasonCount;
1081 // The block must have the correct type.
1082 if (block.fHeader.fType != kPairsDecisionDataBlock)
1084 if (reason != NULL and reasonCount < maxCount)
1086 reason[reasonCount] = kHeaderContainsWrongType;
1092 // The block's record width must be the correct size.
1093 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONPairDecisionStruct))
1095 if (reason != NULL and reasonCount < maxCount)
1097 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1107 bool AliHLTMUONUtils::IntegrityOk(
1108 const AliHLTMUONTriggerRecordStruct& tr,
1109 WhyNotValid* reason,
1110 AliHLTUInt32_t& reasonCount
1113 /// This method is used to check more extensively if the integrity of the
1114 /// trigger record structure is OK and returns true in that case.
1115 /// [in] \param tr The trigger record structure to check.
1116 /// [out] \param reason If this is not NULL, then it is assumed to point
1117 /// to an array of at least 'reasonCount' number of elements. It will
1118 /// be filled with the reason codes describing why the structure is
1120 /// [in/out] \param reasonCount This should initially specify the size of
1121 /// the array pointed to by 'reason'. It will be filled with the number
1122 /// of items actually filled into the reason array upon exit from this
1124 /// \returns true if there is no problem with the structure and false otherwise.
1126 AliHLTUInt32_t maxCount = reasonCount;
1130 // Check that the ID has a valid value.
1131 if (not (tr.fId >= 0 or tr.fId == -1))
1133 if (reason != NULL and reasonCount < maxCount)
1135 reason[reasonCount] = kInvalidIdValue;
1141 // Make sure that the reserved bits in the fFlags field are set
1143 if ((tr.fFlags & 0x3FFFFFF0) != 0)
1145 if (reason != NULL and reasonCount < maxCount)
1147 reason[reasonCount] = kReservedBitsNotZero;
1153 // Make sure the sign is not invalid.
1154 if ((tr.fFlags & 0xC0000000) == 0xC0000000)
1156 if (reason != NULL and reasonCount < maxCount)
1158 reason[reasonCount] = kParticleSignBitsNotValid;
1164 // Check that fHit[i] is nil if the corresponding bit in the
1165 // flags word is zero.
1166 const AliHLTMUONRecHitStruct& nilhit
1167 = AliHLTMUONConstants::NilRecHitStruct();
1168 if ( ((tr.fFlags & 0x1) == 0 and tr.fHit[0] != nilhit) or
1169 ((tr.fFlags & 0x2) == 0 and tr.fHit[1] != nilhit) or
1170 ((tr.fFlags & 0x4) == 0 and tr.fHit[2] != nilhit) or
1171 ((tr.fFlags & 0x8) == 0 and tr.fHit[3] != nilhit)
1174 if (reason != NULL and reasonCount < maxCount)
1176 reason[reasonCount] = kHitNotMarkedAsNil;
1186 bool AliHLTMUONUtils::IntegrityOk(
1187 const AliHLTMUONTriggerRecordsBlockStruct& block,
1188 WhyNotValid* reason,
1189 AliHLTUInt32_t* recordNum,
1190 AliHLTUInt32_t& reasonCount
1193 /// This method is used to check more extensively if the integrity of the
1194 /// dHLT raw internal data block is OK and returns true in that case.
1195 /// [in] \param block The trigger record data block to check.
1196 /// [out] \param reason If this is not NULL, then it is assumed to point
1197 /// to an array of at least 'reasonCount' number of elements. It will
1198 /// be filled with the reason codes describing why the data block is
1200 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1201 /// to an array of at least 'reasonCount' number of elements. It will
1202 /// be filled with the number of the trigger record that had a problem.
1203 /// The value 'recordNum[i]' will only contain a valid value if
1204 /// the corresponding 'reason[i]' contains one of:
1205 /// - kInvalidIdValue
1206 /// - kReservedBitsNotZero
1207 /// - kParticleSignBitsNotValid
1208 /// - kHitNotMarkedAsNil
1209 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1210 /// was set and is valid or not.
1211 /// [in/out] \param reasonCount This should initially specify the size of
1212 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1213 /// with the number of items actually filled into the arrays upon exit
1214 /// from this method.
1215 /// \returns true if there is no problem with the data and false otherwise.
1217 AliHLTUInt32_t maxCount = reasonCount;
1218 bool result = HeaderOk(block, reason, reasonCount);
1220 const AliHLTMUONTriggerRecordStruct* triggerRecord =
1221 reinterpret_cast<const AliHLTMUONTriggerRecordStruct*>(&block + 1);
1223 // Check if any ID is duplicated.
1224 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1226 AliHLTInt32_t id = triggerRecord[i].fId;
1227 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1229 if (id == triggerRecord[j].fId)
1231 if (reason != NULL and reasonCount < maxCount)
1233 reason[reasonCount] = kFoundDuplicateIDs;
1241 // Check integrity of individual trigger records.
1242 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1244 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1245 if (not IntegrityOk(triggerRecord[i], reason+reasonCount, filledCount))
1247 // reasons filled in IntegrityOk, now we just need to adjust
1248 // reasonCount and fill the recordNum values.
1249 if (recordNum != NULL)
1251 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1252 recordNum[reasonCount + n] = i;
1254 reasonCount += filledCount;
1263 bool AliHLTMUONUtils::IntegrityOk(
1264 const AliHLTMUONTrigRecInfoStruct& trigInfo,
1265 WhyNotValid* reason,
1266 AliHLTUInt32_t& reasonCount
1269 /// This method is used to check more extensively if the integrity of the
1270 /// trigger record debug information structure is OK and returns true in that case.
1271 /// [in] \param trigInfo The trigger record debug information structure to check.
1272 /// [out] \param reason If this is not NULL, then it is assumed to point
1273 /// to an array of at least 'reasonCount' number of elements. It will
1274 /// be filled with the reason codes describing why the structure is not
1276 /// [in/out] \param reasonCount This should initially specify the size of
1277 /// the array pointed to by 'reason'. It will be filled with the number
1278 /// of items actually filled into the reason array upon exit from this
1280 /// \returns true if there is no problem with the structure and false otherwise.
1282 AliHLTUInt32_t maxCount = reasonCount;
1286 // Check that the trigger ID has a valid value.
1287 if (not (trigInfo.fTrigRecId >= 0 or trigInfo.fTrigRecId == -1))
1289 if (reason != NULL and reasonCount < maxCount)
1291 reason[reasonCount] = kInvalidIdValue;
1297 // Check that the fDetElemId[i] numbers are valid.
1298 if ( not (trigInfo.fDetElemId[0] >= 0 or trigInfo.fDetElemId[0] == -1) or
1299 not (trigInfo.fDetElemId[1] >= 0 or trigInfo.fDetElemId[1] == -1) or
1300 not (trigInfo.fDetElemId[2] >= 0 or trigInfo.fDetElemId[2] == -1) or
1301 not (trigInfo.fDetElemId[3] >= 0 or trigInfo.fDetElemId[3] == -1)
1304 if (reason != NULL and reasonCount < maxCount)
1306 reason[reasonCount] = kInvalidDetElementNumber;
1316 bool AliHLTMUONUtils::IntegrityOk(
1317 const AliHLTMUONTrigRecsDebugBlockStruct& block,
1318 WhyNotValid* reason,
1319 AliHLTUInt32_t* recordNum,
1320 AliHLTUInt32_t& reasonCount
1323 /// This method is used to check more extensively if the integrity of the
1324 /// dHLT raw internal data block is OK and returns true in that case.
1325 /// [in] \param block The trigger record debugging information data block
1327 /// [out] \param reason If this is not NULL, then it is assumed to point
1328 /// to an array of at least 'reasonCount' number of elements. It will
1329 /// be filled with the reason codes describing why the data block is
1331 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1332 /// to an array of at least 'reasonCount' number of elements. It will
1333 /// be filled with the number of the trigger record debug information
1334 /// structure that had a problem.
1335 /// The value 'recordNum[i]' will only contain a valid value if
1336 /// the corresponding 'reason[i]' contains one of:
1337 /// - kInvalidIdValue
1338 /// - kInvalidDetElementNumber
1339 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1340 /// was set and is valid or not.
1341 /// [in/out] \param reasonCount This should initially specify the size of
1342 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1343 /// with the number of items actually filled into the arrays upon exit
1344 /// from this method.
1345 /// \returns true if there is no problem with the data and false otherwise.
1347 AliHLTUInt32_t maxCount = reasonCount;
1348 bool result = HeaderOk(block, reason, reasonCount);
1350 const AliHLTMUONTrigRecInfoStruct* triggerInfo =
1351 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&block + 1);
1353 // Check if any trigger debug info structure has duplicated trigger IDs.
1354 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1356 AliHLTInt32_t id = triggerInfo[i].fTrigRecId;
1357 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1359 if (id == triggerInfo[j].fTrigRecId)
1361 if (reason != NULL and reasonCount < maxCount)
1363 reason[reasonCount] = kFoundDuplicateIDs;
1371 // Check integrity of individual trigger records.
1372 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1374 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1375 if (not IntegrityOk(triggerInfo[i], reason+reasonCount, filledCount))
1377 // reasons filled in IntegrityOk, now we just need to adjust
1378 // reasonCount and fill the recordNum values.
1379 if (recordNum != NULL)
1381 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1382 recordNum[reasonCount + n] = i;
1384 reasonCount += filledCount;
1393 bool AliHLTMUONUtils::IntegrityOk(
1394 const AliHLTMUONTriggerChannelsBlockStruct& block,
1398 /// This method is used to check more extensively if the integrity of the
1399 /// dHLT raw internal data block is OK and returns true in that case.
1400 /// [in] \param block The trigger channels data block to check.
1401 /// [out] \param reason If this is not NULL, then it will be filled with
1402 /// the reason code describing why the data block is not valid, if and
1403 /// only if a problem is found with the data.
1404 /// \returns true if there is no problem with the data and false otherwise.
1406 if (not HeaderOk(block, reason)) return false;
1411 bool AliHLTMUONUtils::IntegrityOk(
1412 const AliHLTMUONRecHitsBlockStruct& block,
1413 WhyNotValid* reason,
1414 AliHLTUInt32_t& reasonCount
1417 /// This method is used to check more extensively if the integrity of the
1418 /// dHLT raw internal data block is OK and returns true in that case.
1419 /// [in] \param block The reconstructed hits data block to check.
1420 /// [out] \param reason If this is not NULL, then it is assumed to point
1421 /// to an array of at least 'reasonCount' number of elements. It will
1422 /// be filled with the reason codes describing why the data block is
1424 /// [in/out] \param reasonCount This should initially specify the size of
1425 /// the array pointed to by 'reason'. It will be filled with the number
1426 /// of items actually filled into the reason array upon exit from this
1428 /// \returns true if there is no problem with the data and false otherwise.
1430 AliHLTUInt32_t maxCount = reasonCount;
1431 bool result = HeaderOk(block, reason, reasonCount);
1433 const AliHLTMUONRecHitStruct* hit =
1434 reinterpret_cast<const AliHLTMUONRecHitStruct*>(&block + 1);
1436 // Check if any hit structure has been duplicated.
1437 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1439 const AliHLTMUONRecHitStruct& h = hit[i];
1440 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1444 if (reason != NULL and reasonCount < maxCount)
1446 reason[reasonCount] = kFoundDuplicateHits;
1458 bool AliHLTMUONUtils::IntegrityOk(
1459 const AliHLTMUONClusterStruct& cluster,
1460 WhyNotValid* reason,
1461 AliHLTUInt32_t& reasonCount
1464 /// This method is used to check more extensively if the integrity of the
1465 /// cluster structure is OK and returns true in that case.
1466 /// [in] \param cluster The cluster structure to check.
1467 /// [out] \param reason If this is not NULL, then it is assumed to point
1468 /// to an array of at least 'reasonCount' number of elements. It will
1469 /// be filled with the reason codes describing why the structure is
1471 /// [in/out] \param reasonCount This should initially specify the size of
1472 /// the array pointed to by 'reason'. It will be filled with the number
1473 /// of items actually filled into the reason array upon exit from this
1475 /// \returns true if there is no problem with the structure and false otherwise.
1477 AliHLTUInt32_t maxCount = reasonCount;
1481 // Check that the cluster ID has a valid value.
1482 if (not (cluster.fId >= 0 or cluster.fId == -1))
1484 if (reason != NULL and reasonCount < maxCount)
1486 reason[reasonCount] = kInvalidIdValue;
1492 // Check that the cluster does not have a nil value for its hit.
1493 if (cluster.fHit == AliHLTMUONConstants::NilRecHitStruct())
1495 if (reason != NULL and reasonCount < maxCount)
1497 reason[reasonCount] = kHitIsNil;
1503 // Make sure the detector element is a valid value.
1504 if (not (cluster.fDetElemId >= 0 or cluster.fDetElemId == -1))
1506 if (reason != NULL and reasonCount < maxCount)
1508 reason[reasonCount] = kInvalidDetElementNumber;
1514 // The number of channels should be in a reasonable range.
1515 // between 1 and the maximum number of channels per DDL.
1516 // 1<<17 taken from the 11 bits MANU ID + 6 bits channel address.
1517 if (cluster.fNchannels < 1 or (1<<17) < cluster.fNchannels)
1519 if (reason != NULL and reasonCount < maxCount)
1521 reason[reasonCount] = kInvalidChannelCount;
1531 bool AliHLTMUONUtils::IntegrityOk(
1532 const AliHLTMUONClustersBlockStruct& block,
1533 WhyNotValid* reason,
1534 AliHLTUInt32_t* recordNum,
1535 AliHLTUInt32_t& reasonCount
1538 /// This method is used to check more extensively if the integrity of the
1539 /// dHLT internal clusters data block is OK and returns true in that case.
1540 /// [in] \param block The clusters data block to check.
1541 /// [out] \param reason If this is not NULL, then it is assumed to point
1542 /// to an array of at least 'reasonCount' number of elements. It will
1543 /// be filled with the reason codes describing why the data block is
1545 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1546 /// to an array of at least 'reasonCount' number of elements. It will
1547 /// be filled with the number of the cluster structure that had a problem.
1548 /// The value 'recordNum[i]' will only contain a valid value if
1549 /// the corresponding 'reason[i]' contains one of:
1550 /// - kInvalidIdValue
1552 /// - kInvalidDetElementNumber
1553 /// - kInvalidChannelCount
1554 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1555 /// was set and is valid or not.
1556 /// [in/out] \param reasonCount This should initially specify the size of
1557 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1558 /// with the number of items actually filled into the arrays upon exit
1559 /// from this method.
1560 /// \returns true if there is no problem with the data and false otherwise.
1562 AliHLTUInt32_t maxCount = reasonCount;
1563 bool result = HeaderOk(block, reason, reasonCount);
1565 const AliHLTMUONClusterStruct* cluster =
1566 reinterpret_cast<const AliHLTMUONClusterStruct*>(&block + 1);
1568 // Check if any ID is duplicated.
1569 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1571 AliHLTInt32_t id = cluster[i].fId;
1572 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1574 if (id == cluster[j].fId)
1576 if (reason != NULL and reasonCount < maxCount)
1578 reason[reasonCount] = kFoundDuplicateIDs;
1586 // Check if any hit structure has been duplicated.
1587 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1589 const AliHLTMUONRecHitStruct& h = cluster[i].fHit;
1590 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1592 if (h == cluster[j].fHit)
1594 if (reason != NULL and reasonCount < maxCount)
1596 reason[reasonCount] = kFoundDuplicateHits;
1604 // Check integrity of individual cluster structures.
1605 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1607 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1608 if (not IntegrityOk(cluster[i], reason+reasonCount, filledCount))
1610 // reasons filled in IntegrityOk, now we just need to adjust
1611 // reasonCount and fill the recordNum values.
1612 if (recordNum != NULL)
1614 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1615 recordNum[reasonCount + n] = i;
1617 reasonCount += filledCount;
1626 bool AliHLTMUONUtils::IntegrityOk(
1627 const AliHLTMUONChannelStruct& channel,
1628 WhyNotValid* reason,
1629 AliHLTUInt32_t& reasonCount
1632 /// This method is used to check more extensively if the integrity of the
1633 /// channel structure is OK and returns true in that case.
1634 /// [in] \param cluster The channel structure to check.
1635 /// [out] \param reason If this is not NULL, then it is assumed to point
1636 /// to an array of at least 'reasonCount' number of elements. It will
1637 /// be filled with the reason codes describing why the structure is
1639 /// [in/out] \param reasonCount This should initially specify the size of
1640 /// the array pointed to by 'reason'. It will be filled with the number
1641 /// of items actually filled into the reason array upon exit from this
1643 /// \returns true if there is no problem with the structure and false otherwise.
1645 AliHLTUInt32_t maxCount = reasonCount;
1649 // Check that the channel ID has a valid value.
1650 if (not (channel.fClusterId >= 0 or channel.fClusterId == -1))
1652 if (reason != NULL and reasonCount < maxCount)
1654 reason[reasonCount] = kInvalidIdValue;
1660 // Check that the bus patch ID has a valid value, which fits into 12 bits.
1661 if ((channel.fBusPatch & (~0xFFF)) != 0)
1663 if (reason != NULL and reasonCount < maxCount)
1665 reason[reasonCount] = kInvalidBusPatchId;
1671 // Check that the MANU ID has a valid value, which fits into 11 bits.
1672 if ((channel.fManu & (~0x7FF)) != 0)
1674 if (reason != NULL and reasonCount < maxCount)
1676 reason[reasonCount] = kInvalidManuId;
1682 // Check that the channel address has a valid value, which fits into 6 bits.
1683 if ((channel.fChannelAddress & (~0x3F)) != 0)
1685 if (reason != NULL and reasonCount < maxCount)
1687 reason[reasonCount] = kInvalidChannelAddress;
1693 // Check that the ADC signal has a valid value, which fits into 12 bits.
1694 if ((channel.fSignal & (~0xFFF)) != 0)
1696 if (reason != NULL and reasonCount < maxCount)
1698 reason[reasonCount] = kInvalidSignal;
1704 // Check that the raw data word corresponds to the unpacked values for
1705 // the ADC signal, MANU ID and channel address.
1706 UShort_t manuId; UChar_t channelId; UShort_t adc;
1707 AliMUONTrackerDDLDecoderEventHandler::UnpackADC(
1708 channel.fRawDataWord, manuId, channelId, adc
1710 if (manuId != channel.fManu or channelId != channel.fChannelAddress
1711 or adc != channel.fSignal
1714 if (reason != NULL and reasonCount < maxCount)
1716 reason[reasonCount] = kDataWordDifferent;
1726 bool AliHLTMUONUtils::IntegrityOk(
1727 const AliHLTMUONChannelsBlockStruct& block,
1728 WhyNotValid* reason,
1729 AliHLTUInt32_t* recordNum,
1730 AliHLTUInt32_t& reasonCount
1733 /// This method is used to check more extensively if the integrity of the
1734 /// dHLT internal channels data block is OK and returns true in that case.
1735 /// [in] \param block The channels data block to check.
1736 /// [out] \param reason If this is not NULL, then it is assumed to point
1737 /// to an array of at least 'reasonCount' number of elements. It will
1738 /// be filled with the reason codes describing why the data block is
1740 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1741 /// to an array of at least 'reasonCount' number of elements. It will
1742 /// be filled with the number of the channel structure that had a problem.
1743 /// The value 'recordNum[i]' will only contain a valid value if
1744 /// the corresponding 'reason[i]' contains one of:
1745 /// - kInvalidIdValue
1746 /// - kInvalidBusPatchId
1747 /// - kInvalidManuId
1748 /// - kInvalidChannelAddress
1749 /// - kInvalidSignal
1750 /// - kDataWordDifferent
1751 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1752 /// was set and is valid or not.
1753 /// [in/out] \param reasonCount This should initially specify the size of
1754 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1755 /// with the number of items actually filled into the arrays upon exit
1756 /// from this method.
1757 /// \returns true if there is no problem with the data and false otherwise.
1759 AliHLTUInt32_t maxCount = reasonCount;
1760 bool result = HeaderOk(block, reason, reasonCount);
1762 const AliHLTMUONChannelStruct* channel =
1763 reinterpret_cast<const AliHLTMUONChannelStruct*>(&block + 1);
1765 // Check if any cluster ID is duplicated.
1766 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1768 AliHLTInt32_t id = channel[i].fClusterId;
1769 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1771 if (id == channel[j].fClusterId)
1773 if (reason != NULL and reasonCount < maxCount)
1775 reason[reasonCount] = kFoundDuplicateIDs;
1783 // Check integrity of individual channel structures.
1784 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1786 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1787 if (not IntegrityOk(channel[i], reason+reasonCount, filledCount))
1789 // reasons filled in IntegrityOk, now we just need to adjust
1790 // reasonCount and fill the recordNum values.
1791 if (recordNum != NULL)
1793 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1794 recordNum[reasonCount + n] = i;
1796 reasonCount += filledCount;
1805 bool AliHLTMUONUtils::IntegrityOk(
1806 const AliHLTMUONMansoTrackStruct& track,
1807 WhyNotValid* reason,
1808 AliHLTUInt32_t& reasonCount
1811 /// This method is used to check more extensively if the integrity of the
1812 /// Manso track structure is OK and returns true in that case.
1813 /// [in] \param track The track structure to check.
1814 /// [out] \param reason If this is not NULL, then it is assumed to point
1815 /// to an array of at least 'reasonCount' number of elements. It will
1816 /// be filled with the reason codes describing why the structure is
1818 /// [in/out] \param reasonCount This should initially specify the size of
1819 /// the array pointed to by 'reason'. It will be filled with the number
1820 /// of items actually filled into the reason array upon exit from this
1822 /// \returns true if there is no problem with the structure and false otherwise.
1824 AliHLTUInt32_t maxCount = reasonCount;
1828 // Check that the Manso track ID has a valid value.
1829 if (not (track.fId >= 0 or track.fId == -1))
1831 if (reason != NULL and reasonCount < maxCount)
1833 reason[reasonCount] = kInvalidIdValue;
1839 // Check that the corresponding trigger record ID has a valid value.
1840 if (not (track.fTrigRec >= 0 or track.fTrigRec == -1))
1842 if (reason != NULL and reasonCount < maxCount)
1844 reason[reasonCount] = kInvalidTriggerIdValue;
1850 // Make sure that the reserved bits in the fFlags field are set
1852 if ((track.fFlags & 0x3FFFFFF0) != 0)
1854 if (reason != NULL and reasonCount < maxCount)
1856 reason[reasonCount] = kReservedBitsNotZero;
1862 // Make sure the sign is not invalid.
1863 if ((track.fFlags & 0xC0000000) == 0xC0000000)
1865 if (reason != NULL and reasonCount < maxCount)
1867 reason[reasonCount] = kParticleSignBitsNotValid;
1873 // Check that fHit[i] is nil if the corresponding bit in the
1874 // flags word is zero.
1875 const AliHLTMUONRecHitStruct& nilhit
1876 = AliHLTMUONConstants::NilRecHitStruct();
1877 if ( ((track.fFlags & 0x1) == 0 and track.fHit[0] != nilhit) or
1878 ((track.fFlags & 0x2) == 0 and track.fHit[1] != nilhit) or
1879 ((track.fFlags & 0x4) == 0 and track.fHit[2] != nilhit) or
1880 ((track.fFlags & 0x8) == 0 and track.fHit[3] != nilhit)
1883 if (reason != NULL and reasonCount < maxCount)
1885 reason[reasonCount] = kHitNotMarkedAsNil;
1891 // Check that the chi squared value is valid
1892 if (not (track.fChi2 >= 0 or track.fChi2 == -1))
1894 if (reason != NULL and reasonCount < maxCount)
1896 reason[reasonCount] = kChiSquareInvalid;
1902 // Check that if chi squared is -1 then the momentum vector is zero.
1903 if (track.fChi2 == -1 and
1904 not (track.fPx == 0 and track.fPy == 0 and track.fPz == 0)
1907 if (reason != NULL and reasonCount < maxCount)
1909 reason[reasonCount] = kMomentumVectorNotZero;
1919 bool AliHLTMUONUtils::IntegrityOk(
1920 const AliHLTMUONMansoTracksBlockStruct& block,
1921 WhyNotValid* reason,
1922 AliHLTUInt32_t* recordNum,
1923 AliHLTUInt32_t& reasonCount
1926 /// This method is used to check more extensively if the integrity of the
1927 /// dHLT internal Manso track data block is OK and returns true in that case.
1928 /// [in] \param block The Manso track data block to check.
1929 /// [out] \param reason If this is not NULL, then it is assumed to point
1930 /// to an array of at least 'reasonCount' number of elements. It will
1931 /// be filled with the reason codes describing why the data block is
1933 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1934 /// to an array of at least 'reasonCount' number of elements. It will
1935 /// be filled with the number of the Manso track that had a problem.
1936 /// The value 'recordNum[i]' will only contain a valid value if
1937 /// the corresponding 'reason[i]' contains one of:
1938 /// - kInvalidIdValue
1939 /// - kInvalidTriggerIdValue
1940 /// - kReservedBitsNotZero
1941 /// - kParticleSignBitsNotValid
1942 /// - kHitNotMarkedAsNil
1943 /// - kChiSquareInvalid
1944 /// - kMomentumVectorNotZero
1945 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1946 /// was set and is valid or not.
1947 /// [in/out] \param reasonCount This should initially specify the size of
1948 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1949 /// with the number of items actually filled into the arrays upon exit
1950 /// from this method.
1951 /// \returns true if there is no problem with the data and false otherwise.
1953 AliHLTUInt32_t maxCount = reasonCount;
1954 bool result = HeaderOk(block, reason, reasonCount);
1956 const AliHLTMUONMansoTrackStruct* track =
1957 reinterpret_cast<const AliHLTMUONMansoTrackStruct*>(&block + 1);
1959 // Check if any track ID is duplicated.
1960 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1962 AliHLTInt32_t id = track[i].fId;
1963 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1965 if (id == track[j].fId)
1967 if (reason != NULL and reasonCount < maxCount)
1969 reason[reasonCount] = kFoundDuplicateIDs;
1977 // Check that all the tracks have integrity.
1978 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1980 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1981 if (not IntegrityOk(track[i], reason+reasonCount, filledCount))
1983 // reasons filled in IntegrityOk, now we just need to adjust
1984 // reasonCount and fill the recordNum values.
1985 if (recordNum != NULL)
1987 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1988 recordNum[reasonCount + n] = i;
1990 reasonCount += filledCount;
1999 bool AliHLTMUONUtils::IntegrityOk(
2000 const AliHLTMUONMansoCandidateStruct& candidate,
2001 WhyNotValid* reason,
2002 AliHLTUInt32_t& reasonCount
2005 /// This method is used to check more extensively if the integrity of the
2006 /// Manso track candidate structure is OK and returns true in that case.
2007 /// [in] \param track The track candidate structure to check.
2008 /// [out] \param reason If this is not NULL, then it is assumed to point
2009 /// to an array of at least 'reasonCount' number of elements. It will
2010 /// be filled with the reason codes describing why the structure is
2012 /// [in/out] \param reasonCount This should initially specify the size of
2013 /// the array pointed to by 'reason'. It will be filled with the number
2014 /// of items actually filled into the reason array upon exit from this
2016 /// \returns true if there is no problem with the structure and false otherwise.
2018 // First check the integrity of the candidate track structure.
2019 AliHLTUInt32_t maxCount = reasonCount;
2020 bool result = IntegrityOk(candidate.fTrack, reason, reasonCount);
2022 // Now check that the ROIs are reasonable.
2023 // The radius must be positive or -1 indicating computation error and
2024 // the corresponding hit in the track must be within the ROI.
2025 for (AliHLTUInt32_t i = 0; i < 4; i++)
2027 if (not (candidate.fRoI[i].fRadius >= 0 or candidate.fRoI[i].fRadius == -1))
2029 if (reason != NULL and reasonCount < maxCount)
2031 reason[reasonCount] = kRoiRadiusInvalid;
2037 // Check if the corresponding hit was even found in the track.
2038 if ( (candidate.fTrack.fFlags & (0x1 << i)) == 0 ) continue;
2040 double dx = candidate.fRoI[i].fX - candidate.fTrack.fHit[i].fX;
2041 double dy = candidate.fRoI[i].fY - candidate.fTrack.fHit[i].fY;
2042 double dz = candidate.fRoI[i].fZ - candidate.fTrack.fHit[i].fZ;
2043 double r = sqrt(dx*dx + dy*dy);
2044 // Check if the projected distance between ROI centre and hit is
2045 // bigger than the ROI radius. Also the difference between z
2046 // coordinates should not exceed 20 cm.
2047 if (r > candidate.fRoI[i].fRadius or fabs(dz) > 20.)
2049 if (reason != NULL and reasonCount < maxCount)
2051 reason[reasonCount] = kHitNotWithinRoi;
2062 bool AliHLTMUONUtils::IntegrityOk(
2063 const AliHLTMUONMansoCandidatesBlockStruct& block,
2064 WhyNotValid* reason,
2065 AliHLTUInt32_t* recordNum,
2066 AliHLTUInt32_t& reasonCount
2069 /// This method is used to check more extensively if the integrity of the
2070 /// dHLT internal Manso candidates data block is OK and returns true in
2072 /// [in] \param block The Manso track candidate data block to check.
2073 /// [out] \param reason If this is not NULL, then it is assumed to point
2074 /// to an array of at least 'reasonCount' number of elements. It will
2075 /// be filled with the reason codes describing why the data block is
2077 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2078 /// to an array of at least 'reasonCount' number of elements. It will
2079 /// be filled with the number of the track candidate that had a problem.
2080 /// The value 'recordNum[i]' will only contain a valid value if
2081 /// the corresponding 'reason[i]' contains one of:
2082 /// - kInvalidIdValue
2083 /// - kInvalidTriggerIdValue
2084 /// - kReservedBitsNotZero
2085 /// - kParticleSignBitsNotValid
2086 /// - kHitNotMarkedAsNil
2087 /// - kChiSquareInvalid
2088 /// - kRoiRadiusInvalid
2089 /// - kHitNotWithinRoi
2090 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2091 /// was set and is valid or not.
2092 /// [in/out] \param reasonCount This should initially specify the size of
2093 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2094 /// with the number of items actually filled into the arrays upon exit
2095 /// from this method.
2096 /// \returns true if there is no problem with the data and false otherwise.
2098 AliHLTUInt32_t maxCount = reasonCount;
2099 bool result = HeaderOk(block, reason, reasonCount);
2101 const AliHLTMUONMansoCandidateStruct* candidate =
2102 reinterpret_cast<const AliHLTMUONMansoCandidateStruct*>(&block + 1);
2104 // Check if any candidate track ID is duplicated.
2105 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2107 AliHLTInt32_t id = candidate[i].fTrack.fId;
2108 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2110 if (id == candidate[j].fTrack.fId)
2112 if (reason != NULL and reasonCount < maxCount)
2114 reason[reasonCount] = kFoundDuplicateIDs;
2122 // Check that all the track candidates have integrity.
2123 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2125 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2126 if (not IntegrityOk(candidate[i], reason+reasonCount, filledCount))
2128 // reasons filled in IntegrityOk, now we just need to adjust
2129 // reasonCount and fill the recordNum values.
2130 if (recordNum != NULL)
2132 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2133 recordNum[reasonCount + n] = i;
2135 reasonCount += filledCount;
2144 bool AliHLTMUONUtils::IntegrityOk(
2145 const AliHLTMUONTrackDecisionStruct& decision,
2146 WhyNotValid* reason,
2147 AliHLTUInt32_t& reasonCount
2150 /// This method is used to check more extensively if the integrity of the
2151 /// single track trigger decision structure is OK and returns true in that case.
2152 /// [in] \param decision The trigger decision structure to check.
2153 /// [out] \param reason If this is not NULL, then it is assumed to point
2154 /// to an array of at least 'reasonCount' number of elements. It will
2155 /// be filled with the reason codes describing why the structure is not
2157 /// [in/out] \param reasonCount This should initially specify the size of
2158 /// the array pointed to by 'reason'. It will be filled with the number
2159 /// of items actually filled into the reason array upon exit from this
2161 /// \returns true if there is no problem with the structure and false otherwise.
2163 AliHLTUInt32_t maxCount = reasonCount;
2167 // The track ID value must be positive or -1.
2168 if (not (decision.fTrackId >= 0 or decision.fTrackId == -1))
2170 if (reason != NULL and reasonCount < maxCount)
2172 reason[reasonCount] = kInvalidTrackIdValue;
2178 // Make sure that the reserved bits in the fTriggerBits field are set
2180 if ((decision.fTriggerBits & 0xFFFFFFFC) != 0)
2182 if (reason != NULL and reasonCount < maxCount)
2184 reason[reasonCount] = kReservedBitsNotZero;
2190 // The pT should be -1 or a positive number.
2191 if (decision.fPt != -1. and decision.fPt < 0.)
2193 if (reason != NULL and reasonCount < maxCount)
2195 reason[reasonCount] = kPtValueNotValid;
2205 bool AliHLTMUONUtils::IntegrityOk(
2206 const AliHLTMUONSinglesDecisionBlockStruct& block,
2207 WhyNotValid* reason,
2208 AliHLTUInt32_t* recordNum,
2209 AliHLTUInt32_t& reasonCount
2212 /// This method is used to check more extensively if the integrity of the
2213 /// dHLT internal single track trigger decision data block is OK and returns
2214 /// true in that case.
2215 /// [in] \param block The single track trigger decision data block to check.
2216 /// [out] \param reason If this is not NULL, then it is assumed to point
2217 /// to an array of at least 'reasonCount' number of elements. It will
2218 /// be filled with the reason codes describing why the data block is
2220 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2221 /// to an array of at least 'reasonCount' number of elements. It will
2222 /// be filled with the number of the trigger decision that had a problem.
2223 /// The value 'recordNum[i]' will only contain a valid value if
2224 /// the corresponding 'reason[i]' contains one of:
2225 /// - kInvalidTrackIdValue
2226 /// - kReservedBitsNotZero
2227 /// - kPtValueNotValid
2228 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2229 /// was set and is valid or not.
2230 /// [in/out] \param reasonCount This should initially specify the size of
2231 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2232 /// with the number of items actually filled into the arrays upon exit
2233 /// from this method.
2234 /// \returns true if there is no problem with the data and false otherwise.
2236 AliHLTUInt32_t maxCount = reasonCount;
2237 bool result = HeaderOk(block, reason, reasonCount);
2239 const AliHLTMUONTrackDecisionStruct* decision =
2240 reinterpret_cast<const AliHLTMUONTrackDecisionStruct*>(&block + 1);
2242 // Check that there are no duplicate trigger entries.
2243 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2245 AliHLTInt32_t id = decision[i].fTrackId;
2246 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2248 if (id == decision[j].fTrackId)
2250 if (reason != NULL and reasonCount < maxCount)
2252 reason[reasonCount] = kFoundDuplicateTriggers;
2260 // Check that the trigger bits for each track have integrity.
2261 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2263 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2264 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2266 // Reasons filled in IntegrityOk, now we just need to adjust
2267 // reasonCount and fill the recordNum values.
2268 if (recordNum != NULL)
2270 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2271 recordNum[reasonCount + n] = i;
2273 reasonCount += filledCount;
2282 bool AliHLTMUONUtils::IntegrityOk(
2283 const AliHLTMUONPairDecisionStruct& decision,
2284 WhyNotValid* reason,
2285 AliHLTUInt32_t& reasonCount
2288 /// This method is used to check more extensively if the integrity of the
2289 /// track pair trigger decision structure is OK and returns true in that case.
2290 /// [in] \param decision The trigger decision structure to check.
2291 /// [out] \param reason If this is not NULL, then it is assumed to point
2292 /// to an array of at least 'reasonCount' number of elements. It will
2293 /// be filled with the reason codes describing why the structure is not
2295 /// [in/out] \param reasonCount This should initially specify the size of
2296 /// the array pointed to by 'reason'. It will be filled with the number
2297 /// of items actually filled into the reason array upon exit from this
2299 /// \returns true if there is no problem with the structure and false otherwise.
2301 AliHLTUInt32_t maxCount = reasonCount;
2305 //kInvalidTrackIdValue
2307 // The track IDs must have a positive value or -1.
2308 if (not (decision.fTrackAId >= 0 or decision.fTrackAId == -1) or
2309 not (decision.fTrackBId >= 0 or decision.fTrackBId == -1)
2312 if (reason != NULL and reasonCount < maxCount)
2314 reason[reasonCount] = kInvalidTrackIdValue;
2320 // Make sure that the reserved bits in the fTriggerBits field are set
2322 if ((decision.fTriggerBits & 0xFFFFFF80) != 0)
2324 if (reason != NULL and reasonCount < maxCount)
2326 reason[reasonCount] = kReservedBitsNotZero;
2332 // Check that the track IDs are not the same.
2333 if (decision.fTrackAId == decision.fTrackBId)
2335 if (reason != NULL and reasonCount < maxCount)
2337 reason[reasonCount] = kPairTrackIdsAreIdentical;
2343 // The invariant mass should be -1 or a positive number.
2344 if (decision.fInvMass != -1. and decision.fInvMass < 0.)
2346 if (reason != NULL and reasonCount < maxCount)
2348 reason[reasonCount] = kMassValueNotValid;
2354 // Neither the high pt (hipt) or low pt (lopt) count bits can be > 2.
2355 AliHLTUInt8_t lowPtCount = (decision.fTriggerBits & 0x00000003);
2356 AliHLTUInt8_t highPtCount = (decision.fTriggerBits & 0x0000000C) >> 2;
2359 if (reason != NULL and reasonCount < maxCount)
2361 reason[reasonCount] = kLowPtCountInvalid;
2366 if (highPtCount > 2)
2368 if (reason != NULL and reasonCount < maxCount)
2370 reason[reasonCount] = kHighPtCountInvalid;
2380 bool AliHLTMUONUtils::IntegrityOk(
2381 const AliHLTMUONPairsDecisionBlockStruct& block,
2382 WhyNotValid* reason,
2383 AliHLTUInt32_t* recordNum,
2384 AliHLTUInt32_t& reasonCount
2387 /// This method is used to check more extensively if the integrity of the
2388 /// dHLT internal track pair trigger decision data block is OK and returns
2389 /// true in that case.
2390 /// [in] \param block The track pair trigger decision data block to check.
2391 /// [out] \param reason If this is not NULL, then it is assumed to point
2392 /// to an array of at least 'reasonCount' number of elements. It will
2393 /// be filled with the reason codes describing why the data block is
2395 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2396 /// to an array of at least 'reasonCount' number of elements. It will
2397 /// be filled with the number of the trigger decision that had a problem.
2398 /// The value 'recordNum[i]' will only contain a valid value if
2399 /// the corresponding 'reason[i]' contains one of:
2400 /// - kInvalidTrackIdValue
2401 /// - kReservedBitsNotZero
2402 /// - kPairTrackIdsAreIdentical
2403 /// - kMassValueNotValid
2404 /// - kLowPtCountInvalid
2405 /// - kHighPtCountInvalid
2406 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2407 /// was set and is valid or not.
2408 /// [in/out] \param reasonCount This should initially specify the size of
2409 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2410 /// with the number of items actually filled into the arrays upon exit
2411 /// from this method.
2412 /// \returns true if there is no problem with the data and false otherwise.
2414 AliHLTUInt32_t maxCount = reasonCount;
2415 bool result = HeaderOk(block, reason, reasonCount);
2417 const AliHLTMUONPairDecisionStruct* decision =
2418 reinterpret_cast<const AliHLTMUONPairDecisionStruct*>(&block + 1);
2420 // Check that there are no duplicate trigger entries.
2421 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2423 AliHLTInt32_t ta = decision[i].fTrackAId;
2424 AliHLTInt32_t tb = decision[i].fTrackBId;
2425 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2427 if (ta == decision[j].fTrackAId and tb == decision[j].fTrackBId)
2429 if (reason != NULL and reasonCount < maxCount)
2431 reason[reasonCount] = kFoundDuplicateTriggers;
2439 // Check that the trigger bits for each track pair have integrity.
2440 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2442 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2443 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2445 // Reasons filled in IntegrityOk, now we just need to adjust
2446 // reasonCount and fill the recordNum values.
2447 if (recordNum != NULL)
2449 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2450 recordNum[reasonCount + n] = i;
2452 reasonCount += filledCount;