]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/MUON/AliHLTMUONDataBlockWriter.h
update EMCal EP v2
[u/mrichter/AliRoot.git] / HLT / MUON / AliHLTMUONDataBlockWriter.h
index 73c7e1c9e6f5bf8600f07c46cfeb540c3e9b6af7..f254cb06cabd7870355927939049c23ef5605bb2 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
+// $Id$
 
 /**
  * @file   AliHLTMUONDataBlockWriter.h
  * @author Artur Szostak <artursz@iafrica.com>
- * @date   
+ * @date   19 May 2007
  * @brief  Definition of a writer 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 @@
  * variable 'size'. The data block is of type 'block_type', the data block entries
  * are of type 'entries_type' and the data block type code is 'type_code'.
  * The data block can be written in the following way:
- *
+ * \code
  *   void* buffer = somebuffer;
  *   AliHLTUInt32_t size = somebuffer_size;
  *   
@@ -72,9 +72,9 @@
  *      // fill the new entry...
  *      entry.somefield = somevalue;
  *   }
- *
+ * \endcode
  * The slightly slower but safer method is to do the following:
- *
+ * \code
  *   AliHLTMUONDataBlockWriter<block_type, entries_type, type_code>
  *   block(buffer, size);
  *   if (not block.InitCommonHeader())
@@ -93,6 +93,7 @@
  *      // fill the new entry...
  *      entry->somefield = somevalue;
  *   }
+ * \endcode
  */
 template <
        class DataBlockType,
@@ -113,7 +114,7 @@ public:
         */
        AliHLTMUONDataBlockWriter(void* buffer, AliHLTUInt32_t size) :
                fSize(size),
-               fMaxArraySize(size - sizeof(DataBlockType)),
+               fMaxArraySize(size > sizeof(DataBlockType) ? size - sizeof(DataBlockType) : 0),
                fBlock(reinterpret_cast<DataBlockType*>(buffer)),
                fData(reinterpret_cast<DataElementType*>(
                       reinterpret_cast<DataBlockType*>(buffer) + 1
@@ -121,6 +122,33 @@ 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.
+        */
+       AliHLTMUONDataBlockWriter(const AliHLTMUONDataBlockWriter& writer)
+       {
+               fSize = writer.fSize;
+               fMaxArraySize = writer.fMaxArraySize;
+               fBlock = writer.fBlock;
+               fData = writer.fData;
+       }
+       
+       /**
+        * Assignment operator performs a shallow copy.
+        * This is OK because this class does not take direct ownership of the
+        * output memory buffer.
+        */
+       AliHLTMUONDataBlockWriter& operator = (const AliHLTMUONDataBlockWriter& writer)
+       {
+               fSize = writer.fSize;
+               fMaxArraySize = writer.fMaxArraySize;
+               fBlock = writer.fBlock;
+               fData = writer.fData;
+               return *this;
+       }
 
        /**
         * Initialises the common data block header by setting the type and record
@@ -281,12 +309,6 @@ typedef AliHLTMUONDataBlockWriter<
                kTrigRecsDebugDataBlock
        > AliHLTMUONTrigRecsDebugBlockWriter;
 
-typedef AliHLTMUONDataBlockWriter<
-               AliHLTMUONTriggerChannelsBlockStruct,
-               AliHLTMUONTriggerChannelStruct,
-               kTriggerChannelsDataBlock
-       > AliHLTMUONTriggerChannelsBlockWriter;
-
 typedef AliHLTMUONDataBlockWriter<
                AliHLTMUONRecHitsBlockStruct,
                AliHLTMUONRecHitStruct,
@@ -316,6 +338,12 @@ typedef AliHLTMUONDataBlockWriter<
                AliHLTMUONMansoCandidateStruct,
                kMansoCandidatesDataBlock
        > AliHLTMUONMansoCandidatesBlockWriter;
+
+typedef AliHLTMUONDataBlockWriter<
+               AliHLTMUONTracksBlockStruct,
+               AliHLTMUONTrackStruct,
+               kTracksDataBlock
+       > AliHLTMUONTracksBlockWriter;
        
 typedef AliHLTMUONDataBlockWriter<
                AliHLTMUONSinglesDecisionBlockStruct,