]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/MUON/AliHLTMUONDataBlockReader.h
Disable retireval of DCS data points from AliShuttle for SDD
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONDataBlockReader.h
index 7d1b608e623d567f82bdd47cc2b72b21ef8b36d4..1b8b435eff506fe98bfdf270931445392ccc2c05 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+// $Id$
 
 /**
  * @file   AliHLTMUONDataBlockReader.h
  * @author Artur Szostak <artursz@iafrica.com>
- * @date   
+ * @date   19 May 2007
  * @brief  Definition of a reader class for internal dimuon HLT raw data blocks.
  */
 
 
 #include "AliHLTMUONTriggerRecordsBlockStruct.h"
 #include "AliHLTMUONTrigRecsDebugBlockStruct.h"
-#include "AliHLTMUONTriggerChannelsBlockStruct.h"
 #include "AliHLTMUONRecHitsBlockStruct.h"
 #include "AliHLTMUONClustersBlockStruct.h"
 #include "AliHLTMUONChannelsBlockStruct.h"
 #include "AliHLTMUONMansoTracksBlockStruct.h"
 #include "AliHLTMUONMansoCandidatesBlockStruct.h"
+#include "AliHLTMUONTracksBlockStruct.h"
 #include "AliHLTMUONSinglesDecisionBlockStruct.h"
 #include "AliHLTMUONPairsDecisionBlockStruct.h"
 
@@ -45,7 +45,7 @@
  * stored in memory and the size of the data block is given by the variable 'size'.
  * The data block is of type 'block_type' and the data block entries are of type
  * 'entries_type'. The data block can be accessed in the following way:
- *
+ * \code
  *   void* buffer = somebuffer;
  *   AliHLTUInt32_t size = somebuffer_size;
  *   
@@ -67,6 +67,7 @@
  *      const entries_type& entry = block[i];
  *      // Do something with the entry...
  *   }
+ * \endcode
  */
 template <class DataBlockType, class DataElementType>
 class AliHLTMUONDataBlockReader
@@ -90,6 +91,31 @@ public:
        {
                assert( buffer != NULL );
        }
+       
+       /**
+        * Copy constructor that performs a shallow copy.
+        * Since this class does not take direct ownership of the buffer, never
+        * allocates or deallocates memory, this can be allowed.
+        */
+       AliHLTMUONDataBlockReader(const AliHLTMUONDataBlockReader& reader)
+       {
+               fSize = reader.fSize;
+               fBlock = reader.fBlock;
+               fData = reader.fData;
+       }
+       
+       /**
+        * Assignment operator performs a shallow copy.
+        * This is OK because this class does not take direct ownership of the
+        * output memory buffer.
+        */
+       AliHLTMUONDataBlockReader& operator = (const AliHLTMUONDataBlockReader& reader)
+       {
+               fSize = reader.fSize;
+               fBlock = reader.fBlock;
+               fData = reader.fData;
+               return *this;
+       }
 
        /**
         * Checks that the size of the buffer storing the data block is correct.
@@ -100,6 +126,8 @@ public:
        bool BufferSizeOk() const
        {
                // The block size must be at least sizeof(DataBlockType) bytes.
+               // Do not try read the header otherwise, because we could get a
+               // seg fault.
                if (fSize < sizeof(DataBlockType)) return false;
 
                // Now check if the size of the data block corresponds to the
@@ -121,7 +149,7 @@ public:
         */
        const DataBlockType& BlockHeader() const
        {
-               return fBlock;
+               return *fBlock;
        }
 
        /**
@@ -160,7 +188,18 @@ public:
         */
        const DataElementType* GetArray() const { return fData; }
 
-       AliHLTUInt32_t BufferSize() { return fSize; }
+       /**
+        * Calculates the number of bytes used for the data block in the buffer.
+        * This value should be the same as what is returned by BufferSize()
+        * unless too much buffer space was allocated.
+        */
+       AliHLTUInt32_t BytesUsed() const
+       {
+               assert( sizeof(DataElementType) == fBlock->fHeader.fRecordWidth);
+               return sizeof(DataBlockType) + Nentries() * sizeof(DataElementType);
+       }
+
+       AliHLTUInt32_t BufferSize() const { return fSize; }
        
 private:
 
@@ -183,11 +222,6 @@ typedef AliHLTMUONDataBlockReader<
                AliHLTMUONTrigRecInfoStruct
        > AliHLTMUONTrigRecsDebugBlockReader;
 
-typedef AliHLTMUONDataBlockReader<
-               AliHLTMUONTriggerChannelsBlockStruct,
-               AliHLTMUONTriggerChannelStruct
-       > AliHLTMUONTriggerChannelsBlockReader;
-
 typedef AliHLTMUONDataBlockReader<
                AliHLTMUONRecHitsBlockStruct,
                AliHLTMUONRecHitStruct
@@ -213,6 +247,11 @@ typedef AliHLTMUONDataBlockReader<
                AliHLTMUONMansoCandidateStruct
        > AliHLTMUONMansoCandidatesBlockReader;
 
+typedef AliHLTMUONDataBlockReader<
+               AliHLTMUONTracksBlockStruct,
+               AliHLTMUONTrackStruct
+       > AliHLTMUONTracksBlockReader;
+
 typedef AliHLTMUONDataBlockReader<
                AliHLTMUONSinglesDecisionBlockStruct,
                AliHLTMUONTrackDecisionStruct