]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/MUON/AliHLTMUONUtils.h
Changing to using char** rather than const char** for main() due to coverty warning.
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONUtils.h
index 491550d949dda7290fc034f18e5a8e526b1c64e6..48cf384020d52c88400f3e318985084a0e64031f 100644 (file)
@@ -3,7 +3,7 @@
 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
+// $Id$
 
 ///
 /// @file   AliHLTMUONUtils.h
@@ -12,6 +12,7 @@
 /// @brief  Class containing various dimuon HLT utility routines and macros.
 ///
 
+#include "TObject.h"
 #include "AliHLTMUONDataTypes.h"
 #include <ostream>
 
@@ -21,7 +22,7 @@ struct AliHLTMUONTriggerRecordStruct;
 struct AliHLTMUONTriggerRecordsBlockStruct;
 struct AliHLTMUONTrigRecInfoStruct;
 struct AliHLTMUONTrigRecsDebugBlockStruct;
-struct AliHLTMUONTriggerChannelsBlockStruct;
+struct AliHLTMUONRecHitStruct;
 struct AliHLTMUONRecHitsBlockStruct;
 struct AliHLTMUONClusterStruct;
 struct AliHLTMUONClustersBlockStruct;
@@ -31,6 +32,8 @@ struct AliHLTMUONMansoTrackStruct;
 struct AliHLTMUONMansoTracksBlockStruct;
 struct AliHLTMUONMansoCandidateStruct;
 struct AliHLTMUONMansoCandidatesBlockStruct;
+struct AliHLTMUONTrackStruct;
+struct AliHLTMUONTracksBlockStruct;
 struct AliHLTMUONTrackDecisionStruct;
 struct AliHLTMUONSinglesDecisionBlockStruct;
 struct AliHLTMUONPairDecisionStruct;
@@ -71,6 +74,39 @@ public:
                        AliHLTMUONParticleSign& sign, // [out]
                        bool hitset[4] // [out]
                );
+       
+       /**
+        * This packs the given parameters into the bits of a word appropriate
+        * for AliHLTMUONRecHitStruct::fFlags.
+        * @param chamber    The chamber number in the range [0..13].
+        * @param detElemId  Detector element ID number.
+        * @return  Returns the 32 bit packed word.
+        */
+       static AliHLTUInt32_t PackRecHitFlags(
+                       AliHLTUInt8_t chamber, AliHLTUInt16_t detElemId
+               );
+
+       /**
+        * 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.
+        */
+       static void UnpackRecHitFlags(
+                       AliHLTUInt32_t flags, // [in]
+                       AliHLTUInt8_t& chamber, // [out]
+                       AliHLTUInt16_t& detElemId // [out]
+               );
+
+       /**
+        * Returns the detector element ID from the flags bits.
+        * [in]  @param flags  The flags from an AliHLTMUONRecHitStruct structure.
+        */
+       static AliHLTUInt16_t GetDetElemIdFromFlags(AliHLTUInt32_t flags)
+       {
+               return flags & 0xFFF;
+       }
 
        /**
         * This packs the given parameters into the bits of a word appropriate
@@ -103,6 +139,32 @@ public:
        {
                UnpackTriggerRecordFlags(flags, sign, hitset);
        }
+
+       /**
+        * 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.
+        */
+       static AliHLTUInt32_t PackTrackFlags(
+                       AliHLTMUONParticleSign sign, const 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.
+        */
+       static void UnpackTrackFlags(
+                       AliHLTUInt32_t flags, // [in]
+                       AliHLTMUONParticleSign& sign, // [out]
+                       bool hitset[16] // [out]
+               );
        
        /**
         * This packs the given parameters into the bits of a word appropriate
@@ -279,7 +341,7 @@ public:
         */
        static bool IsSpecValid(AliHLTUInt32_t spec)
        {
-               AliHLTUInt32_t mask = ~((1 << 22) - 1);  // First 22 bits indicate DDL number.
+               AliHLTUInt32_t mask = ~AliHLTUInt32_t((1 << 22) - 1);  // First 22 bits indicate DDL number.
                return (spec & mask) == 0x0;
        }
 
@@ -289,7 +351,7 @@ public:
         */
        static bool ContainsDataFromTrigger(AliHLTUInt32_t spec)
        {
-               AliHLTUInt32_t mask = ((1 << 22) - 1) & ~((1 << 20) - 1);
+               AliHLTUInt32_t mask = AliHLTUInt32_t((1 << 22) - 1) & ~AliHLTUInt32_t((1 << 20) - 1);
                return (spec & mask) != 0x0;
        }
 
@@ -299,7 +361,7 @@ public:
         */
        static bool ContainsDataFromTracker(AliHLTUInt32_t spec)
        {
-               AliHLTUInt32_t mask = ((1 << 20) - 1);
+               AliHLTUInt32_t mask = AliHLTUInt32_t((1 << 20) - 1);
                return (spec & mask) != 0x0;
        }
        
@@ -334,8 +396,12 @@ public:
                kParticleSignBitsNotValid,  ///< The particle sign bits are not a valid value.
                kHitNotMarkedAsNil,  ///< A hit was marked as not found, but the corresponding hit structure was not set to nil.
                kInvalidDetElementNumber,  ///< An invalid detector element ID was found.
+               kInvalidChamberNumber,  ///< An invalid chamber number was found.
                kHitIsNil,  ///< The hit cannot be set to a nil value.
-               kInvalidChannelCount,  ///< The number of channels indicated is zero or outside the valid range.
+               kInvalidChannelCountB,  ///< The number of channels in the bending plane indicated is zero or outside the valid range.
+               kInvalidChannelCountNB,  ///< The number of channels in the non-bending plane indicated is zero or outside the valid range.
+               kInvalidChargeB, ///< The charge for the bending plane does not have a valid value.
+               kInvalidChargeNB, ///< The charge for the non-bending plane does not have a valid value.
                kInvalidBusPatchId,  ///< The bus patch ID is outside the valid range.
                kInvalidManuId,  ///< The MANU ID is outside the valid range.
                kInvalidChannelAddress,  ///< The MANU channel address is outside the valid range.
@@ -343,6 +409,8 @@ public:
                kDataWordDifferent, ///< The raw data word is different from the unpacked values.
                kChiSquareInvalid,  ///< The chi squared value must be a positive value or -1 indicating a fitting error.
                kMomentumVectorNotZero, ///< The chi sqaured value is set to -1, but momentum vector not zero.
+               kMomentumParamsNotZero, ///< The chi sqaured value is set to -1, but fitted momentum parameters are not zero.
+               kDCAVertexNotZero, ///< The chi sqaured value is set to -1, but DCA vertex is not zero.
                kRoiRadiusInvalid, ///< The region of interest radius is invalid.
                kHitNotWithinRoi, ///< A tracks hit is not within the corresponding region of interest.
                kPtValueNotValid,  ///< The pT value is not positive nor -1 indicating an invalid value.
@@ -402,9 +470,6 @@ public:
                return HeaderOk(block, reason, count);
        }
        
