Gaudi Framework, version v23r5
Home
Generated: Wed Nov 28 2012
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
RootHistCnv
src
RRWNTupleCnv.cpp
Go to the documentation of this file.
1
// $Id: RRWNTupleCnv.cpp,v 1.6 2006/01/10 20:12:02 hmd Exp $
2
#define ROOTHISTCNV_RRWNTUPLECNV_CPP
3
4
#define ALLOW_ALL_TYPES
5
6
// Compiler include files
7
#include "
GaudiKernel/CnvFactory.h
"
8
#include "
GaudiKernel/MsgStream.h
"
9
#include "
GaudiKernel/NTuple.h
"
10
#include "
GaudiKernel/INTupleSvc.h
"
11
12
#include "
RRWNTupleCnv.h
"
13
#include "TTree.h"
14
15
// Instantiation of a static factory class used by clients to create
16
// instances of this service
17
DECLARE_NAMESPACE_CONVERTER_FACTORY
(RootHistCnv,RRWNTupleCnv)
18
19
//------------------------------------------------------------------------------
20
StatusCode
RootHistCnv::
RRWNTupleCnv
::
book
(const
std
::
string
& desc,
21
INTuple
* nt,
22
TTree*& rtree)
23
//------------------------------------------------------------------------------
24
{
25
MsgStream
log
(msgSvc(),
"RRWNTupleCnv"
);
26
const
INTuple::ItemContainer
&
itms
= nt->items();
27
// Book the tree
28
rtree =
new
TTree(desc.c_str(),nt->title().c_str());
29
// Add the branches
30
for
(
size_t
length = itms.
size
(),
i
= 0;
i
< length;
i
++ ) {
31
const
char
*
itm
= itms[
i
]->name().c_str();
32
std::string
tag =
itm
;
33
tag += rootVarType( itms[
i
]->
type
() );
34
// add the branch
35
log <<
MSG::INFO
<<
"ID "
<< desc <<
": added branch: "
36
<< itm <<
" / "
<< tag <<
endmsg
;
37
rtree->Branch(itm,const_cast<void*>(itms[
i
]->buffer()),tag.c_str());
38
}
39
log <<
MSG::INFO
<<
"Booked TTree with ID:"
<< desc
40
<<
" \""
<< nt->title() <<
"\""
<<
endmsg
;
41
return
StatusCode::SUCCESS
;
42
}
43
44
//------------------------------------------------------------------------------
45
StatusCode
RootHistCnv::RRWNTupleCnv::writeData
(TTree* rtree,
INTuple
* nt)
46
//------------------------------------------------------------------------------
47
{
48
if
( 0 != rtree ) {
49
// Fill the tree;
50
rtree->Fill();
51
// Reset the NTuple
52
nt->
reset
();
53
return
StatusCode::SUCCESS
;
54
}
55
MsgStream
log
(
msgSvc
(),
"RRWNTupleCnv"
);
56
log <<
MSG::ERROR
<<
"Attempt to write invalid N-tuple."
;
57
if
( nt != 0 ) log << nt->
title
();
58
log <<
endmsg
;
59
return
StatusCode::FAILURE
;
60
}
61
62
//------------------------------------------------------------------------------
63
StatusCode
RootHistCnv::RRWNTupleCnv::readData
(TTree*
/* tree */
,
64
INTuple
*
/* nt */
,
65
long
/* ievt */
)
66
//------------------------------------------------------------------------------
67
{
68
return
StatusCode::FAILURE
;
69
}
70
71
//------------------------------------------------------------------------------
72
StatusCode
RootHistCnv::RRWNTupleCnv::load
(TTree*
/* tree */
,
73
INTuple
*&
/* refpObject */
)
74
//------------------------------------------------------------------------------
75
{
76
return
StatusCode::FAILURE
;
77
}
Generated at Wed Nov 28 2012 12:17:19 for Gaudi Framework, version v23r5 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004