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 "AliHLTMUONRecHitsBlockStruct.h"
30 #include "AliHLTMUONClustersBlockStruct.h"
31 #include "AliHLTMUONChannelsBlockStruct.h"
32 #include "AliHLTMUONMansoTracksBlockStruct.h"
33 #include "AliHLTMUONMansoCandidatesBlockStruct.h"
34 #include "AliHLTMUONSinglesDecisionBlockStruct.h"
35 #include "AliHLTMUONPairsDecisionBlockStruct.h"
36 #include "AliMUONTrackerDDLDecoderEventHandler.h"
41 ClassImp(AliHLTMUONUtils);
44 AliHLTUInt32_t AliHLTMUONUtils::PackTriggerRecordFlags(
45 AliHLTMUONParticleSign sign, const bool hitset[4]
49 /// This packs the given parameters into the bits of a word appropriate
50 /// for AliHLTMUONTriggerRecordStruct::fFlags.
51 /// @param sign The particle sign.
52 /// @param hitset Flags to indicate if the corresponding fHits[i] elements
54 /// @return Returns the 32 bit packed word.
60 case kSignMinus: flags = 0x80000000; break;
61 case kSignPlus: flags = 0x40000000; break;
62 default: flags = 0x00000000; break;
65 return flags | (hitset[0] ? 0x1 : 0) | (hitset[1] ? 0x2 : 0)
66 | (hitset[2] ? 0x4 : 0) | (hitset[3] ? 0x8 : 0);
70 void AliHLTMUONUtils::UnpackTriggerRecordFlags(
71 AliHLTUInt32_t flags, AliHLTMUONParticleSign& sign, bool hitset[4]
75 /// This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
76 /// its component fields.
77 /// @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
78 /// @param sign Sets this to the particle sign.
79 /// @param hitset Sets the array elements to indicate if the corresponding
80 /// fHits[i] element was set/filled.
83 AliHLTUInt32_t signbits = flags & 0xC0000000;
86 case 0x80000000: sign = kSignMinus; break;
87 case 0x40000000: sign = kSignPlus; break;
88 default: sign = kSignUnknown; break;
90 hitset[0] = (flags & 0x1) == 0x1;
91 hitset[1] = (flags & 0x2) == 0x2;
92 hitset[2] = (flags & 0x4) == 0x4;
93 hitset[3] = (flags & 0x8) == 0x8;
97 AliHLTUInt32_t AliHLTMUONUtils::PackRecHitFlags(
98 AliHLTUInt8_t chamber, AliHLTUInt16_t detElemId
101 /// This packs the given parameters into the bits of a word appropriate
102 /// for AliHLTMUONRecHitStruct::fFlags.
103 /// @param chamber The chamber number in the range [0..13].
104 /// @param detElemId Detector element ID number.
105 /// @return Returns the 32 bit packed word.
107 return ((chamber & 0xF) << 12) | (detElemId & 0xFFF);
111 void AliHLTMUONUtils::UnpackRecHitFlags(
112 AliHLTUInt32_t flags, // [in]
113 AliHLTUInt8_t& chamber, // [out]
114 AliHLTUInt16_t& detElemId // [out]
117 /// This unpacks the AliHLTMUONRecHitStruct::fFlags bits into
118 /// its component fields.
119 /// [in] @param flags The flags from an AliHLTMUONRecHitStruct structure.
120 /// [out] @param chamber Sets the chamber number in the range [0..13].
121 /// [out] @param detElemId Sets the detector element ID number.
123 chamber = (flags >> 12) & 0xF;
124 detElemId = flags & 0xFFF;
128 AliHLTUInt32_t AliHLTMUONUtils::PackTrackDecisionBits(bool highPt, bool lowPt)
131 /// This packs the given parameters into the bits of a word appropriate
132 /// for AliHLTMUONTrackDecisionStruct::fTriggerBits.
133 /// @param highPt Has the track passed the high pt cut.
134 /// @param lowPt Has the track passed the low pt cut.
135 /// @return Returns the 32 bit packed word.
138 return (highPt ? 0x2 : 0) | (lowPt ? 0x1 : 0);
142 void AliHLTMUONUtils::UnpackTrackDecisionBits(
143 AliHLTUInt32_t bits, bool& highPt, bool& lowPt
147 /// This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
148 /// its component fields.
149 /// @param bits The trigger bits from an AliHLTMUONTrackDecisionStruct
151 /// @param highPt Sets this to the value of the high pt cut bit.
152 /// @param lowPt Sets this to the value of the low pt cut bit.
155 lowPt = (bits & 0x1) == 0x1;
156 highPt = (bits & 0x2) == 0x2;
160 AliHLTUInt32_t AliHLTMUONUtils::PackPairDecisionBits(
161 bool highMass, bool lowMass, bool unlike,
162 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
166 /// This packs the given parameters into the bits of a word appropriate
167 /// for AliHLTMUONPairDecisionStruct::fTriggerBits.
169 /// @param highMass Has the track pair passed the high invariant mass cut.
170 /// @param lowMass Has the track pair passed the low invariant mass cut.
171 /// @param unlike Does the track pair have unlike signs.
172 /// @param highPtCount The number of tracks that passed the high pt cut
174 /// @param lowPtCount The number of tracks that passed the low pt cut
176 /// @return Returns the 32 bit packed word.
178 /// Note: Must have highPtCount <= 2, lowPtCount <= 2 and
179 /// unlike == true if highMass or lowMass is true.
182 assert( lowPtCount <= 2 );
183 assert( highPtCount <= 2 );
184 // highMass and lowMass must be false if unlike is false:
185 assert( not unlike ? (highMass == false and lowMass == false) : true );
187 return (highMass ? 0x40 : 0) | (lowMass ? 0x20 : 0) | (unlike ? 0x10 : 0)
188 | ((highPtCount & 0x3) << 2) | (lowPtCount & 0x3);
192 void AliHLTMUONUtils::UnpackPairDecisionBits(
193 AliHLTUInt32_t bits, bool& highMass, bool& lowMass, bool& unlike,
194 AliHLTUInt8_t& highPtCount, AliHLTUInt8_t& lowPtCount
198 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
199 /// its component fields.
200 /// @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
202 /// @param highMass Sets this to the value of the high invariant mass cut bit.
203 /// @param lowMass Sets this to the value of the low invariant mass cut bit.
204 /// @param unlike Sets this if the pair is unlike sign.
205 /// @param highPtCount Sets this to the high pt count bits.
206 /// @param lowPtCount Sets this to the low pt count bits.
209 highMass = (bits & 0x40) == 0x40;
210 lowMass = (bits & 0x20) == 0x20;
211 unlike = (bits & 0x10) == 0x10;
212 highPtCount = (bits & 0xC) >> 2;
213 lowPtCount = bits & 0x3;
217 AliHLTUInt32_t AliHLTMUONUtils::PackSpecBits(
222 /// This packs the given parameters into the 32bit Pub/Sub specification
223 /// word in the data block descriptor.
225 /// @param ddl The list of DDLs forming part of the readout. ddl[0]
226 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
227 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
228 /// trigger DDLs 2816 and 2817 respectively.
229 /// @return Returns the 32 bit packed specification word.
232 // Pack the bits into the following format:
233 // bit: [ 31 - 22 ][ 21 ][ 20 ][ 19 - 0 ]
234 // field: [ reserved, set to zero ][ TRGDDL2817 ][ TRGDDL2816 ][ TRKDDLS ]
235 // Meaning of field acronyms:
236 // TRGDDL2816 - Trigger DDL number 2816.
237 // TRGDDL2817 - Trigger DDL number 2817.
238 // TRKDDLS - Tracking DDL flags where bit 0 will be for DDL number 2560,
239 // bit 1 for DDL no. 2561 etc. up to bit 19 which is for DDL 2579.
240 AliHLTUInt32_t bits = 0;
241 for (int i = 0; i < 22; i++)
242 bits |= (ddl[i] ? 0x1 : 0x0) << i;
247 void AliHLTMUONUtils::UnpackSpecBits(
248 AliHLTUInt32_t bits, bool ddl[22]
252 /// This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
253 /// its component fields.
254 /// @param bits The Pub/Sub specification word from a data block descriptor.
255 /// @param ddl The output list of DDLs forming part of the readout. ddl[0]
256 /// indicates DDL number 2560, ddl[1] is for DDL 2561 and so
257 /// on up to ddl[19]. ddl[20] and ddl[21] will be for the
258 /// trigger DDLs 2816 and 2817 respectively.
261 // Perform the inverse operation of PackSpecBits.
262 for (int i = 0; i < 22; i++)
263 ddl[i] = ((bits >> i) & 0x1) == 1;
267 AliHLTInt32_t AliHLTMUONUtils::DDLNumberToEquipId(AliHLTInt32_t ddlNo)
270 /// This method converts the DDL number for the muon spectrometer in the
271 /// range [0..21] to the equipment ID number.
272 /// @param ddlNo The DDL number in the range [0..21].
273 /// @return Returns the equipment ID number or -1 if ddlNo was invalid.
276 if (0 <= ddlNo and ddlNo <= 19)
280 else if (20 <= ddlNo and ddlNo <= 21)
282 return 2816 + (ddlNo - 20);
291 AliHLTInt32_t AliHLTMUONUtils::EquipIdToDDLNumber(AliHLTInt32_t id)
294 /// This method converts the equipment ID number for a muon spectrometer
295 /// DDL to the DDL number in the range [0..21].
296 /// @param id The equipment ID of the DDL.
297 /// @return Returns the DDL number in the range [0..21] or -1 if the
298 /// equipment ID was invalid.
301 if (2560 <= id and id <= 2560+19)
305 else if (2816 <= id and id <= 2817)
307 return id - 2816 + 20;
316 AliHLTInt32_t AliHLTMUONUtils::SpecToEquipId(AliHLTUInt32_t spec)
319 /// This method converts a 32 bit data block specification for a MUON-HLT
320 /// data block into its corresponding DDL equipment ID number.
321 /// It is assumed that the specification is for a data block comming from
322 /// a single DDL source. If more than one DDL contributed to the data block
323 /// then -1 is returned.
324 /// @param spec The 32 bit specification for a data block.
325 /// @return Returns the equipment ID corresponding to the specification
326 /// or -1 if the specification was invalid.
329 for (AliHLTInt32_t ddlNo = 0; ddlNo < 20; ddlNo++)
331 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
334 for (AliHLTInt32_t ddlNo = 20; ddlNo < 22; ddlNo++)
336 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
337 return ddlNo - 20 + 2816;
343 AliHLTUInt32_t AliHLTMUONUtils::EquipIdToSpec(AliHLTInt32_t id)
346 /// This method converts a equipment ID number for a DDL into its corresponding
347 /// 32 bit data block specification for the MUON-HLT.
348 /// @param id The equipment ID number of the DDL.
349 /// @return Returns the 32 bit data block specification or 0x0 if the
350 /// equipment ID was invalid.
353 if (2560 <= id and id <= 2560+19)
355 return 0x1 << (id - 2560);
357 else if (2816 <= id and id <= 2817)
359 return 0x1 << (id - 2816 + 20);
368 AliHLTInt32_t AliHLTMUONUtils::SpecToDDLNumber(AliHLTUInt32_t spec)
371 /// This method converts a 32 bit data block specification for a MUON-HLT
372 /// data block into its corresponding DDL number in the range [0..21].
373 /// It is assumed that the specification is for a data block comming from
374 /// a single DDL source. If more than one DDL contributed to the data block
375 /// then -1 is returned.
376 /// @param spec The 32 bit specification for a data block.
377 /// @return Returns the corresponding DDL number for the specification
378 /// or -1 if the specification was invalid.
381 for (AliHLTInt32_t ddlNo = 0; ddlNo < 22; ddlNo++)
383 if (spec == AliHLTUInt32_t(0x1 << ddlNo))
390 AliHLTUInt32_t AliHLTMUONUtils::DDLNumberToSpec(AliHLTInt32_t ddlNo)
393 /// This method converts a DDL number in the range [0..21] into its
394 /// corresponding 32 bit data block specification for the MUON-HLT.
395 /// @param ddlNo The equipment ID number of the DDL.
396 /// @return Returns the 32 bit data block specification or 0x0 if the
397 /// DDL number was invalid (out of range).
400 if (0 <= ddlNo and ddlNo <= 21)
411 AliHLTMUONDataBlockType AliHLTMUONUtils::ParseCommandLineTypeString(const char* type)
413 /// Parses the string containing the type name of a dHLT data block and
414 /// returns the corresponding AliHLTMUONDataBlockType value.
415 /// \param type The string containing the type name.
416 /// \returns The data block type or kUnknownDataBlock if the type name
419 if (strcmp(type, "trigrecs") == 0)
421 return kTriggerRecordsDataBlock;
423 else if (strcmp(type, "trigrecsdebug") == 0)
425 return kTrigRecsDebugDataBlock;
427 else if (strcmp(type, "rechits") == 0)
429 return kRecHitsDataBlock;
431 else if (strcmp(type,"channels") == 0)
433 return kChannelsDataBlock;
435 else if (strcmp(type,"clusters") == 0)
437 return kClustersDataBlock;
439 else if (strcmp(type, "mansotracks") == 0)
441 return kMansoTracksDataBlock;
443 else if (strcmp(type, "mansocandidates") == 0)
445 return kMansoCandidatesDataBlock;
447 else if (strcmp(type, "singlesdecision") == 0)
449 return kSinglesDecisionDataBlock;
451 else if (strcmp(type, "pairsdecision") == 0)
453 return kPairsDecisionDataBlock;
456 return kUnknownDataBlock;
460 const char* AliHLTMUONUtils::DataBlockTypeToString(AliHLTMUONDataBlockType type)
462 /// Converts a type ID to a type string compatible with
465 static char str[kAliHLTComponentDataTypefIDsize+1];
466 AliHLTComponentDataType t;
469 case kTriggerRecordsDataBlock:
470 t = AliHLTMUONConstants::TriggerRecordsBlockDataType();
472 case kTrigRecsDebugDataBlock:
473 t = AliHLTMUONConstants::TrigRecsDebugBlockDataType();
475 case kRecHitsDataBlock:
476 t = AliHLTMUONConstants::RecHitsBlockDataType();
478 case kClustersDataBlock:
479 t = AliHLTMUONConstants::ClusterBlockDataType();
481 case kChannelsDataBlock:
482 t = AliHLTMUONConstants::ChannelBlockDataType();
484 case kMansoTracksDataBlock:
485 t = AliHLTMUONConstants::MansoTracksBlockDataType();
487 case kMansoCandidatesDataBlock:
488 t = AliHLTMUONConstants::MansoCandidatesBlockDataType();
490 case kSinglesDecisionDataBlock:
491 t = AliHLTMUONConstants::SinglesDecisionBlockDataType();
493 case kPairsDecisionDataBlock:
494 t = AliHLTMUONConstants::PairsDecisionBlockDataType();
499 memcpy(&str, &t.fID, kAliHLTComponentDataTypefIDsize);
500 // Must insert the NULL character to make this an ANSI C string.
501 str[kAliHLTComponentDataTypefIDsize] = '\0';
506 const char* AliHLTMUONUtils::FailureReasonToString(WhyNotValid reason)
508 /// This method converts the WhyNotValid enumeration to a string representation.
512 case kNoReason: return "kNoReason";
513 case kHeaderContainsWrongType: return "kHeaderContainsWrongType";
514 case kHeaderContainsWrongRecordWidth: return "kHeaderContainsWrongRecordWidth";
515 case kInvalidIdValue: return "kInvalidIdValue";
516 case kInvalidTriggerIdValue: return "kInvalidTriggerIdValue";
517 case kInvalidTrackIdValue: return "kInvalidTrackIdValue";
518 case kReservedBitsNotZero: return "kReservedBitsNotZero";
519 case kParticleSignBitsNotValid: return "kParticleSignBitsNotValid";
520 case kHitNotMarkedAsNil: return "kHitNotMarkedAsNil";
521 case kInvalidDetElementNumber: return "kInvalidDetElementNumber";
522 case kInvalidChamberNumber: return "kInvalidChamberNumber";
523 case kHitIsNil: return "kHitIsNil";
524 case kInvalidChannelCount: return "kInvalidChannelCount";
525 case kInvalidBusPatchId: return "kInvalidBusPatchId";
526 case kInvalidManuId: return "kInvalidManuId";
527 case kInvalidChannelAddress: return "kInvalidChannelAddress";
528 case kInvalidSignal: return "kInvalidSignal";
529 case kDataWordDifferent: return "kDataWordDifferent";
530 case kChiSquareInvalid: return "kChiSquareInvalid";
531 case kMomentumVectorNotZero: return "kMomentumVectorNotZero";
532 case kRoiRadiusInvalid: return "kRoiRadiusInvalid";
533 case kHitNotWithinRoi: return "kHitNotWithinRoi";
534 case kPtValueNotValid: return "kPtValueNotValid";
535 case kPairTrackIdsAreIdentical: return "kPairTrackIdsAreIdentical";
536 case kMassValueNotValid: return "kMassValueNotValid";
537 case kLowPtCountInvalid: return "kLowPtCountInvalid";
538 case kHighPtCountInvalid: return "kHighPtCountInvalid";
539 case kFoundDuplicateIDs: return "kFoundDuplicateIDs";
540 case kFoundDuplicateHits: return "kFoundDuplicateHits";
541 case kFoundDuplicateTriggers: return "kFoundDuplicateTriggers";
542 default: return "INVALID";
547 const char* AliHLTMUONUtils::FailureReasonToMessage(WhyNotValid reason)
549 /// This method returns a string containing a user readable message explaining
550 /// the reason for failure described by the WhyNotValid enumeration.
555 return "There was no problem with the data block.";
556 case kHeaderContainsWrongType:
557 return "The common data header contains an incorrect type"
559 case kHeaderContainsWrongRecordWidth:
560 return "The common data header contains an incorrect data"
562 case kInvalidIdValue:
563 return "The structure identifier does not have a valid value.";
564 case kInvalidTriggerIdValue:
565 return "The trigger structure identifier does not have a valid"
567 case kInvalidTrackIdValue:
568 return "The track structure identifier does not have a valid"
570 case kReservedBitsNotZero:
571 return "Reserved bits have not been set to zero.";
572 case kParticleSignBitsNotValid:
573 return "The particle sign bits are not a valid value.";
574 case kHitNotMarkedAsNil:
575 return "A hit was marked as not found, but the corresponding hit"
576 " structure was not set to nil.";
577 case kInvalidDetElementNumber:
578 return "An invalid detector element ID was found.";
579 case kInvalidChamberNumber:
580 return "An invalid chamber number was found.";
582 return "The hit cannot be set to a nil value.";
583 case kInvalidChannelCount:
584 return "The number of channels indicated is zero or outside"
586 case kInvalidBusPatchId:
587 return "The bus patch identifier is outside the valid range.";
589 return "The MANU identifier is outside the valid range.";
590 case kInvalidChannelAddress:
591 return "The MANU channel address is outside the valid range.";
593 return "The ADC signal value is outside the valid range.";
594 case kDataWordDifferent:
595 return "The raw data word is different from the unpacked values.";
596 case kChiSquareInvalid:
597 return "The chi squared value must be a positive value or -1"
598 " indicating a fitting error.";
599 case kMomentumVectorNotZero:
600 return "The chi sqaured value is set to -1 indicating momentum"
601 " was not fitted, but the momentum vector was not zero.";
602 case kRoiRadiusInvalid:
603 return "The region of interest radius is invalid.";
604 case kHitNotWithinRoi:
605 return "A tracks hit is not within the corresponding region"
607 case kPtValueNotValid:
608 return "The pT value is not positive, nor -1 indicating an"
610 case kPairTrackIdsAreIdentical:
611 return "The track identifiers of the track pair are identical.";
612 case kMassValueNotValid:
613 return "The invariant mass value is not positive, nor -1"
614 " indicating an invalid value.";
615 case kLowPtCountInvalid:
616 return "The low pT trigger count is greater than 2,"
617 " which is invalid.";
618 case kHighPtCountInvalid:
619 return "The high pT trigger count is greater than 2,"
620 " which is invalid.";
621 case kFoundDuplicateIDs:
622 return "Found duplicate data record identifiers, but they"
623 " should all be unique.";
624 case kFoundDuplicateHits:
625 return "Found duplicate hit structures, but they should all"
627 case kFoundDuplicateTriggers:
628 return "Found duplicate trigger decisions.";
630 return "UNKNOWN REASON CODE";
635 bool AliHLTMUONUtils::RecordNumberWasSet(WhyNotValid reason)
637 /// Returns true if the \em recordNum in the corresponding IntegrityOk method
638 /// would have been set, if it returned false and a reason was set.
639 /// This helper method makes it easy to test if the \em recordNum parameter
640 /// is filled with a valid value or not.
641 /// \param reason The reason code as returned by the IntegrityOk method.
642 /// \returns true if the \em recordNum parameter was set for the given
647 case kInvalidIdValue:
648 case kInvalidTriggerIdValue:
649 case kInvalidTrackIdValue:
650 case kReservedBitsNotZero:
651 case kParticleSignBitsNotValid:
652 case kHitNotMarkedAsNil:
653 case kInvalidDetElementNumber:
654 case kInvalidChamberNumber:
656 case kInvalidChannelCount:
657 case kInvalidBusPatchId:
659 case kInvalidChannelAddress:
661 case kDataWordDifferent:
662 case kChiSquareInvalid:
663 case kPtValueNotValid:
664 case kPairTrackIdsAreIdentical:
665 case kMassValueNotValid:
666 case kLowPtCountInvalid:
667 case kHighPtCountInvalid:
669 default: return false;
674 bool AliHLTMUONUtils::HeaderOk(
675 const AliHLTMUONTriggerRecordsBlockStruct& block,
676 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
679 /// Method used to check if the header information corresponds to the
680 /// supposed type of the raw dHLT data block.
681 /// [in] \param block The data block to check.
682 /// [out] \param reason If this is not NULL, then it is assumed to point
683 /// to an array of at least 'reasonCount' number of elements. It will
684 /// be filled with the reason codes describing why the header is not
686 /// [in/out] \param reasonCount This should initially specify the size of
687 /// the array pointed to by 'reason'. It will be filled with the number
688 /// of items actually filled into the reason array upon exit from this
690 /// \returns true if there is no problem with the header and false otherwise.
692 AliHLTUInt32_t maxCount = reasonCount;
696 // The block must have the correct type.
697 if (block.fHeader.fType != kTriggerRecordsDataBlock)
699 if (reason != NULL and reasonCount < maxCount)
701 reason[reasonCount] = kHeaderContainsWrongType;
707 // The block's record width must be the correct size.
708 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTriggerRecordStruct))
710 if (reason != NULL and reasonCount < maxCount)
712 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
722 bool AliHLTMUONUtils::HeaderOk(
723 const AliHLTMUONTrigRecsDebugBlockStruct& block,
724 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
727 /// Method used to check if the header information corresponds to the
728 /// supposed type of the raw dHLT data block.
729 /// [in] \param block The data block to check.
730 /// [out] \param reason If this is not NULL, then it is assumed to point
731 /// to an array of at least 'reasonCount' number of elements. It will
732 /// be filled with the reason codes describing why the header is not
734 /// [in/out] \param reasonCount This should initially specify the size of
735 /// the array pointed to by 'reason'. It will be filled with the number
736 /// of items actually filled into the reason array upon exit from this
738 /// \returns true if there is no problem with the header and false otherwise.
740 AliHLTUInt32_t maxCount = reasonCount;
744 // The block must have the correct type.
745 if (block.fHeader.fType != kTrigRecsDebugDataBlock)
747 if (reason != NULL and reasonCount < maxCount)
749 reason[reasonCount] = kHeaderContainsWrongType;
755 // The block's record width must be the correct size.
756 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrigRecInfoStruct))
758 if (reason != NULL and reasonCount < maxCount)
760 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
770 bool AliHLTMUONUtils::HeaderOk(
771 const AliHLTMUONRecHitsBlockStruct& block,
772 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
775 /// Method used to check if the header information corresponds to the
776 /// supposed type of the raw dHLT data block.
777 /// [in] \param block The data block to check.
778 /// [out] \param reason If this is not NULL, then it is assumed to point
779 /// to an array of at least 'reasonCount' number of elements. It will
780 /// be filled with the reason codes describing why the header is not
782 /// [in/out] \param reasonCount This should initially specify the size of
783 /// the array pointed to by 'reason'. It will be filled with the number
784 /// of items actually filled into the reason array upon exit from this
786 /// \returns true if there is no problem with the header and false otherwise.
788 AliHLTUInt32_t maxCount = reasonCount;
792 // The block must have the correct type.
793 if (block.fHeader.fType != kRecHitsDataBlock)
795 if (reason != NULL and reasonCount < maxCount)
797 reason[reasonCount] = kHeaderContainsWrongType;
803 // The block's record width must be the correct size.
804 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONRecHitStruct))
806 if (reason != NULL and reasonCount < maxCount)
808 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
818 bool AliHLTMUONUtils::HeaderOk(
819 const AliHLTMUONClustersBlockStruct& block,
820 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
823 /// Method used to check if the header information corresponds to the
824 /// supposed type of the raw dHLT data block.
825 /// [in] \param block The data block to check.
826 /// [out] \param reason If this is not NULL, then it is assumed to point
827 /// to an array of at least 'reasonCount' number of elements. It will
828 /// be filled with the reason codes describing why the header is not
830 /// [in/out] \param reasonCount This should initially specify the size of
831 /// the array pointed to by 'reason'. It will be filled with the number
832 /// of items actually filled into the reason array upon exit from this
834 /// \returns true if there is no problem with the header and false otherwise.
836 AliHLTUInt32_t maxCount = reasonCount;
840 // The block must have the correct type.
841 if (block.fHeader.fType != kClustersDataBlock)
843 if (reason != NULL and reasonCount < maxCount)
845 reason[reasonCount] = kHeaderContainsWrongType;
851 // The block's record width must be the correct size.
852 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONClusterStruct))
854 if (reason != NULL and reasonCount < maxCount)
856 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
866 bool AliHLTMUONUtils::HeaderOk(
867 const AliHLTMUONChannelsBlockStruct& block,
868 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
871 /// Method used to check if the header information corresponds to the
872 /// supposed type of the raw dHLT data block.
873 /// [in] \param block The data block to check.
874 /// [out] \param reason If this is not NULL, then it is assumed to point
875 /// to an array of at least 'reasonCount' number of elements. It will
876 /// be filled with the reason codes describing why the header is not
878 /// [in/out] \param reasonCount This should initially specify the size of
879 /// the array pointed to by 'reason'. It will be filled with the number
880 /// of items actually filled into the reason array upon exit from this
882 /// \returns true if there is no problem with the header and false otherwise.
884 AliHLTUInt32_t maxCount = reasonCount;
888 // The block must have the correct type.
889 if (block.fHeader.fType != kChannelsDataBlock)
891 if (reason != NULL and reasonCount < maxCount)
893 reason[reasonCount] = kHeaderContainsWrongType;
899 // The block's record width must be the correct size.
900 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONChannelStruct))
902 if (reason != NULL and reasonCount < maxCount)
904 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
914 bool AliHLTMUONUtils::HeaderOk(
915 const AliHLTMUONMansoTracksBlockStruct& block,
916 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
919 /// Method used to check if the header information corresponds to the
920 /// supposed type of the raw dHLT data block.
921 /// [in] \param block The data block to check.
922 /// [out] \param reason If this is not NULL, then it is assumed to point
923 /// to an array of at least 'reasonCount' number of elements. It will
924 /// be filled with the reason codes describing why the header is not
926 /// [in/out] \param reasonCount This should initially specify the size of
927 /// the array pointed to by 'reason'. It will be filled with the number
928 /// of items actually filled into the reason array upon exit from this
930 /// \returns true if there is no problem with the header and false otherwise.
932 AliHLTUInt32_t maxCount = reasonCount;
936 // The block must have the correct type.
937 if (block.fHeader.fType != kMansoTracksDataBlock)
939 if (reason != NULL and reasonCount < maxCount)
941 reason[reasonCount] = kHeaderContainsWrongType;
947 // The block's record width must be the correct size.
948 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoTrackStruct))
950 if (reason != NULL and reasonCount < maxCount)
952 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
962 bool AliHLTMUONUtils::HeaderOk(
963 const AliHLTMUONMansoCandidatesBlockStruct& block,
964 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
967 /// Method used to check if the header information corresponds to the
968 /// supposed type of the raw dHLT data block.
969 /// [in] \param block The data block to check.
970 /// [out] \param reason If this is not NULL, then it is assumed to point
971 /// to an array of at least 'reasonCount' number of elements. It will
972 /// be filled with the reason codes describing why the header is not
974 /// [in/out] \param reasonCount This should initially specify the size of
975 /// the array pointed to by 'reason'. It will be filled with the number
976 /// of items actually filled into the reason array upon exit from this
978 /// \returns true if there is no problem with the header and false otherwise.
980 AliHLTUInt32_t maxCount = reasonCount;
984 // The block must have the correct type.
985 if (block.fHeader.fType != kMansoCandidatesDataBlock)
987 if (reason != NULL and reasonCount < maxCount)
989 reason[reasonCount] = kHeaderContainsWrongType;
995 // The block's record width must be the correct size.
996 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONMansoCandidateStruct))
998 if (reason != NULL and reasonCount < maxCount)
1000 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1010 bool AliHLTMUONUtils::HeaderOk(
1011 const AliHLTMUONSinglesDecisionBlockStruct& block,
1012 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1015 /// Method used to check if the header information corresponds to the
1016 /// supposed type of the raw dHLT data block.
1017 /// [in] \param block The data block to check.
1018 /// [out] \param reason If this is not NULL, then it is assumed to point
1019 /// to an array of at least 'reasonCount' number of elements. It will
1020 /// be filled with the reason codes describing why the header is not
1022 /// [in/out] \param reasonCount This should initially specify the size of
1023 /// the array pointed to by 'reason'. It will be filled with the number
1024 /// of items actually filled into the reason array upon exit from this
1026 /// \returns true if there is no problem with the header and false otherwise.
1028 AliHLTUInt32_t maxCount = reasonCount;
1032 // The block must have the correct type.
1033 if (block.fHeader.fType != kSinglesDecisionDataBlock)
1035 if (reason != NULL and reasonCount < maxCount)
1037 reason[reasonCount] = kHeaderContainsWrongType;
1043 // The block's record width must be the correct size.
1044 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrackDecisionStruct))
1046 if (reason != NULL and reasonCount < maxCount)
1048 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1058 bool AliHLTMUONUtils::HeaderOk(
1059 const AliHLTMUONPairsDecisionBlockStruct& block,
1060 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1063 /// Method used to check if the header information corresponds to the
1064 /// supposed type of the raw dHLT data block.
1065 /// [in] \param block The data block to check.
1066 /// [out] \param reason If this is not NULL, then it is assumed to point
1067 /// to an array of at least 'reasonCount' number of elements. It will
1068 /// be filled with the reason codes describing why the header is not
1070 /// [in/out] \param reasonCount This should initially specify the size of
1071 /// the array pointed to by 'reason'. It will be filled with the number
1072 /// of items actually filled into the reason array upon exit from this
1074 /// \returns true if there is no problem with the header and false otherwise.
1076 AliHLTUInt32_t maxCount = reasonCount;
1080 // The block must have the correct type.
1081 if (block.fHeader.fType != kPairsDecisionDataBlock)
1083 if (reason != NULL and reasonCount < maxCount)
1085 reason[reasonCount] = kHeaderContainsWrongType;
1091 // The block's record width must be the correct size.
1092 if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONPairDecisionStruct))
1094 if (reason != NULL and reasonCount < maxCount)
1096 reason[reasonCount] = kHeaderContainsWrongRecordWidth;
1106 bool AliHLTMUONUtils::IntegrityOk(
1107 const AliHLTMUONTriggerRecordStruct& tr,
1108 WhyNotValid* reason,
1109 AliHLTUInt32_t& reasonCount
1112 /// This method is used to check more extensively if the integrity of the
1113 /// trigger record structure is OK and returns true in that case.
1114 /// [in] \param tr The trigger record structure to check.
1115 /// [out] \param reason If this is not NULL, then it is assumed to point
1116 /// to an array of at least 'reasonCount' number of elements. It will
1117 /// be filled with the reason codes describing why the structure is
1119 /// [in/out] \param reasonCount This should initially specify the size of
1120 /// the array pointed to by 'reason'. It will be filled with the number
1121 /// of items actually filled into the reason array upon exit from this
1123 /// \returns true if there is no problem with the structure and false otherwise.
1125 AliHLTUInt32_t maxCount = reasonCount;
1129 // Check that the ID has a valid value.
1130 if (not (tr.fId >= 0 or tr.fId == -1))
1132 if (reason != NULL and reasonCount < maxCount)
1134 reason[reasonCount] = kInvalidIdValue;
1140 // Make sure that the reserved bits in the fFlags field are set
1142 if ((tr.fFlags & 0x3FFFFFF0) != 0)
1144 if (reason != NULL and reasonCount < maxCount)
1146 reason[reasonCount] = kReservedBitsNotZero;
1152 // Make sure the sign is not invalid.
1153 if ((tr.fFlags & 0xC0000000) == 0xC0000000)
1155 if (reason != NULL and reasonCount < maxCount)
1157 reason[reasonCount] = kParticleSignBitsNotValid;
1163 // Check that fHit[i] is nil if the corresponding bit in the
1164 // flags word is zero.
1165 const AliHLTMUONRecHitStruct& nilhit
1166 = AliHLTMUONConstants::NilRecHitStruct();
1167 if ( ((tr.fFlags & 0x1) == 0 and tr.fHit[0] != nilhit) or
1168 ((tr.fFlags & 0x2) == 0 and tr.fHit[1] != nilhit) or
1169 ((tr.fFlags & 0x4) == 0 and tr.fHit[2] != nilhit) or
1170 ((tr.fFlags & 0x8) == 0 and tr.fHit[3] != nilhit)
1173 if (reason != NULL and reasonCount < maxCount)
1175 reason[reasonCount] = kHitNotMarkedAsNil;
1181 // Check the individual hits
1182 for (int i = 0; i < 4; i++)
1184 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1185 if (not IntegrityOk(tr.fHit[i], reason + reasonCount, filledCount))
1187 reasonCount += filledCount;
1196 bool AliHLTMUONUtils::IntegrityOk(
1197 const AliHLTMUONTriggerRecordsBlockStruct& block,
1198 WhyNotValid* reason,
1199 AliHLTUInt32_t* recordNum,
1200 AliHLTUInt32_t& reasonCount
1203 /// This method is used to check more extensively if the integrity of the
1204 /// dHLT raw internal data block is OK and returns true in that case.
1205 /// [in] \param block The trigger record data block to check.
1206 /// [out] \param reason If this is not NULL, then it is assumed to point
1207 /// to an array of at least 'reasonCount' number of elements. It will
1208 /// be filled with the reason codes describing why the data block is
1210 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1211 /// to an array of at least 'reasonCount' number of elements. It will
1212 /// be filled with the number of the trigger record that had a problem.
1213 /// The value 'recordNum[i]' will only contain a valid value if
1214 /// the corresponding 'reason[i]' contains one of:
1215 /// - kInvalidIdValue
1216 /// - kReservedBitsNotZero
1217 /// - kParticleSignBitsNotValid
1218 /// - kHitNotMarkedAsNil
1219 /// - kInvalidDetElementNumber
1220 /// - kInvalidChamberNumber
1221 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1222 /// was set and is valid or not.
1223 /// [in/out] \param reasonCount This should initially specify the size of
1224 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1225 /// with the number of items actually filled into the arrays upon exit
1226 /// from this method.
1227 /// \returns true if there is no problem with the data and false otherwise.
1229 AliHLTUInt32_t maxCount = reasonCount;
1230 bool result = HeaderOk(block, reason, reasonCount);
1232 const AliHLTMUONTriggerRecordStruct* triggerRecord =
1233 reinterpret_cast<const AliHLTMUONTriggerRecordStruct*>(&block + 1);
1235 // Check if any ID is duplicated.
1236 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1238 AliHLTInt32_t id = triggerRecord[i].fId;
1239 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1241 if (id == triggerRecord[j].fId)
1243 if (reason != NULL and reasonCount < maxCount)
1245 reason[reasonCount] = kFoundDuplicateIDs;
1253 // Check integrity of individual trigger records.
1254 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1256 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1257 if (not IntegrityOk(triggerRecord[i], reason+reasonCount, filledCount))
1259 // reasons filled in IntegrityOk, now we just need to adjust
1260 // reasonCount and fill the recordNum values.
1261 if (recordNum != NULL)
1263 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1264 recordNum[reasonCount + n] = i;
1266 reasonCount += filledCount;
1275 bool AliHLTMUONUtils::IntegrityOk(
1276 const AliHLTMUONTrigRecInfoStruct& trigInfo,
1277 WhyNotValid* reason,
1278 AliHLTUInt32_t& reasonCount
1281 /// This method is used to check more extensively if the integrity of the
1282 /// trigger record debug information structure is OK and returns true in that case.
1283 /// [in] \param trigInfo The trigger record debug information structure to check.
1284 /// [out] \param reason If this is not NULL, then it is assumed to point
1285 /// to an array of at least 'reasonCount' number of elements. It will
1286 /// be filled with the reason codes describing why the structure is not
1288 /// [in/out] \param reasonCount This should initially specify the size of
1289 /// the array pointed to by 'reason'. It will be filled with the number
1290 /// of items actually filled into the reason array upon exit from this
1292 /// \returns true if there is no problem with the structure and false otherwise.
1294 AliHLTUInt32_t maxCount = reasonCount;
1298 // Check that the trigger ID has a valid value.
1299 if (not (trigInfo.fTrigRecId >= 0 or trigInfo.fTrigRecId == -1))
1301 if (reason != NULL and reasonCount < maxCount)
1303 reason[reasonCount] = kInvalidIdValue;
1309 // Check that the fDetElemId[i] numbers are valid.
1310 if ( not ((trigInfo.fDetElemId[0] >= 100 and trigInfo.fDetElemId[0] < 1500)
1311 or trigInfo.fDetElemId[0] == -1)
1312 or not ((trigInfo.fDetElemId[1] >= 100 and trigInfo.fDetElemId[1] < 1500)
1313 or trigInfo.fDetElemId[1] == -1)
1314 or not ((trigInfo.fDetElemId[2] >= 100 and trigInfo.fDetElemId[2] < 1500)
1315 or trigInfo.fDetElemId[2] == -1)
1316 or not ((trigInfo.fDetElemId[3] >= 100 and trigInfo.fDetElemId[3] < 1500)
1317 or trigInfo.fDetElemId[3] == -1)
1320 if (reason != NULL and reasonCount < maxCount)
1322 reason[reasonCount] = kInvalidDetElementNumber;
1332 bool AliHLTMUONUtils::IntegrityOk(
1333 const AliHLTMUONTrigRecsDebugBlockStruct& block,
1334 WhyNotValid* reason,
1335 AliHLTUInt32_t* recordNum,
1336 AliHLTUInt32_t& reasonCount
1339 /// This method is used to check more extensively if the integrity of the
1340 /// dHLT raw internal data block is OK and returns true in that case.
1341 /// [in] \param block The trigger record debugging information data block
1343 /// [out] \param reason If this is not NULL, then it is assumed to point
1344 /// to an array of at least 'reasonCount' number of elements. It will
1345 /// be filled with the reason codes describing why the data block is
1347 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1348 /// to an array of at least 'reasonCount' number of elements. It will
1349 /// be filled with the number of the trigger record debug information
1350 /// structure that had a problem.
1351 /// The value 'recordNum[i]' will only contain a valid value if
1352 /// the corresponding 'reason[i]' contains one of:
1353 /// - kInvalidIdValue
1354 /// - kInvalidDetElementNumber
1355 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1356 /// was set and is valid or not.
1357 /// [in/out] \param reasonCount This should initially specify the size of
1358 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1359 /// with the number of items actually filled into the arrays upon exit
1360 /// from this method.
1361 /// \returns true if there is no problem with the data and false otherwise.
1363 AliHLTUInt32_t maxCount = reasonCount;
1364 bool result = HeaderOk(block, reason, reasonCount);
1366 const AliHLTMUONTrigRecInfoStruct* triggerInfo =
1367 reinterpret_cast<const AliHLTMUONTrigRecInfoStruct*>(&block + 1);
1369 // Check if any trigger debug info structure has duplicated trigger IDs.
1370 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1372 AliHLTInt32_t id = triggerInfo[i].fTrigRecId;
1373 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1375 if (id == triggerInfo[j].fTrigRecId)
1377 if (reason != NULL and reasonCount < maxCount)
1379 reason[reasonCount] = kFoundDuplicateIDs;
1387 // Check integrity of individual trigger records.
1388 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1390 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1391 if (not IntegrityOk(triggerInfo[i], reason+reasonCount, filledCount))
1393 // reasons filled in IntegrityOk, now we just need to adjust
1394 // reasonCount and fill the recordNum values.
1395 if (recordNum != NULL)
1397 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1398 recordNum[reasonCount + n] = i;
1400 reasonCount += filledCount;
1409 bool AliHLTMUONUtils::IntegrityOk(
1410 const AliHLTMUONRecHitStruct& hit,
1411 WhyNotValid* reason,
1412 AliHLTUInt32_t& reasonCount
1415 /// This method is used to check more extensively if the integrity of the
1416 /// reconstructed hit structure is OK and returns true in that case.
1417 /// [in] \param hit The reconstructed hit structure to check.
1418 /// [out] \param reason If this is not NULL, then it is assumed to point
1419 /// to an array of at least 'reasonCount' number of elements. It will
1420 /// be filled with the reason codes describing why the structure is
1422 /// [in/out] \param reasonCount This should initially specify the size of
1423 /// the array pointed to by 'reason'. It will be filled with the number
1424 /// of items actually filled into the reason array upon exit from this
1426 /// \returns true if there is no problem with the structure and false otherwise.
1428 AliHLTUInt32_t maxCount = reasonCount;
1432 // If this is a NIL hit then skip all other checks.
1433 if (hit == AliHLTMUONConstants::NilRecHitStruct())
1438 // Make sure that the reserved bits in the fFlags field are set
1440 if ((hit.fFlags & 0x3FFF0000) != 0)
1442 if (reason != NULL and reasonCount < maxCount)
1444 reason[reasonCount] = kReservedBitsNotZero;
1450 AliHLTUInt32_t detElemId = hit.fFlags & 0x00000FFF;
1451 AliHLTUInt32_t chamber = (hit.fFlags & 0x0000F000) >> 12;
1453 // Make sure the detector element ID number is valid.
1454 if (not (detElemId >= 100 and detElemId < 1500))
1456 if (reason != NULL and reasonCount < maxCount)
1458 reason[reasonCount] = kInvalidDetElementNumber;
1464 // Make sure the chamber number is valid.
1465 if (((detElemId / 100) - 1) != chamber or chamber >= 14)
1467 if (reason != NULL and reasonCount < maxCount)
1469 reason[reasonCount] = kInvalidChamberNumber;
1479 bool AliHLTMUONUtils::IntegrityOk(
1480 const AliHLTMUONRecHitsBlockStruct& block,
1481 WhyNotValid* reason,
1482 AliHLTUInt32_t* recordNum,
1483 AliHLTUInt32_t& reasonCount
1486 /// This method is used to check more extensively if the integrity of the
1487 /// dHLT raw internal hits data block is OK and returns true in that case.
1488 /// [in] \param block The reconstructed hits data block to check.
1489 /// [out] \param reason If this is not NULL, then it is assumed to point
1490 /// to an array of at least 'reasonCount' number of elements. It will
1491 /// be filled with the reason codes describing why the data block is
1493 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1494 /// to an array of at least 'reasonCount' number of elements. It will
1495 /// be filled with the number of the reconstructed hits that had a problem.
1496 /// The value 'recordNum[i]' will only contain a valid value if
1497 /// the corresponding 'reason[i]' contains one of:
1498 /// - kReservedBitsNotZero
1499 /// - kInvalidDetElementNumber
1500 /// - kInvalidChamberNumber
1501 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1502 /// was set and is valid or not.
1503 /// [in/out] \param reasonCount This should initially specify the size of
1504 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1505 /// with the number of items actually filled into the arrays upon exit
1506 /// from this method.
1507 /// \returns true if there is no problem with the data and false otherwise.
1509 AliHLTUInt32_t maxCount = reasonCount;
1510 bool result = HeaderOk(block, reason, reasonCount);
1512 const AliHLTMUONRecHitStruct* hit =
1513 reinterpret_cast<const AliHLTMUONRecHitStruct*>(&block + 1);
1515 // Check if any hit structure has been duplicated.
1516 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1518 const AliHLTMUONRecHitStruct& h = hit[i];
1519 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1523 if (reason != NULL and reasonCount < maxCount)
1525 reason[reasonCount] = kFoundDuplicateHits;
1533 // Check integrity of the individual hit structures.
1534 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1536 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1537 if (not IntegrityOk(hit[i], reason+reasonCount, filledCount))
1539 // reasons filled in IntegrityOk, now we just need to adjust
1540 // reasonCount and fill the recordNum values.
1541 if (recordNum != NULL)
1543 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1544 recordNum[reasonCount + n] = i;
1546 reasonCount += filledCount;
1555 bool AliHLTMUONUtils::IntegrityOk(
1556 const AliHLTMUONClusterStruct& cluster,
1557 WhyNotValid* reason,
1558 AliHLTUInt32_t& reasonCount
1561 /// This method is used to check more extensively if the integrity of the
1562 /// cluster structure is OK and returns true in that case.
1563 /// [in] \param cluster The cluster structure to check.
1564 /// [out] \param reason If this is not NULL, then it is assumed to point
1565 /// to an array of at least 'reasonCount' number of elements. It will
1566 /// be filled with the reason codes describing why the structure is
1568 /// [in/out] \param reasonCount This should initially specify the size of
1569 /// the array pointed to by 'reason'. It will be filled with the number
1570 /// of items actually filled into the reason array upon exit from this
1572 /// \returns true if there is no problem with the structure and false otherwise.
1574 AliHLTUInt32_t maxCount = reasonCount;
1578 // Check that the cluster ID has a valid value.
1579 if (not (cluster.fId >= 0 or cluster.fId == -1))
1581 if (reason != NULL and reasonCount < maxCount)
1583 reason[reasonCount] = kInvalidIdValue;
1589 // Check that the cluster does not have a nil value for its hit.
1590 if (cluster.fHit == AliHLTMUONConstants::NilRecHitStruct())
1592 if (reason != NULL and reasonCount < maxCount)
1594 reason[reasonCount] = kHitIsNil;
1600 // Make sure the detector element is a valid value.
1601 if (not ((cluster.fDetElemId >= 100 and cluster.fDetElemId < 1500)
1602 or cluster.fDetElemId == -1)
1605 if (reason != NULL and reasonCount < maxCount)
1607 reason[reasonCount] = kInvalidDetElementNumber;
1613 // The number of channels should be in a reasonable range.
1614 // between 1 and the maximum number of channels per DDL.
1615 // 1<<17 taken from the 11 bits MANU ID + 6 bits channel address.
1616 if (cluster.fNchannels < 1 or (1<<17) < cluster.fNchannels)
1618 if (reason != NULL and reasonCount < maxCount)
1620 reason[reasonCount] = kInvalidChannelCount;
1630 bool AliHLTMUONUtils::IntegrityOk(
1631 const AliHLTMUONClustersBlockStruct& block,
1632 WhyNotValid* reason,
1633 AliHLTUInt32_t* recordNum,
1634 AliHLTUInt32_t& reasonCount
1637 /// This method is used to check more extensively if the integrity of the
1638 /// dHLT internal clusters data block is OK and returns true in that case.
1639 /// [in] \param block The clusters data block to check.
1640 /// [out] \param reason If this is not NULL, then it is assumed to point
1641 /// to an array of at least 'reasonCount' number of elements. It will
1642 /// be filled with the reason codes describing why the data block is
1644 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1645 /// to an array of at least 'reasonCount' number of elements. It will
1646 /// be filled with the number of the cluster structure that had a problem.
1647 /// The value 'recordNum[i]' will only contain a valid value if
1648 /// the corresponding 'reason[i]' contains one of:
1649 /// - kInvalidIdValue
1651 /// - kInvalidDetElementNumber
1652 /// - kInvalidChannelCount
1653 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1654 /// was set and is valid or not.
1655 /// [in/out] \param reasonCount This should initially specify the size of
1656 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1657 /// with the number of items actually filled into the arrays upon exit
1658 /// from this method.
1659 /// \returns true if there is no problem with the data and false otherwise.
1661 AliHLTUInt32_t maxCount = reasonCount;
1662 bool result = HeaderOk(block, reason, reasonCount);
1664 const AliHLTMUONClusterStruct* cluster =
1665 reinterpret_cast<const AliHLTMUONClusterStruct*>(&block + 1);
1667 // Check if any ID is duplicated.
1668 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1670 AliHLTInt32_t id = cluster[i].fId;
1671 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1673 if (id == cluster[j].fId)
1675 if (reason != NULL and reasonCount < maxCount)
1677 reason[reasonCount] = kFoundDuplicateIDs;
1685 // Check if any hit structure has been duplicated.
1686 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1688 const AliHLTMUONRecHitStruct& h = cluster[i].fHit;
1689 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1691 if (h == cluster[j].fHit)
1693 if (reason != NULL and reasonCount < maxCount)
1695 reason[reasonCount] = kFoundDuplicateHits;
1703 // Check integrity of individual cluster structures.
1704 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1706 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1707 if (not IntegrityOk(cluster[i], reason+reasonCount, filledCount))
1709 // reasons filled in IntegrityOk, now we just need to adjust
1710 // reasonCount and fill the recordNum values.
1711 if (recordNum != NULL)
1713 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1714 recordNum[reasonCount + n] = i;
1716 reasonCount += filledCount;
1725 bool AliHLTMUONUtils::IntegrityOk(
1726 const AliHLTMUONChannelStruct& channel,
1727 WhyNotValid* reason,
1728 AliHLTUInt32_t& reasonCount
1731 /// This method is used to check more extensively if the integrity of the
1732 /// channel structure is OK and returns true in that case.
1733 /// [in] \param cluster The channel structure to check.
1734 /// [out] \param reason If this is not NULL, then it is assumed to point
1735 /// to an array of at least 'reasonCount' number of elements. It will
1736 /// be filled with the reason codes describing why the structure is
1738 /// [in/out] \param reasonCount This should initially specify the size of
1739 /// the array pointed to by 'reason'. It will be filled with the number
1740 /// of items actually filled into the reason array upon exit from this
1742 /// \returns true if there is no problem with the structure and false otherwise.
1744 AliHLTUInt32_t maxCount = reasonCount;
1748 // Check that the channel ID has a valid value.
1749 if (not (channel.fClusterId >= 0 or channel.fClusterId == -1))
1751 if (reason != NULL and reasonCount < maxCount)
1753 reason[reasonCount] = kInvalidIdValue;
1759 // Check that the bus patch ID has a valid value, which fits into 12 bits.
1760 if ((channel.fBusPatch & (~0xFFF)) != 0)
1762 if (reason != NULL and reasonCount < maxCount)
1764 reason[reasonCount] = kInvalidBusPatchId;
1770 // Check that the MANU ID has a valid value, which fits into 11 bits.
1771 if ((channel.fManu & (~0x7FF)) != 0)
1773 if (reason != NULL and reasonCount < maxCount)
1775 reason[reasonCount] = kInvalidManuId;
1781 // Check that the channel address has a valid value, which fits into 6 bits.
1782 if ((channel.fChannelAddress & (~0x3F)) != 0)
1784 if (reason != NULL and reasonCount < maxCount)
1786 reason[reasonCount] = kInvalidChannelAddress;
1792 // Check that the ADC signal has a valid value, which fits into 12 bits.
1793 if ((channel.fSignal & (~0xFFF)) != 0)
1795 if (reason != NULL and reasonCount < maxCount)
1797 reason[reasonCount] = kInvalidSignal;
1803 // Check that the raw data word corresponds to the unpacked values for
1804 // the ADC signal, MANU ID and channel address.
1805 UShort_t manuId; UChar_t channelId; UShort_t adc;
1806 AliMUONTrackerDDLDecoderEventHandler::UnpackADC(
1807 channel.fRawDataWord, manuId, channelId, adc
1809 if (manuId != channel.fManu or channelId != channel.fChannelAddress
1810 or adc != channel.fSignal
1813 if (reason != NULL and reasonCount < maxCount)
1815 reason[reasonCount] = kDataWordDifferent;
1825 bool AliHLTMUONUtils::IntegrityOk(
1826 const AliHLTMUONChannelsBlockStruct& block,
1827 WhyNotValid* reason,
1828 AliHLTUInt32_t* recordNum,
1829 AliHLTUInt32_t& reasonCount
1832 /// This method is used to check more extensively if the integrity of the
1833 /// dHLT internal channels data block is OK and returns true in that case.
1834 /// [in] \param block The channels data block to check.
1835 /// [out] \param reason If this is not NULL, then it is assumed to point
1836 /// to an array of at least 'reasonCount' number of elements. It will
1837 /// be filled with the reason codes describing why the data block is
1839 /// [out] \param recordNum If this is not NULL, then it is assumed to point
1840 /// to an array of at least 'reasonCount' number of elements. It will
1841 /// be filled with the number of the channel structure that had a problem.
1842 /// The value 'recordNum[i]' will only contain a valid value if
1843 /// the corresponding 'reason[i]' contains one of:
1844 /// - kInvalidIdValue
1845 /// - kInvalidBusPatchId
1846 /// - kInvalidManuId
1847 /// - kInvalidChannelAddress
1848 /// - kInvalidSignal
1849 /// - kDataWordDifferent
1850 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
1851 /// was set and is valid or not.
1852 /// [in/out] \param reasonCount This should initially specify the size of
1853 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
1854 /// with the number of items actually filled into the arrays upon exit
1855 /// from this method.
1856 /// \returns true if there is no problem with the data and false otherwise.
1858 AliHLTUInt32_t maxCount = reasonCount;
1859 bool result = HeaderOk(block, reason, reasonCount);
1861 const AliHLTMUONChannelStruct* channel =
1862 reinterpret_cast<const AliHLTMUONChannelStruct*>(&block + 1);
1864 // Check if any cluster ID is duplicated.
1865 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1867 AliHLTInt32_t id = channel[i].fClusterId;
1868 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
1870 if (id == channel[j].fClusterId)
1872 if (reason != NULL and reasonCount < maxCount)
1874 reason[reasonCount] = kFoundDuplicateIDs;
1882 // Check integrity of individual channel structures.
1883 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
1885 AliHLTUInt32_t filledCount = maxCount - reasonCount;
1886 if (not IntegrityOk(channel[i], reason+reasonCount, filledCount))
1888 // reasons filled in IntegrityOk, now we just need to adjust
1889 // reasonCount and fill the recordNum values.
1890 if (recordNum != NULL)
1892 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
1893 recordNum[reasonCount + n] = i;
1895 reasonCount += filledCount;
1904 bool AliHLTMUONUtils::IntegrityOk(
1905 const AliHLTMUONMansoTrackStruct& track,
1906 WhyNotValid* reason,
1907 AliHLTUInt32_t& reasonCount
1910 /// This method is used to check more extensively if the integrity of the
1911 /// Manso track structure is OK and returns true in that case.
1912 /// [in] \param track The track structure to check.
1913 /// [out] \param reason If this is not NULL, then it is assumed to point
1914 /// to an array of at least 'reasonCount' number of elements. It will
1915 /// be filled with the reason codes describing why the structure is
1917 /// [in/out] \param reasonCount This should initially specify the size of
1918 /// the array pointed to by 'reason'. It will be filled with the number
1919 /// of items actually filled into the reason array upon exit from this
1921 /// \returns true if there is no problem with the structure and false otherwise.
1923 AliHLTUInt32_t maxCount = reasonCount;
1927 // Check that the Manso track ID has a valid value.
1928 if (not (track.fId >= 0 or track.fId == -1))
1930 if (reason != NULL and reasonCount < maxCount)
1932 reason[reasonCount] = kInvalidIdValue;
1938 // Check that the corresponding trigger record ID has a valid value.
1939 if (not (track.fTrigRec >= 0 or track.fTrigRec == -1))
1941 if (reason != NULL and reasonCount < maxCount)
1943 reason[reasonCount] = kInvalidTriggerIdValue;
1949 // Make sure that the reserved bits in the fFlags field are set
1951 if ((track.fFlags & 0x3FFFFFF0) != 0)
1953 if (reason != NULL and reasonCount < maxCount)
1955 reason[reasonCount] = kReservedBitsNotZero;
1961 // Make sure the sign is not invalid.
1962 if ((track.fFlags & 0xC0000000) == 0xC0000000)
1964 if (reason != NULL and reasonCount < maxCount)
1966 reason[reasonCount] = kParticleSignBitsNotValid;
1972 // Check that fHit[i] is nil if the corresponding bit in the
1973 // flags word is zero.
1974 const AliHLTMUONRecHitStruct& nilhit
1975 = AliHLTMUONConstants::NilRecHitStruct();
1976 if ( ((track.fFlags & 0x1) == 0 and track.fHit[0] != nilhit) or
1977 ((track.fFlags & 0x2) == 0 and track.fHit[1] != nilhit) or
1978 ((track.fFlags & 0x4) == 0 and track.fHit[2] != nilhit) or
1979 ((track.fFlags & 0x8) == 0 and track.fHit[3] != nilhit)
1982 if (reason != NULL and reasonCount < maxCount)
1984 reason[reasonCount] = kHitNotMarkedAsNil;
1990 // Check that the chi squared value is valid
1991 if (not (track.fChi2 >= 0 or track.fChi2 == -1))
1993 if (reason != NULL and reasonCount < maxCount)
1995 reason[reasonCount] = kChiSquareInvalid;
2001 // Check that if chi squared is -1 then the momentum vector is zero.
2002 if (track.fChi2 == -1 and
2003 not (track.fPx == 0 and track.fPy == 0 and track.fPz == 0)
2006 if (reason != NULL and reasonCount < maxCount)
2008 reason[reasonCount] = kMomentumVectorNotZero;
2014 // Check the individual hits
2015 for (int i = 0; i < 4; i++)
2017 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2018 if (not IntegrityOk(track.fHit[i], reason + reasonCount, filledCount))
2020 reasonCount += filledCount;
2029 bool AliHLTMUONUtils::IntegrityOk(
2030 const AliHLTMUONMansoTracksBlockStruct& block,
2031 WhyNotValid* reason,
2032 AliHLTUInt32_t* recordNum,
2033 AliHLTUInt32_t& reasonCount
2036 /// This method is used to check more extensively if the integrity of the
2037 /// dHLT internal Manso track data block is OK and returns true in that case.
2038 /// [in] \param block The Manso track data block to check.
2039 /// [out] \param reason If this is not NULL, then it is assumed to point
2040 /// to an array of at least 'reasonCount' number of elements. It will
2041 /// be filled with the reason codes describing why the data block is
2043 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2044 /// to an array of at least 'reasonCount' number of elements. It will
2045 /// be filled with the number of the Manso track that had a problem.
2046 /// The value 'recordNum[i]' will only contain a valid value if
2047 /// the corresponding 'reason[i]' contains one of:
2048 /// - kInvalidIdValue
2049 /// - kInvalidTriggerIdValue
2050 /// - kReservedBitsNotZero
2051 /// - kParticleSignBitsNotValid
2052 /// - kHitNotMarkedAsNil
2053 /// - kChiSquareInvalid
2054 /// - kMomentumVectorNotZero
2055 /// - kInvalidDetElementNumber
2056 /// - kInvalidChamberNumber
2057 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2058 /// was set and is valid or not.
2059 /// [in/out] \param reasonCount This should initially specify the size of
2060 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2061 /// with the number of items actually filled into the arrays upon exit
2062 /// from this method.
2063 /// \returns true if there is no problem with the data and false otherwise.
2065 AliHLTUInt32_t maxCount = reasonCount;
2066 bool result = HeaderOk(block, reason, reasonCount);
2068 const AliHLTMUONMansoTrackStruct* track =
2069 reinterpret_cast<const AliHLTMUONMansoTrackStruct*>(&block + 1);
2071 // Check if any track ID is duplicated.
2072 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2074 AliHLTInt32_t id = track[i].fId;
2075 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2077 if (id == track[j].fId)
2079 if (reason != NULL and reasonCount < maxCount)
2081 reason[reasonCount] = kFoundDuplicateIDs;
2089 // Check that all the tracks have integrity.
2090 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2092 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2093 if (not IntegrityOk(track[i], reason+reasonCount, filledCount))
2095 // reasons filled in IntegrityOk, now we just need to adjust
2096 // reasonCount and fill the recordNum values.
2097 if (recordNum != NULL)
2099 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2100 recordNum[reasonCount + n] = i;
2102 reasonCount += filledCount;
2111 bool AliHLTMUONUtils::IntegrityOk(
2112 const AliHLTMUONMansoCandidateStruct& candidate,
2113 WhyNotValid* reason,
2114 AliHLTUInt32_t& reasonCount
2117 /// This method is used to check more extensively if the integrity of the
2118 /// Manso track candidate structure is OK and returns true in that case.
2119 /// [in] \param track The track candidate structure to check.
2120 /// [out] \param reason If this is not NULL, then it is assumed to point
2121 /// to an array of at least 'reasonCount' number of elements. It will
2122 /// be filled with the reason codes describing why the structure is
2124 /// [in/out] \param reasonCount This should initially specify the size of
2125 /// the array pointed to by 'reason'. It will be filled with the number
2126 /// of items actually filled into the reason array upon exit from this
2128 /// \returns true if there is no problem with the structure and false otherwise.
2130 // First check the integrity of the candidate track structure.
2131 AliHLTUInt32_t maxCount = reasonCount;
2132 bool result = IntegrityOk(candidate.fTrack, reason, reasonCount);
2134 // Now check that the ROIs are reasonable.
2135 // The radius must be positive or -1 indicating computation error and
2136 // the corresponding hit in the track must be within the ROI.
2137 for (AliHLTUInt32_t i = 0; i < 4; i++)
2139 if (not (candidate.fRoI[i].fRadius >= 0 or candidate.fRoI[i].fRadius == -1))
2141 if (reason != NULL and reasonCount < maxCount)
2143 reason[reasonCount] = kRoiRadiusInvalid;
2149 // Check if the corresponding hit was even found in the track.
2150 if ( (candidate.fTrack.fFlags & (0x1 << i)) == 0 ) continue;
2152 double dx = candidate.fRoI[i].fX - candidate.fTrack.fHit[i].fX;
2153 double dy = candidate.fRoI[i].fY - candidate.fTrack.fHit[i].fY;
2154 double dz = candidate.fRoI[i].fZ - candidate.fTrack.fHit[i].fZ;
2155 double r = sqrt(dx*dx + dy*dy);
2156 // Check if the projected distance between ROI centre and hit is
2157 // bigger than the ROI radius. Also the difference between z
2158 // coordinates should not exceed 20 cm.
2159 if (r > candidate.fRoI[i].fRadius or fabs(dz) > 20.)
2161 if (reason != NULL and reasonCount < maxCount)
2163 reason[reasonCount] = kHitNotWithinRoi;
2174 bool AliHLTMUONUtils::IntegrityOk(
2175 const AliHLTMUONMansoCandidatesBlockStruct& block,
2176 WhyNotValid* reason,
2177 AliHLTUInt32_t* recordNum,
2178 AliHLTUInt32_t& reasonCount
2181 /// This method is used to check more extensively if the integrity of the
2182 /// dHLT internal Manso candidates data block is OK and returns true in
2184 /// [in] \param block The Manso track candidate data block to check.
2185 /// [out] \param reason If this is not NULL, then it is assumed to point
2186 /// to an array of at least 'reasonCount' number of elements. It will
2187 /// be filled with the reason codes describing why the data block is
2189 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2190 /// to an array of at least 'reasonCount' number of elements. It will
2191 /// be filled with the number of the track candidate that had a problem.
2192 /// The value 'recordNum[i]' will only contain a valid value if
2193 /// the corresponding 'reason[i]' contains one of:
2194 /// - kInvalidIdValue
2195 /// - kInvalidTriggerIdValue
2196 /// - kReservedBitsNotZero
2197 /// - kParticleSignBitsNotValid
2198 /// - kHitNotMarkedAsNil
2199 /// - kChiSquareInvalid
2200 /// - kRoiRadiusInvalid
2201 /// - kHitNotWithinRoi
2202 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2203 /// was set and is valid or not.
2204 /// [in/out] \param reasonCount This should initially specify the size of
2205 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2206 /// with the number of items actually filled into the arrays upon exit
2207 /// from this method.
2208 /// \returns true if there is no problem with the data and false otherwise.
2210 AliHLTUInt32_t maxCount = reasonCount;
2211 bool result = HeaderOk(block, reason, reasonCount);
2213 const AliHLTMUONMansoCandidateStruct* candidate =
2214 reinterpret_cast<const AliHLTMUONMansoCandidateStruct*>(&block + 1);
2216 // Check if any candidate track ID is duplicated.
2217 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2219 AliHLTInt32_t id = candidate[i].fTrack.fId;
2220 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2222 if (id == candidate[j].fTrack.fId)
2224 if (reason != NULL and reasonCount < maxCount)
2226 reason[reasonCount] = kFoundDuplicateIDs;
2234 // Check that all the track candidates have integrity.
2235 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2237 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2238 if (not IntegrityOk(candidate[i], reason+reasonCount, filledCount))
2240 // reasons filled in IntegrityOk, now we just need to adjust
2241 // reasonCount and fill the recordNum values.
2242 if (recordNum != NULL)
2244 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2245 recordNum[reasonCount + n] = i;
2247 reasonCount += filledCount;
2256 bool AliHLTMUONUtils::IntegrityOk(
2257 const AliHLTMUONTrackDecisionStruct& decision,
2258 WhyNotValid* reason,
2259 AliHLTUInt32_t& reasonCount
2262 /// This method is used to check more extensively if the integrity of the
2263 /// single track trigger decision structure is OK and returns true in that case.
2264 /// [in] \param decision The trigger decision structure to check.
2265 /// [out] \param reason If this is not NULL, then it is assumed to point
2266 /// to an array of at least 'reasonCount' number of elements. It will
2267 /// be filled with the reason codes describing why the structure is not
2269 /// [in/out] \param reasonCount This should initially specify the size of
2270 /// the array pointed to by 'reason'. It will be filled with the number
2271 /// of items actually filled into the reason array upon exit from this
2273 /// \returns true if there is no problem with the structure and false otherwise.
2275 AliHLTUInt32_t maxCount = reasonCount;
2279 // The track ID value must be positive or -1.
2280 if (not (decision.fTrackId >= 0 or decision.fTrackId == -1))
2282 if (reason != NULL and reasonCount < maxCount)
2284 reason[reasonCount] = kInvalidTrackIdValue;
2290 // Make sure that the reserved bits in the fTriggerBits field are set
2292 if ((decision.fTriggerBits & 0xFFFFFFFC) != 0)
2294 if (reason != NULL and reasonCount < maxCount)
2296 reason[reasonCount] = kReservedBitsNotZero;
2302 // The pT should be -1 or a positive number.
2303 if (decision.fPt != -1. and decision.fPt < 0.)
2305 if (reason != NULL and reasonCount < maxCount)
2307 reason[reasonCount] = kPtValueNotValid;
2317 bool AliHLTMUONUtils::IntegrityOk(
2318 const AliHLTMUONSinglesDecisionBlockStruct& block,
2319 WhyNotValid* reason,
2320 AliHLTUInt32_t* recordNum,
2321 AliHLTUInt32_t& reasonCount
2324 /// This method is used to check more extensively if the integrity of the
2325 /// dHLT internal single track trigger decision data block is OK and returns
2326 /// true in that case.
2327 /// [in] \param block The single track trigger decision data block to check.
2328 /// [out] \param reason If this is not NULL, then it is assumed to point
2329 /// to an array of at least 'reasonCount' number of elements. It will
2330 /// be filled with the reason codes describing why the data block is
2332 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2333 /// to an array of at least 'reasonCount' number of elements. It will
2334 /// be filled with the number of the trigger decision that had a problem.
2335 /// The value 'recordNum[i]' will only contain a valid value if
2336 /// the corresponding 'reason[i]' contains one of:
2337 /// - kInvalidTrackIdValue
2338 /// - kReservedBitsNotZero
2339 /// - kPtValueNotValid
2340 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2341 /// was set and is valid or not.
2342 /// [in/out] \param reasonCount This should initially specify the size of
2343 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2344 /// with the number of items actually filled into the arrays upon exit
2345 /// from this method.
2346 /// \returns true if there is no problem with the data and false otherwise.
2348 AliHLTUInt32_t maxCount = reasonCount;
2349 bool result = HeaderOk(block, reason, reasonCount);
2351 const AliHLTMUONTrackDecisionStruct* decision =
2352 reinterpret_cast<const AliHLTMUONTrackDecisionStruct*>(&block + 1);
2354 // Check that there are no duplicate trigger entries.
2355 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2357 AliHLTInt32_t id = decision[i].fTrackId;
2358 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2360 if (id == decision[j].fTrackId)
2362 if (reason != NULL and reasonCount < maxCount)
2364 reason[reasonCount] = kFoundDuplicateTriggers;
2372 // Check that the trigger bits for each track have integrity.
2373 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2375 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2376 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2378 // Reasons filled in IntegrityOk, now we just need to adjust
2379 // reasonCount and fill the recordNum values.
2380 if (recordNum != NULL)
2382 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2383 recordNum[reasonCount + n] = i;
2385 reasonCount += filledCount;
2394 bool AliHLTMUONUtils::IntegrityOk(
2395 const AliHLTMUONPairDecisionStruct& decision,
2396 WhyNotValid* reason,
2397 AliHLTUInt32_t& reasonCount
2400 /// This method is used to check more extensively if the integrity of the
2401 /// track pair trigger decision structure is OK and returns true in that case.
2402 /// [in] \param decision The trigger decision structure to check.
2403 /// [out] \param reason If this is not NULL, then it is assumed to point
2404 /// to an array of at least 'reasonCount' number of elements. It will
2405 /// be filled with the reason codes describing why the structure is not
2407 /// [in/out] \param reasonCount This should initially specify the size of
2408 /// the array pointed to by 'reason'. It will be filled with the number
2409 /// of items actually filled into the reason array upon exit from this
2411 /// \returns true if there is no problem with the structure and false otherwise.
2413 AliHLTUInt32_t maxCount = reasonCount;
2417 //kInvalidTrackIdValue
2419 // The track IDs must have a positive value or -1.
2420 if (not (decision.fTrackAId >= 0 or decision.fTrackAId == -1) or
2421 not (decision.fTrackBId >= 0 or decision.fTrackBId == -1)
2424 if (reason != NULL and reasonCount < maxCount)
2426 reason[reasonCount] = kInvalidTrackIdValue;
2432 // Make sure that the reserved bits in the fTriggerBits field are set
2434 if ((decision.fTriggerBits & 0xFFFFFF80) != 0)
2436 if (reason != NULL and reasonCount < maxCount)
2438 reason[reasonCount] = kReservedBitsNotZero;
2444 // Check that the track IDs are not the same.
2445 if (decision.fTrackAId == decision.fTrackBId)
2447 if (reason != NULL and reasonCount < maxCount)
2449 reason[reasonCount] = kPairTrackIdsAreIdentical;
2455 // The invariant mass should be -1 or a positive number.
2456 if (decision.fInvMass != -1. and decision.fInvMass < 0.)
2458 if (reason != NULL and reasonCount < maxCount)
2460 reason[reasonCount] = kMassValueNotValid;
2466 // Neither the high pt (hipt) or low pt (lopt) count bits can be > 2.
2467 AliHLTUInt8_t lowPtCount = (decision.fTriggerBits & 0x00000003);
2468 AliHLTUInt8_t highPtCount = (decision.fTriggerBits & 0x0000000C) >> 2;
2471 if (reason != NULL and reasonCount < maxCount)
2473 reason[reasonCount] = kLowPtCountInvalid;
2478 if (highPtCount > 2)
2480 if (reason != NULL and reasonCount < maxCount)
2482 reason[reasonCount] = kHighPtCountInvalid;
2492 bool AliHLTMUONUtils::IntegrityOk(
2493 const AliHLTMUONPairsDecisionBlockStruct& block,
2494 WhyNotValid* reason,
2495 AliHLTUInt32_t* recordNum,
2496 AliHLTUInt32_t& reasonCount
2499 /// This method is used to check more extensively if the integrity of the
2500 /// dHLT internal track pair trigger decision data block is OK and returns
2501 /// true in that case.
2502 /// [in] \param block The track pair trigger decision data block to check.
2503 /// [out] \param reason If this is not NULL, then it is assumed to point
2504 /// to an array of at least 'reasonCount' number of elements. It will
2505 /// be filled with the reason codes describing why the data block is
2507 /// [out] \param recordNum If this is not NULL, then it is assumed to point
2508 /// to an array of at least 'reasonCount' number of elements. It will
2509 /// be filled with the number of the trigger decision that had a problem.
2510 /// The value 'recordNum[i]' will only contain a valid value if
2511 /// the corresponding 'reason[i]' contains one of:
2512 /// - kInvalidTrackIdValue
2513 /// - kReservedBitsNotZero
2514 /// - kPairTrackIdsAreIdentical
2515 /// - kMassValueNotValid
2516 /// - kLowPtCountInvalid
2517 /// - kHighPtCountInvalid
2518 /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
2519 /// was set and is valid or not.
2520 /// [in/out] \param reasonCount This should initially specify the size of
2521 /// the array pointed to by 'reason' and 'recordNum'. It will be filled
2522 /// with the number of items actually filled into the arrays upon exit
2523 /// from this method.
2524 /// \returns true if there is no problem with the data and false otherwise.
2526 AliHLTUInt32_t maxCount = reasonCount;
2527 bool result = HeaderOk(block, reason, reasonCount);
2529 const AliHLTMUONPairDecisionStruct* decision =
2530 reinterpret_cast<const AliHLTMUONPairDecisionStruct*>(&block + 1);
2532 // Check that there are no duplicate trigger entries.
2533 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2535 AliHLTInt32_t ta = decision[i].fTrackAId;
2536 AliHLTInt32_t tb = decision[i].fTrackBId;
2537 for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
2539 if (ta == decision[j].fTrackAId and tb == decision[j].fTrackBId)
2541 if (reason != NULL and reasonCount < maxCount)
2543 reason[reasonCount] = kFoundDuplicateTriggers;
2551 // Check that the trigger bits for each track pair have integrity.
2552 for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
2554 AliHLTUInt32_t filledCount = maxCount - reasonCount;
2555 if (not IntegrityOk(decision[i], reason+reasonCount, filledCount))
2557 // Reasons filled in IntegrityOk, now we just need to adjust
2558 // reasonCount and fill the recordNum values.
2559 if (recordNum != NULL)
2561 for (AliHLTUInt32_t n = 0; n < filledCount; n++)
2562 recordNum[reasonCount + n] = i;
2564 reasonCount += filledCount;