| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

# 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 namespace RootHistCnv {
    00019
    00026   class RCWNTupleCnv : public RNTupleCnv {
    00027
    00028     friend class CnvFactory<RCWNTupleCnv>;
    00029
    00030   public:
    00032     static const CLID& classID()    {
    00033       return CLID_ColumnWiseTuple;
    00034     }
    00036     RCWNTupleCnv( ISvcLocator* svc ) : RNTupleCnv(svc, classID())    {
    00037     }
    00039     virtual ~RCWNTupleCnv()   {
    00040     }
    00041   protected:
    00043     virtual StatusCode load(TTree* tree, INTuple*& refpObject);
    00045     virtual StatusCode book(const std::string& desc, INTuple* pObject, TTree*& tree);
    00047     virtual StatusCode writeData(TTree* rtree, INTuple* pObject);
    00049     virtual StatusCode readData(TTree* rtree, INTuple* pObject, long ievt);
    00050
    00051     template <class T>
    00052     size_t saveItem(char* target, const T* src, size_t len)   {
    00053       long* tar = (long*)target;
    00054       for ( size_t i = 0; i < len; i++ )   {
    00055         *(tar++) = long( *(src++));
    00056       }
    00057       return sizeof(long)*len;
    00058     }
    00059     template <typename T>
    00060     size_t saveItem(char* target, T* src, size_t len) {
    00061       memcpy(target, src, sizeof(T)*len);
    00062       return sizeof(T)*len;
    00063     }
    00064
    00065     template <class T>
    00066     size_t loadItem(char* src, T* tar, size_t len)   {
    00067       long* s = (long*)src;
    00068       for ( size_t i = 0; i < len; i++ )   {
    00069         *(tar++) = T( *(s++));
    00070       }
    00071       return sizeof(long)*len;
    00072     }
    00073     size_t loadItem(char* src, bool* tar, size_t len)   {
    00074       long* s = (long*)src;
    00075       for ( size_t i = 0; i < len; i++ )   {
    00076         *(tar++) = (*(s++)) ? true : false;
    00077       }
    00078       return sizeof(long)*len;
    00079     }
    00080     size_t loadItem(char* src, float* target, size_t len)   {
    00081       memcpy(target, src, sizeof(float)*len);
    00082       return sizeof(float)*len;
    00083     }
    00084     size_t loadItem(char* src, double* target, size_t len)   {
    00085       memcpy(target, src, sizeof(double)*len);
    00086       return sizeof(double)*len;
    00087     }
    00088     size_t loadItem(char* src, long* target, size_t len)   {
    00089       memcpy(target, src, sizeof(long)*len);
    00090       return sizeof(long)*len;
    00091     }
    00092     size_t loadItem(char* src, unsigned long* target, size_t len)   {
    00093       memcpy(target, src, sizeof(unsigned long)*len);
    00094       return sizeof(unsigned long)*len;
    00095     }
    00096
    00097   };
    00098 }    // namespace RootHistCnv
    00099
    00100
    00101 #endif    // ROOTHISTCNV_RCWNTCNV_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines