| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RCWNTupleCnv.h
Go to the documentation of this file.
1 // $Id: RCWNTupleCnv.h,v 1.7 2006/11/30 15:04:07 mato Exp $
2 #ifndef ROOTHISTCNV_RCWNTCNV_H
3 #define ROOTHISTCNV_RCWNTCNV_H 1
4
5
6 // Include files
7 #include "GaudiKernel/Converter.h"
8 #include "RNTupleCnv.h"
9 #include <string>
10
11 #include "TFile.h"
12 #include "TTree.h"
13
14
15 namespace RootHistCnv {
16
23 class RCWNTupleCnv : public RNTupleCnv {
24 public:
26 static const CLID& classID() {
27 return CLID_ColumnWiseTuple;
28 }
30 RCWNTupleCnv( ISvcLocator* svc ) : RNTupleCnv(svc, classID()) {
31 }
33 virtual ~RCWNTupleCnv() {
34 }
35 protected:
37 virtual StatusCode load(TTree* tree, INTuple*& refpObject);
39 virtual StatusCode book(const std::string& desc, INTuple* pObject, TTree*& tree);
41 virtual StatusCode writeData(TTree* rtree, INTuple* pObject);
43 virtual StatusCode readData(TTree* rtree, INTuple* pObject, long ievt);
44
45 template <class T>
46 size_t saveItem(char* target, const T* src, size_t len) {
47 long* tar = (long*)target;
48 for ( size_t i = 0; i < len; i++ ) {
49 *(tar++) = long( *(src++));
50 }
51 return sizeof(long)*len;
52 }
53 template <typename T>
54 size_t saveItem(char* target, T* src, size_t len) {
55 memcpy(target, src, sizeof(T)*len);
56 return sizeof(T)*len;
57 }
58
59 template <class T>
60 size_t loadItem(char* src, T* tar, size_t len) {
61 long* s = (long*)src;
62 for ( size_t i = 0; i < len; i++ ) {
63 *(tar++) = T( *(s++));
64 }
65 return sizeof(long)*len;
66 }
67 size_t loadItem(char* src, bool* tar, size_t len) {
68 long* s = (long*)src;
69 for ( size_t i = 0; i < len; i++ ) {
70 *(tar++) = (*(s++)) ? true : false;
71 }
72 return sizeof(long)*len;
73 }
74 size_t loadItem(char* src, float* target, size_t len) {
75 memcpy(target, src, sizeof(float)*len);
76 return sizeof(float)*len;
77 }
78 size_t loadItem(char* src, double* target, size_t len) {
79 memcpy(target, src, sizeof(double)*len);
80 return sizeof(double)*len;
81 }
82 size_t loadItem(char* src, long* target, size_t len) {
83 memcpy(target, src, sizeof(long)*len);
84 return sizeof(long)*len;
85 }
86 size_t loadItem(char* src, unsigned long* target, size_t len) {
87 memcpy(target, src, sizeof(unsigned long)*len);
88 return sizeof(unsigned long)*len;
89 }
90
91 };
92 } // namespace RootHistCnv
93
94
95 #endif // ROOTHISTCNV_RCWNTCNV_H