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 <= 2, lowPtCount <= 2 and
147 /// unlike == true if highMass or lowMass is true.
150 assert( lowPtCount <= 2 );
151 assert( highPtCount <= 2 );
152 // highMass and lowMass must be false if unlike is false:
153 assert( not unlike ? (highMass == false and lowMass == false) : true );
155 return (highMass ? 0x40 : 0) | (lowMass ? 0x20 : 0) | (unlike ? 0x10 : 0)
156 | ((highPtCount & 0x3) << 2) | (lowPtCount & 0x3);
160 void AliHLTMUONUtils::UnpackPairDecisionBits(
161 AliHLTUInt32_t bits, bool& highMass, bool& lowMass, bool& unlike,
162 AliHLTUInt8_t& highPtCount, AliHLTUInt8_t& lowPtCount
166 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
167 /// its component fields.
168 /// @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
170 /// @param highMass Sets this to the value of the high invariant mass cut bit.
171 /// @param lowMass Sets this to the value of the low invariant mass cut bit.
172 /// @param unlike Sets this if the pair is unlike sign.
173 /// @param highPtCount Sets this to the high pt count bits.
174 /// @param lowPtCount Sets this to the low pt count bits.
177 highMass = (bits & 0x40) == 0x40;
178 lowMass = (bits & 0x20) == 0x20;
179 unlike = (bits & 0x10) == 0x10;
180 highPtCount = (bits & 0xC) >> 2;
181 lowPtCount = bits & 0x3;
185 AliHLTUInt32_t AliHLTMUONUtils::PackSpecBits(
190 /// This packs the given parameters into the 32bit Pub/Sub specification
191 /// word in the data block descriptor.
193 /// @param ddl The list of DDLs forming part of the readout. ddl[0]
194 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
195 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
196 /// trigger DDLs 2816 and 2817 respectively.
197 /// @return Returns the 32 bit packed specification word.
200 // Pack the bits into the following format:
201 // bit: [ 31 - 22 ][ 21 ][ 20 ][ 19 - 0 ]
202 // field: [ reserved, set to zero ][ TRGDDL2817 ][ TRGDDL2816 ][ TRKDDLS ]
203 // Meaning of field acronyms:
204 // TRGDDL2816 - Trigger DDL number 2816.
205 // TRGDDL2817 - Trigger DDL number 2817.
206 // TRKDDLS - Tracking DDL flags where bit 0 will be for DDL number 2560,
207 // bit 1 for DDL no. 2561 etc. up to bit 19 which is for DDL 2579.
208 AliHLTUInt32_t bits = 0;
209 for (int i = 0; i < 22; i++)
210 bits |= (ddl[i] ? 0x1 : 0x0) << i;
215 void AliHLTMUONUtils::UnpackSpecBits(
216 AliHLTUInt32_t bits, bool ddl[22]
220 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
221 /// its component fields.
222 /// @param bits The Pub/Sub specification word from a data block descriptor.
223 /// @param ddl The output list of DDLs forming part of the readout. ddl[0]
224 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
225 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
226 /// trigger DDLs 2816 and 2817 respectively.
229 // Perform the inverse operation of PackSpecBits.
230 for (int i = 0; i < 22; i++)
231 ddl[i] = ((bits >> i) & 0x1) == 1;
235 AliHLTInt32_t AliHLTMUONUtils::DDLNumberToEquipId(AliHLTInt32_t ddlNo)
238 /// This method converts the DDL number for the muon spectrometer in the
239 /// range [0..21] to the equipment ID number.
240 /// @param ddlNo The DDL number in the range [0..21].
241 /// @return Returns the equipment ID number or -1 if ddlNo was invalid.
244 if (0 <= ddlNo and ddlNo <= 19)
248 else if (20 <= ddlNo and ddlNo <= 21)
250 return 2816 + (ddlNo - 20);
259 AliHLTInt32_t AliHLTMUONUtils::EquipIdToDDLNumber(AliHLTInt32_t id)
262 /// This method converts the equipment ID number for a muon spectrometer
263 /// DDL to the DDL number in the range [0..21].
264 /// @param id The equipment ID of the DDL.
265 /// @return Returns the DDL number in the range [0..21] or -1 if the
266 /// equipment ID was invalid.
269 if (2560 <= id and id <= 2560+19)
273 else if (2816 <= id and id <= 2817)
275 return id - 2816 + 20;
284 AliHLTInt32_t AliHLTMUONUtils::SpecToEquipId(AliHLTUInt32_t spec)
287 /// This method converts a 32 bit data block specification for a MUON-HLT
288 /// data block into its corresponding DDL equipment ID number.
289 /// It is assumed that the specification is for a data block comming from
290 /// a single DDL source. If more than one DDL contributed to the data block
291 /// then -1 is returned.
292 /// @param spec The 32 bit specification for a data block.
293 /// @return Returns the equipment ID corresponding to the specification
294 /// or -1 if the specification was invalid.
297 for (AliHLTInt32_t ddlNo = 0; ddlNo < 20; ddlNo++)
299 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
302 for (AliHLTInt32_t ddlNo = 20; ddlNo < 22; ddlNo++)
304 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
305 return ddlNo - 20 + 2816;
311 AliHLTUInt32_t AliHLTMUONUtils::EquipIdToSpec(AliHLTInt32_t id)
314 /// This method converts a equipment ID number for a DDL into its corresponding
315 /// 32 bit data block specification for the MUON-HLT.
316 /// @param id The equipment ID number of the DDL.
317 /// @return Returns the 32 bit data block specification or 0x0 if the
318 /// equipment ID was invalid.
321 if (2560 <= id and id <= 2560+19)
323 return 0x1 << (id - 2560);
325 else if (2816 <= id and id <= 2817)
327 return 0x1 << (id - 2816 + 20);
336 AliHLTInt32_t AliHLTMUONUtils::SpecToDDLNumber(AliHLTUInt32_t spec)
339 /// This method converts a 32 bit data block specification for a MUON-HLT
340 /// data block into its corresponding DDL number in the range [0..21].
341 /// It is assumed that the specification is for a data block comming from
342 /// a single DDL source. If more than one DDL contributed to the data block
343 /// then -1 is returned.
344 /// @param spec The 32 bit specification for a data block.
345 /// @return Returns the corresponding DDL number for the specification
346 /// or -1 if the specification was invalid.
349 for (AliHLTInt32_t ddlNo = 0; ddlNo < 22; ddlNo++)
351 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
358 AliHLTUInt32_t AliHLTMUONUtils::DDLNumberToSpec(AliHLTInt32_t ddlNo)
361 /// This method converts a DDL number in the range [0..21] into its
362 /// corresponding 32 bit data block specification for the MUON-HLT.
363 /// @param ddlNo The equipment ID number of the DDL.
364 /// @return Returns the 32 bit data block specification or 0x0 if the
365 /// DDL number was invalid (out of range).
368 if (0 <= ddlNo and ddlNo <= 21)
379 AliHLTMUONDataBlockType AliHLTMUONUtils::ParseCommandLineTypeString(const char* type)
381 /// Parses the string containing the type name of a dHLT data block and
382 /// returns the corresponding AliHLTMUONDataBlockType value.
383 /// \param type The string containing the type name.
384 /// \returns The data block type or kUnknownDataBlock if the type name
387 if (strcmp(type, "trigrecs") == 0)
389 return kTriggerRecordsDataBlock;
391 else if (strcmp(type, "trigrecsdebug") == 0)
393 return kTrigRecsDebugDataBlock;
395 else if (strcmp(type, "trigchannels") == 0)
397 return kTriggerChannelsDataBlock;
399 else if (strcmp(type, "rechits") == 0)
401 return kRecHitsDataBlock;
403 else if (strcmp(type,"channels") == 0)
405 return kChannelsDataBlock;
407 else if (strcmp(type,"clusters") == 0)
409 return kClustersDataBlock;
411 else if (strcmp(type, "mansotracks") == 0)
413 return kMansoTracksDataBlock;
415 else if (strcmp(type, "mansocandidates") == 0)
417 return kMansoCandidatesDataBlock;
419 else if (strcmp(type, "singlesdecision") == 0)
421 return kSinglesDecisionDataBlock;
423 else if (strcmp(type, "pairsdecision") == 0)
425 return kPairsDecisionDataBlock;
428 return kUnknownDataBlock;
432 const char* AliHLTMUONUtils::DataBlockTypeToString(AliHLTMUONDataBlockType type)
434 /// Converts a type ID to a type string compatible with
437 static char str[kAliHLTComponentDataTypefIDsize+1];
438 AliHLTComponentDataType t;
441 case kTriggerRecordsDataBlock:
442 t = AliHLTMUONConstants::TriggerRecordsBlockDataType();
444 case kTrigRecsDebugDataBlock:
445 t = AliHLTMUONConstants::TrigRecsDebugBlockDataType();
447 case kTriggerChannelsDataBlock:
448 t = AliHLTMUONConstants::TriggerChannelBlockDataType();
450 case kRecHitsDataBlock:
451 t = AliHLTMUONConstants::RecHitsBlockDataType();
453 case kClustersDataBlock:
454 t = AliHLTMUONConstants::ClusterBlockDataType();
456 case kChannelsDataBlock:
457 t = AliHLTMUONConstants::ChannelBlockDataType();
459 case kMansoTracksDataBlock:
460 t = AliHLTMUONConstants::MansoTracksBlockDataType();
462 case kMansoCandidatesDataBlock:
463 t = AliHLTMUONConstants::MansoCandidatesBlockDataType();
465 case kSinglesDecisionDataBlock:
466 t = AliHLTMUONConstants::SinglesDecisionBlockDataType();
468 case kPairsDecisionDataBlock:
469 t = AliHLTMUONConstants::PairsDecisionBlockDataType();
474 memcpy(&str, &t.fID, kAliHLTComponentDataTypefIDsize);
475 // Must insert the NULL character to make this an ANSI C string.
476 str[kAliHLTComponentDataTypefIDsize] = '\0';
481 const char* AliHLTMUONUtils::FailureReasonToString(WhyNotValid reason)
483 /// This method converts the WhyNotValid enumeration to a string representation.
487 case kNoReason: return "kNoReason";
488 case kHeaderContainsWrongType: return "kHeaderContainsWrongType";
489 case kHeaderContainsWrongRecordWidth: return "kHeaderContainsWrongRecordWidth";
490 case kInvalidIdValue: return "kInvalidIdValue";
491 case kInvalidTriggerIdValue: return "kInvalidTriggerIdValue";
492 case kInvalidTrackIdValue: return "kInvalidTrackIdValue";
493 case kReservedBitsNotZero: return "kReservedBitsNotZero";
494 case kParticleSignBitsNotValid: return "kParticleSignBitsNotValid";
495 case kHitNotMarkedAsNil: return "kHitNotMarkedAsNil";
496 case kInvalidDetElementNumber: return "kInvalidDetElementNumber";
497 case kHitIsNil: return "kHitIsNil";
498 case kInvalidChannelCount: return "kInvalidChannelCount";
499 case kInvalidBusPatchId: return "kInvalidBusPatchId";
500 case kInvalidManuId: return "kInvalidManuId";
501 case kInvalidChannelAddress: return "kInvalidChannelAddress";
502 case kInvalidSignal: return "kInvalidSignal";
503 case kDataWordDifferent: return "kDataWordDifferent";
504 case kChiSquareInvalid: return "kChiSquareInvalid";
505 case kMomentumVectorNotZero: return "kMomentumVectorNotZero";
506 case kRoiRadiusInvalid: return "kRoiRadiusInvalid";
507 case kHitNotWithinRoi: return "kHitNotWithinRoi";
508 case kPtValueNotValid: return "kPtValueNotValid";
509 case kPairTrackIdsAreIdentical: return "kPairTrackIdsAreIdentical";
510 case kMassValueNotValid: return "kMassValueNotValid";
511 case kLowPtCountInvalid: return "kLowPtCountInvalid";
512 case kHighPtCountInvalid: return "kHighPtCountInvalid";
513 case kFoundDuplicateIDs: return "kFoundDuplicateIDs";
514 case kFoundDuplicateHits: return "kFoundDuplicateHits";
515 case kFoundDuplicateTriggers: return "kFoundDuplicateTriggers";
516 default: return "INVALID";
521 const char* AliHLTMUONUtils::FailureReasonToMessage(WhyNotValid reason)
523 /// This method returns a string containing a user readable message explaining
524 /// the reason for failure described by the WhyNotValid enumeration.
529 return "There was no problem with the data block.";
530 case kHeaderContainsWrongType:
531 return "The common data header contains an incorrect type"
533 case kHeaderContainsWrongRecordWidth:
534 return "The common data header contains an incorrect data"
536 case kInvalidIdValue:
537 return "The structure identifier does not have a valid value.";
538 case kInvalidTriggerIdValue:
539 return "The trigger structure identifier does not have a valid"
541 case kInvalidTrackIdValue:
542 return "The track structure identifier does not have a valid"
544 case kReservedBitsNotZero:
545 return "Reserved bits have not been set to zero.";
546 case kParticleSignBitsNotValid:
547 return "The particle sign bits are not a valid value.";
548 case kHitNotMarkedAsNil:
549 return "A hit was marked as not found, but the corresponding hit"
550 " structure was not set to nil.";
551 case kInvalidDetElementNumber:
552 return "An invalid detector element ID was found.";
554 return "The hit cannot be set to a nil value.";
555 case kInvalidChannelCount:
556 return "The number of channels indicated is zero or outside"
558 case kInvalidBusPatchId:
559 return "The bus patch identifier is outside the valid range.";
561 return "The MANU identifier is outside the valid range.";
562 case kInvalidChannelAddress:
563 return "The MANU channel address is outside the valid range.";
565 return "The ADC signal value is outside the valid range.";
566 case kDataWordDifferent:
567 return "The raw data word is different from the unpacked values.";
568 case kChiSquareInvalid:
569 return "The chi squared value must be a positive value or -1"
570 " indicating a fitting error.";
571 case kMomentumVectorNotZero:
572 return "The chi sqaured value is set to -1 indicating momentum"
573 " was not fitted, but the momentum vector was not zero.";
574 case kRoiRadiusInvalid:
575 return "The region of interest radius is invalid.";
576 case kHitNotWithinRoi:
577 return "A tracks hit is not within the corresponding region"
579 case kPtValueNotValid:
580 return "The pT value is not positive, nor -1 indicating an"
582 case kPairTrackIdsAreIdentical:
583 return "The track identifiers of the track pair are identical.";
584 case kMassValueNotValid:
585 return "The invariant mass value is not positive, nor -1"
586 " indicating an invalid value.";
587 case kLowPtCountInvalid:
588 return "The low pT trigger count is greater than 2,"
589 " which is invalid.";
590 case kHighPtCountInvalid:
591 return "The high pT trigger count is greater than 2,"
592 " which is invalid.";
593 case kFoundDuplicateIDs:
594 return "Found duplicate data record identifiers, but they"
595 " should all be unique.";
596 case kFoundDuplicateHits:
597 return "Found duplicate hit structures, but they should all"
599 case kFoundDuplicateTriggers:
600 return "Found duplicate trigger decisions.";
602 return "UNKNOWN REASON CODE";
607 bool AliHLTMUONUtils::RecordNumberWasSet(WhyNotValid reason)
609 /// Returns true if the \em recordNum in the corresponding IntegrityOk method
610 /// would have been set, if it returned false and a reason was set.
611 /// This helper method makes it easy to test if the \em recordNum parameter
612 /// is filled with a valid value or not.
613 /// \param reason The reason code as returned by the IntegrityOk method.
614 /// \returns true if the \em recordNum parameter was set for the given
619 case kInvalidIdValue:
620 case kInvalidTriggerIdValue:
621 case kInvalidTrackIdValue:
622 case kReservedBitsNotZero:
623 case kParticleSignBitsNotValid:
624 case kHitNotMarkedAsNil:
625 case kInvalidDetElementNumber:
627 case kInvalidChannelCount:
628 case kInvalidBusPatchId:
630 case kInvalidChannelAddress:
632 case kDataWordDifferent:
633 case kChiSquareInvalid:
634 case kPtValueNotValid:
635 case kPairTrackIdsAreIdentical:
636 case kMassValueNotValid:
637 case kLowPtCountInvalid:
638 case kHighPtCountInvalid:
640 default: return false;
645 bool AliHLTMUONUtils::HeaderOk(
646 const AliHLTMUONTriggerRecordsBlockStruct& block,
647 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
650 /// Method used to check if the header information corresponds to the
651 /// supposed type of the raw dHLT data block.
652 /// [in] \param block The data block to check.
653 /// [out] \param reason If this is not NULL, then it is assumed to point
654 /// to an array of at least 'reasonCount' number of elements. It will
655 /// be filled with the reason codes describing why the header is not
657 /// [in/out] \param reasonCount This should initially specify the size of
658 /// the array pointed to by 'reason'. It will be filled with the number
659 /// of items actually filled into the reason array upon exit from this
661 /// \returns true if there is no problem with the header and false otherwise.
663 AliHLTUInt32_t maxCount = reasonCount;
667 // The block must have the correct type.
668 if (block.fHeader.fType != kTriggerRecordsDataBlock)
670 if (reason != NULL and reasonCount < maxCount)
672 reason[reasonCount] = kHeaderContainsWrongType;
678 // The block's record width must be the correct size.
679 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerRecordStruct))
681 if (reason != NULL and reasonCount < maxCount)
683 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
693 bool AliHLTMUONUtils::HeaderOk(
694 const AliHLTMUONTrigRecsDebugBlockStruct& block,
695 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
698 /// Method used to check if the header information corresponds to the
699 /// supposed type of the raw dHLT data block.
700 /// [in] \param block The data block to check.
701 /// [out] \param reason If this is not NULL, then it is assumed to point
702 /// to an array of at least 'reasonCount' number of elements. It will
703 /// be filled with the reason codes describing why the header is not
705 /// [in/out] \param reasonCount This should initially specify the size of
706 /// the array pointed to by 'reason'. It will be filled with the number
707 /// of items actually filled into the reason array upon exit from this
709 /// \returns true if there is no problem with the header and false otherwise.
711 AliHLTUInt32_t maxCount = reasonCount;
715 // The block must have the correct type.
716 if (block.fHeader.fType != kTrigRecsDebugDataBlock)
718 if (reason != NULL and reasonCount < maxCount)
720 reason[reasonCount] = kHeaderContainsWrongType;
726 // The block's record width must be the correct size.
727 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrigRecInfoStruct))
729 if (reason != NULL and reasonCount < maxCount)
731 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
741 bool AliHLTMUONUtils::HeaderOk(
742 const AliHLTMUONTriggerChannelsBlockStruct& block,
746 /// Method used to check if the header information corresponds to the
747 /// supposed type of the raw dHLT data block.
748 /// [in] \param block The data block to check.
749 /// [out] \param reason If this is not NULL, then it will be filled with
750 /// the reason code describing why the header is not valid, if and
751 /// only if a problem is found with the data.
752 /// \returns true if there is no problem with the header and false otherwise.
754 // The block must have the correct type.
755 if (block.fHeader.fType != kTriggerChannelsDataBlock)
757 if (reason != NULL) *reason = kHeaderContainsWrongType;
761 // The block's record width must be the correct size.
762 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerChannelStruct))
764 if (reason != NULL) *reason = kHeaderContainsWrongRecordWidth;
772 bool AliHLTMUONUtils::HeaderOk(
773 const AliHLTMUONRecHitsBlockStruct& block,
774 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
777 /// Method used to check if the header information corresponds to the
778 /// supposed type of the raw dHLT data block.
779 /// [in] \param block The data block to check.
780 /// [out] \param reason If this is not NULL, then it is assumed to point
781 /// to an array of at least 'reasonCount' number of elements. It will
782 /// be filled with the reason codes describing why the header is not
784 /// [in/out] \param reasonCount This should initially specify the size of
785 /// the array pointed to by 'reason'. It will be filled with the number
786 /// of items actually filled into the reason array upon exit from this
788 /// \returns true if there is no problem with the header and false otherwise.
790 AliHLTUInt32_t maxCount = reasonCount;
794 // The block must have the correct type.
795 if (block.fHeader.fType != kRecHitsDataBlock)
797 if (reason != NULL and reasonCount < maxCount)
799 reason[reasonCount] = kHeaderContainsWrongType;
805 // The block's record width must be the correct size.
806 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONRecHitStruct))
808 if (reason != NULL and reasonCount < maxCount)
810 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
820 bool AliHLTMUONUtils::HeaderOk(
821 const AliHLTMUONClustersBlockStruct& block,
822 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
825 /// Method used to check if the header information corresponds to the
826 /// supposed type of the raw dHLT data block.
827 /// [in] \param block The data block to check.
828 /// [out] \param reason If this is not NULL, then it is assumed to point
829 /// to an array of at least 'reasonCount' number of elements. It will
830 /// be filled with the reason codes describing why the header is not
832 /// [in/out] \param reasonCount This should initially specify the size of
833 /// the array pointed to by 'reason'. It will be filled with the number
834 /// of items actually filled into the reason array upon exit from this
836 /// \returns true if there is no problem with the header and false otherwise.
838 AliHLTUInt32_t maxCount = reasonCount;
842 // The block must have the correct type.
843 if (block.fHeader.fType != kClustersDataBlock)
845 if (reason != NULL and reasonCount < maxCount)
847 reason[reasonCount] = kHeaderContainsWrongType;
853 // The block's record width must be the correct size.
854 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONClusterStruct))
856 if (reason != NULL and reasonCount < maxCount)
858 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
868 bool AliHLTMUONUtils::HeaderOk(
869 const AliHLTMUONChannelsBlockStruct& block,
870 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
873 /// Method used to check if the header information corresponds to the
874 /// supposed type of the raw dHLT data block.
875 /// [in] \param block The data block to check.
876 /// [out] \param reason If this is not NULL, then it is assumed to point
877 /// to an array of at least 'reasonCount' number of elements. It will
878 /// be filled with the reason codes describing why the header is not
880 /// [in/out] \param reasonCount This should initially specify the size of
881 /// the array pointed to by 'reason'. It will be filled with the number
882 /// of items actually filled into the reason array upon exit from this
884 /// \returns true if there is no problem with the header and false otherwise.
886 AliHLTUInt32_t maxCount = reasonCount;
890 // The block must have the correct type.
891 if (block.fHeader.fType != kChannelsDataBlock)
893 if (reason != NULL and reasonCount < maxCount)
895 reason[reasonCount] = kHeaderContainsWrongType;
901 // The block's record width must be the correct size.
902 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONChannelStruct))
904 if (reason != NULL and reasonCount < maxCount)
906 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
916 bool AliHLTMUONUtils::HeaderOk(
917 const AliHLTMUONMansoTracksBlockStruct& block,
918 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
921 /// Method used to check if the header information corresponds to the
922 /// supposed type of the raw dHLT data block.
923 /// [in] \param block The data block to check.
924 /// [out] \param reason If this is not NULL, then it is assumed to point
925 /// to an array of at least 'reasonCount' number of elements. It will
926 /// be filled with the reason codes describing why the header is not
928 /// [in/out] \param reasonCount This should initially specify the size of
929 /// the array pointed to by 'reason'. It will be filled with the number
930 /// of items actually filled into the reason array upon exit from this
932 /// \returns true if there is no problem with the header and false otherwise.
934 AliHLTUInt32_t maxCount = reasonCount;
938 // The block must have the correct type.
939 if (block.fHeader.fType != kMansoTracksDataBlock)
941 if (reason != NULL and reasonCount < maxCount)
943 reason[reasonCount] = kHeaderContainsWrongType;
949 // The block's record width must be the correct size.
950 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoTrackStruct))
952 if (reason != NULL and reasonCount < maxCount)
954 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
964 bool AliHLTMUONUtils::HeaderOk(
965 const AliHLTMUONMansoCandidatesBlockStruct& block,
966 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
969 /// Method used to check if the header information corresponds to the
970 /// supposed type of the raw dHLT data block.
971 /// [in] \param block The data block to check.
972 /// [out] \param reason If this is not NULL, then it is assumed to point
973 /// to an array of at least 'reasonCount' number of elements. It will
974 /// be filled with the reason codes describing why the header is not
976 /// [in/out] \param reasonCount This should initially specify the size of
977 /// the array pointed to by 'reason'. It will be filled with the number
978 /// of items actually filled into the reason array upon exit from this
980 /// \returns true if there is no problem with the header and false otherwise.
982 AliHLTUInt32_t maxCount = reasonCount;
986 // The block must have the correct type.
987 if (block.fHeader.fType != kMansoCandidatesDataBlock)
989 if (reason != NULL and reasonCount < maxCount)
991 reason[reasonCount] = kHeaderContainsWrongType;
997 // The block's record width must be the correct size.
998 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoCandidateStruct))
1000 if (reason != NULL and reasonCount < maxCount)
1002 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1012 bool AliHLTMUONUtils::HeaderOk(
1013 const AliHLTMUONSinglesDecisionBlockStruct& block,
1014 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1017 /// Method used to check if the header information corresponds to the
1018 /// supposed type of the raw dHLT data block.
1019 /// [in] \param block The data block to check.
1020 /// [out] \param reason If this is not NULL, then it is assumed to point
1021 /// to an array of at least 'reasonCount' number of elements. It will
1022 /// be filled with the reason codes describing why the header is not
1024 /// [in/out] \param reasonCount This should initially specify the size of
1025 /// the array pointed to by 'reason'. It will be filled with the number
1026 /// of items actually filled into the reason array upon exit from this
1028 /// \returns true if there is no problem with the header and false otherwise.
1030 AliHLTUInt32_t maxCount = reasonCount;
1034 // The block must have the correct type.
1035 if (block.fHeader.fType != kSinglesDecisionDataBlock)
1037 if (reason != NULL and reasonCount < maxCount)
1039 reason[reasonCount] = kHeaderContainsWrongType;
1045 // The block's record width must be the correct size.
1046 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrackDecisionStruct))
1048 if (reason != NULL and reasonCount < maxCount)
1050 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1060 bool AliHLTMUONUtils::HeaderOk(
1061 const AliHLTMUONPairsDecisionBlockStruct& block,
1062 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1065 /// Method used to check if the header information corresponds to the
1066 /// supposed type of the raw dHLT data block.
1067 /// [in] \param block The data block to check.
1068 /// [out] \param reason If this is not NULL, then it is assumed to point
1069 /// to an array of at least 'reasonCount' number of elements. It will
1070 /// be filled with the reason codes describing why the header is not
1072 /// [in/out] \param reasonCount This should initially specify the size of
1073 /// the array pointed to by 'reason'. It will be filled with the number
1074 /// of items actually filled into the reason array upon exit from this
1076 /// \returns true if there is no problem with the header and false otherwise.
1078 AliHLTUInt32_t maxCount = reasonCount;
1082 // The block must have the correct type.
1083 if (block.fHeader.fType != kPairsDecisionDataBlock)
1085 if (reason != NULL and reasonCount < maxCount)
1087 reason[reasonCount] = kHeaderContainsWrongType;
1093 // The block's record width must be the correct size.
1094 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONPairDecisionStruct))
1096 if (reason != NULL and reasonCount < maxCount)
1098 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1108 bool AliHLTMUONUtils::IntegrityOk(
1109 const AliHLTMUONTriggerRecordStruct& tr,
1110 WhyNotValid* reason,
1111 AliHLTUInt32_t& reasonCount
1114 /// This method is used to check more extensively if the integrity of the
1115 /// trigger record structure is OK and returns true in that case.
1116 /// [in] \param tr The trigger record structure to check.
1117 /// [out] \param reason If this is not NULL, then it is assumed to point
1118 /// to an array of at least 'reasonCount' number of elements. It will
1119 /// be filled with the reason codes describing why the structure is
1121 /// [in/out] \param reasonCount This should initially specify the size of
1122 /// the array pointed to by 'reason'. It will be filled with the number
1123 /// of items actually filled into the reason array upon exit from this
1125 /// \returns true if there is no problem with the structure and false otherwise.
1127 AliHLTUInt32_t maxCount = reasonCount;
1131 // Check that the ID has a valid value.
1132 if (not (tr.fId >= 0 or tr.fId == -1))
1134 if (reason != NULL and reasonCount < maxCount)
1136 reason[reasonCount] = kInvalidIdValue;
1142 // Make sure that the reserved bits in the fFlags field are set
1144 if ((tr.fFlags & 0x3FFFFFF0) != 0)
1146 if (reason != NULL and reasonCount < maxCount)
1148 reason[reasonCount] = kReservedBitsNotZero;
1154 // Make sure the sign is not invalid.
1155 if ((tr.fFlags & 0xC0000000) == 0xC0000000)
1157 if (reason != NULL and reasonCount < maxCount)
1159 reason[reasonCount] = kParticleSignBitsNotValid;
1165 // Check that fHit[i] is nil if the corresponding bit in the
1166 // flags word is zero.
1167 const AliHLTMUONRecHitStruct& nilhit
1168 = AliHLTMUONConstants::NilRecHitStruct();
1169 if ( ((tr.fFlags & 0x1) == 0 and tr.fHit[0] != nilhit) or
1170 ((tr.fFlags & 0x2) == 0 and tr.fHit[1] != nilhit) or
1171 ((tr.fFlags & 0x4) == 0 and tr.fHit[2] != nilhit) or
1172 ((tr.fFlags & 0x8) == 0 and tr.fHit[3] != nilhit)
1175 if (reason != NULL and reasonCount < maxCount)
1177 reason[reasonCount] = kHitNotMarkedAsNil;
1187 bool AliHLTMUONUtils::IntegrityOk(
1188 const AliHLTMUONTriggerRecordsBlockStruct& block,
1189 WhyNotValid* reason,
1190 AliHLTUInt32_t* recordNum,
1191 AliHLTUInt32_t& reasonCount
1194 /// This method is used to check more extensively if the integrity of the
1195 /// dHLT raw internal data block is OK and returns true in that case.
1196 /// [in] \param block The trigger record data block to check.
1197 /// [out] \param reason If this is not NULL, then it is assumed to point
1198 /// to an array of at least 'reasonCount' number of elements. It will
1199 /// be filled with the reason codes describing why the data block is
1201 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1202 /// to an array of at least 'reasonCount' number of elements. It will
1203 /// be filled with the number of the trigger record that had a problem.
1204 /// The value 'recordNum[i]' will only contain a valid value if
1205 /// the corresponding 'reason[i]' contains one of:
1206 /// - kInvalidIdValue
1207 /// - kReservedBitsNotZero
1208 /// - kParticleSignBitsNotValid
1209 /// - kHitNotMarkedAsNil
1210 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1211 /// was set and is valid or not.
1212 /// [in/out] \param reasonCount This should initially specify the size of
1213 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1214 /// with the number of items actually filled into the arrays upon exit
1215 /// from this method.
1216 /// \returns true if there is no problem with the data and false otherwise.
1218 AliHLTUInt32_t maxCount = reasonCount;
1219 bool result = HeaderOk(block, reason, reasonCount);
1221 const AliHLTMUONTriggerRecordStruct* triggerRecord =
1222 reinterpret_cast<const AliHLTMUONTriggerRecordStruct*>(&block + 1);
1224 // Check if any ID is duplicated.
1225 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1227 AliHLTInt32_t id = triggerRecord[i].fId;
1228 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1230 if (id == triggerRecord[j].fId)
1232 if (reason != NULL and reasonCount < maxCount)
1234 reason[reasonCount] = kFoundDuplicateIDs;
1242 // Check integrity of individual trigger records.
1243 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1245 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1246 if (not IntegrityOk(triggerRecord[i], reason+reasonCount, filledCount))
1248 // reasons filled in IntegrityOk, now we just need to adjust
1249 // reasonCount and fill the recordNum values.
1250 if (recordNum != NULL)
1252 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1253 recordNum[reasonCount + n] = i;
1255 reasonCount += filledCount;
1264 bool AliHLTMUONUtils::IntegrityOk(
1265 const AliHLTMUONTrigRecInfoStruct& trigInfo,
1266 WhyNotValid* reason,
1267 AliHLTUInt32_t& reasonCount
1270 /// This method is used to check more extensively if the integrity of the
1271 /// trigger record debug information structure is OK and returns true in that case.
1272 /// [in] \param trigInfo The trigger record debug information structure to check.
1273 /// [out] \param reason If this is not NULL, then it is assumed to point
1274 /// to an array of at least 'reasonCount' number of elements. It will
1275 /// be filled with the reason codes describing why the structure is not
1277 /// [in/out] \param reasonCount This should initially specify the size of
1278 /// the array pointed to by 'reason'. It will be filled with the number
1279 /// of items actually filled into the reason array upon exit from this
1281 /// \returns true if there is no problem with the structure and false otherwise.
1283 AliHLTUInt32_t maxCount = reasonCount;
1287 // Check that the trigger ID has a valid value.
1288 if (not (trigInfo.fTrigRecId >= 0 or trigInfo.fTrigRecId == -1))
1290 if (reason != NULL and reasonCount < maxCount)
1292 reason[reasonCount] = kInvalidIdValue;
1298 // Check that the fDetElemId[i] numbers are valid.
1299 if ( not (trigInfo.fDetElemId[0] >= 0 or trigInfo.fDetElemId[0] == -1) or
1300 not (trigInfo.fDetElemId[1] >= 0 or trigInfo.fDetElemId[1] == -1) or
1301 not (trigInfo.fDetElemId[2] >= 0 or trigInfo.fDetElemId[2] == -1) or
1302 not (trigInfo.fDetElemId[3] >= 0 or trigInfo.fDetElemId[3] == -1)
1305 if (reason != NULL and reasonCount < maxCount)
1307 reason[reasonCount] = kInvalidDetElementNumber;
1317 bool AliHLTMUONUtils::IntegrityOk(
1318 const AliHLTMUONTrigRecsDebugBlockStruct& block,
1319 WhyNotValid* reason,
1320 AliHLTUInt32_t* recordNum,
1321 AliHLTUInt32_t& reasonCount
1324 /// This method is used to check more extensively if the integrity of the
1325 /// dHLT raw internal data block is OK and returns true in that case.
1326 /// [in] \param block The trigger record debugging information data block
1328 /// [out] \param reason If this is not NULL, then it is assumed to point
1329 /// to an array of at least 'reasonCount' number of elements. It will
1330 /// be filled with the reason codes describing why the data block is
1332 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1333 /// to an array of at least 'reasonCount' number of elements. It will
1334 /// be filled with the number of the trigger record debug information
1335 /// structure that had a problem.
1336 /// The value 'recordNum[i]' will only contain a valid value if
1337 /// the corresponding 'reason[i]' contains one of:
1338 /// - kInvalidIdValue
1339 /// - kInvalidDetElementNumber
1340 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1341 /// was set and is valid or not.
1342 /// [in/out] \param reasonCount This should initially specify the size of
1343 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1344 /// with the number of items actually filled into the arrays upon exit
1345 /// from this method.
1346 /// \returns true if there is no problem with the data and false otherwise.
1348 AliHLTUInt32_t maxCount = reasonCount;
1349 bool result = HeaderOk(block, reason, reasonCount);
1351 const AliHLTMUONTrigRecInfoStruct* triggerInfo =
1352 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&block + 1);
1354 // Check if any trigger debug info structure has duplicated trigger IDs.
1355 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1357 AliHLTInt32_t id = triggerInfo[i].fTrigRecId;
1358 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1360 if (id == triggerInfo[j].fTrigRecId)
1362 if (reason != NULL and reasonCount < maxCount)
1364 reason[reasonCount] = kFoundDuplicateIDs;
1372 // Check integrity of individual trigger records.
1373 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1375 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1376 if (not IntegrityOk(triggerInfo[i], reason+reasonCount, filledCount))
1378 // reasons filled in IntegrityOk, now we just need to adjust
1379 // reasonCount and fill the recordNum values.
1380 if (recordNum != NULL)
1382 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1383 recordNum[reasonCount + n] = i;
1385 reasonCount += filledCount;
1394 bool AliHLTMUONUtils::IntegrityOk(
1395 const AliHLTMUONTriggerChannelsBlockStruct& block,
1399 /// This method is used to check more extensively if the integrity of the
1400 /// dHLT raw internal data block is OK and returns true in that case.
1401 /// [in] \param block The trigger channels data block to check.
1402 /// [out] \param reason If this is not NULL, then it will be filled with
1403 /// the reason code describing why the data block is not valid, if and
1404 /// only if a problem is found with the data.
1405 /// \returns true if there is no problem with the data and false otherwise.
1407 if (not HeaderOk(block, reason)) return false;
1412 bool AliHLTMUONUtils::IntegrityOk(
1413 const AliHLTMUONRecHitsBlockStruct& block,
1414 WhyNotValid* reason,
1415 AliHLTUInt32_t& reasonCount
1418 /// This method is used to check more extensively if the integrity of the
1419 /// dHLT raw internal data block is OK and returns true in that case.
1420 /// [in] \param block The reconstructed hits data block to check.
1421 /// [out] \param reason If this is not NULL, then it is assumed to point
1422 /// to an array of at least 'reasonCount' number of elements. It will
1423 /// be filled with the reason codes describing why the data block is
1425 /// [in/out] \param reasonCount This should initially specify the size of
1426 /// the array pointed to by 'reason'. It will be filled with the number
1427 /// of items actually filled into the reason array upon exit from this
1429 /// \returns true if there is no problem with the data and false otherwise.
1431 AliHLTUInt32_t maxCount = reasonCount;
1432 bool result = HeaderOk(block, reason, reasonCount);
1434 const AliHLTMUONRecHitStruct* hit =
1435 reinterpret_cast<const AliHLTMUONRecHitStruct*>(&block + 1);
1437 // Check if any hit structure has been duplicated.
1438 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1440 const AliHLTMUONRecHitStruct& h = hit[i];
1441 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1445 if (reason != NULL and reasonCount < maxCount)
1447 reason[reasonCount] = kFoundDuplicateHits;
1459 bool AliHLTMUONUtils::IntegrityOk(
1460 const AliHLTMUONClusterStruct& cluster,
1461 WhyNotValid* reason,
1462 AliHLTUInt32_t& reasonCount
1465 /// This method is used to check more extensively if the integrity of the
1466 /// cluster structure is OK and returns true in that case.
1467 /// [in] \param cluster The cluster structure to check.
1468 /// [out] \param reason If this is not NULL, then it is assumed to point
1469 /// to an array of at least 'reasonCount' number of elements. It will
1470 /// be filled with the reason codes describing why the structure is
1472 /// [in/out] \param reasonCount This should initially specify the size of
1473 /// the array pointed to by 'reason'. It will be filled with the number
1474 /// of items actually filled into the reason array upon exit from this
1476 /// \returns true if there is no problem with the structure and false otherwise.
1478 AliHLTUInt32_t maxCount = reasonCount;
1482 // Check that the cluster ID has a valid value.
1483 if (not (cluster.fId >= 0 or cluster.fId == -1))
1485 if (reason != NULL and reasonCount < maxCount)
1487 reason[reasonCount] = kInvalidIdValue;
1493 // Check that the cluster does not have a nil value for its hit.
1494 if (cluster.fHit == AliHLTMUONConstants::NilRecHitStruct())
1496 if (reason != NULL and reasonCount < maxCount)
1498 reason[reasonCount] = kHitIsNil;
1504 // Make sure the detector element is a valid value.
1505 if (not (cluster.fDetElemId >= 0 or cluster.fDetElemId == -1))
1507 if (reason != NULL and reasonCount < maxCount)
1509 reason[reasonCount] = kInvalidDetElementNumber;
1515 // The number of channels should be in a reasonable range.
1516 // between 1 and the maximum number of channels per DDL.
1517 // 1<<17 taken from the 11 bits MANU ID + 6 bits channel address.
1518 if (cluster.fNchannels < 1 or (1<<17) < cluster.fNchannels)
1520 if (reason != NULL and reasonCount < maxCount)
1522 reason[reasonCount] = kInvalidChannelCount;
1532 bool AliHLTMUONUtils::IntegrityOk(
1533 const AliHLTMUONClustersBlockStruct& block,
1534 WhyNotValid* reason,
1535 AliHLTUInt32_t* recordNum,
1536 AliHLTUInt32_t& reasonCount
1539 /// This method is used to check more extensively if the integrity of the
1540 /// dHLT internal clusters data block is OK and returns true in that case.
1541 /// [in] \param block The clusters data block to check.
1542 /// [out] \param reason If this is not NULL, then it is assumed to point
1543 /// to an array of at least 'reasonCount' number of elements. It will
1544 /// be filled with the reason codes describing why the data block is
1546 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1547 /// to an array of at least 'reasonCount' number of elements. It will
1548 /// be filled with the number of the cluster structure that had a problem.
1549 /// The value 'recordNum[i]' will only contain a valid value if
1550 /// the corresponding 'reason[i]' contains one of:
1551 /// - kInvalidIdValue
1553 /// - kInvalidDetElementNumber
1554 /// - kInvalidChannelCount
1555 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1556 /// was set and is valid or not.
1557 /// [in/out] \param reasonCount This should initially specify the size of
1558 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1559 /// with the number of items actually filled into the arrays upon exit
1560 /// from this method.
1561 /// \returns true if there is no problem with the data and false otherwise.
1563 AliHLTUInt32_t maxCount = reasonCount;
1564 bool result = HeaderOk(block, reason, reasonCount);
1566 const AliHLTMUONClusterStruct* cluster =
1567 reinterpret_cast<const AliHLTMUONClusterStruct*>(&block + 1);
1569 // Check if any ID is duplicated.
1570 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1572 AliHLTInt32_t id = cluster[i].fId;
1573 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1575 if (id == cluster[j].fId)
1577 if (reason != NULL and reasonCount < maxCount)
1579 reason[reasonCount] = kFoundDuplicateIDs;
1587 // Check if any hit structure has been duplicated.
1588 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1590 const AliHLTMUONRecHitStruct& h = cluster[i].fHit;
1591 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1593 if (h == cluster[j].fHit)
1595 if (reason != NULL and reasonCount < maxCount)
1597 reason[reasonCount] = kFoundDuplicateHits;
1605 // Check integrity of individual cluster structures.
1606 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1608 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1609 if (not IntegrityOk(cluster[i], reason+reasonCount, filledCount))
1611 // reasons filled in IntegrityOk, now we just need to adjust
1612 // reasonCount and fill the recordNum values.
1613 if (recordNum != NULL)
1615 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1616 recordNum[reasonCount + n] = i;
1618 reasonCount += filledCount;
1627 bool AliHLTMUONUtils::IntegrityOk(
1628 const AliHLTMUONChannelStruct& channel,
1629 WhyNotValid* reason,
1630 AliHLTUInt32_t& reasonCount
1633 /// This method is used to check more extensively if the integrity of the
1634 /// channel structure is OK and returns true in that case.
1635 /// [in] \param cluster The channel structure to check.
1636 /// [out] \param reason If this is not NULL, then it is assumed to point
1637 /// to an array of at least 'reasonCount' number of elements. It will
1638 /// be filled with the reason codes describing why the structure is
1640 /// [in/out] \param reasonCount This should initially specify the size of
1641 /// the array pointed to by 'reason'. It will be filled with the number
1642 /// of items actually filled into the reason array upon exit from this
1644 /// \returns true if there is no problem with the structure and false otherwise.
1646 AliHLTUInt32_t maxCount = reasonCount;
1650 // Check that the channel ID has a valid value.
1651 if (not (channel.fClusterId >= 0 or channel.fClusterId == -1))
1653 if (reason != NULL and reasonCount < maxCount)
1655 reason[reasonCount] = kInvalidIdValue;
1661 // Check that the bus patch ID has a valid value, which fits into 12 bits.
1662 if ((channel.fBusPatch & (~0xFFF)) != 0)
1664 if (reason != NULL and reasonCount < maxCount)
1666 reason[reasonCount] = kInvalidBusPatchId;
1672 // Check that the MANU ID has a valid value, which fits into 11 bits.
1673 if ((channel.fManu & (~0x7FF)) != 0)
1675 if (reason != NULL and reasonCount < maxCount)
1677 reason[reasonCount] = kInvalidManuId;
1683 // Check that the channel address has a valid value, which fits into 6 bits.
1684 if ((channel.fChannelAddress & (~0x3F)) != 0)
1686 if (reason != NULL and reasonCount < maxCount)
1688 reason[reasonCount] = kInvalidChannelAddress;
1694 // Check that the ADC signal has a valid value, which fits into 12 bits.
1695 if ((channel.fSignal & (~0xFFF)) != 0)
1697 if (reason != NULL and reasonCount < maxCount)
1699 reason[reasonCount] = kInvalidSignal;
1705 // Check that the raw data word corresponds to the unpacked values for
1706 // the ADC signal, MANU ID and channel address.
1707 UShort_t manuId; UChar_t channelId; UShort_t adc;
1708 AliMUONTrackerDDLDecoderEventHandler::UnpackADC(
1709 channel.fRawDataWord, manuId, channelId, adc
1711 if (manuId != channel.fManu or channelId != channel.fChannelAddress
1712 or adc != channel.fSignal
1715 if (reason != NULL and reasonCount < maxCount)
1717 reason[reasonCount] = kDataWordDifferent;
1727 bool AliHLTMUONUtils::IntegrityOk(
1728 const AliHLTMUONChannelsBlockStruct& block,
1729 WhyNotValid* reason,
1730 AliHLTUInt32_t* recordNum,
1731 AliHLTUInt32_t& reasonCount
1734 /// This method is used to check more extensively if the integrity of the
1735 /// dHLT internal channels data block is OK and returns true in that case.
1736 /// [in] \param block The channels data block to check.
1737 /// [out] \param reason If this is not NULL, then it is assumed to point
1738 /// to an array of at least 'reasonCount' number of elements. It will
1739 /// be filled with the reason codes describing why the data block is
1741 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1742 /// to an array of at least 'reasonCount' number of elements. It will
1743 /// be filled with the number of the channel structure that had a problem.
1744 /// The value 'recordNum[i]' will only contain a valid value if
1745 /// the corresponding 'reason[i]' contains one of:
1746 /// - kInvalidIdValue
1747 /// - kInvalidBusPatchId
1748 /// - kInvalidManuId
1749 /// - kInvalidChannelAddress
1750 /// - kInvalidSignal
1751 /// - kDataWordDifferent
1752 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1753 /// was set and is valid or not.
1754 /// [in/out] \param reasonCount This should initially specify the size of
1755 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1756 /// with the number of items actually filled into the arrays upon exit
1757 /// from this method.
1758 /// \returns true if there is no problem with the data and false otherwise.
1760 AliHLTUInt32_t maxCount = reasonCount;
1761 bool result = HeaderOk(block, reason, reasonCount);
1763 const AliHLTMUONChannelStruct* channel =
1764 reinterpret_cast<const AliHLTMUONChannelStruct*>(&block + 1);
1766 // Check if any cluster ID is duplicated.
1767 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1769 AliHLTInt32_t id = channel[i].fClusterId;
1770 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1772 if (id == channel[j].fClusterId)
1774 if (reason != NULL and reasonCount < maxCount)
1776 reason[reasonCount] = kFoundDuplicateIDs;
1784 // Check integrity of individual channel structures.
1785 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1787 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1788 if (not IntegrityOk(channel[i], reason+reasonCount, filledCount))
1790 // reasons filled in IntegrityOk, now we just need to adjust
1791 // reasonCount and fill the recordNum values.
1792 if (recordNum != NULL)
1794 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1795 recordNum[reasonCount + n] = i;
1797 reasonCount += filledCount;
1806 bool AliHLTMUONUtils::IntegrityOk(
1807 const AliHLTMUONMansoTrackStruct& track,
1808 WhyNotValid* reason,
1809 AliHLTUInt32_t& reasonCount
1812 /// This method is used to check more extensively if the integrity of the
1813 /// Manso track structure is OK and returns true in that case.
1814 /// [in] \param track The track structure to check.
1815 /// [out] \param reason If this is not NULL, then it is assumed to point
1816 /// to an array of at least 'reasonCount' number of elements. It will
1817 /// be filled with the reason codes describing why the structure is
1819 /// [in/out] \param reasonCount This should initially specify the size of
1820 /// the array pointed to by 'reason'. It will be filled with the number
1821 /// of items actually filled into the reason array upon exit from this
1823 /// \returns true if there is no problem with the structure and false otherwise.
1825 AliHLTUInt32_t maxCount = reasonCount;
1829 // Check that the Manso track ID has a valid value.
1830 if (not (track.fId >= 0 or track.fId == -1))
1832 if (reason != NULL and reasonCount < maxCount)
1834 reason[reasonCount] = kInvalidIdValue;
1840 // Check that the corresponding trigger record ID has a valid value.
1841 if (not (track.fTrigRec >= 0 or track.fTrigRec == -1))
1843 if (reason != NULL and reasonCount < maxCount)
1845 reason[reasonCount] = kInvalidTriggerIdValue;
1851 // Make sure that the reserved bits in the fFlags field are set
1853 if ((track.fFlags & 0x3FFFFFF0) != 0)
1855 if (reason != NULL and reasonCount < maxCount)
1857 reason[reasonCount] = kReservedBitsNotZero;
1863 // Make sure the sign is not invalid.
1864 if ((track.fFlags & 0xC0000000) == 0xC0000000)
1866 if (reason != NULL and reasonCount < maxCount)
1868 reason[reasonCount] = kParticleSignBitsNotValid;
1874 // Check that fHit[i] is nil if the corresponding bit in the
1875 // flags word is zero.
1876 const AliHLTMUONRecHitStruct& nilhit
1877 = AliHLTMUONConstants::NilRecHitStruct();
1878 if ( ((track.fFlags & 0x1) == 0 and track.fHit[0] != nilhit) or
1879 ((track.fFlags & 0x2) == 0 and track.fHit[1] != nilhit) or
1880 ((track.fFlags & 0x4) == 0 and track.fHit[2] != nilhit) or
1881 ((track.fFlags & 0x8) == 0 and track.fHit[3] != nilhit)
1884 if (reason != NULL and reasonCount < maxCount)
1886 reason[reasonCount] = kHitNotMarkedAsNil;
1892 // Check that the chi squared value is valid
1893 if (not (track.fChi2 >= 0 or track.fChi2 == -1))
1895 if (reason != NULL and reasonCount < maxCount)
1897 reason[reasonCount] = kChiSquareInvalid;
1903 // Check that if chi squared is -1 then the momentum vector is zero.
1904 if (track.fChi2 == -1 and
1905 not (track.fPx == 0 and track.fPy == 0 and track.fPz == 0)
1908 if (reason != NULL and reasonCount < maxCount)
1910 reason[reasonCount] = kMomentumVectorNotZero;
1920 bool AliHLTMUONUtils::IntegrityOk(
1921 const AliHLTMUONMansoTracksBlockStruct& block,
1922 WhyNotValid* reason,
1923 AliHLTUInt32_t* recordNum,
1924 AliHLTUInt32_t& reasonCount
1927 /// This method is used to check more extensively if the integrity of the
1928 /// dHLT internal Manso track data block is OK and returns true in that case.
1929 /// [in] \param block The Manso track data block to check.
1930 /// [out] \param reason If this is not NULL, then it is assumed to point
1931 /// to an array of at least 'reasonCount' number of elements. It will
1932 /// be filled with the reason codes describing why the data block is
1934 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1935 /// to an array of at least 'reasonCount' number of elements. It will
1936 /// be filled with the number of the Manso track that had a problem.
1937 /// The value 'recordNum[i]' will only contain a valid value if
1938 /// the corresponding 'reason[i]' contains one of:
1939 /// - kInvalidIdValue
1940 /// - kInvalidTriggerIdValue
1941 /// - kReservedBitsNotZero
1942 /// - kParticleSignBitsNotValid
1943 /// - kHitNotMarkedAsNil
1944 /// - kChiSquareInvalid
1945 /// - kMomentumVectorNotZero
1946 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1947 /// was set and is valid or not.
1948 /// [in/out] \param reasonCount This should initially specify the size of
1949 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1950 /// with the number of items actually filled into the arrays upon exit
1951 /// from this method.
1952 /// \returns true if there is no problem with the data and false otherwise.
1954 AliHLTUInt32_t maxCount = reasonCount;
1955 bool result = HeaderOk(block, reason, reasonCount);
1957 const AliHLTMUONMansoTrackStruct* track =
1958 reinterpret_cast<const AliHLTMUONMansoTrackStruct*>(&block + 1);
1960 // Check if any track ID is duplicated.
1961 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1963 AliHLTInt32_t id = track[i].fId;
1964 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1966 if (id == track[j].fId)
1968 if (reason != NULL and reasonCount < maxCount)
1970 reason[reasonCount] = kFoundDuplicateIDs;
1978 // Check that all the tracks have integrity.
1979 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1981 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1982 if (not IntegrityOk(track[i], reason+reasonCount, filledCount))
1984 // reasons filled in IntegrityOk, now we just need to adjust
1985 // reasonCount and fill the recordNum values.
1986 if (recordNum != NULL)
1988 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1989 recordNum[reasonCount + n] = i;
1991 reasonCount += filledCount;
2000 bool AliHLTMUONUtils::IntegrityOk(
2001 const AliHLTMUONMansoCandidateStruct& candidate,
2002 WhyNotValid* reason,
2003 AliHLTUInt32_t& reasonCount
2006 /// This method is used to check more extensively if the integrity of the
2007 /// Manso track candidate structure is OK and returns true in that case.
2008 /// [in] \param track The track candidate structure to check.
2009 /// [out] \param reason If this is not NULL, then it is assumed to point
2010 /// to an array of at least 'reasonCount' number of elements. It will
2011 /// be filled with the reason codes describing why the structure is
2013 /// [in/out] \param reasonCount This should initially specify the size of
2014 /// the array pointed to by 'reason'. It will be filled with the number
2015 /// of items actually filled into the reason array upon exit from this
2017 /// \returns true if there is no problem with the structure and false otherwise.
2019 // First check the integrity of the candidate track structure.
2020 AliHLTUInt32_t maxCount = reasonCount;
2021 bool result = IntegrityOk(candidate.fTrack, reason, reasonCount);
2023 // Now check that the ROIs are reasonable.
2024 // The radius must be positive or -1 indicating computation error and
2025 // the corresponding hit in the track must be within the ROI.
2026 for (AliHLTUInt32_t i = 0; i < 4; i++)
2028 if (not (candidate.fRoI[i].fRadius >= 0 or candidate.fRoI[i].fRadius == -1))
2030 if (reason != NULL and reasonCount < maxCount)
2032 reason[reasonCount] = kRoiRadiusInvalid;
2038 // Check if the corresponding hit was even found in the track.
2039 if ( (candidate.fTrack.fFlags & (0x1 << i)) == 0 ) continue;
2041 double dx = candidate.fRoI[i].fX - candidate.fTrack.fHit[i].fX;
2042 double dy = candidate.fRoI[i].fY - candidate.fTrack.fHit[i].fY;
2043 double dz = candidate.fRoI[i].fZ - candidate.fTrack.fHit[i].fZ;
2044 double r = sqrt(dx*dx + dy*dy);
2045 // Check if the projected distance between ROI centre and hit is
2046 // bigger than the ROI radius. Also the difference between z
2047 // coordinates should not exceed 20 cm.
2048 if (r > candidate.fRoI[i].fRadius or fabs(dz) > 20.)
2050 if (reason != NULL and reasonCount < maxCount)
2052 reason[reasonCount] = kHitNotWithinRoi;
2063 bool AliHLTMUONUtils::IntegrityOk(
2064 const AliHLTMUONMansoCandidatesBlockStruct& block,
2065 WhyNotValid* reason,
2066 AliHLTUInt32_t* recordNum,
2067 AliHLTUInt32_t& reasonCount
2070 /// This method is used to check more extensively if the integrity of the
2071 /// dHLT internal Manso candidates data block is OK and returns true in
2073 /// [in] \param block The Manso track candidate data block to check.
2074 /// [out] \param reason If this is not NULL, then it is assumed to point
2075 /// to an array of at least 'reasonCount' number of elements. It will
2076 /// be filled with the reason codes describing why the data block is
2078 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2079 /// to an array of at least 'reasonCount' number of elements. It will
2080 /// be filled with the number of the track candidate that had a problem.
2081 /// The value 'recordNum[i]' will only contain a valid value if
2082 /// the corresponding 'reason[i]' contains one of:
2083 /// - kInvalidIdValue
2084 /// - kInvalidTriggerIdValue
2085 /// - kReservedBitsNotZero
2086 /// - kParticleSignBitsNotValid
2087 /// - kHitNotMarkedAsNil
2088 /// - kChiSquareInvalid
2089 /// - kRoiRadiusInvalid
2090 /// - kHitNotWithinRoi
2091 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2092 /// was set and is valid or not.
2093 /// [in/out] \param reasonCount This should initially specify the size of
2094 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2095 /// with the number of items actually filled into the arrays upon exit
2096 /// from this method.
2097 /// \returns true if there is no problem with the data and false otherwise.
2099 AliHLTUInt32_t maxCount = reasonCount;
2100 bool result = HeaderOk(block, reason, reasonCount);
2102 const AliHLTMUONMansoCandidateStruct* candidate =
2103 reinterpret_cast<const AliHLTMUONMansoCandidateStruct*>(&block + 1);
2105 // Check if any candidate track ID is duplicated.
2106 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2108 AliHLTInt32_t id = candidate[i].fTrack.fId;
2109 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2111 if (id == candidate[j].fTrack.fId)
2113 if (reason != NULL and reasonCount < maxCount)
2115 reason[reasonCount] = kFoundDuplicateIDs;
2123 // Check that all the track candidates have integrity.
2124 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2126 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2127 if (not IntegrityOk(candidate[i], reason+reasonCount, filledCount))
2129 // reasons filled in IntegrityOk, now we just need to adjust
2130 // reasonCount and fill the recordNum values.
2131 if (recordNum != NULL)
2133 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2134 recordNum[reasonCount + n] = i;
2136 reasonCount += filledCount;
2145 bool AliHLTMUONUtils::IntegrityOk(
2146 const AliHLTMUONTrackDecisionStruct& decision,
2147 WhyNotValid* reason,
2148 AliHLTUInt32_t& reasonCount
2151 /// This method is used to check more extensively if the integrity of the
2152 /// single track trigger decision structure is OK and returns true in that case.
2153 /// [in] \param decision The trigger decision structure to check.
2154 /// [out] \param reason If this is not NULL, then it is assumed to point
2155 /// to an array of at least 'reasonCount' number of elements. It will
2156 /// be filled with the reason codes describing why the structure is not
2158 /// [in/out] \param reasonCount This should initially specify the size of
2159 /// the array pointed to by 'reason'. It will be filled with the number
2160 /// of items actually filled into the reason array upon exit from this
2162 /// \returns true if there is no problem with the structure and false otherwise.
2164 AliHLTUInt32_t maxCount = reasonCount;
2168 // The track ID value must be positive or -1.
2169 if (not (decision.fTrackId >= 0 or decision.fTrackId == -1))
2171 if (reason != NULL and reasonCount < maxCount)
2173 reason[reasonCount] = kInvalidTrackIdValue;
2179 // Make sure that the reserved bits in the fTriggerBits field are set
2181 if ((decision.fTriggerBits & 0xFFFFFFFC) != 0)
2183 if (reason != NULL and reasonCount < maxCount)
2185 reason[reasonCount] = kReservedBitsNotZero;
2191 // The pT should be -1 or a positive number.
2192 if (decision.fPt != -1. and decision.fPt < 0.)
2194 if (reason != NULL and reasonCount < maxCount)
2196 reason[reasonCount] = kPtValueNotValid;
2206 bool AliHLTMUONUtils::IntegrityOk(
2207 const AliHLTMUONSinglesDecisionBlockStruct& block,
2208 WhyNotValid* reason,
2209 AliHLTUInt32_t* recordNum,
2210 AliHLTUInt32_t& reasonCount
2213 /// This method is used to check more extensively if the integrity of the
2214 /// dHLT internal single track trigger decision data block is OK and returns
2215 /// true in that case.
2216 /// [in] \param block The single track trigger decision data block to check.
2217 /// [out] \param reason If this is not NULL, then it is assumed to point
2218 /// to an array of at least 'reasonCount' number of elements. It will
2219 /// be filled with the reason codes describing why the data block is
2221 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2222 /// to an array of at least 'reasonCount' number of elements. It will
2223 /// be filled with the number of the trigger decision that had a problem.
2224 /// The value 'recordNum[i]' will only contain a valid value if
2225 /// the corresponding 'reason[i]' contains one of:
2226 /// - kInvalidTrackIdValue
2227 /// - kReservedBitsNotZero
2228 /// - kPtValueNotValid
2229 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2230 /// was set and is valid or not.
2231 /// [in/out] \param reasonCount This should initially specify the size of
2232 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2233 /// with the number of items actually filled into the arrays upon exit
2234 /// from this method.
2235 /// \returns true if there is no problem with the data and false otherwise.
2237 AliHLTUInt32_t maxCount = reasonCount;
2238 bool result = HeaderOk(block, reason, reasonCount);
2240 const AliHLTMUONTrackDecisionStruct* decision =
2241 reinterpret_cast<const AliHLTMUONTrackDecisionStruct*>(&block + 1);
2243 // Check that there are no duplicate trigger entries.
2244 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2246 AliHLTInt32_t id = decision[i].fTrackId;
2247 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2249 if (id == decision[j].fTrackId)
2251 if (reason != NULL and reasonCount < maxCount)
2253 reason[reasonCount] = kFoundDuplicateTriggers;
2261 // Check that the trigger bits for each track have integrity.
2262 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2264 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2265 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2267 // Reasons filled in IntegrityOk, now we just need to adjust
2268 // reasonCount and fill the recordNum values.
2269 if (recordNum != NULL)
2271 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2272 recordNum[reasonCount + n] = i;
2274 reasonCount += filledCount;
2283 bool AliHLTMUONUtils::IntegrityOk(
2284 const AliHLTMUONPairDecisionStruct& decision,
2285 WhyNotValid* reason,
2286 AliHLTUInt32_t& reasonCount
2289 /// This method is used to check more extensively if the integrity of the
2290 /// track pair trigger decision structure is OK and returns true in that case.
2291 /// [in] \param decision The trigger decision structure to check.
2292 /// [out] \param reason If this is not NULL, then it is assumed to point
2293 /// to an array of at least 'reasonCount' number of elements. It will
2294 /// be filled with the reason codes describing why the structure is not
2296 /// [in/out] \param reasonCount This should initially specify the size of
2297 /// the array pointed to by 'reason'. It will be filled with the number
2298 /// of items actually filled into the reason array upon exit from this
2300 /// \returns true if there is no problem with the structure and false otherwise.
2302 AliHLTUInt32_t maxCount = reasonCount;
2306 //kInvalidTrackIdValue
2308 // The track IDs must have a positive value or -1.
2309 if (not (decision.fTrackAId >= 0 or decision.fTrackAId == -1) or
2310 not (decision.fTrackBId >= 0 or decision.fTrackBId == -1)
2313 if (reason != NULL and reasonCount < maxCount)
2315 reason[reasonCount] = kInvalidTrackIdValue;
2321 // Make sure that the reserved bits in the fTriggerBits field are set
2323 if ((decision.fTriggerBits & 0xFFFFFF80) != 0)
2325 if (reason != NULL and reasonCount < maxCount)
2327 reason[reasonCount] = kReservedBitsNotZero;
2333 // Check that the track IDs are not the same.
2334 if (decision.fTrackAId == decision.fTrackBId)
2336 if (reason != NULL and reasonCount < maxCount)
2338 reason[reasonCount] = kPairTrackIdsAreIdentical;
2344 // The invariant mass should be -1 or a positive number.
2345 if (decision.fInvMass != -1. and decision.fInvMass < 0.)
2347 if (reason != NULL and reasonCount < maxCount)
2349 reason[reasonCount] = kMassValueNotValid;
2355 // Neither the high pt (hipt) or low pt (lopt) count bits can be > 2.
2356 AliHLTUInt8_t lowPtCount = (decision.fTriggerBits & 0x00000003);
2357 AliHLTUInt8_t highPtCount = (decision.fTriggerBits & 0x0000000C) >> 2;
2360 if (reason != NULL and reasonCount < maxCount)
2362 reason[reasonCount] = kLowPtCountInvalid;
2367 if (highPtCount > 2)
2369 if (reason != NULL and reasonCount < maxCount)
2371 reason[reasonCount] = kHighPtCountInvalid;
2381 bool AliHLTMUONUtils::IntegrityOk(
2382 const AliHLTMUONPairsDecisionBlockStruct& block,
2383 WhyNotValid* reason,
2384 AliHLTUInt32_t* recordNum,
2385 AliHLTUInt32_t& reasonCount
2388 /// This method is used to check more extensively if the integrity of the
2389 /// dHLT internal track pair trigger decision data block is OK and returns
2390 /// true in that case.
2391 /// [in] \param block The track pair trigger decision data block to check.
2392 /// [out] \param reason If this is not NULL, then it is assumed to point
2393 /// to an array of at least 'reasonCount' number of elements. It will
2394 /// be filled with the reason codes describing why the data block is
2396 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2397 /// to an array of at least 'reasonCount' number of elements. It will
2398 /// be filled with the number of the trigger decision that had a problem.
2399 /// The value 'recordNum[i]' will only contain a valid value if
2400 /// the corresponding 'reason[i]' contains one of:
2401 /// - kInvalidTrackIdValue
2402 /// - kReservedBitsNotZero
2403 /// - kPairTrackIdsAreIdentical
2404 /// - kMassValueNotValid
2405 /// - kLowPtCountInvalid
2406 /// - kHighPtCountInvalid
2407 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2408 /// was set and is valid or not.
2409 /// [in/out] \param reasonCount This should initially specify the size of
2410 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2411 /// with the number of items actually filled into the arrays upon exit
2412 /// from this method.
2413 /// \returns true if there is no problem with the data and false otherwise.
2415 AliHLTUInt32_t maxCount = reasonCount;
2416 bool result = HeaderOk(block, reason, reasonCount);
2418 const AliHLTMUONPairDecisionStruct* decision =
2419 reinterpret_cast<const AliHLTMUONPairDecisionStruct*>(&block + 1);
2421 // Check that there are no duplicate trigger entries.
2422 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2424 AliHLTInt32_t ta = decision[i].fTrackAId;
2425 AliHLTInt32_t tb = decision[i].fTrackBId;
2426 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2428 if (ta == decision[j].fTrackAId and tb == decision[j].fTrackBId)
2430 if (reason != NULL and reasonCount < maxCount)
2432 reason[reasonCount] = kFoundDuplicateTriggers;
2440 // Check that the trigger bits for each track pair have integrity.
2441 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2443 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2444 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2446 // Reasons filled in IntegrityOk, now we just need to adjust
2447 // reasonCount and fill the recordNum values.
2448 if (recordNum != NULL)
2450 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2451 recordNum[reasonCount + n] = i;
2453 reasonCount += filledCount;