| The Gaudi Framework v30r0 (c919700c)

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

- File List
- File Members

RRWNTupleCnv.cpp
Go to the documentation of this file.
1 #define ALLOW_ALL_TYPES
2
3 // Compiler include files
4 #include "GaudiKernel/INTupleSvc.h"
5 #include "GaudiKernel/MsgStream.h"
6 #include "GaudiKernel/NTuple.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, INTuple* nt, TTree*& rtree )
17 //------------------------------------------------------------------------------
18 {
19 MsgStream log( msgSvc(), "RRWNTupleCnv" );
20 // Book the tree
21 rtree = new TTree( desc.c_str(), nt->title().c_str() );
22 // Add the branches
23 for ( const auto& i : nt->items() ) {
24 std::string tag = i->name() + rootVarType( i->type() );
25 // add the branch
26 log << MSG::INFO << "ID " << desc << ": added branch: " << i->name() << " / " << tag << endmsg;
27 rtree->Branch( i->name().c_str(), const_cast<void*>( i->buffer() ), tag.c_str() );
28 }
29 log << MSG::INFO << "Booked TTree with ID:" << desc << " \"" << nt->title() << "\"" << endmsg;
30 return StatusCode::SUCCESS;
31 }
32
33 //------------------------------------------------------------------------------
34 StatusCode RootHistCnv::RRWNTupleCnv::writeData( TTree* rtree, INTuple* nt )
35 //------------------------------------------------------------------------------
36 {
37 if ( rtree ) {
38 // Fill the tree;
39 rtree->Fill();
40 // Reset the NTuple
41 nt->reset();
42 return StatusCode::SUCCESS;
43 }
44 MsgStream log( msgSvc(), "RRWNTupleCnv" );
45 log << MSG::ERROR << "Attempt to write invalid N-tuple.";
46 if ( nt ) log << nt->title();
47 log << endmsg;
48 return StatusCode::FAILURE;
49 }
50
51 //------------------------------------------------------------------------------
52 StatusCode RootHistCnv::RRWNTupleCnv::readData( TTree* /* tree */, INTuple* /* nt */, long /* ievt */ )
53 //------------------------------------------------------------------------------
54 {
55 return StatusCode::FAILURE;
56 }
57
58 //------------------------------------------------------------------------------
59 StatusCode RootHistCnv::RRWNTupleCnv::load( TTree* /* tree */, INTuple*& /* refpObject */ )
60 //------------------------------------------------------------------------------
61 {
62 return StatusCode::FAILURE;
63 }
RRWNTupleCnv.h
StatusCode::SUCCESS
Definition: StatusCode.h:29
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:95
MsgStream.h
NTuple.h
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
std
STL namespace.
RootHistCnv::RRWNTupleCnv
Row wise NTuple converter class definition.
Definition: RRWNTupleCnv.h:18
RootHistCnv::RRWNTupleCnv::load
StatusCode load(TTree *tree, INTuple *&refpObject) override
Create the transient representation of an object.
Definition: RRWNTupleCnv.cpp:59
std::string
STL class.
INTuple
NTuple interface class definition.
Definition: INTuple.h:82
INTuple::reset
virtual void reset()=0
Reset all entries to their default values.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
RootHistCnv::RRWNTupleCnv::readData
StatusCode readData(TTree *rtree, INTuple *pObject, long ievt) override
Read N tuple data.
Definition: RRWNTupleCnv.cpp:52
RootHistCnv
Definition: DirectoryCnv.h:17
DECLARE_NAMESPACE_CONVERTER_FACTORY
#define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x)
Definition: Converter.h:177
std::string::c_str
T c_str(T...args)
MSG::ERROR
Definition: IMessageSvc.h:16
StatusCode::FAILURE
Definition: StatusCode.h:29
MSG::INFO
Definition: IMessageSvc.h:16
INTuple::title
virtual const std::string & title() const =0
Object title.
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
RootHistCnv::RRWNTupleCnv::writeData
StatusCode writeData(TTree *rtree, INTuple *pObject) override
Write N tuple data.
Definition: RRWNTupleCnv.cpp:34
Gaudi.Configuration.log
log
Definition: Configuration.py:13
INTupleSvc.h