1 #ifndef ALIHLTMUONUTILS_H
2 #define ALIHLTMUONUTILS_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
9 /// @file AliHLTMUONUtils.h
10 /// @author Artur Szostak <artursz@iafrica.com>
12 /// @brief Class containing various dimuon HLT utility routines and macros.
16 #include "AliHLTMUONDataTypes.h"
19 // Forward declare structures.
21 struct AliHLTMUONTriggerRecordStruct;
22 struct AliHLTMUONTriggerRecordsBlockStruct;
23 struct AliHLTMUONTrigRecInfoStruct;
24 struct AliHLTMUONTrigRecsDebugBlockStruct;
25 struct AliHLTMUONRecHitStruct;
26 struct AliHLTMUONRecHitsBlockStruct;
27 struct AliHLTMUONClusterStruct;
28 struct AliHLTMUONClustersBlockStruct;
29 struct AliHLTMUONChannelStruct;
30 struct AliHLTMUONChannelsBlockStruct;
31 struct AliHLTMUONMansoTrackStruct;
32 struct AliHLTMUONMansoTracksBlockStruct;
33 struct AliHLTMUONMansoCandidateStruct;
34 struct AliHLTMUONMansoCandidatesBlockStruct;
35 struct AliHLTMUONTrackStruct;
36 struct AliHLTMUONTracksBlockStruct;
37 struct AliHLTMUONTrackDecisionStruct;
38 struct AliHLTMUONSinglesDecisionBlockStruct;
39 struct AliHLTMUONPairDecisionStruct;
40 struct AliHLTMUONPairsDecisionBlockStruct;
44 * AliHLTMUONUtils contains arbitrary utility methods to be used in various
45 * parts of the dimuon HLT system.
46 * These include methods to perform basic sanity checks on the integrity of
53 * This packs the given parameters into the bits of a word appropriate
54 * for AliHLTMUONTriggerRecordStruct::fFlags.
55 * @param sign The particle sign.
56 * @param hitset Flags to indicate if the corresponding fHits[i] elements
58 * @return Returns the 32 bit packed word.
60 static AliHLTUInt32_t PackTriggerRecordFlags(
61 AliHLTMUONParticleSign sign, const bool hitset[4]
65 * This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
66 * its component fields.
67 * @param [in] flags The flags from an AliHLTMUONTriggerRecordStruct structure.
68 * @param [out] sign Sets this to the particle sign.
69 * @param [out] hitset Sets the array elements to indicate if the corresponding
70 * fHits[i] element was set/filled.
72 static void UnpackTriggerRecordFlags(
73 AliHLTUInt32_t flags, // [in]
74 AliHLTMUONParticleSign& sign, // [out]
75 bool hitset[4] // [out]
79 * This packs the given parameters into the bits of a word appropriate
80 * for AliHLTMUONRecHitStruct::fFlags.
81 * @param chamber The chamber number in the range [0..13].
82 * @param detElemId Detector element ID number.
83 * @return Returns the 32 bit packed word.
85 static AliHLTUInt32_t PackRecHitFlags(
86 AliHLTUInt8_t chamber, AliHLTUInt16_t detElemId
90 * This unpacks the AliHLTMUONRecHitStruct::fFlags bits into
91 * its component fields.
92 * @param [in] flags The flags from an AliHLTMUONRecHitStruct structure.
93 * @param [out] chamber Sets the chamber number in the range [0..13].
94 * @param [out] detElemId Sets the detector element ID number.
96 static void UnpackRecHitFlags(
97 AliHLTUInt32_t flags, // [in]
98 AliHLTUInt8_t& chamber, // [out]
99 AliHLTUInt16_t& detElemId // [out]
103 * Returns the detector element ID from the flags bits.
104 * @param [in] flags The flags from an AliHLTMUONRecHitStruct structure.
106 static AliHLTUInt16_t GetDetElemIdFromFlags(AliHLTUInt32_t flags)
108 return flags & 0xFFF;
112 * This packs the given parameters into the bits of a word appropriate
113 * for AliHLTMUONMansoTrackStruct::fFlags.
114 * @param sign The particle sign.
115 * @param hitset Flags to indicate if the corresponding fHits[i] elements
117 * @return Returns the 32 bit packed word.
119 static AliHLTUInt32_t PackMansoTrackFlags(
120 AliHLTMUONParticleSign sign, const bool hitset[4]
123 return PackTriggerRecordFlags(sign, hitset);
127 * This unpacks the AliHLTMUONMansoTrackStruct::fFlags bits into
128 * its component fields.
129 * @param [in] flags The flags from an AliHLTMUONMansoTrackStruct structure.
130 * @param [out] sign Sets this to the particle sign.
131 * @param [out] hitset Sets the array elements to indicate if the corresponding
132 * fHits[i] element was set/filled.
134 static void UnpackMansoTrackFlags(
135 AliHLTUInt32_t flags, // [in]
136 AliHLTMUONParticleSign& sign, // [out]
137 bool hitset[4] // [out]
140 UnpackTriggerRecordFlags(flags, sign, hitset);
144 * This packs the given parameters into the bits of a word appropriate
145 * for AliHLTMUONTrackStruct::fFlags.
146 * @param sign The particle sign.
147 * @param hitset Flags to indicate if the corresponding fHits[i] elements
149 * @return Returns the 32 bit packed word.
151 static AliHLTUInt32_t PackTrackFlags(
152 AliHLTMUONParticleSign sign, const bool hitset[16]
156 * This unpacks the AliHLTMUONTrackStruct::fFlags bits into
157 * its component fields.
158 * @param [in] flags The flags from an AliHLTMUONTrackStruct structure.
159 * @param [out] sign Sets this to the particle sign.
160 * @param [out] hitset Sets the array elements to indicate if the corresponding
161 * fHits[i] element was set/filled.
163 static void UnpackTrackFlags(
164 AliHLTUInt32_t flags, // [in]
165 AliHLTMUONParticleSign& sign, // [out]
166 bool hitset[16] // [out]
170 * This packs the given parameters into the bits of a word appropriate
171 * for AliHLTMUONTrackDecisionStruct::fTriggerBits.
172 * @param highPt Has the track passed the high pt cut.
173 * @param lowPt Has the track passed the low pt cut.
174 * @return Returns the 32 bit packed word.
176 static AliHLTUInt32_t PackTrackDecisionBits(bool highPt, bool lowPt);
179 * This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
180 * its component fields.
181 * @param [in] bits The trigger bits from an AliHLTMUONTrackDecisionStruct
183 * @param [out] highPt Sets this to the value of the high pt cut bit.
184 * @param [out] lowPt Sets this to the value of the low pt cut bit.
186 static void UnpackTrackDecisionBits(
187 AliHLTUInt32_t bits, // [in]
188 bool& highPt, // [out]
193 * This packs the given parameters into the bits of a word appropriate
194 * for AliHLTMUONPairDecisionStruct::fTriggerBits.
196 * @param highMass Has the track pair passed the high invariant mass cut.
197 * @param lowMass Has the track pair passed the low invariant mass cut.
198 * @param unlike Does the track pair have unlike signs.
199 * @param highPtCount The number of tracks that passed the high pt cut
201 * @param lowPtCount The number of tracks that passed the low pt cut
203 * @return Returns the 32 bit packed word.
205 * Note: Must have highPtCount + lowPtCount <= 2 and unlike == true if
206 * highMass or lowMass is true.
208 static AliHLTUInt32_t PackPairDecisionBits(
209 bool highMass, bool lowMass, bool unlike,
210 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
214 * This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
215 * its component fields.
216 * @param [in] bits The trigger bits from an AliHLTMUONPairDecisionStruct
218 * @param [out] highMass Sets this to the value of the high invariant mass cut bit.
219 * @param [out] lowMass Sets this to the value of the low invariant mass cut bit.
220 * @param [out] unlike Sets this if the pair is unlike sign.
221 * @param [out] highPtCount Sets this to the high pt count bits.
222 * @param [out] lowPtCount Sets this to the low pt count bits.
224 static void UnpackPairDecisionBits(
225 AliHLTUInt32_t bits, // [in]
226 bool& highMass, // [out]
227 bool& lowMass, // [out]
228 bool& unlike, // [out]
229 AliHLTUInt8_t& highPtCount, // [out]
230 AliHLTUInt8_t& lowPtCount // [out]
234 * This packs the given parameters into the 32bit Pub/Sub specification
235 * word in the data block descriptor.
237 * @param ddl The list of DDLs forming part of the readout. ddl[0]
238 * indicates DDL number 2560, ddl[1] is for DDL 2561 and so
239 * on up to ddl[19]. ddl[20] and ddl[21] will be for the
240 * trigger DDLs 2816 and 2817 respectively.
241 * @return Returns the 32 bit packed specification word.
243 static AliHLTUInt32_t PackSpecBits(
248 * This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
249 * its component fields.
250 * @param [in] bits The Pub/Sub specification word from a data block descriptor.
251 * @param [out] ddl The output list of DDLs forming part of the readout. ddl[0]
252 * indicates DDL number 2560, ddl[1] is for DDL 2561 and so
253 * on up to ddl[19]. ddl[20] and ddl[21] will be for the
254 * trigger DDLs 2816 and 2817 respectively.
256 static void UnpackSpecBits(
257 AliHLTUInt32_t bits, // [in]
258 bool ddl[22] // [out]
262 * This method converts the DDL number for the muon spectrometer in the
263 * range [0..21] to the equipment ID number.
264 * @param ddlNo The DDL number in the range [0..21].
265 * @return Returns the equipment ID number or -1 if ddlNo was invalid.
267 static AliHLTInt32_t DDLNumberToEquipId(AliHLTInt32_t ddlNo);
270 * This method converts the equipment ID number for a muon spectrometer
271 * DDL to the DDL number in the range [0..21].
272 * @param id The equipment ID of the DDL.
273 * @return Returns the DDL number in the range [0..21] or -1 if the
274 * equipment ID was invalid.
276 static AliHLTInt32_t EquipIdToDDLNumber(AliHLTInt32_t id);
279 * This method converts a 32 bit data block specification for a MUON-HLT
280 * data block into its corresponding DDL equipment ID number.
281 * It is assumed that the specification is for a data block comming from
282 * a single DDL source. If more than one DDL contributed to the data block
283 * then -1 is returned.
284 * @param spec The 32 bit specification for a data block.
285 * @return Returns the equipment ID corresponding to the specification
286 * or -1 if the specification was invalid.
288 static AliHLTInt32_t SpecToEquipId(AliHLTUInt32_t spec);
291 * This method converts a equipment ID number for a DDL into its corresponding
292 * 32 bit data block specification for the MUON-HLT.
293 * @param id The equipment ID number of the DDL.
294 * @return Returns the 32 bit data block specification or 0x0 if the
295 * equipment ID was invalid.
297 static AliHLTUInt32_t EquipIdToSpec(AliHLTInt32_t id);
300 * This method converts a 32 bit data block specification for a MUON-HLT
301 * data block into its corresponding DDL number in the range [0..21].
302 * It is assumed that the specification is for a data block comming from
303 * a single DDL source. If more than one DDL contributed to the data block
304 * then -1 is returned.
305 * @param spec The 32 bit specification for a data block.
306 * @return Returns the corresponding DDL number for the specification
307 * or -1 if the specification was invalid.
309 static AliHLTInt32_t SpecToDDLNumber(AliHLTUInt32_t spec);
312 * This method converts a DDL number in the range [0..21] into its
313 * corresponding 32 bit data block specification for the MUON-HLT.
314 * @param ddlNo The equipment ID number of the DDL.
315 * @return Returns the 32 bit data block specification or 0x0 if the
316 * DDL number was invalid (out of range).
318 static AliHLTUInt32_t DDLNumberToSpec(AliHLTInt32_t ddlNo);
321 * Returns true if the given specification was for a single trigger DDL.
323 static bool IsTriggerDDL(AliHLTUInt32_t spec)
325 AliHLTInt32_t ddl = SpecToDDLNumber(spec);
326 return (20 <= ddl and ddl <= 21);
330 * Returns true if the given specification was for a single tracker DDL.
332 static bool IsTrackerDDL(AliHLTUInt32_t spec)
334 AliHLTInt32_t ddl = SpecToDDLNumber(spec);
335 return (0 <= ddl and ddl <= 19);
339 * Returns true if the given specification is in principle valid.
340 * It checks if the bits that should be zero are indeed zero.
342 static bool IsSpecValid(AliHLTUInt32_t spec)
344 AliHLTUInt32_t mask = ~AliHLTUInt32_t((1 << 22) - 1); // First 22 bits indicate DDL number.
345 return (spec & mask) == 0x0;
349 * Returns true if the data specification indicates the data block contains
350 * information generated from a trigger DDL or data fragments thereof.
352 static bool ContainsDataFromTrigger(AliHLTUInt32_t spec)
354 AliHLTUInt32_t mask = AliHLTUInt32_t((1 << 22) - 1) & ~AliHLTUInt32_t((1 << 20) - 1);
355 return (spec & mask) != 0x0;
359 * Returns true if the data specification indicates the data block contains
360 * information generated from a tracker DDL or data fragments thereof.
362 static bool ContainsDataFromTracker(AliHLTUInt32_t spec)
364 AliHLTUInt32_t mask = AliHLTUInt32_t((1 << 20) - 1);
365 return (spec & mask) != 0x0;
369 * Parses the string containing the type name of a dHLT data block and
370 * returns the corresponding AliHLTMUONDataBlockType value.
371 * \param type The string containing the type name.
372 * \returns The data block type or kUnknownDataBlock if the type name
375 static AliHLTMUONDataBlockType ParseCommandLineTypeString(const char* type);
378 * Converts a type ID to a type string to be used for the dHLT FilePublisher
379 * component configuration parameters for example.
381 static const char* DataBlockTypeToString(AliHLTMUONDataBlockType type);
384 * These codes indicate the reason why a data block failed its
389 kNoReason, ///< There was no reason for failure.
390 kHeaderContainsWrongType, ///< The common header contains an incorrect type ID.
391 kHeaderContainsWrongRecordWidth, ///< The common header contains an incorrect data record width.
392 kInvalidIdValue, ///< The structure identifier does not have a valid value.
393 kInvalidTriggerIdValue, ///< The trigger structure identifier does not have a valid value.
394 kInvalidTrackIdValue, ///< The track structure identifier does not have a valid value.
395 kReservedBitsNotZero, ///< Reserved bits have not been set to zero.
396 kParticleSignBitsNotValid, ///< The particle sign bits are not a valid value.
397 kHitNotMarkedAsNil, ///< A hit was marked as not found, but the corresponding hit structure was not set to nil.
398 kInvalidDetElementNumber, ///< An invalid detector element ID was found.
399 kInvalidChamberNumber, ///< An invalid chamber number was found.
400 kHitIsNil, ///< The hit cannot be set to a nil value.
401 kInvalidChannelCountB, ///< The number of channels in the bending plane indicated is zero or outside the valid range.
402 kInvalidChannelCountNB, ///< The number of channels in the non-bending plane indicated is zero or outside the valid range.
403 kInvalidChargeB, ///< The charge for the bending plane does not have a valid value.
404 kInvalidChargeNB, ///< The charge for the non-bending plane does not have a valid value.
405 kInvalidBusPatchId, ///< The bus patch ID is outside the valid range.
406 kInvalidManuId, ///< The MANU ID is outside the valid range.
407 kInvalidChannelAddress, ///< The MANU channel address is outside the valid range.
408 kInvalidSignal, ///< The ADC signal value is outside the valid range.
409 kDataWordDifferent, ///< The raw data word is different from the unpacked values.
410 kChiSquareInvalid, ///< The chi squared value must be a positive value or -1 indicating a fitting error.
411 kMomentumVectorNotZero, ///< The chi sqaured value is set to -1, but momentum vector not zero.
412 kMomentumParamsNotZero, ///< The chi sqaured value is set to -1, but fitted momentum parameters are not zero.
413 kDCAVertexNotZero, ///< The chi sqaured value is set to -1, but DCA vertex is not zero.
414 kRoiRadiusInvalid, ///< The region of interest radius is invalid.
415 kHitNotWithinRoi, ///< A tracks hit is not within the corresponding region of interest.
416 kPtValueNotValid, ///< The pT value is not positive nor -1 indicating an invalid value.
417 kPairTrackIdsAreIdentical, ///< The track IDs of the track pair are identical.
418 kMassValueNotValid, ///< The invariant mass value is not positive nor -1 indicating an invalid value.
419 kLowPtCountInvalid, ///< The low pT trigger count is greater than 2, which is invalid.
420 kHighPtCountInvalid, ///< The high pT trigger count is greater than 2, which is invalid.
421 kFoundDuplicateIDs, ///< Found duplicate identifiers, but they should all be unique.
422 kFoundDuplicateHits, ///< Found duplicate hits.
423 kFoundDuplicateTriggers ///< Found duplicate trigger decisions.
427 * This method converts the WhyNotValid enumeration to a string representation.
429 static const char* FailureReasonToString(WhyNotValid reason);
432 * This method returns a string containing a user readable message explaining
433 * the reason for failure described by the WhyNotValid enumeration.
435 static const char* FailureReasonToMessage(WhyNotValid reason);
438 * Method used to check if the header information corresponds to the
439 * supposed type of the trigger records data block.
440 * This method will return either kHeaderContainsWrongType or
441 * kHeaderContainsWrongRecordWidth as the reason code.
442 * \param [in] block The data block to check.
443 * \param [out] reason If this is not NULL, then the variable pointed to
444 * by this pointer will be filled with the reason code describing why
445 * the header is not valid, if and only if a problem is found with
447 * \returns true if there is no problem with the header and false otherwise.
449 static bool HeaderOk(const AliHLTMUONTriggerRecordsBlockStruct& block, WhyNotValid* reason = NULL)
451 AliHLTUInt32_t count = 1;
452 return HeaderOk(block, reason, count);
456 * Method used to check if the header information corresponds to the
457 * supposed type of the trigger debug information data block.
458 * This method will return either kHeaderContainsWrongType or
459 * kHeaderContainsWrongRecordWidth as the reason code.
460 * \param [in] block The data block to check.
461 * \param [out] reason If this is not NULL, then the variable pointed to
462 * by this pointer will be filled with the reason code describing why
463 * the header is not valid, if and only if a problem is found with
465 * \returns true if there is no problem with the header and false otherwise.
467 static bool HeaderOk(const AliHLTMUONTrigRecsDebugBlockStruct& block, WhyNotValid* reason = NULL)
469 AliHLTUInt32_t count = 1;
470 return HeaderOk(block, reason, count);
474 * Method used to check if the header information corresponds to the
475 * supposed type of the reconstructed hits data block.
476 * This method will return either kHeaderContainsWrongType or
477 * kHeaderContainsWrongRecordWidth as the reason code.
478 * \param [in] block The data block to check.
479 * \param [out] reason If this is not NULL, then the variable pointed to
480 * by this pointer will be filled with the reason code describing why
481 * the header is not valid, if and only if a problem is found with
483 * \returns true if there is no problem with the header and false otherwise.
485 static bool HeaderOk(const AliHLTMUONRecHitsBlockStruct& block, WhyNotValid* reason = NULL)
487 AliHLTUInt32_t count = 1;
488 return HeaderOk(block, reason, count);
492 * Method used to check if the header information corresponds to the
493 * supposed type of the clusters data block.
494 * This method will return either kHeaderContainsWrongType or
495 * kHeaderContainsWrongRecordWidth as the reason code.
496 * \param [in] block The data block to check.
497 * \param [out] reason If this is not NULL, then the variable pointed to
498 * by this pointer will be filled with the reason code describing why
499 * the header is not valid, if and only if a problem is found with
501 * \returns true if there is no problem with the header and false otherwise.
503 static bool HeaderOk(const AliHLTMUONClustersBlockStruct& block, WhyNotValid* reason = NULL)
505 AliHLTUInt32_t count = 1;
506 return HeaderOk(block, reason, count);
510 * Method used to check if the header information corresponds to the
511 * supposed type of the channels data block.
512 * This method will return either kHeaderContainsWrongType or
513 * kHeaderContainsWrongRecordWidth as the reason code.
514 * \param [in] block The data block to check.
515 * \param [out] reason If this is not NULL, then the variable pointed to
516 * by this pointer will be filled with the reason code describing why
517 * the header is not valid, if and only if a problem is found with
519 * \returns true if there is no problem with the header and false otherwise.
521 static bool HeaderOk(const AliHLTMUONChannelsBlockStruct& block, WhyNotValid* reason = NULL)
523 AliHLTUInt32_t count = 1;
524 return HeaderOk(block, reason, count);
528 * Method used to check if the header information corresponds to the
529 * supposed type of the Manso tracks data block.
530 * This method will return either kHeaderContainsWrongType or
531 * kHeaderContainsWrongRecordWidth as the reason code.
532 * \param [in] block The data block to check.
533 * \param [out] reason If this is not NULL, then the variable pointed to
534 * by this pointer will be filled with the reason code describing why
535 * the header is not valid, if and only if a problem is found with
537 * \returns true if there is no problem with the header and false otherwise.
539 static bool HeaderOk(const AliHLTMUONMansoTracksBlockStruct& block, WhyNotValid* reason = NULL)
541 AliHLTUInt32_t count = 1;
542 return HeaderOk(block, reason, count);
546 * Method used to check if the header information corresponds to the
547 * supposed type of the Manso candidates data block.
548 * This method will return either kHeaderContainsWrongType or
549 * kHeaderContainsWrongRecordWidth as the reason code.
550 * \param [in] block The data block to check.
551 * \param [out] reason If this is not NULL, then the variable pointed to
552 * by this pointer will be filled with the reason code describing why
553 * the header is not valid, if and only if a problem is found with
555 * \returns true if there is no problem with the header and false otherwise.
557 static bool HeaderOk(const AliHLTMUONMansoCandidatesBlockStruct& block, WhyNotValid* reason = NULL)
559 AliHLTUInt32_t count = 1;
560 return HeaderOk(block, reason, count);
564 * Method used to check if the header information corresponds to the
565 * supposed type of the tracks data block given.
566 * This method will return either kHeaderContainsWrongType or
567 * kHeaderContainsWrongRecordWidth as the reason code.
568 * \param [in] block The data block to check.
569 * \param [out] reason If this is not NULL, then the variable pointed to
570 * by this pointer will be filled with the reason code describing why
571 * the header is not valid, if and only if a problem is found with
573 * \returns true if there is no problem with the header and false otherwise.
575 static bool HeaderOk(const AliHLTMUONTracksBlockStruct& block, WhyNotValid* reason = NULL)
577 AliHLTUInt32_t count = 1;
578 return HeaderOk(block, reason, count);
582 * Method used to check if the header information corresponds to the
583 * supposed type of the single tracks dHLT trigger decision data block.
584 * This method will return either kHeaderContainsWrongType or
585 * kHeaderContainsWrongRecordWidth as the reason code.
586 * \param [in] block The data block to check.
587 * \param [out] reason If this is not NULL, then the variable pointed to
588 * by this pointer will be filled with the reason code describing why
589 * the header is not valid, if and only if a problem is found with
591 * \returns true if there is no problem with the header and false otherwise.
593 static bool HeaderOk(const AliHLTMUONSinglesDecisionBlockStruct& block, WhyNotValid* reason = NULL)
595 AliHLTUInt32_t count = 1;
596 return HeaderOk(block, reason, count);
600 * Method used to check if the header information corresponds to the
601 * supposed type of the track pairs dHLT trigger decision data block.
602 * This method will return either kHeaderContainsWrongType or
603 * kHeaderContainsWrongRecordWidth as the reason code.
604 * \param [in] block The data block to check.
605 * \param [out] reason If this is not NULL, then the variable pointed to
606 * by this pointer will be filled with the reason code describing why
607 * the header is not valid, if and only if a problem is found with
609 * \returns true if there is no problem with the header and false otherwise.
611 static bool HeaderOk(const AliHLTMUONPairsDecisionBlockStruct& block, WhyNotValid* reason = NULL)
613 AliHLTUInt32_t count = 1;
614 return HeaderOk(block, reason, count);
618 * Methods used to check if the header information corresponds to the
619 * supposed type of the data block.
620 * If the 'reason' parameter should point to an array which will store
621 * the reason codes indicating the problems with the data block.
622 * The 'reasonCount' parameter should initialy contain the number of
623 * elements that can be stored in reason. When the method exits it will
624 * store the number of elements in the 'reason' array actually filled.
626 static bool HeaderOk(
627 const AliHLTMUONTriggerRecordsBlockStruct& block,
628 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
631 static bool HeaderOk(
632 const AliHLTMUONTrigRecsDebugBlockStruct& block,
633 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
636 static bool HeaderOk(
637 const AliHLTMUONRecHitsBlockStruct& block,
638 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
641 static bool HeaderOk(
642 const AliHLTMUONClustersBlockStruct& block,
643 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
646 static bool HeaderOk(
647 const AliHLTMUONChannelsBlockStruct& block,
648 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
651 static bool HeaderOk(
652 const AliHLTMUONMansoTracksBlockStruct& block,
653 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
656 static bool HeaderOk(
657 const AliHLTMUONMansoCandidatesBlockStruct& block,
658 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
661 static bool HeaderOk(
662 const AliHLTMUONTracksBlockStruct& block,
663 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
666 static bool HeaderOk(
667 const AliHLTMUONSinglesDecisionBlockStruct& block,
668 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
671 static bool HeaderOk(
672 const AliHLTMUONPairsDecisionBlockStruct& block,
673 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
677 * This method is used to check more extensively if the integrity of the
678 * trigger record structure is OK and returns true in that case.
679 * \param [in] tr The trigger record structure to check.
680 * \param [out] reason If this is not NULL, then it will be filled with
681 * the reason code describing why the structure is not valid, if and
682 * only if a problem is found with the data.
683 * \returns true if there is no problem with the structure and false otherwise.
685 static bool IntegrityOk(
686 const AliHLTMUONTriggerRecordStruct& tr,
687 WhyNotValid* reason = NULL
690 AliHLTUInt32_t count = 1;
691 return IntegrityOk(tr, reason, count);
695 * This method is used to check more extensively if the integrity of the
696 * dHLT raw internal data block is OK and returns true in that case.
697 * \param [in] block The trigger record data block to check.
698 * \param [out] reason If this is not NULL, then it will be filled with
699 * the reason code describing why the data block is not valid, if and
700 * only if a problem is found with the data.
701 * \param [out] recordNum If this is not NULL, then it will be filled with
702 * the number of the trigger record that had a problem. This value will
703 * only contain a valid value if the method RecordNumberWasSet(*reason)
704 * returns true. Thus, 'reason' must be set.
705 * \returns true if there is no problem with the data and false otherwise.
707 static bool IntegrityOk(
708 const AliHLTMUONTriggerRecordsBlockStruct& block,
709 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
712 AliHLTUInt32_t count = 1;
713 return IntegrityOk(block, reason, recordNum, count);
717 * This method is used to check more extensively if the integrity of the
718 * trigger record debug information structure is OK and returns true in that case.
719 * \param [in] trigInfo The trigger record debug information structure to check.
720 * \param [out] reason If this is not NULL, then it will be filled with
721 * the reason code describing why the structure is not valid, if and
722 * only if a problem is found with the data.
723 * \returns true if there is no problem with the structure and false otherwise.
725 static bool IntegrityOk(
726 const AliHLTMUONTrigRecInfoStruct& trigInfo,
727 WhyNotValid* reason = NULL
730 AliHLTUInt32_t count = 1;
731 return IntegrityOk(trigInfo, reason, count);
735 * This method is used to check more extensively if the integrity of the
736 * dHLT raw internal data block is OK and returns true in that case.
737 * \param [in] block The trigger record debugging information data block to check.
738 * \param [out] reason If this is not NULL, then it will be filled with
739 * the reason code describing why the data block is not valid, if and
740 * only if a problem is found with the data.
741 * \param [out] recordNum If this is not NULL, then it will be filled with
742 * the number of the trigger record debug information structure that had
743 * a problem. This value will only contain a valid value if the method
744 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
745 * \returns true if there is no problem with the data and false otherwise.
747 static bool IntegrityOk(
748 const AliHLTMUONTrigRecsDebugBlockStruct& block,
749 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
752 AliHLTUInt32_t count = 1;
753 return IntegrityOk(block, reason, recordNum, count);
757 * This method is used to check more extensively if the integrity of the
758 * reconstructed hit structure is OK and returns true in that case.
759 * \param [in] hit The reconstructed hit structure to check.
760 * \param [out] reason If this is not NULL, then it will be filled with
761 * the reason code describing why the structure is not valid, if and
762 * only if a problem is found with the data.
763 * \returns true if there is no problem with the data and false otherwise.
765 static bool IntegrityOk(
766 const AliHLTMUONRecHitStruct& hit,
767 WhyNotValid* reason = NULL
770 AliHLTUInt32_t count = 1;
771 return IntegrityOk(hit, reason, count);
775 * This method is used to check more extensively if the integrity of the
776 * dHLT raw internal data block is OK and returns true in that case.
777 * \param [in] block The reconstructed hits data block to check.
778 * \param [out] reason If this is not NULL, then it will be filled with
779 * the reason code describing why the data block is not valid, if and
780 * only if a problem is found with the data.
781 * \param [out] recordNum If this is not NULL, then it will be filled with
782 * the number of the cluster structure that had a problem. This value
783 * will only contain a valid value if the method
784 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
785 * \returns true if there is no problem with the data and false otherwise.
787 static bool IntegrityOk(
788 const AliHLTMUONRecHitsBlockStruct& block,
789 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
792 AliHLTUInt32_t count = 1;
793 return IntegrityOk(block, reason, recordNum, count);
797 * This method is used to check more extensively if the integrity of the
798 * cluster data structure is OK and returns true in that case.
799 * \param [in] cluster The cluster structure to check.
800 * \param [out] reason If this is not NULL, then it will be filled with
801 * the reason code describing why the structure is not valid, if and
802 * only if a problem is found with the data.
803 * \returns true if there is no problem with the data and false otherwise.
805 static bool IntegrityOk(
806 const AliHLTMUONClusterStruct& cluster,
807 WhyNotValid* reason = NULL
810 AliHLTUInt32_t count = 1;
811 return IntegrityOk(cluster, reason, count);
815 * This method is used to check more extensively if the integrity of the
816 * dHLT raw internal data block is OK and returns true in that case.
817 * \param [in] block The clusters data block to check.
818 * \param [out] reason If this is not NULL, then it will be filled with
819 * the reason code describing why the data block is not valid, if and
820 * only if a problem is found with the data.
821 * \param [out] recordNum If this is not NULL, then it will be filled with
822 * the number of the cluster structure that had a problem. This value
823 * will only contain a valid value if the method
824 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
825 * \returns true if there is no problem with the data and false otherwise.
827 static bool IntegrityOk(
828 const AliHLTMUONClustersBlockStruct& block,
829 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
832 AliHLTUInt32_t count = 1;
833 return IntegrityOk(block, reason, recordNum, count);
837 * This method is used to check more extensively if the integrity of the
838 * channel data structure is OK and returns true in that case.
839 * \param [in] cluster The channel structure to check.
840 * \param [out] reason If this is not NULL, then it will be filled with
841 * the reason code describing why the structure is not valid, if and
842 * only if a problem is found with the data.
843 * \returns true if there is no problem with the data and false otherwise.
845 static bool IntegrityOk(
846 const AliHLTMUONChannelStruct& channel,
847 WhyNotValid* reason = NULL
850 AliHLTUInt32_t count = 1;
851 return IntegrityOk(channel, reason, count);
855 * This method is used to check more extensively if the integrity of the
856 * dHLT raw internal data block is OK and returns true in that case.
857 * \param [in] block The ADC channels data block to check.
858 * \param [out] reason If this is not NULL, then it will be filled with
859 * the reason code describing why the data block is not valid, if and
860 * only if a problem is found with the data.
861 * \param [out] recordNum If this is not NULL, then it will be filled with
862 * the number of the channel structure that had a problem. This value
863 * will only contain a valid value if the method
864 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
865 * \returns true if there is no problem with the data and false otherwise.
867 static bool IntegrityOk(
868 const AliHLTMUONChannelsBlockStruct& block,
869 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
872 AliHLTUInt32_t count = 1;
873 return IntegrityOk(block, reason, recordNum, count);
877 * This method is used to check more extensively if the integrity of the
878 * Manso track structure is OK and returns true in that case.
879 * \param [in] track The Manso track structure to check.
880 * \param [out] reason If this is not NULL, then it will be filled with
881 * the reason code describing why the structure is not valid, if and
882 * only if a problem is found with the data.
883 * \returns true if there is no problem with the structure and false otherwise.
885 static bool IntegrityOk(
886 const AliHLTMUONMansoTrackStruct& track,
887 WhyNotValid* reason = NULL
890 AliHLTUInt32_t count = 1;
891 return IntegrityOk(track, reason, count);
895 * This method is used to check more extensively if the integrity of the
896 * dHLT raw internal data block is OK and returns true in that case.
897 * \param [in] block The Manso track data block to check.
898 * \param [out] reason If this is not NULL, then it will be filled with
899 * the reason code describing why the data block is not valid, if and
900 * only if a problem is found with the data.
901 * \param [out] recordNum If this is not NULL, then it will be filled with
902 * the number of the Manso track structure that had a problem.
903 * This value will only contain a valid value if the method
904 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
905 * \returns true if there is no problem with the data and false otherwise.
907 static bool IntegrityOk(
908 const AliHLTMUONMansoTracksBlockStruct& block,
909 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
912 AliHLTUInt32_t count = 1;
913 return IntegrityOk(block, reason, recordNum, count);
917 * This method is used to check more extensively if the integrity of the
918 * Manso track candidate structure is OK and returns true in that case.
919 * \param [in] candidate The Manso track candidate structure to check.
920 * \param [out] reason If this is not NULL, then it will be filled with
921 * the reason code describing why the structure is not valid, if and
922 * only if a problem is found with the data.
923 * \returns true if there is no problem with the structure and false otherwise.
925 static bool IntegrityOk(
926 const AliHLTMUONMansoCandidateStruct& candidate,
927 WhyNotValid* reason = NULL
930 AliHLTUInt32_t count = 1;
931 return IntegrityOk(candidate, reason, count);
935 * This method is used to check more extensively if the integrity of the
936 * dHLT raw internal data block is OK and returns true in that case.
937 * \param [in] block The Manso track candidate data block to check.
938 * \param [out] reason If this is not NULL, then it will be filled with
939 * the reason code describing why the data block is not valid, if and
940 * only if a problem is found with the data.
941 * \param [out] recordNum If this is not NULL, then it will be filled with
942 * the number of the Manso track candidate structure that had a problem.
943 * This value will only contain a valid value if the method
944 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
945 * \returns true if there is no problem with the data and false otherwise.
947 static bool IntegrityOk(
948 const AliHLTMUONMansoCandidatesBlockStruct& block,
949 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
952 AliHLTUInt32_t count = 1;
953 return IntegrityOk(block, reason, recordNum, count);
957 * This method is used to check more extensively if the integrity of the
958 * full track structure is OK and returns true in that case.
959 * \param [in] track The track structure to check.
960 * \param [out] reason If this is not NULL, then it will be filled with
961 * the reason code describing why the structure is not valid, if and
962 * only if a problem is found with the data.
963 * \returns true if there is no problem with the structure and false otherwise.
965 static bool IntegrityOk(
966 const AliHLTMUONTrackStruct& track,
967 WhyNotValid* reason = NULL
970 AliHLTUInt32_t count = 1;
971 return IntegrityOk(track, reason, count);
975 * This method is used to check more extensively if the integrity of the
976 * dHLT raw internal data block is OK and returns true in that case.
977 * \param [in] block The track data block to check.
978 * \param [out] reason If this is not NULL, then it will be filled with
979 * the reason code describing why the data block is not valid, if and
980 * only if a problem is found with the data.
981 * \param [out] recordNum If this is not NULL, then it will be filled with
982 * the number of the Manso track structure that had a problem.
983 * This value will only contain a valid value if the method
984 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
985 * \returns true if there is no problem with the data and false otherwise.
987 static bool IntegrityOk(
988 const AliHLTMUONTracksBlockStruct& block,
989 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
992 AliHLTUInt32_t count = 1;
993 return IntegrityOk(block, reason, recordNum, count);
997 * This method is used to check more extensively if the integrity of the
998 * single track trigger decision structure is OK and returns true in that case.
999 * \param [in] decision The trigger decision structure to check.
1000 * \param [out] reason If this is not NULL, then it will be filled with
1001 * the reason code describing why the structure is not valid, if and
1002 * only if a problem is found with the data.
1003 * \returns true if there is no problem with the structure and false otherwise.
1005 static bool IntegrityOk(
1006 const AliHLTMUONTrackDecisionStruct& decision,
1007 WhyNotValid* reason = NULL
1010 AliHLTUInt32_t count = 1;
1011 return IntegrityOk(decision, reason, count);
1015 * This method is used to check more extensively if the integrity of the
1016 * dHLT raw internal data block is OK and returns true in that case.
1017 * \param [in] block The single track trigger decision data block to check.
1018 * \param [out] reason If this is not NULL, then it will be filled with
1019 * the reason code describing why the data block is not valid, if and
1020 * only if a problem is found with the data.
1021 * \param [out] recordNum If this is not NULL, then it will be filled with
1022 * the number of the single track trigger decision structure that had
1023 * a problem. This value will only contain a valid value if the method
1024 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
1025 * \returns true if there is no problem with the data and false otherwise.
1027 static bool IntegrityOk(
1028 const AliHLTMUONSinglesDecisionBlockStruct& block,
1029 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
1032 AliHLTUInt32_t count = 1;
1033 return IntegrityOk(block, reason, recordNum, count);
1037 * This method is used to check more extensively if the integrity of the
1038 * track pair trigger decision structure is OK and returns true in that case.
1039 * \param [in] decision The trigger decision structure to check.
1040 * \param [out] reason If this is not NULL, then it will be filled with
1041 * the reason code describing why the structure is not valid, if and
1042 * only if a problem is found with the data.
1043 * \returns true if there is no problem with the structure and false otherwise.
1045 static bool IntegrityOk(
1046 const AliHLTMUONPairDecisionStruct& decision,
1047 WhyNotValid* reason = NULL
1050 AliHLTUInt32_t count = 1;
1051 return IntegrityOk(decision, reason, count);
1055 * This method is used to check more extensively if the integrity of the
1056 * dHLT raw internal data block is OK and returns true in that case.
1057 * \param [in] block The track pair trigger decision data block to check.
1058 * \param [out] reason If this is not NULL, then it will be filled with
1059 * the reason code describing why the data block is not valid, if and
1060 * only if a problem is found with the data.
1061 * \param [out] recordNum If this is not NULL, then it will be filled with
1062 * the number of the track pairs trigger decision structure that had
1063 * a problem. This value will only contain a valid value if the method
1064 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
1065 * \returns true if there is no problem with the data and false otherwise.
1067 static bool IntegrityOk(
1068 const AliHLTMUONPairsDecisionBlockStruct& block,
1069 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
1072 AliHLTUInt32_t count = 1;
1073 return IntegrityOk(block, reason, recordNum, count);
1077 * Methods used to check more extensively if the integrity of various
1078 * types of data blocks are Ok and returns true in that case.
1079 * These can be slow and should generally only be used for debugging.
1080 * The methods are able to return multiple reasons for the problems related
1081 * to the data block under test.
1083 static bool IntegrityOk(
1084 const AliHLTMUONTriggerRecordStruct& tr,
1085 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1088 static bool IntegrityOk(
1089 const AliHLTMUONTriggerRecordsBlockStruct& block,
1090 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1091 AliHLTUInt32_t& reasonCount
1094 static bool IntegrityOk(
1095 const AliHLTMUONTrigRecInfoStruct& trigInfo,
1096 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1099 static bool IntegrityOk(
1100 const AliHLTMUONTrigRecsDebugBlockStruct& block,
1101 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1102 AliHLTUInt32_t& reasonCount
1105 static bool IntegrityOk(
1106 const AliHLTMUONRecHitStruct& hit,
1107 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1110 static bool IntegrityOk(
1111 const AliHLTMUONRecHitsBlockStruct& block,
1112 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1113 AliHLTUInt32_t& reasonCount
1116 static bool IntegrityOk(
1117 const AliHLTMUONClusterStruct& cluster,
1118 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1121 static bool IntegrityOk(
1122 const AliHLTMUONClustersBlockStruct& block,
1123 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1124 AliHLTUInt32_t& reasonCount
1127 static bool IntegrityOk(
1128 const AliHLTMUONChannelStruct& channel,
1129 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1132 static bool IntegrityOk(
1133 const AliHLTMUONChannelsBlockStruct& block,
1134 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1135 AliHLTUInt32_t& reasonCount
1138 static bool IntegrityOk(
1139 const AliHLTMUONMansoTrackStruct& track,
1140 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1143 static bool IntegrityOk(
1144 const AliHLTMUONMansoTracksBlockStruct& block,
1145 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1146 AliHLTUInt32_t& reasonCount
1149 static bool IntegrityOk(
1150 const AliHLTMUONMansoCandidateStruct& candidate,
1151 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1154 static bool IntegrityOk(
1155 const AliHLTMUONMansoCandidatesBlockStruct& block,
1156 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1157 AliHLTUInt32_t& reasonCount
1160 static bool IntegrityOk(
1161 const AliHLTMUONTrackStruct& track,
1162 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1165 static bool IntegrityOk(
1166 const AliHLTMUONTracksBlockStruct& block,
1167 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1168 AliHLTUInt32_t& reasonCount
1171 static bool IntegrityOk(
1172 const AliHLTMUONTrackDecisionStruct& decision,
1173 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1176 static bool IntegrityOk(
1177 const AliHLTMUONSinglesDecisionBlockStruct& block,
1178 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1179 AliHLTUInt32_t& reasonCount
1182 static bool IntegrityOk(
1183 const AliHLTMUONPairDecisionStruct& decision,
1184 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1187 static bool IntegrityOk(
1188 const AliHLTMUONPairsDecisionBlockStruct& block,
1189 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1190 AliHLTUInt32_t& reasonCount
1194 * Returns true if the \em recordNum in the corresponding IntegrityOk method
1195 * would have been set, if it returned false and a reason was set.
1196 * This helper method makes it easy to test if the \em recordNum parameter
1197 * is filled with a valid value or not.
1199 static bool RecordNumberWasSet(WhyNotValid reason);
1203 // Should never have to create, copy or destroy this object.
1204 AliHLTMUONUtils() {}
1205 AliHLTMUONUtils(const AliHLTMUONUtils& obj);
1206 virtual ~AliHLTMUONUtils() {}
1207 AliHLTMUONUtils& operator = (const AliHLTMUONUtils& obj);
1209 ClassDef(AliHLTMUONUtils, 0); // Interface for helpful dHLT utility methods.
1212 //_____________________________________________________________________________
1214 inline std::ostream& operator << (std::ostream& stream, AliHLTMUONUtils::WhyNotValid reason)
1216 /// Stream operator for the WhyNotValid enumeration for usage with
1217 /// std::ostream classes. Allows usages such as:
1218 /// AliHLTMUONUtils::WhyNotValid r; std::cout << r;
1220 stream << AliHLTMUONUtils::FailureReasonToString(reason);
1224 //_____________________________________________________________________________
1226 // Since c++ is missing a finally "keyword" we define one. Its usage is identical
1227 // to a try..finally statement in Java etc.. however, since it is officialy a macro
1228 // one must use the ( ) brackets instead of { }
1229 // If the compiler supports __finally use it otherwise make our own.
1230 #if defined(__BORLANDC__)
1231 # define finally(str) __finally{str}
1233 # define finally(code) \
1240 #endif // __BORLANDC__
1242 // Here we define the DebugTrace(message) macro for easy embedding of debug
1243 // information into the dimuon HLT code. Its usage is meant to be for generating
1244 // traces of the program which are only useful during full scale debugging.
1245 // Log messages should use the standard HLT logging mechanisms.
1246 // The output is only generated in programs compiled with the DEBUGTRACE directive
1247 // defined. Here is a usage example:
1250 // DebugTrace("some debug information.");
1253 // One can also use C++ ostream operators and manipulators like so:
1257 // DebugTrace("x = " << x << " and y = 0x" << std::hex << y );
1261 # include <iostream>
1262 # define DebugTrace(message) {std::cout << message << std::endl;}
1264 # define DebugTrace(message)
1268 #endif // ALIHLTMUONUTILS_H