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 AliHLTMUONTrackDecisionStruct;
36 struct AliHLTMUONSinglesDecisionBlockStruct;
37 struct AliHLTMUONPairDecisionStruct;
38 struct AliHLTMUONPairsDecisionBlockStruct;
42 * AliHLTMUONUtils contains arbitrary utility methods to be used in various
43 * parts of the dimuon HLT system.
44 * These include methods to perform basic sanity checks on the integrity of
51 * This packs the given parameters into the bits of a word appropriate
52 * for AliHLTMUONTriggerRecordStruct::fFlags.
53 * @param sign The particle sign.
54 * @param hitset Flags to indicate if the corresponding fHits[i] elements
56 * @return Returns the 32 bit packed word.
58 static AliHLTUInt32_t PackTriggerRecordFlags(
59 AliHLTMUONParticleSign sign, const bool hitset[4]
63 * This unpacks the AliHLTMUONTriggerRecordStruct::fFlags bits into
64 * its component fields.
65 * @param flags The flags from an AliHLTMUONTriggerRecordStruct structure.
66 * @param sign Sets this to the particle sign.
67 * @param hitset Sets the array elements to indicate if the corresponding
68 * fHits[i] element was set/filled.
70 static void UnpackTriggerRecordFlags(
71 AliHLTUInt32_t flags, // [in]
72 AliHLTMUONParticleSign& sign, // [out]
73 bool hitset[4] // [out]
77 * This packs the given parameters into the bits of a word appropriate
78 * for AliHLTMUONRecHitStruct::fFlags.
79 * @param chamber The chamber number in the range [0..13].
80 * @param detElemId Detector element ID number.
81 * @return Returns the 32 bit packed word.
83 static AliHLTUInt32_t PackRecHitFlags(
84 AliHLTUInt8_t chamber, AliHLTUInt16_t detElemId
88 * This unpacks the AliHLTMUONRecHitStruct::fFlags bits into
89 * its component fields.
90 * [in] @param flags The flags from an AliHLTMUONRecHitStruct structure.
91 * [out] @param chamber Sets the chamber number in the range [0..13].
92 * [out] @param detElemId Sets the detector element ID number.
94 static void UnpackRecHitFlags(
95 AliHLTUInt32_t flags, // [in]
96 AliHLTUInt8_t& chamber, // [out]
97 AliHLTUInt16_t& detElemId // [out]
101 * This packs the given parameters into the bits of a word appropriate
102 * for AliHLTMUONMansoTrackStruct::fFlags.
103 * @param sign The particle sign.
104 * @param hitset Flags to indicate if the corresponding fHits[i] elements
106 * @return Returns the 32 bit packed word.
108 static AliHLTUInt32_t PackMansoTrackFlags(
109 AliHLTMUONParticleSign sign, const bool hitset[4]
112 return PackTriggerRecordFlags(sign, hitset);
116 * This unpacks the AliHLTMUONMansoTrackStruct::fFlags bits into
117 * its component fields.
118 * @param flags The flags from an AliHLTMUONMansoTrackStruct structure.
119 * @param sign Sets this to the particle sign.
120 * @param hitset Sets the array elements to indicate if the corresponding
121 * fHits[i] element was set/filled.
123 static void UnpackMansoTrackFlags(
124 AliHLTUInt32_t flags, // [in]
125 AliHLTMUONParticleSign& sign, // [out]
126 bool hitset[4] // [out]
129 UnpackTriggerRecordFlags(flags, sign, hitset);
133 * This packs the given parameters into the bits of a word appropriate
134 * for AliHLTMUONTrackDecisionStruct::fTriggerBits.
135 * @param highPt Has the track passed the high pt cut.
136 * @param lowPt Has the track passed the low pt cut.
137 * @return Returns the 32 bit packed word.
139 static AliHLTUInt32_t PackTrackDecisionBits(bool highPt, bool lowPt);
142 * This unpacks the AliHLTMUONTrackDecisionStruct::fTriggerBits bits into
143 * its component fields.
144 * @param bits The trigger bits from an AliHLTMUONTrackDecisionStruct
146 * @param highPt Sets this to the value of the high pt cut bit.
147 * @param lowPt Sets this to the value of the low pt cut bit.
149 static void UnpackTrackDecisionBits(
150 AliHLTUInt32_t bits, // [in]
151 bool& highPt, // [out]
156 * This packs the given parameters into the bits of a word appropriate
157 * for AliHLTMUONPairDecisionStruct::fTriggerBits.
159 * @param highMass Has the track pair passed the high invariant mass cut.
160 * @param lowMass Has the track pair passed the low invariant mass cut.
161 * @param unlike Does the track pair have unlike signs.
162 * @param highPtCount The number of tracks that passed the high pt cut
164 * @param lowPtCount The number of tracks that passed the low pt cut
166 * @return Returns the 32 bit packed word.
168 * Note: Must have highPtCount + lowPtCount <= 2 and unlike == true if
169 * highMass or lowMass is true.
171 static AliHLTUInt32_t PackPairDecisionBits(
172 bool highMass, bool lowMass, bool unlike,
173 AliHLTUInt8_t highPtCount, AliHLTUInt8_t lowPtCount
177 * This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
178 * its component fields.
179 * @param bits The trigger bits from an AliHLTMUONPairDecisionStruct
181 * @param highMass Sets this to the value of the high invariant mass cut bit.
182 * @param lowMass Sets this to the value of the low invariant mass cut bit.
183 * @param unlike Sets this if the pair is unlike sign.
184 * @param highPtCount Sets this to the high pt count bits.
185 * @param lowPtCount Sets this to the low pt count bits.
187 static void UnpackPairDecisionBits(
188 AliHLTUInt32_t bits, // [in]
189 bool& highMass, // [out]
190 bool& lowMass, // [out]
191 bool& unlike, // [out]
192 AliHLTUInt8_t& highPtCount, // [out]
193 AliHLTUInt8_t& lowPtCount // [out]
197 * This packs the given parameters into the 32bit Pub/Sub specification
198 * word in the data block descriptor.
200 * @param ddl The list of DDLs forming part of the readout. ddl[0]
201 * indicates DDL number 2560, ddl[1] is for DDL 2561 and so
202 * on up to ddl[19]. ddl[20] and ddl[21] will be for the
203 * trigger DDLs 2816 and 2817 respectively.
204 * @return Returns the 32 bit packed specification word.
206 static AliHLTUInt32_t PackSpecBits(
211 * This unpacks the AliHLTMUONPairDecisionStruct::fTriggerBits bits into
212 * its component fields.
213 * @param bits The Pub/Sub specification word from a data block descriptor.
214 * @param ddl The output list of DDLs forming part of the readout. ddl[0]
215 * indicates DDL number 2560, ddl[1] is for DDL 2561 and so
216 * on up to ddl[19]. ddl[20] and ddl[21] will be for the
217 * trigger DDLs 2816 and 2817 respectively.
219 static void UnpackSpecBits(
220 AliHLTUInt32_t bits, // [in]
221 bool ddl[22] // [out]
225 * This method converts the DDL number for the muon spectrometer in the
226 * range [0..21] to the equipment ID number.
227 * @param ddlNo The DDL number in the range [0..21].
228 * @return Returns the equipment ID number or -1 if ddlNo was invalid.
230 static AliHLTInt32_t DDLNumberToEquipId(AliHLTInt32_t ddlNo);
233 * This method converts the equipment ID number for a muon spectrometer
234 * DDL to the DDL number in the range [0..21].
235 * @param id The equipment ID of the DDL.
236 * @return Returns the DDL number in the range [0..21] or -1 if the
237 * equipment ID was invalid.
239 static AliHLTInt32_t EquipIdToDDLNumber(AliHLTInt32_t id);
242 * This method converts a 32 bit data block specification for a MUON-HLT
243 * data block into its corresponding DDL equipment ID number.
244 * It is assumed that the specification is for a data block comming from
245 * a single DDL source. If more than one DDL contributed to the data block
246 * then -1 is returned.
247 * @param spec The 32 bit specification for a data block.
248 * @return Returns the equipment ID corresponding to the specification
249 * or -1 if the specification was invalid.
251 static AliHLTInt32_t SpecToEquipId(AliHLTUInt32_t spec);
254 * This method converts a equipment ID number for a DDL into its corresponding
255 * 32 bit data block specification for the MUON-HLT.
256 * @param id The equipment ID number of the DDL.
257 * @return Returns the 32 bit data block specification or 0x0 if the
258 * equipment ID was invalid.
260 static AliHLTUInt32_t EquipIdToSpec(AliHLTInt32_t id);
263 * This method converts a 32 bit data block specification for a MUON-HLT
264 * data block into its corresponding DDL number in the range [0..21].
265 * It is assumed that the specification is for a data block comming from
266 * a single DDL source. If more than one DDL contributed to the data block
267 * then -1 is returned.
268 * @param spec The 32 bit specification for a data block.
269 * @return Returns the corresponding DDL number for the specification
270 * or -1 if the specification was invalid.
272 static AliHLTInt32_t SpecToDDLNumber(AliHLTUInt32_t spec);
275 * This method converts a DDL number in the range [0..21] into its
276 * corresponding 32 bit data block specification for the MUON-HLT.
277 * @param ddlNo The equipment ID number of the DDL.
278 * @return Returns the 32 bit data block specification or 0x0 if the
279 * DDL number was invalid (out of range).
281 static AliHLTUInt32_t DDLNumberToSpec(AliHLTInt32_t ddlNo);
284 * Returns true if the given specification was for a single trigger DDL.
286 static bool IsTriggerDDL(AliHLTUInt32_t spec)
288 AliHLTInt32_t ddl = SpecToDDLNumber(spec);
289 return (20 <= ddl and ddl <= 21);
293 * Returns true if the given specification was for a single tracker DDL.
295 static bool IsTrackerDDL(AliHLTUInt32_t spec)
297 AliHLTInt32_t ddl = SpecToDDLNumber(spec);
298 return (0 <= ddl and ddl <= 19);
302 * Returns true if the given specification is in principle valid.
303 * It checks if the bits that should be zero are indeed zero.
305 static bool IsSpecValid(AliHLTUInt32_t spec)
307 AliHLTUInt32_t mask = ~((1 << 22) - 1); // First 22 bits indicate DDL number.
308 return (spec & mask) == 0x0;
312 * Returns true if the data specification indicates the data block contains
313 * information generated from a trigger DDL or data fragments thereof.
315 static bool ContainsDataFromTrigger(AliHLTUInt32_t spec)
317 AliHLTUInt32_t mask = ((1 << 22) - 1) & ~((1 << 20) - 1);
318 return (spec & mask) != 0x0;
322 * Returns true if the data specification indicates the data block contains
323 * information generated from a tracker DDL or data fragments thereof.
325 static bool ContainsDataFromTracker(AliHLTUInt32_t spec)
327 AliHLTUInt32_t mask = ((1 << 20) - 1);
328 return (spec & mask) != 0x0;
332 * Parses the string containing the type name of a dHLT data block and
333 * returns the corresponding AliHLTMUONDataBlockType value.
334 * \param type The string containing the type name.
335 * \returns The data block type or kUnknownDataBlock if the type name
338 static AliHLTMUONDataBlockType ParseCommandLineTypeString(const char* type);
341 * Converts a type ID to a type string to be used for the dHLT FilePublisher
342 * component configuration parameters for example.
344 static const char* DataBlockTypeToString(AliHLTMUONDataBlockType type);
347 * These codes indicate the reason why a data block failed its
352 kNoReason, ///< There was no reason for failure.
353 kHeaderContainsWrongType, ///< The common header contains an incorrect type ID.
354 kHeaderContainsWrongRecordWidth, ///< The common header contains an incorrect data record width.
355 kInvalidIdValue, ///< The structure identifier does not have a valid value.
356 kInvalidTriggerIdValue, ///< The trigger structure identifier does not have a valid value.
357 kInvalidTrackIdValue, ///< The track structure identifier does not have a valid value.
358 kReservedBitsNotZero, ///< Reserved bits have not been set to zero.
359 kParticleSignBitsNotValid, ///< The particle sign bits are not a valid value.
360 kHitNotMarkedAsNil, ///< A hit was marked as not found, but the corresponding hit structure was not set to nil.
361 kInvalidDetElementNumber, ///< An invalid detector element ID was found.
362 kInvalidChamberNumber, ///< An invalid chamber number was found.
363 kHitIsNil, ///< The hit cannot be set to a nil value.
364 kInvalidChannelCountB, ///< The number of channels in the bending plane indicated is zero or outside the valid range.
365 kInvalidChannelCountNB, ///< The number of channels in the non-bending plane indicated is zero or outside the valid range.
366 kInvalidChargeB, ///< The charge for the bending plane does not have a valid value.
367 kInvalidChargeNB, ///< The charge for the non-bending plane does not have a valid value.
368 kInvalidBusPatchId, ///< The bus patch ID is outside the valid range.
369 kInvalidManuId, ///< The MANU ID is outside the valid range.
370 kInvalidChannelAddress, ///< The MANU channel address is outside the valid range.
371 kInvalidSignal, ///< The ADC signal value is outside the valid range.
372 kDataWordDifferent, ///< The raw data word is different from the unpacked values.
373 kChiSquareInvalid, ///< The chi squared value must be a positive value or -1 indicating a fitting error.
374 kMomentumVectorNotZero, ///< The chi sqaured value is set to -1, but momentum vector not zero.
375 kRoiRadiusInvalid, ///< The region of interest radius is invalid.
376 kHitNotWithinRoi, ///< A tracks hit is not within the corresponding region of interest.
377 kPtValueNotValid, ///< The pT value is not positive nor -1 indicating an invalid value.
378 kPairTrackIdsAreIdentical, ///< The track IDs of the track pair are identical.
379 kMassValueNotValid, ///< The invariant mass value is not positive nor -1 indicating an invalid value.
380 kLowPtCountInvalid, ///< The low pT trigger count is greater than 2, which is invalid.
381 kHighPtCountInvalid, ///< The high pT trigger count is greater than 2, which is invalid.
382 kFoundDuplicateIDs, ///< Found duplicate identifiers, but they should all be unique.
383 kFoundDuplicateHits, ///< Found duplicate hits.
384 kFoundDuplicateTriggers ///< Found duplicate trigger decisions.
388 * This method converts the WhyNotValid enumeration to a string representation.
390 static const char* FailureReasonToString(WhyNotValid reason);
393 * This method returns a string containing a user readable message explaining
394 * the reason for failure described by the WhyNotValid enumeration.
396 static const char* FailureReasonToMessage(WhyNotValid reason);
399 * Method used to check if the header information corresponds to the
400 * supposed type of the trigger records data block.
401 * This method will return either kHeaderContainsWrongType or
402 * kHeaderContainsWrongRecordWidth as the reason code.
403 * [in] \param block The data block to check.
404 * [out] \param reason If this is not NULL, then the variable pointed to
405 * by this pointer will be filled with the reason code describing why
406 * the header is not valid, if and only if a problem is found with
408 * \returns true if there is no problem with the header and false otherwise.
410 static bool HeaderOk(const AliHLTMUONTriggerRecordsBlockStruct& block, WhyNotValid* reason = NULL)
412 AliHLTUInt32_t count = 1;
413 return HeaderOk(block, reason, count);
417 * Method used to check if the header information corresponds to the
418 * supposed type of the trigger debug information data block.
419 * This method will return either kHeaderContainsWrongType or
420 * kHeaderContainsWrongRecordWidth as the reason code.
421 * [in] \param block The data block to check.
422 * [out] \param reason If this is not NULL, then the variable pointed to
423 * by this pointer will be filled with the reason code describing why
424 * the header is not valid, if and only if a problem is found with
426 * \returns true if there is no problem with the header and false otherwise.
428 static bool HeaderOk(const AliHLTMUONTrigRecsDebugBlockStruct& block, WhyNotValid* reason = NULL)
430 AliHLTUInt32_t count = 1;
431 return HeaderOk(block, reason, count);
435 * Method used to check if the header information corresponds to the
436 * supposed type of the reconstructed hits data block.
437 * This method will return either kHeaderContainsWrongType or
438 * kHeaderContainsWrongRecordWidth as the reason code.
439 * [in] \param block The data block to check.
440 * [out] \param reason If this is not NULL, then the variable pointed to
441 * by this pointer will be filled with the reason code describing why
442 * the header is not valid, if and only if a problem is found with
444 * \returns true if there is no problem with the header and false otherwise.
446 static bool HeaderOk(const AliHLTMUONRecHitsBlockStruct& block, WhyNotValid* reason = NULL)
448 AliHLTUInt32_t count = 1;
449 return HeaderOk(block, reason, count);
453 * Method used to check if the header information corresponds to the
454 * supposed type of the clusters data block.
455 * This method will return either kHeaderContainsWrongType or
456 * kHeaderContainsWrongRecordWidth as the reason code.
457 * [in] \param block The data block to check.
458 * [out] \param reason If this is not NULL, then the variable pointed to
459 * by this pointer will be filled with the reason code describing why
460 * the header is not valid, if and only if a problem is found with
462 * \returns true if there is no problem with the header and false otherwise.
464 static bool HeaderOk(const AliHLTMUONClustersBlockStruct& block, WhyNotValid* reason = NULL)
466 AliHLTUInt32_t count = 1;
467 return HeaderOk(block, reason, count);
471 * Method used to check if the header information corresponds to the
472 * supposed type of the channels data block.
473 * This method will return either kHeaderContainsWrongType or
474 * kHeaderContainsWrongRecordWidth as the reason code.
475 * [in] \param block The data block to check.
476 * [out] \param reason If this is not NULL, then the variable pointed to
477 * by this pointer will be filled with the reason code describing why
478 * the header is not valid, if and only if a problem is found with
480 * \returns true if there is no problem with the header and false otherwise.
482 static bool HeaderOk(const AliHLTMUONChannelsBlockStruct& block, WhyNotValid* reason = NULL)
484 AliHLTUInt32_t count = 1;
485 return HeaderOk(block, reason, count);
489 * Method used to check if the header information corresponds to the
490 * supposed type of the Manso tracks data block.
491 * This method will return either kHeaderContainsWrongType or
492 * kHeaderContainsWrongRecordWidth as the reason code.
493 * [in] \param block The data block to check.
494 * [out] \param reason If this is not NULL, then the variable pointed to
495 * by this pointer will be filled with the reason code describing why
496 * the header is not valid, if and only if a problem is found with
498 * \returns true if there is no problem with the header and false otherwise.
500 static bool HeaderOk(const AliHLTMUONMansoTracksBlockStruct& block, WhyNotValid* reason = NULL)
502 AliHLTUInt32_t count = 1;
503 return HeaderOk(block, reason, count);
507 * Method used to check if the header information corresponds to the
508 * supposed type of the Manso candidates data block.
509 * This method will return either kHeaderContainsWrongType or
510 * kHeaderContainsWrongRecordWidth as the reason code.
511 * [in] \param block The data block to check.
512 * [out] \param reason If this is not NULL, then the variable pointed to
513 * by this pointer will be filled with the reason code describing why
514 * the header is not valid, if and only if a problem is found with
516 * \returns true if there is no problem with the header and false otherwise.
518 static bool HeaderOk(const AliHLTMUONMansoCandidatesBlockStruct& block, WhyNotValid* reason = NULL)
520 AliHLTUInt32_t count = 1;
521 return HeaderOk(block, reason, count);
525 * Method used to check if the header information corresponds to the
526 * supposed type of the single tracks dHLT trigger decision data block.
527 * This method will return either kHeaderContainsWrongType or
528 * kHeaderContainsWrongRecordWidth as the reason code.
529 * [in] \param block The data block to check.
530 * [out] \param reason If this is not NULL, then the variable pointed to
531 * by this pointer will be filled with the reason code describing why
532 * the header is not valid, if and only if a problem is found with
534 * \returns true if there is no problem with the header and false otherwise.
536 static bool HeaderOk(const AliHLTMUONSinglesDecisionBlockStruct& block, WhyNotValid* reason = NULL)
538 AliHLTUInt32_t count = 1;
539 return HeaderOk(block, reason, count);
543 * Method used to check if the header information corresponds to the
544 * supposed type of the track pairs dHLT trigger decision data block.
545 * This method will return either kHeaderContainsWrongType or
546 * kHeaderContainsWrongRecordWidth as the reason code.
547 * [in] \param block The data block to check.
548 * [out] \param reason If this is not NULL, then the variable pointed to
549 * by this pointer will be filled with the reason code describing why
550 * the header is not valid, if and only if a problem is found with
552 * \returns true if there is no problem with the header and false otherwise.
554 static bool HeaderOk(const AliHLTMUONPairsDecisionBlockStruct& block, WhyNotValid* reason = NULL)
556 AliHLTUInt32_t count = 1;
557 return HeaderOk(block, reason, count);
561 * Methods used to check if the header information corresponds to the
562 * supposed type of the data block.
563 * If the 'reason' parameter should point to an array which will store
564 * the reason codes indicating the problems with the data block.
565 * The 'reasonCount' parameter should initialy contain the number of
566 * elements that can be stored in reason. When the method exits it will
567 * store the number of elements in the 'reason' array actually filled.
569 static bool HeaderOk(
570 const AliHLTMUONTriggerRecordsBlockStruct& block,
571 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
574 static bool HeaderOk(
575 const AliHLTMUONTrigRecsDebugBlockStruct& block,
576 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
579 static bool HeaderOk(
580 const AliHLTMUONRecHitsBlockStruct& block,
581 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
584 static bool HeaderOk(
585 const AliHLTMUONClustersBlockStruct& block,
586 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
589 static bool HeaderOk(
590 const AliHLTMUONChannelsBlockStruct& block,
591 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
594 static bool HeaderOk(
595 const AliHLTMUONMansoTracksBlockStruct& block,
596 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
599 static bool HeaderOk(
600 const AliHLTMUONMansoCandidatesBlockStruct& block,
601 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
604 static bool HeaderOk(
605 const AliHLTMUONSinglesDecisionBlockStruct& block,
606 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
609 static bool HeaderOk(
610 const AliHLTMUONPairsDecisionBlockStruct& block,
611 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
615 * This method is used to check more extensively if the integrity of the
616 * trigger record structure is OK and returns true in that case.
617 * [in] \param tr The trigger record structure to check.
618 * [out] \param reason If this is not NULL, then it will be filled with
619 * the reason code describing why the structure is not valid, if and
620 * only if a problem is found with the data.
621 * \returns true if there is no problem with the structure and false otherwise.
623 static bool IntegrityOk(
624 const AliHLTMUONTriggerRecordStruct& tr,
625 WhyNotValid* reason = NULL
628 AliHLTUInt32_t count = 1;
629 return IntegrityOk(tr, reason, count);
633 * This method is used to check more extensively if the integrity of the
634 * dHLT raw internal data block is OK and returns true in that case.
635 * [in] \param block The trigger record data block to check.
636 * [out] \param reason If this is not NULL, then it will be filled with
637 * the reason code describing why the data block is not valid, if and
638 * only if a problem is found with the data.
639 * [out] \param recordNum If this is not NULL, then it will be filled with
640 * the number of the trigger record that had a problem. This value will
641 * only contain a valid value if the method RecordNumberWasSet(*reason)
642 * returns true. Thus, 'reason' must be set.
643 * \returns true if there is no problem with the data and false otherwise.
645 static bool IntegrityOk(
646 const AliHLTMUONTriggerRecordsBlockStruct& block,
647 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
650 AliHLTUInt32_t count = 1;
651 return IntegrityOk(block, reason, recordNum, count);
655 * This method is used to check more extensively if the integrity of the
656 * trigger record debug information structure is OK and returns true in that case.
657 * [in] \param trigInfo The trigger record debug information structure to check.
658 * [out] \param reason If this is not NULL, then it will be filled with
659 * the reason code describing why the structure is not valid, if and
660 * only if a problem is found with the data.
661 * \returns true if there is no problem with the structure and false otherwise.
663 static bool IntegrityOk(
664 const AliHLTMUONTrigRecInfoStruct& trigInfo,
665 WhyNotValid* reason = NULL
668 AliHLTUInt32_t count = 1;
669 return IntegrityOk(trigInfo, reason, count);
673 * This method is used to check more extensively if the integrity of the
674 * dHLT raw internal data block is OK and returns true in that case.
675 * [in] \param block The trigger record debugging information data block to check.
676 * [out] \param reason If this is not NULL, then it will be filled with
677 * the reason code describing why the data block is not valid, if and
678 * only if a problem is found with the data.
679 * [out] \param recordNum If this is not NULL, then it will be filled with
680 * the number of the trigger record debug information structure that had
681 * a problem. This value will only contain a valid value if the method
682 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
683 * \returns true if there is no problem with the data and false otherwise.
685 static bool IntegrityOk(
686 const AliHLTMUONTrigRecsDebugBlockStruct& block,
687 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
690 AliHLTUInt32_t count = 1;
691 return IntegrityOk(block, reason, recordNum, count);
695 * This method is used to check more extensively if the integrity of the
696 * reconstructed hit structure is OK and returns true in that case.
697 * [in] \param hit The reconstructed hit structure to check.
698 * [out] \param reason If this is not NULL, then it will be filled with
699 * the reason code describing why the structure is not valid, if and
700 * only if a problem is found with the data.
701 * \returns true if there is no problem with the data and false otherwise.
703 static bool IntegrityOk(
704 const AliHLTMUONRecHitStruct& hit,
705 WhyNotValid* reason = NULL
708 AliHLTUInt32_t count = 1;
709 return IntegrityOk(hit, reason, count);
713 * This method is used to check more extensively if the integrity of the
714 * dHLT raw internal data block is OK and returns true in that case.
715 * [in] \param block The reconstructed hits data block to check.
716 * [out] \param reason If this is not NULL, then it will be filled with
717 * the reason code describing why the data block is not valid, if and
718 * only if a problem is found with the data.
719 * [out] \param recordNum If this is not NULL, then it will be filled with
720 * the number of the cluster structure that had a problem. This value
721 * will only contain a valid value if the method
722 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
723 * \returns true if there is no problem with the data and false otherwise.
725 static bool IntegrityOk(
726 const AliHLTMUONRecHitsBlockStruct& block,
727 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
730 AliHLTUInt32_t count = 1;
731 return IntegrityOk(block, reason, recordNum, count);
735 * This method is used to check more extensively if the integrity of the
736 * cluster data structure is OK and returns true in that case.
737 * [in] \param cluster The cluster structure to check.
738 * [out] \param reason If this is not NULL, then it will be filled with
739 * the reason code describing why the structure is not valid, if and
740 * only if a problem is found with the data.
741 * \returns true if there is no problem with the data and false otherwise.
743 static bool IntegrityOk(
744 const AliHLTMUONClusterStruct& cluster,
745 WhyNotValid* reason = NULL
748 AliHLTUInt32_t count = 1;
749 return IntegrityOk(cluster, reason, count);
753 * This method is used to check more extensively if the integrity of the
754 * dHLT raw internal data block is OK and returns true in that case.
755 * [in] \param block The clusters data block to check.
756 * [out] \param reason If this is not NULL, then it will be filled with
757 * the reason code describing why the data block is not valid, if and
758 * only if a problem is found with the data.
759 * [out] \param recordNum If this is not NULL, then it will be filled with
760 * the number of the cluster structure that had a problem. This value
761 * will only contain a valid value if the method
762 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
763 * \returns true if there is no problem with the data and false otherwise.
765 static bool IntegrityOk(
766 const AliHLTMUONClustersBlockStruct& block,
767 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
770 AliHLTUInt32_t count = 1;
771 return IntegrityOk(block, reason, recordNum, count);
775 * This method is used to check more extensively if the integrity of the
776 * channel data structure is OK and returns true in that case.
777 * [in] \param cluster The channel structure to check.
778 * [out] \param reason If this is not NULL, then it will be filled with
779 * the reason code describing why the structure is not valid, if and
780 * only if a problem is found with the data.
781 * \returns true if there is no problem with the data and false otherwise.
783 static bool IntegrityOk(
784 const AliHLTMUONChannelStruct& channel,
785 WhyNotValid* reason = NULL
788 AliHLTUInt32_t count = 1;
789 return IntegrityOk(channel, reason, count);
793 * This method is used to check more extensively if the integrity of the
794 * dHLT raw internal data block is OK and returns true in that case.
795 * [in] \param block The ADC channels data block to check.
796 * [out] \param reason If this is not NULL, then it will be filled with
797 * the reason code describing why the data block is not valid, if and
798 * only if a problem is found with the data.
799 * [out] \param recordNum If this is not NULL, then it will be filled with
800 * the number of the channel structure that had a problem. This value
801 * will only contain a valid value if the method
802 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
803 * \returns true if there is no problem with the data and false otherwise.
805 static bool IntegrityOk(
806 const AliHLTMUONChannelsBlockStruct& block,
807 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
810 AliHLTUInt32_t count = 1;
811 return IntegrityOk(block, reason, recordNum, count);
815 * This method is used to check more extensively if the integrity of the
816 * Manso track structure is OK and returns true in that case.
817 * [in] \param track The Manso track structure to check.
818 * [out] \param reason If this is not NULL, then it will be filled with
819 * the reason code describing why the structure is not valid, if and
820 * only if a problem is found with the data.
821 * \returns true if there is no problem with the structure and false otherwise.
823 static bool IntegrityOk(
824 const AliHLTMUONMansoTrackStruct& track,
825 WhyNotValid* reason = NULL
828 AliHLTUInt32_t count = 1;
829 return IntegrityOk(track, reason, count);
833 * This method is used to check more extensively if the integrity of the
834 * dHLT raw internal data block is OK and returns true in that case.
835 * [in] \param block The Manso track data block to check.
836 * [out] \param reason If this is not NULL, then it will be filled with
837 * the reason code describing why the data block is not valid, if and
838 * only if a problem is found with the data.
839 * [out] \param recordNum If this is not NULL, then it will be filled with
840 * the number of the Manso track structure that had a problem.
841 * This value will only contain a valid value if the method
842 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
843 * \returns true if there is no problem with the data and false otherwise.
845 static bool IntegrityOk(
846 const AliHLTMUONMansoTracksBlockStruct& block,
847 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
850 AliHLTUInt32_t count = 1;
851 return IntegrityOk(block, reason, recordNum, count);
855 * This method is used to check more extensively if the integrity of the
856 * Manso track candidate structure is OK and returns true in that case.
857 * [in] \param candidate The Manso track candidate structure to check.
858 * [out] \param reason If this is not NULL, then it will be filled with
859 * the reason code describing why the structure is not valid, if and
860 * only if a problem is found with the data.
861 * \returns true if there is no problem with the structure and false otherwise.
863 static bool IntegrityOk(
864 const AliHLTMUONMansoCandidateStruct& candidate,
865 WhyNotValid* reason = NULL
868 AliHLTUInt32_t count = 1;
869 return IntegrityOk(candidate, reason, count);
873 * This method is used to check more extensively if the integrity of the
874 * dHLT raw internal data block is OK and returns true in that case.
875 * [in] \param block The Manso track candidate data block to check.
876 * [out] \param reason If this is not NULL, then it will be filled with
877 * the reason code describing why the data block is not valid, if and
878 * only if a problem is found with the data.
879 * [out] \param recordNum If this is not NULL, then it will be filled with
880 * the number of the Manso track candidate structure that had a problem.
881 * This value will only contain a valid value if the method
882 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
883 * \returns true if there is no problem with the data and false otherwise.
885 static bool IntegrityOk(
886 const AliHLTMUONMansoCandidatesBlockStruct& block,
887 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
890 AliHLTUInt32_t count = 1;
891 return IntegrityOk(block, reason, recordNum, count);
895 * This method is used to check more extensively if the integrity of the
896 * single track trigger decision structure is OK and returns true in that case.
897 * [in] \param decision The trigger decision structure to check.
898 * [out] \param reason If this is not NULL, then it will be filled with
899 * the reason code describing why the structure is not valid, if and
900 * only if a problem is found with the data.
901 * \returns true if there is no problem with the structure and false otherwise.
903 static bool IntegrityOk(
904 const AliHLTMUONTrackDecisionStruct& decision,
905 WhyNotValid* reason = NULL
908 AliHLTUInt32_t count = 1;
909 return IntegrityOk(decision, reason, count);
913 * This method is used to check more extensively if the integrity of the
914 * dHLT raw internal data block is OK and returns true in that case.
915 * [in] \param block The single track trigger decision data block to check.
916 * [out] \param reason If this is not NULL, then it will be filled with
917 * the reason code describing why the data block is not valid, if and
918 * only if a problem is found with the data.
919 * [out] \param recordNum If this is not NULL, then it will be filled with
920 * the number of the single track trigger decision structure that had
921 * a problem. This value will only contain a valid value if the method
922 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
923 * \returns true if there is no problem with the data and false otherwise.
925 static bool IntegrityOk(
926 const AliHLTMUONSinglesDecisionBlockStruct& block,
927 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
930 AliHLTUInt32_t count = 1;
931 return IntegrityOk(block, reason, recordNum, count);
935 * This method is used to check more extensively if the integrity of the
936 * track pair trigger decision structure is OK and returns true in that case.
937 * [in] \param decision The trigger decision structure to check.
938 * [out] \param reason If this is not NULL, then it will be filled with
939 * the reason code describing why the structure is not valid, if and
940 * only if a problem is found with the data.
941 * \returns true if there is no problem with the structure and false otherwise.
943 static bool IntegrityOk(
944 const AliHLTMUONPairDecisionStruct& decision,
945 WhyNotValid* reason = NULL
948 AliHLTUInt32_t count = 1;
949 return IntegrityOk(decision, reason, count);
953 * This method is used to check more extensively if the integrity of the
954 * dHLT raw internal data block is OK and returns true in that case.
955 * [in] \param block The track pair trigger decision data block to check.
956 * [out] \param reason If this is not NULL, then it will be filled with
957 * the reason code describing why the data block is not valid, if and
958 * only if a problem is found with the data.
959 * [out] \param recordNum If this is not NULL, then it will be filled with
960 * the number of the track pairs trigger decision structure that had
961 * a problem. This value will only contain a valid value if the method
962 * RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
963 * \returns true if there is no problem with the data and false otherwise.
965 static bool IntegrityOk(
966 const AliHLTMUONPairsDecisionBlockStruct& block,
967 WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
970 AliHLTUInt32_t count = 1;
971 return IntegrityOk(block, reason, recordNum, count);
975 * Methods used to check more extensively if the integrity of various
976 * types of data blocks are Ok and returns true in that case.
977 * These can be slow and should generally only be used for debugging.
978 * The methods are able to return multiple reasons for the problems related
979 * to the data block under test.
981 static bool IntegrityOk(
982 const AliHLTMUONTriggerRecordStruct& tr,
983 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
986 static bool IntegrityOk(
987 const AliHLTMUONTriggerRecordsBlockStruct& block,
988 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
989 AliHLTUInt32_t& reasonCount
992 static bool IntegrityOk(
993 const AliHLTMUONTrigRecInfoStruct& trigInfo,
994 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
997 static bool IntegrityOk(
998 const AliHLTMUONTrigRecsDebugBlockStruct& block,
999 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1000 AliHLTUInt32_t& reasonCount
1003 static bool IntegrityOk(
1004 const AliHLTMUONRecHitStruct& hit,
1005 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1008 static bool IntegrityOk(
1009 const AliHLTMUONRecHitsBlockStruct& block,
1010 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1011 AliHLTUInt32_t& reasonCount
1014 static bool IntegrityOk(
1015 const AliHLTMUONClusterStruct& cluster,
1016 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1019 static bool IntegrityOk(
1020 const AliHLTMUONClustersBlockStruct& block,
1021 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1022 AliHLTUInt32_t& reasonCount
1025 static bool IntegrityOk(
1026 const AliHLTMUONChannelStruct& channel,
1027 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1030 static bool IntegrityOk(
1031 const AliHLTMUONChannelsBlockStruct& block,
1032 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1033 AliHLTUInt32_t& reasonCount
1036 static bool IntegrityOk(
1037 const AliHLTMUONMansoTrackStruct& track,
1038 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1041 static bool IntegrityOk(
1042 const AliHLTMUONMansoTracksBlockStruct& block,
1043 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1044 AliHLTUInt32_t& reasonCount
1047 static bool IntegrityOk(
1048 const AliHLTMUONMansoCandidateStruct& candidate,
1049 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1052 static bool IntegrityOk(
1053 const AliHLTMUONMansoCandidatesBlockStruct& block,
1054 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1055 AliHLTUInt32_t& reasonCount
1058 static bool IntegrityOk(
1059 const AliHLTMUONTrackDecisionStruct& decision,
1060 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1063 static bool IntegrityOk(
1064 const AliHLTMUONSinglesDecisionBlockStruct& block,
1065 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1066 AliHLTUInt32_t& reasonCount
1069 static bool IntegrityOk(
1070 const AliHLTMUONPairDecisionStruct& decision,
1071 WhyNotValid* reason, AliHLTUInt32_t& reasonCount
1074 static bool IntegrityOk(
1075 const AliHLTMUONPairsDecisionBlockStruct& block,
1076 WhyNotValid* reason, AliHLTUInt32_t* recordNum,
1077 AliHLTUInt32_t& reasonCount
1081 * Returns true if the \em recordNum in the corresponding IntegrityOk method
1082 * would have been set, if it returned false and a reason was set.
1083 * This helper method makes it easy to test if the \em recordNum parameter
1084 * is filled with a valid value or not.
1086 static bool RecordNumberWasSet(WhyNotValid reason);
1090 // Should never have to create, copy or destroy this object.
1091 AliHLTMUONUtils() {}
1092 AliHLTMUONUtils(const AliHLTMUONUtils& obj);
1093 virtual ~AliHLTMUONUtils() {}
1094 AliHLTMUONUtils& operator = (const AliHLTMUONUtils& obj);
1096 ClassDef(AliHLTMUONUtils, 0); // Interface for helpful dHLT utility methods.
1099 //_____________________________________________________________________________
1101 inline std::ostream& operator << (std::ostream& stream, AliHLTMUONUtils::WhyNotValid reason)
1103 /// Stream operator for the WhyNotValid enumeration for usage with
1104 /// std::ostream classes. Allows usages such as:
1105 /// AliHLTMUONUtils::WhyNotValid r; std::cout << r;
1107 stream << AliHLTMUONUtils::FailureReasonToString(reason);
1111 //_____________________________________________________________________________
1113 // Since c++ is missing a finally "keyword" we define one. Its usage is identical
1114 // to a try..finally statement in Java etc.. however, since it is officialy a macro
1115 // one must use the ( ) brackets instead of { }
1116 // If the compiler supports __finally use it otherwise make our own.
1117 #if defined(__BORLANDC__)
1118 # define finally(str) __finally{str}
1120 # define finally(code) \
1127 #endif // __BORLANDC__
1129 // Here we define the DebugTrace(message) macro for easy embedding of debug
1130 // information into the dimuon HLT code. Its usage is meant to be for generating
1131 // traces of the program which are only useful during full scale debugging.
1132 // Log messages should use the standard HLT logging mechanisms.
1133 // The output is only generated in programs compiled with the DEBUGTRACE directive
1134 // defined. Here is a usage example:
1137 // DebugTrace("some debug information.");
1140 // One can also use C++ ostream operators and manipulators like so:
1144 // DebugTrace("x = " << x << " and y = 0x" << std::hex << y );
1148 # include <iostream>
1149 # define DebugTrace(message) {std::cout << message << std::endl;}
1151 # define DebugTrace(message)
1155 #endif // ALIHLTMUONUTILS_H