| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# RCWNTupleCnv.h

Go to the documentation of this file.

    00001 // $Id: RCWNTupleCnv.h,v 1.7 2006/11/30 15:04:07 mato Exp $
    00002 #ifndef ROOTHISTCNV_RCWNTCNV_H
    00003 #define ROOTHISTCNV_RCWNTCNV_H 1
    00004
    00005
    00006 // Include files
    00007 #include "GaudiKernel/Converter.h"
    00008 #include "RNTupleCnv.h"
    00009 #include <string>
    00010
    00011 #include "TFile.h"
    00012 #include "TTree.h"
    00013
    00014
    00015 // Forward declarations
    00016 template <class TYPE> class CnvFactory;
    00017
    00018
    00019
    00020 namespace RootHistCnv {
    00021
    00028   class RCWNTupleCnv : public RNTupleCnv {
    00029
    00030     friend class CnvFactory<RCWNTupleCnv>;
    00031
    00032   public:
    00034     static const CLID& classID()    {
    00035       return CLID_ColumnWiseTuple;
    00036     }
    00038     RCWNTupleCnv( ISvcLocator* svc ) : RNTupleCnv(svc, classID())    {
    00039     }
    00041     virtual ~RCWNTupleCnv()   {
    00042     }
    00043   protected:
    00045     virtual StatusCode load(TTree* tree, INTuple*& refpObject);
    00047     virtual StatusCode book(const std::string& desc, INTuple* pObject, TTree*& tree);
    00049     virtual StatusCode writeData(TTree* rtree, INTuple* pObject);
    00051     virtual StatusCode readData(TTree* rtree, INTuple* pObject, long ievt);
    00052
    00053     template <class T>
    00054     size_t saveItem(char* target, const T* src, size_t len)   {
    00055       long* tar = (long*)target;
    00056       for ( size_t i = 0; i < len; i++ )   {
    00057         *(tar++) = long( *(src++));
    00058       }
    00059       return sizeof(long)*len;
    00060     }
    00061     template <typename T>
    00062     size_t saveItem(char* target, T* src, size_t len) {
    00063       memcpy(target, src, sizeof(T)*len);
    00064       return sizeof(T)*len;
    00065     }
    00066
    00067     template <class T>
    00068     size_t loadItem(char* src, T* tar, size_t len)   {
    00069       long* s = (long*)src;
    00070       for ( size_t i = 0; i < len; i++ )   {
    00071         *(tar++) = T( *(s++));
    00072       }
    00073       return sizeof(long)*len;
    00074     }
    00075     size_t loadItem(char* src, bool* tar, size_t len)   {
    00076       long* s = (long*)src;
    00077       for ( size_t i = 0; i < len; i++ )   {
    00078         *(tar++) = (*(s++)) ? true : false;
    00079       }
    00080       return sizeof(long)*len;
    00081     }
    00082     size_t loadItem(char* src, float* target, size_t len)   {
    00083       memcpy(target, src, sizeof(float)*len);
    00084       return sizeof(float)*len;
    00085     }
    00086     size_t loadItem(char* src, double* target, size_t len)   {
    00087       memcpy(target, src, sizeof(double)*len);
    00088       return sizeof(double)*len;
    00089     }
    00090     size_t loadItem(char* src, long* target, size_t len)   {
    00091       memcpy(target, src, sizeof(long)*len);
    00092       return sizeof(long)*len;
    00093     }
    00094     size_t loadItem(char* src, unsigned long* target, size_t len)   {
    00095       memcpy(target, src, sizeof(unsigned long)*len);
    00096       return sizeof(unsigned long)*len;
    00097     }
    00098
    00099   };
    00100 }    // namespace RootHistCnv
    00101
    00102
    00103 #endif    // ROOTHISTCNV_RCWNTCNV_H