| The Gaudi Framework v32r1 (f65d50dc)

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_CONVERTER( 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
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:87
MsgStream.h
NTuple.h
INTuple::title
virtual const std::string & title() const =0
Object title.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std
STL namespace.
DECLARE_CONVERTER
#define DECLARE_CONVERTER(x)
Definition: Converter.h:150
RootHistCnv::RRWNTupleCnv
Row wise NTuple converter class definition.
Definition: RRWNTupleCnv.h:17
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:67
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:81
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:95
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:50
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
std::string::c_str
T c_str(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
MSG::INFO
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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