| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

RCWNTupleCnv.h
Go to the documentation of this file.
1 #ifndef ROOTHISTCNV_RCWNTCNV_H
2 #define ROOTHISTCNV_RCWNTCNV_H 1
3
4 // Include files
5 #include "GaudiKernel/Converter.h"
6 #include "RNTupleCnv.h"
7 #include <string>
8
9 #include "TFile.h"
10 #include "TTree.h"
11
12 namespace RootHistCnv
13 {
14
21 class RCWNTupleCnv : public RNTupleCnv
22 {
23 public:
25 static const CLID& classID() { return CLID_ColumnWiseTuple; }
27 RCWNTupleCnv( ISvcLocator* svc ) : RNTupleCnv( svc, classID() ) {}
29 ~RCWNTupleCnv() override {}
30
31 protected:
33 StatusCode load( TTree* tree, INTuple*& refpObject ) override;
35 StatusCode book( const std::string& desc, INTuple* pObject, TTree*& tree ) override;
37 StatusCode writeData( TTree* rtree, INTuple* pObject ) override;
39 StatusCode readData( TTree* rtree, INTuple* pObject, long ievt ) override;
40
41 template <class T>
42 size_t saveItem( char* target, const T* src, size_t len )
43 {
44 long* tar = (long*)target;
45 for ( size_t i = 0; i < len; i++ ) {
46 *( tar++ ) = long( *( src++ ) );
47 }
48 return sizeof( long ) * len;
49 }
50 template <typename T>
51 size_t saveItem( char* target, T* src, size_t len )
52 {
53 memcpy( target, src, sizeof( T ) * len );
54 return sizeof( T ) * len;
55 }
56
57 template <class T>
58 size_t loadItem( char* src, T* tar, size_t len )
59 {
60 long* s = (long*)src;
61 for ( size_t i = 0; i < len; i++ ) {
62 *( tar++ ) = T( *( s++ ) );
63 }
64 return sizeof( long ) * len;
65 }
66 size_t loadItem( char* src, bool* tar, size_t len )
67 {
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 {
76 memcpy( target, src, sizeof( float ) * len );
77 return sizeof( float ) * len;
78 }
79 size_t loadItem( char* src, double* target, size_t len )
80 {
81 memcpy( target, src, sizeof( double ) * len );
82 return sizeof( double ) * len;
83 }
84 size_t loadItem( char* src, long* target, size_t len )
85 {
86 memcpy( target, src, sizeof( long ) * len );
87 return sizeof( long ) * len;
88 }
89 size_t loadItem( char* src, unsigned long* target, size_t len )
90 {
91 memcpy( target, src, sizeof( unsigned long ) * len );
92 return sizeof( unsigned long ) * len;
93 }
94 };
95 } // namespace RootHistCnv
96
97 #endif // ROOTHISTCNV_RCWNTCNV_H
RootHistCnv::RNTupleCnv
NTuple converter class definition.
Definition: RNTupleCnv.h:25
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
RootHistCnv::RCWNTupleCnv
Converter of Column-wise NTuple into ROOT format.
Definition: RCWNTupleCnv.h:21
RootHistCnv::RCWNTupleCnv::book
StatusCode book(const std::string &desc, INTuple *pObject, TTree *&tree) override
Book the N tuple.
Definition: RCWNTupleCnv.cpp:77
RootHistCnv::RCWNTupleCnv::RCWNTupleCnv
RCWNTupleCnv(ISvcLocator *svc)
Standard constructor.
Definition: RCWNTupleCnv.h:27
std::string
STL class.
INTuple
NTuple interface class definition.
Definition: INTuple.h:82
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, bool *tar, size_t len)
Definition: RCWNTupleCnv.h:66
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
RootHistCnv::RCWNTupleCnv::load
StatusCode load(TTree *tree, INTuple *&refpObject) override
Create the transient representation of an object.
Definition: RCWNTupleCnv.cpp:372
RootHistCnv
Definition: DirectoryCnv.h:17
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, double *target, size_t len)
Definition: RCWNTupleCnv.h:79
RootHistCnv::RCWNTupleCnv::readData
StatusCode readData(TTree *rtree, INTuple *pObject, long ievt) override
Read N tuple data.
Definition: RCWNTupleCnv.cpp:303
RootHistCnv::RCWNTupleCnv::saveItem
size_t saveItem(char *target, const T *src, size_t len)
Definition: RCWNTupleCnv.h:42
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, long *target, size_t len)
Definition: RCWNTupleCnv.h:84
RootHistCnv::RCWNTupleCnv::~RCWNTupleCnv
~RCWNTupleCnv() override
Standard destructor.
Definition: RCWNTupleCnv.h:29
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, T *tar, size_t len)
Definition: RCWNTupleCnv.h:58
RootHistCnv::RCWNTupleCnv::classID
static const CLID & classID()
Inquire class type.
Definition: RCWNTupleCnv.h:25
RNTupleCnv.h
RootHistCnv::RCWNTupleCnv::saveItem
size_t saveItem(char *target, T *src, size_t len)
Definition: RCWNTupleCnv.h:51
gaudirun.s
string s
Definition: gaudirun.py:253
Converter.h
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, unsigned long *target, size_t len)
Definition: RCWNTupleCnv.h:89
RootHistCnv::RCWNTupleCnv::loadItem
size_t loadItem(char *src, float *target, size_t len)
Definition: RCWNTupleCnv.h:74
RootHistCnv::RCWNTupleCnv::writeData
StatusCode writeData(TTree *rtree, INTuple *pObject) override
Write N tuple data.
Definition: RCWNTupleCnv.cpp:246