| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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/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 // Book the tree
23 rtree = new TTree(desc.c_str(),nt->title().c_str());
24 // Add the branches
25 for (const auto& i : nt->items() ) {
26 std::string tag = i->name() + rootVarType( i->type() );
27 // add the branch
28 log << MSG::INFO << "ID " << desc << ": added branch: "
29 << i->name() << " / " << tag << endmsg;
30 rtree->Branch(i->name().c_str(),const_cast<void*>(i->buffer()),tag.c_str());
31 }
32 log << MSG::INFO << "Booked TTree with ID:" << desc
33 << " \"" << nt->title() << "\"" << endmsg;
34 return StatusCode::SUCCESS;
35 }
36
37 //------------------------------------------------------------------------------
38 StatusCode RootHistCnv::RRWNTupleCnv::writeData(TTree* rtree, INTuple* nt)
39 //------------------------------------------------------------------------------
40 {
41 if ( rtree ) {
42 // Fill the tree;
43 rtree->Fill();
44 // Reset the NTuple
45 nt->reset();
46 return StatusCode::SUCCESS;
47 }
48 MsgStream log(msgSvc(), "RRWNTupleCnv");
49 log << MSG::ERROR << "Attempt to write invalid N-tuple.";
50 if ( nt ) log << nt->title();
51 log << endmsg;
52 return StatusCode::FAILURE;
53 }
54
55 //------------------------------------------------------------------------------
56 StatusCode RootHistCnv::RRWNTupleCnv::readData(TTree* /* tree */,
57 INTuple* /* nt */,
58 long /* ievt */)
59 //------------------------------------------------------------------------------
60 {
61 return StatusCode::FAILURE;
62 }
63
64 //------------------------------------------------------------------------------
65 StatusCode RootHistCnv::RRWNTupleCnv::load(TTree* /* tree */,
66 INTuple*& /* refpObject */)
67 //------------------------------------------------------------------------------
68 {
69 return StatusCode::FAILURE;
70 }
RRWNTupleCnv.h
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode::FAILURE
Definition: StatusCode.h:29
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:124
MsgStream.h
NTuple.h
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:129
std
STL namespace.
RootHistCnv::RRWNTupleCnv
Row wise NTuple converter class definition.
Definition: RRWNTupleCnv.h:17
RootHistCnv::RRWNTupleCnv::load
StatusCode load(TTree *tree, INTuple *&refpObject) override
Create the transient representation of an object.
Definition: RRWNTupleCnv.cpp:65
std::string
STL class.
INTuple
NTuple interface class definition.
Definition: INTuple.h:79
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:56
ForwardSchedulerSimpleTest.msgSvc
msgSvc
Definition: ForwardSchedulerSimpleTest.py:112
RootHistCnv
Definition: DirectoryCnv.h:17
DECLARE_NAMESPACE_CONVERTER_FACTORY
#define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x)
Definition: Converter.h:184
std::string::c_str
T c_str(T...args)
MSG::ERROR
Definition: IMessageSvc.h:21
MSG::INFO
Definition: IMessageSvc.h:19
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:244
RootHistCnv::RRWNTupleCnv::writeData
StatusCode writeData(TTree *rtree, INTuple *pObject) override
Write N tuple data.
Definition: RRWNTupleCnv.cpp:38
Gaudi.Configuration.log
log
Definition: Configuration.py:13
INTupleSvc.h