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
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  }
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
NTuple converter class definition.
Definition: RNTupleCnv.h:24
virtual StatusCode readData(TTree *rtree, INTuple *pObject, long ievt)
Read N tuple data.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
Converter of Column-wise NTuple into ROOT format.
Definition: RCWNTupleCnv.h:23
virtual StatusCode book(const std::string &desc, INTuple *pObject, TTree *&tree)
Book the N tuple.
RCWNTupleCnv(ISvcLocator *svc)
Standard constructor.
Definition: RCWNTupleCnv.h:30
NTuple interface class definition.
Definition: INTuple.h:80
size_t loadItem(char *src, bool *tar, size_t len)
Definition: RCWNTupleCnv.h:67
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
size_t loadItem(char *src, double *target, size_t len)
Definition: RCWNTupleCnv.h:78
virtual StatusCode writeData(TTree *rtree, INTuple *pObject)
Write N tuple data.
size_t saveItem(char *target, const T *src, size_t len)
Definition: RCWNTupleCnv.h:46
size_t loadItem(char *src, long *target, size_t len)
Definition: RCWNTupleCnv.h:82
size_t loadItem(char *src, T *tar, size_t len)
Definition: RCWNTupleCnv.h:60
static const CLID & classID()
Inquire class type.
Definition: RCWNTupleCnv.h:26
size_t saveItem(char *target, T *src, size_t len)
Definition: RCWNTupleCnv.h:54
string s
Definition: gaudirun.py:210
virtual StatusCode load(TTree *tree, INTuple *&refpObject)
Create the transient representation of an object.
virtual ~RCWNTupleCnv()
Standard destructor.
Definition: RCWNTupleCnv.h:33
size_t loadItem(char *src, unsigned long *target, size_t len)
Definition: RCWNTupleCnv.h:86
size_t loadItem(char *src, float *target, size_t len)
Definition: RCWNTupleCnv.h:74
list i
Definition: ana.py:128