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