]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/MUON/AliHLTMUONUtils.cxx
FindFASTJET
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONUtils.cxx
index 1fb7c59bba558518d6f1ce4b4637d7489185184e..12c13ff83263b5125a78e6b2c556762c3f852c26 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+// $Id$
 
 ///
 /// @file   AliHLTMUONUtils.cxx
@@ -31,6 +31,7 @@
 #include "AliHLTMUONChannelsBlockStruct.h"
 #include "AliHLTMUONMansoTracksBlockStruct.h"
 #include "AliHLTMUONMansoCandidatesBlockStruct.h"
+#include "AliHLTMUONTracksBlockStruct.h"
 #include "AliHLTMUONSinglesDecisionBlockStruct.h"
 #include "AliHLTMUONPairsDecisionBlockStruct.h"
 #include "AliMUONTrackerDDLDecoderEventHandler.h"
@@ -116,15 +117,68 @@ void AliHLTMUONUtils::UnpackRecHitFlags(
 {
        /// This unpacks the AliHLTMUONRecHitStruct::fFlags bits into
        /// its component fields.
-       /// [in]  @param flags  The flags from an AliHLTMUONRecHitStruct structure.
-       /// [out] @param chamber    Sets the chamber number in the range [0..13].
-       /// [out] @param detElemId  Sets the detector element ID number.
+       /// @param [in]  flags  The flags from an AliHLTMUONRecHitStruct structure.
+       /// @param [out] chamber    Sets the chamber number in the range [0..13].
+       /// @param [out] detElemId  Sets the detector element ID number.
        
        chamber = (flags >> 12) & 0xF;
        detElemId = flags & 0xFFF;
 }
 
 
+AliHLTUInt32_t AliHLTMUONUtils::PackTrackFlags(
+               AliHLTMUONParticleSign sign, const bool hitset[16]
+       )
+{
+       /// This packs the given parameters into the bits of a word appropriate
+       /// for AliHLTMUONTrackStruct::fFlags.
+       /// @param sign    The particle sign.
+       /// @param hitset  Flags to indicate if the corresponding fHits[i] elements
+       ///                was set/filled.
+       /// @return  Returns the 32 bit packed word.
+       
+       AliHLTUInt32_t flags;
+       switch (sign)
+       {
+       case kSignMinus: flags = 0x80000000; break;
+       case kSignPlus:  flags = 0x40000000; break;
+       default:         flags = 0x00000000; break;
+       }
+       
+       for (AliHLTUInt32_t i = 0; i < 16; i++)
+       {
+               flags |= (hitset[i] ? (0x1 << i) : 0);
+       }
+       return flags;
+}
+
+
+void AliHLTMUONUtils::UnpackTrackFlags(
+               AliHLTUInt32_t flags, AliHLTMUONParticleSign& sign, bool hitset[16]
+       )
+{
+       /// This unpacks the AliHLTMUONTrackStruct::fFlags bits into
+       /// its component fields.
+       /// @param flags  The flags from an AliHLTMUONTrackStruct structure.
+       /// @param sign    Sets this to the particle sign.
+       /// @param hitset  Sets the array elements to indicate if the corresponding
+       ///                fHits[i] element was set/filled.
+       
+       AliHLTUInt32_t signbits = flags & 0xC0000000;
+       switch (signbits)
+       {
+       case 0x80000000: sign = kSignMinus;   break;
+       case 0x40000000: sign = kSignPlus;    break;
+       default:         sign = kSignUnknown; break;
+       }
+       
+       for (AliHLTUInt32_t i = 0; i < 16; i++)
+       {
+               hitset[i] = ((flags & (0x1u << i)) == (0x1u << i));
+       }
+}
+
+
 AliHLTUInt32_t AliHLTMUONUtils::PackTrackDecisionBits(bool highPt, bool lowPt)
 {
        ///
@@ -444,6 +498,10 @@ AliHLTMUONDataBlockType AliHLTMUONUtils::ParseCommandLineTypeString(const char*
        {
                return kMansoCandidatesDataBlock;
        }
+       else if (strcmp(type, "tracks") == 0)
+       {
+               return kTracksDataBlock;
+       }
        else if (strcmp(type, "singlesdecision") == 0)
        {
                return kSinglesDecisionDataBlock;
@@ -487,6 +545,9 @@ const char* AliHLTMUONUtils::DataBlockTypeToString(AliHLTMUONDataBlockType type)
        case kMansoCandidatesDataBlock:
                t = AliHLTMUONConstants::MansoCandidatesBlockDataType();
                break;
+       case kTracksDataBlock:
+               t = AliHLTMUONConstants::TracksBlockDataType();
+               break;
        case kSinglesDecisionDataBlock:
                t = AliHLTMUONConstants::SinglesDecisionBlockDataType();
                break;
@@ -532,6 +593,8 @@ const char* AliHLTMUONUtils::FailureReasonToString(WhyNotValid reason)
        case kDataWordDifferent: return "kDataWordDifferent";
        case kChiSquareInvalid: return "kChiSquareInvalid";
        case kMomentumVectorNotZero: return "kMomentumVectorNotZero";
+       case kMomentumParamsNotZero: return "kMomentumParamsNotZero";
+       case kDCAVertexNotZero: return "kDCAVertexNotZero";
        case kRoiRadiusInvalid: return "kRoiRadiusInvalid";
        case kHitNotWithinRoi: return "kHitNotWithinRoi";
        case kPtValueNotValid: return "kPtValueNotValid";
@@ -605,10 +668,16 @@ const char* AliHLTMUONUtils::FailureReasonToMessage(WhyNotValid reason)
                return "The raw data word is different from the unpacked values.";
        case kChiSquareInvalid:
                return "The chi squared value must be a positive value or -1"
-                       " indicating a fitting error.";
+                       " indicating no fit or a fitting error.";
        case kMomentumVectorNotZero:
                return "The chi sqaured value is set to -1 indicating momentum"
                        " was not fitted, but the momentum vector was not zero.";
+       case kMomentumParamsNotZero:
+               return "The chi sqaured value is set to -1 indicating the track"
+                       " was not fitted, but the fitted momentum parameters are not zero.";
+       case kDCAVertexNotZero:
+               return "The chi sqaured value is set to -1 indicating the track"
+                       " was not fitted, but the DCA vertex is not zero.";
        case kRoiRadiusInvalid:
                return "The region of interest radius is invalid.";
        case kHitNotWithinRoi:
@@ -691,12 +760,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -739,12 +808,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -787,12 +856,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -835,12 +904,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -883,12 +952,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -931,12 +1000,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -979,12 +1048,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1020,6 +1089,54 @@ bool AliHLTMUONUtils::HeaderOk(
 }
 
 
+bool AliHLTMUONUtils::HeaderOk(
+               const AliHLTMUONTracksBlockStruct& block,
+               WhyNotValid* reason, AliHLTUInt32_t& reasonCount
+       )
+{
+       /// Method used to check if the header information corresponds to the
+       /// supposed type of the raw dHLT data block.
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
+       ///      to an array of at least 'reasonCount' number of elements. It will
+       ///      be filled with the reason codes describing why the header is not
+       ///      valid.
+       /// \param [in,out] reasonCount  This should initially specify the size of
+       ///      the array pointed to by 'reason'. It will be filled with the number
+       ///      of items actually filled into the reason array upon exit from this
+       ///      method.
+       /// \returns  true if there is no problem with the header and false otherwise.
+       
+       AliHLTUInt32_t maxCount = reasonCount;
+       reasonCount = 0;
+       bool result = true;
+       
+       // The block must have the correct type.
+       if (block.fHeader.fType != kTracksDataBlock)
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kHeaderContainsWrongType;
+                       reasonCount++;
+               }
+               result = false;
+       }
+       
+       // The block's record width must be the correct size.
+       if (block.fHeader.fRecordWidth != sizeof(AliHLTMUONTrackStruct))
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kHeaderContainsWrongRecordWidth;
+                       reasonCount++;
+               }
+               result = false;
+       }
+       
+       return result;
+}
+
+
 bool AliHLTMUONUtils::HeaderOk(
                const AliHLTMUONSinglesDecisionBlockStruct& block,
                WhyNotValid* reason, AliHLTUInt32_t& reasonCount
@@ -1027,12 +1144,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1075,12 +1192,12 @@ bool AliHLTMUONUtils::HeaderOk(
 {
        /// Method used to check if the header information corresponds to the
        /// supposed type of the raw dHLT data block.
-       /// [in]  \param block  The data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the header is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1124,12 +1241,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// trigger record structure is OK and returns true in that case.
-       /// [in] \param tr  The trigger record structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  tr  The trigger record structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1215,12 +1332,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT raw internal data block is OK and returns true in that case.
-       /// [in] \param block  The trigger record data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The trigger record data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the trigger record that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -1233,7 +1350,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kInvalidChamberNumber
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -1293,12 +1410,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// trigger record debug information structure is OK and returns true in that case.
-       /// [in] \param trigInfo  The trigger record debug information structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  trigInfo  The trigger record debug information structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1351,13 +1468,13 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT raw internal data block is OK and returns true in that case.
-       /// [in] \param block  The trigger record debugging information data block
+       /// \param [in]  block  The trigger record debugging information data block
        ///      to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the trigger record debug information
        ///      structure that had a problem.
@@ -1367,7 +1484,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kInvalidDetElementNumber
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -1427,12 +1544,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// reconstructed hit structure is OK and returns true in that case.
-       /// [in] \param hit  The reconstructed hit structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  hit  The reconstructed hit structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1498,12 +1615,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT raw internal hits data block is OK and returns true in that case.
-       /// [in] \param block  The reconstructed hits data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The reconstructed hits data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the reconstructed hits that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -1513,7 +1630,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kInvalidChamberNumber
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -1573,12 +1690,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// cluster structure is OK and returns true in that case.
-       /// [in] \param cluster  The cluster structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  cluster  The cluster structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1678,12 +1795,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal clusters data block is OK and returns true in that case.
-       /// [in] \param block  The clusters data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The clusters data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the cluster structure that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -1697,7 +1814,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kInvalidChargeNB
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -1775,12 +1892,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// channel structure is OK and returns true in that case.
-       /// [in] \param cluster  The channel structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  cluster  The channel structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -1876,12 +1993,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal channels data block is OK and returns true in that case.
-       /// [in] \param block  The channels data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The channels data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the channel structure that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -1894,7 +2011,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kDataWordDifferent
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -1936,12 +2053,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// Manso track structure is OK and returns true in that case.
-       /// [in] \param track  The track structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  track  The track structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -2062,12 +2179,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal Manso track data block is OK and returns true in that case.
-       /// [in] \param block  The Manso track data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The Manso track data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the Manso track that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -2083,7 +2200,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kInvalidChamberNumber
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -2143,12 +2260,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// Manso track candidate structure is OK and returns true in that case.
-       /// [in] \param track  The track candidate structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  track  The track candidate structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is
        ///      not valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -2208,12 +2325,12 @@ bool AliHLTMUONUtils::IntegrityOk(
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal Manso candidates data block is OK and returns true in
        /// that case.
-       /// [in] \param block  The Manso track candidate data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The Manso track candidate data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the track candidate that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -2228,7 +2345,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kHitNotWithinRoi
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -2280,6 +2397,240 @@ bool AliHLTMUONUtils::IntegrityOk(
 }
 
 
+bool AliHLTMUONUtils::IntegrityOk(
+               const AliHLTMUONTrackStruct& track,
+               WhyNotValid* reason,
+               AliHLTUInt32_t& reasonCount
+       )
+{
+       /// This method is used to check more extensively if the integrity of the
+       /// full track structure is OK and returns true in that case.
+       /// \param [in]  track  The track structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
+       ///      to an array of at least 'reasonCount' number of elements. It will
+       ///      be filled with the reason codes describing why the structure is
+       ///      not valid.
+       /// \param [in,out] reasonCount  This should initially specify the size of
+       ///      the array pointed to by 'reason'. It will be filled with the number
+       ///      of items actually filled into the reason array upon exit from this
+       ///      method.
+       /// \returns  true if there is no problem with the structure and false otherwise.
+       
+       AliHLTUInt32_t maxCount = reasonCount;
+       reasonCount = 0;
+       bool result = true;
+       
+       // Check that the track ID has a valid value.
+       if (not (track.fId >= 0 or track.fId == -1))
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kInvalidIdValue;
+                       reasonCount++;
+               }
+               result = false;
+       }
+       
+       // Check that the corresponding trigger record ID has a valid value.
+       if (not (track.fTrigRec >= 0 or track.fTrigRec == -1))
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kInvalidTriggerIdValue;
+                       reasonCount++;
+               }
+               result = false;
+       }
+       
+       // Make sure that the reserved bits in the fFlags field are set
+       // to zero.
+       if ((track.fFlags & 0x3FFF0000) != 0)
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kReservedBitsNotZero;
+                       reasonCount++;
+               }
+               result = false;
+       }
+
+       // Make sure the sign is not invalid.
+       if ((track.fFlags & 0xC0000000) == 0xC0000000)
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kParticleSignBitsNotValid;
+                       reasonCount++;
+               }
+               result = false;
+       }
+
+       // Check that fHit[i] is nil if the corresponding bit in the
+       // flags word is zero.
+       const AliHLTMUONRecHitStruct& nilhit = AliHLTMUONConstants::NilRecHitStruct();
+       for (int i = 0; i < 16; i++)
+       {
+               if ((track.fFlags & (0x1 << i)) == 0 and track.fHit[i] != nilhit)
+               {
+                       if (reason != NULL and reasonCount < maxCount)
+                       {
+                               reason[reasonCount] = kHitNotMarkedAsNil;
+                               reasonCount++;
+                       }
+                       result = false;
+                       break;
+               }
+       }
+
+       // Check that the chi squared value is valid
+       if (not (track.fChi2 >= 0 or track.fChi2 == -1))
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kChiSquareInvalid;
+                       reasonCount++;
+               }
+               result = false;
+       }
+
+       // Check that if chi squared is -1 then the momentum vector is zero.
+       if (track.fChi2 == -1 and
+           not (track.fPx == 0 and track.fPy == 0 and track.fPz == 0)
+          )
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kMomentumVectorNotZero;
+                       reasonCount++;
+               }
+               result = false;
+       }
+
+       // Check that if chi squared is -1 then the momentum parameters are zero.
+       if (track.fChi2 == -1 and
+           not (track.fInverseBendingMomentum == 0 and track.fThetaX == 0 and track.fThetaY == 0)
+          )
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kMomentumParamsNotZero;
+                       reasonCount++;
+               }
+               result = false;
+       }
+
+       // Check that if chi squared is -1 then the momentum parameters are zero.
+       if (track.fChi2 == -1 and
+           not (track.fX == 0 and track.fY == 0 and track.fZ == 0)
+          )
+       {
+               if (reason != NULL and reasonCount < maxCount)
+               {
+                       reason[reasonCount] = kDCAVertexNotZero;
+                       reasonCount++;
+               }
+               result = false;
+       }
+       
+       // Check the individual hits
+       for (int i = 0; i < 16; i++)
+       {
+               AliHLTUInt32_t filledCount = maxCount - reasonCount;
+               if (not IntegrityOk(track.fHit[i], reason + reasonCount, filledCount))
+               {
+                       reasonCount += filledCount;
+                       result = false;
+               }
+       }
+       
+       return result;
+}
+
+
+bool AliHLTMUONUtils::IntegrityOk(
+               const AliHLTMUONTracksBlockStruct& block,
+               WhyNotValid* reason,
+               AliHLTUInt32_t* recordNum,
+               AliHLTUInt32_t& reasonCount
+       )
+{
+       /// This method is used to check more extensively if the integrity of the
+       /// dHLT internal track data block is OK and returns true in that case.
+       /// \param [in]  block  The track data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
+       ///      to an array of at least 'reasonCount' number of elements. It will
+       ///      be filled with the reason codes describing why the data block is
+       ///      not valid.
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
+       ///      to an array of at least 'reasonCount' number of elements. It will
+       ///      be filled with the number of the Manso track that had a problem.
+       ///      The value 'recordNum[i]' will only contain a valid value if
+       ///      the corresponding 'reason[i]' contains one of:
+       ///        - kInvalidIdValue
+       ///        - kInvalidTriggerIdValue
+       ///        - kReservedBitsNotZero
+       ///        - kParticleSignBitsNotValid
+       ///        - kHitNotMarkedAsNil
+       ///        - kChiSquareInvalid
+       ///        - kMomentumVectorNotZero
+       ///        - kMomentumParamsNotZero
+       ///        - kDCAVertexNotZero
+       ///        - kInvalidDetElementNumber
+       ///        - kInvalidChamberNumber
+       /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
+       ///      was set and is valid or not.
+       /// \param [in,out] reasonCount  This should initially specify the size of
+       ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
+       ///      with the number of items actually filled into the arrays upon exit
+       ///      from this method.
+       /// \returns  true if there is no problem with the data and false otherwise.
+       
+       AliHLTUInt32_t maxCount = reasonCount;
+       bool result = HeaderOk(block, reason, reasonCount);
+       
+       const AliHLTMUONTrackStruct* track =
+               reinterpret_cast<const AliHLTMUONTrackStruct*>(&block + 1);
+       
+       // Check if any track ID is duplicated.
+       for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
+       {
+               AliHLTInt32_t id = track[i].fId;
+               for (AliHLTUInt32_t j = i+1; j < block.fHeader.fNrecords; j++)
+               {
+                       if (id == track[j].fId)
+                       {
+                               if (reason != NULL and reasonCount < maxCount)
+                               {
+                                       reason[reasonCount] = kFoundDuplicateIDs;
+                                       reasonCount++;
+                               }
+                               result = false;
+                       }
+               }
+       }
+       
+       // Check that all the tracks have integrity.
+       for (AliHLTUInt32_t i = 0; i < block.fHeader.fNrecords; i++)
+       {
+               AliHLTUInt32_t filledCount = maxCount - reasonCount;
+               if (not IntegrityOk(track[i], reason+reasonCount, filledCount))
+               {
+                       // reasons filled in IntegrityOk, now we just need to adjust
+                       // reasonCount and fill the recordNum values.
+                       if (recordNum != NULL)
+                       {
+                               for (AliHLTUInt32_t n = 0; n < filledCount; n++)
+                                       recordNum[reasonCount + n] = i;
+                       }
+                       reasonCount += filledCount;
+                       result = false;
+               }
+       }
+       
+       return result;
+}
+
+
 bool AliHLTMUONUtils::IntegrityOk(
                const AliHLTMUONTrackDecisionStruct& decision,
                WhyNotValid* reason,
@@ -2288,12 +2639,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// single track trigger decision structure is OK and returns true in that case.
-       /// [in] \param decision  The trigger decision structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  decision  The trigger decision structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -2351,12 +2702,12 @@ bool AliHLTMUONUtils::IntegrityOk(
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal single track trigger decision data block is OK and returns
        /// true in that case.
-       /// [in] \param block  The single track trigger decision data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The single track trigger decision data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the trigger decision that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -2366,7 +2717,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kPtValueNotValid
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.
@@ -2426,12 +2777,12 @@ bool AliHLTMUONUtils::IntegrityOk(
 {
        /// This method is used to check more extensively if the integrity of the
        /// track pair trigger decision structure is OK and returns true in that case.
-       /// [in] \param decision  The trigger decision structure to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  decision  The trigger decision structure to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the structure is not
        ///      valid.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason'. It will be filled with the number
        ///      of items actually filled into the reason array upon exit from this
        ///      method.
@@ -2526,12 +2877,12 @@ bool AliHLTMUONUtils::IntegrityOk(
        /// This method is used to check more extensively if the integrity of the
        /// dHLT internal track pair trigger decision data block is OK and returns
        /// true in that case.
-       /// [in] \param block  The track pair trigger decision data block to check.
-       /// [out] \param reason  If this is not NULL, then it is assumed to point
+       /// \param [in]  block  The track pair trigger decision data block to check.
+       /// \param [out] reason  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the reason codes describing why the data block is
        ///      not valid.
-       /// [out] \param recordNum  If this is not NULL, then it is assumed to point
+       /// \param [out] recordNum  If this is not NULL, then it is assumed to point
        ///      to an array of at least 'reasonCount' number of elements. It will
        ///      be filled with the number of the trigger decision that had a problem.
        ///      The value 'recordNum[i]' will only contain a valid value if
@@ -2544,7 +2895,7 @@ bool AliHLTMUONUtils::IntegrityOk(
        ///        - kHighPtCountInvalid
        /// \note You can use RecordNumberWasSet(reason[i]) to check if 'recordNum[i]'
        ///      was set and is valid or not.
-       /// [in/out] \param reasonCount  This should initially specify the size of
+       /// \param [in,out] reasonCount  This should initially specify the size of
        ///      the array pointed to by 'reason' and 'recordNum'. It will be filled
        ///      with the number of items actually filled into the arrays upon exit
        ///      from this method.