-       // this method is deprecated.
-       static bool HeaderOk(const AliHLTMUONTriggerChannelsBlockStruct& block, WhyNotValid* reason = NULL);
-       
        /**
         * Method used to check if the header information corresponds to the
         * supposed type of the reconstructed hits data block.
@@ -495,6 +560,24 @@ public:
                return HeaderOk(block, reason, count);
        }
        
+       /**
+        * Method used to check if the header information corresponds to the
+        * supposed type of the tracks data block given.
+        * This method will return either kHeaderContainsWrongType or
+        * kHeaderContainsWrongRecordWidth as the reason code.
+        * [in]  \param block  The data block to check.
+        * [out] \param reason  If this is not NULL, then the variable pointed to
+        *      by this pointer will be filled with the reason code describing why
+        *      the header is not valid, if and only if a problem is found with
+        *      the data.
+        * \returns  true if there is no problem with the header and false otherwise.
+        */
+       static bool HeaderOk(const AliHLTMUONTracksBlockStruct& block, WhyNotValid* reason = NULL)
+       {
+               AliHLTUInt32_t count = 1;
+               return HeaderOk(block, reason, count);
+       }
+       
        /**
         * Method used to check if the header information corresponds to the
         * supposed type of the single tracks dHLT trigger decision data block.
@@ -575,6 +658,11 @@ public:
                        WhyNotValid* reason, AliHLTUInt32_t& reasonCount
                );
        
+       static bool HeaderOk(
+                       const AliHLTMUONTracksBlockStruct& block,
+                       WhyNotValid* reason, AliHLTUInt32_t& reasonCount
+               );
+       
        static bool HeaderOk(
                        const AliHLTMUONSinglesDecisionBlockStruct& block,
                        WhyNotValid* reason, AliHLTUInt32_t& reasonCount
@@ -665,8 +753,23 @@ public:
                return IntegrityOk(block, reason, recordNum, count);
        }
        
-       // this method is deprecated.
-       static bool IntegrityOk(const AliHLTMUONTriggerChannelsBlockStruct& block, WhyNotValid* reason = NULL);
+       /**
+        * 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 will be filled with
+        *      the reason code describing why the structure is not valid, if and
+        *      only if a problem is found with the data.
+        * \returns  true if there is no problem with the data and false otherwise.
+        */
+       static bool IntegrityOk(
+                       const AliHLTMUONRecHitStruct& hit,
+                       WhyNotValid* reason = NULL
+               )
+       {
+               AliHLTUInt32_t count = 1;
+               return IntegrityOk(hit, reason, count);
+       }
        
        /**
         * This method is used to check more extensively if the integrity of the
@@ -675,15 +778,19 @@ public:
         * [out] \param reason  If this is not NULL, then it will be filled with
         *      the reason code describing why the data block is not valid, if and
         *      only if a problem is found with the data.
+        * [out] \param recordNum  If this is not NULL, then it will be filled with
+        *      the number of the cluster structure that had a problem. This value
+        *      will only contain a valid value if the method
+        *      RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
         * \returns  true if there is no problem with the data and false otherwise.
         */
        static bool IntegrityOk(
                        const AliHLTMUONRecHitsBlockStruct& block,
-                       WhyNotValid* reason = NULL
+                       WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
                )
        {
                AliHLTUInt32_t count = 1;
-               return IntegrityOk(block, reason, count);
+               return IntegrityOk(block, reason, recordNum, count);
        }
        
        /**
@@ -846,6 +953,46 @@ public:
                return IntegrityOk(block, reason, recordNum, count);
        }
        
+       /**
+        * This method is used to check more extensively if the integrity of the
+        * full 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 will be filled with
+        *      the reason code describing why the structure is not valid, if and
+        *      only if a problem is found with the data.
+        * \returns  true if there is no problem with the structure and false otherwise.
+        */
+       static bool IntegrityOk(
+                       const AliHLTMUONTrackStruct& track,
+                       WhyNotValid* reason = NULL
+               )
+       {
+               AliHLTUInt32_t count = 1;
+               return IntegrityOk(track, reason, count);
+       }
+       
+       /**
+        * 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 track data block to check.
+        * [out] \param reason  If this is not NULL, then it will be filled with
+        *      the reason code describing why the data block is not valid, if and
+        *      only if a problem is found with the data.
+        * [out] \param recordNum  If this is not NULL, then it will be filled with
+        *      the number of the Manso track structure that had a problem.
+        *      This value will only contain a valid value if the method
+        *      RecordNumberWasSet(*reason) returns true. Thus, 'reason' must be set.
+        * \returns  true if there is no problem with the data and false otherwise.
+        */
+       static bool IntegrityOk(
+                       const AliHLTMUONTracksBlockStruct& block,
+                       WhyNotValid* reason = NULL, AliHLTUInt32_t* recordNum = NULL
+               )
+       {
+               AliHLTUInt32_t count = 1;
+               return IntegrityOk(block, reason, recordNum, count);
+       }
+       
        /**
         * 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.
@@ -956,10 +1103,16 @@ public:
                );
        
        static bool IntegrityOk(
-                       const AliHLTMUONRecHitsBlockStruct& block,
+                       const AliHLTMUONRecHitStruct& hit,
                        WhyNotValid* reason, AliHLTUInt32_t& reasonCount
                );
        
+       static bool IntegrityOk(
+                       const AliHLTMUONRecHitsBlockStruct& block,
+                       WhyNotValid* reason, AliHLTUInt32_t* recordNum,
+                       AliHLTUInt32_t& reasonCount
+               );
+       
        static bool IntegrityOk(
                        const AliHLTMUONClusterStruct& cluster,
                        WhyNotValid* reason, AliHLTUInt32_t& reasonCount
@@ -1004,6 +1157,17 @@ public:
                        AliHLTUInt32_t& reasonCount
                );
        
+       static bool IntegrityOk(
+                       const AliHLTMUONTrackStruct& track,
+                       WhyNotValid* reason, AliHLTUInt32_t& reasonCount
+               );
+       
+       static bool IntegrityOk(
+                       const AliHLTMUONTracksBlockStruct& block,
+                       WhyNotValid* reason, AliHLTUInt32_t* recordNum,
+                       AliHLTUInt32_t& reasonCount
+               );
+       
        static bool IntegrityOk(
                        const AliHLTMUONTrackDecisionStruct& decision,
                        WhyNotValid* reason, AliHLTUInt32_t& reasonCount
@@ -1035,9 +1199,14 @@ public:
        static bool RecordNumberWasSet(WhyNotValid reason);
 
 private:
-       // Should never have to create or destroy this object.
-       AliHLTMUONUtils();
-       ~AliHLTMUONUtils();
+
+       // Should never have to create, copy or destroy this object.
+       AliHLTMUONUtils() {}
+       AliHLTMUONUtils(const AliHLTMUONUtils& obj);
+       virtual ~AliHLTMUONUtils() {}
+       AliHLTMUONUtils& operator = (const AliHLTMUONUtils& obj);
+       
+       ClassDef(AliHLTMUONUtils, 0);  // Interface for helpful dHLT utility methods.
 };
 
 //_____________________________________________________________________________
@@ -1074,7 +1243,7 @@ inline std::ostream& operator << (std::ostream& stream, AliHLTMUONUtils::WhyNotV
 // information into the dimuon HLT code. Its usage is meant to be for generating
 // traces of the program which are only useful during full scale debugging.
 // Log messages should use the standard HLT logging mechanisms.
-// The output is only generated in programs compiled with the DEBUG directive
+// The output is only generated in programs compiled with the DEBUGTRACE directive
 // defined. Here is a usage example:
 //
 //  // statements...
@@ -1088,7 +1257,7 @@ inline std::ostream& operator << (std::ostream& stream, AliHLTMUONUtils::WhyNotV
 //  DebugTrace("x = " << x << " and y = 0x" << std::hex << y );
 //  // statements...
 //
-#ifdef DEBUG
+#ifdef DEBUGTRACE
 #      include <iostream>
 #      define DebugTrace(message) {std::cout << message << std::endl;}
 #else // DEBUG