The Gaudi Framework
master (2e57474e)
Toggle main menu visibility
Loading...
Searching...
No Matches
RRWNTupleCnv.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#define ALLOW_ALL_TYPES
12
13
// Compiler include files
14
#include <
GaudiKernel/INTupleSvc.h
>
15
#include <
GaudiKernel/MsgStream.h
>
16
#include <
GaudiKernel/NTuple.h
>
17
18
#include "
RRWNTupleCnv.h
"
19
#include <TTree.h>
20
21
// Instantiation of a static factory class used by clients to create
22
// instances of this service
23
DECLARE_CONVERTER
(
RootHistCnv::RRWNTupleCnv
)
24
25
//------------------------------------------------------------------------------
26
StatusCode
RootHistCnv
::
RRWNTupleCnv
::
book
( const
std
::
string
& desc,
INTuple
* nt, TTree*& rtree )
27
//------------------------------------------------------------------------------
28
{
29
MsgStream
log(
msgSvc
(),
"RRWNTupleCnv"
);
30
// Book the tree
31
rtree =
new
TTree( desc.c_str(), nt->title().c_str() );
32
// Add the branches
33
for
(
const
auto
& i : nt->items() ) {
34
std::string tag = i->name() +
rootVarType
( i->type() );
35
// add the branch
36
log <<
MSG::INFO
<<
"ID "
<< desc <<
": added branch: "
<< i->name() <<
" / "
<< tag <<
endmsg
;
37
rtree->Branch( i->name().c_str(),
const_cast<
void
*
>
( i->buffer() ), tag.c_str() );
38
}
39
log <<
MSG::INFO
<<
"Booked TTree with ID:"
<< desc <<
" \""
<< nt->title() <<
"\""
<<
endmsg
;
40
return
StatusCode::SUCCESS
;
41
}
42
43
//------------------------------------------------------------------------------
44
StatusCode
RootHistCnv::RRWNTupleCnv::writeData
( TTree* rtree,
INTuple
* nt )
45
//------------------------------------------------------------------------------
46
{
47
if
( rtree ) {
48
// Fill the tree;
49
rtree->Fill();
50
// Reset the NTuple
51
nt->
reset
();
52
return
StatusCode::SUCCESS
;
53
}
54
MsgStream
log(
msgSvc
(),
"RRWNTupleCnv"
);
55
log <<
MSG::ERROR
<<
"Attempt to write invalid N-tuple."
;
56
if
( nt ) log << nt->
title
();
57
log <<
endmsg
;
58
return
StatusCode::FAILURE
;
59
}
60
61
//------------------------------------------------------------------------------
62
StatusCode
RootHistCnv::RRWNTupleCnv::readData
( TTree*
/* tree */
,
INTuple
*
/* nt */
,
long
/* ievt */
)
63
//------------------------------------------------------------------------------
64
{
65
return
StatusCode::FAILURE
;
66
}
67
68
//------------------------------------------------------------------------------
69
StatusCode
RootHistCnv::RRWNTupleCnv::load
( TTree*
/* tree */
,
INTuple
*&
/* refpObject */
)
70
//------------------------------------------------------------------------------
71
{
72
return
StatusCode::FAILURE
;
73
}
DECLARE_CONVERTER
#define DECLARE_CONVERTER(x)
Definition
Converter.h:142
INTupleSvc.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
NTuple.h
RRWNTupleCnv.h
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition
Converter.cpp:104
INTuple
NTuple interface class definition.
Definition
INTuple.h:86
INTuple::reset
virtual void reset()=0
Reset all entries to their default values.
INTuple::title
virtual const std::string & title() const =0
Object title.
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
RootHistCnv::RNTupleCnv::rootVarType
virtual std::string rootVarType(int)
Return ROOT type info:
Definition
RNTupleCnv.cpp:204
RootHistCnv::RRWNTupleCnv
Row wise NTuple converter class definition.
Definition
RRWNTupleCnv.h:26
RootHistCnv::RRWNTupleCnv::book
StatusCode book(const std::string &desc, INTuple *pObject, TTree *&tree) override
Book the N tuple.
Definition
RRWNTupleCnv.cpp:26
RootHistCnv::RRWNTupleCnv::readData
StatusCode readData(TTree *rtree, INTuple *pObject, long ievt) override
Read N tuple data.
Definition
RRWNTupleCnv.cpp:62
RootHistCnv::RRWNTupleCnv::RRWNTupleCnv
RRWNTupleCnv(ISvcLocator *svc)
Standard constructor.
Definition
RRWNTupleCnv.h:31
RootHistCnv::RRWNTupleCnv::writeData
StatusCode writeData(TTree *rtree, INTuple *pObject) override
Write N tuple data.
Definition
RRWNTupleCnv.cpp:44
RootHistCnv::RRWNTupleCnv::load
StatusCode load(TTree *tree, INTuple *&refpObject) override
Create the transient representation of an object.
Definition
RRWNTupleCnv.cpp:69
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
MSG::ERROR
@ ERROR
Definition
IMessageSvc.h:22
MSG::INFO
@ INFO
Definition
IMessageSvc.h:22
RootHistCnv
Definition
DirectoryCnv.h:26
std
STL namespace.
RootHistCnv
src
RRWNTupleCnv.cpp
Generated on
for The Gaudi Framework by
1.17.0