Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RRWNTupleCnv.cpp
Go to the documentation of this file.
1 // $Id: RRWNTupleCnv.cpp,v 1.6 2006/01/10 20:12:02 hmd Exp $
2 #define ROOTHISTCNV_RRWNTUPLECNV_CPP
3 
4 #define ALLOW_ALL_TYPES
5 
6 // Compiler include files
9 #include "GaudiKernel/NTuple.h"
10 #include "GaudiKernel/INTupleSvc.h"
11 
12 #include "RRWNTupleCnv.h"
13 #include "TTree.h"
14 
15 // Instantiation of a static factory class used by clients to create
16 // instances of this service
17 DECLARE_NAMESPACE_CONVERTER_FACTORY(RootHistCnv,RRWNTupleCnv)
18 
19 //------------------------------------------------------------------------------
20 StatusCode RootHistCnv::RRWNTupleCnv::book(const std::string& desc,
21  INTuple* nt,
22  TTree*& rtree)
23 //------------------------------------------------------------------------------
24 {
25  MsgStream log(msgSvc(), "RRWNTupleCnv");
26  const INTuple::ItemContainer& itms = nt->items();
27  // Book the tree
28  rtree = new TTree(desc.c_str(),nt->title().c_str());
29  // Add the branches
30  for (size_t length = itms.size(), i = 0; i < length; i++ ) {
31  const char* itm = itms[i]->name().c_str();
32  std::string tag = itm;
33  tag += rootVarType( itms[i]->type() );
34  // add the branch
35  log << MSG::INFO << "ID " << desc << ": added branch: "
36  << itm << " / " << tag << endmsg;
37  rtree->Branch(itm,const_cast<void*>(itms[i]->buffer()),tag.c_str());
38  }
39  log << MSG::INFO << "Booked TTree with ID:" << desc
40  << " \"" << nt->title() << "\"" << endmsg;
41  return StatusCode::SUCCESS;
42 }
43 
44 //------------------------------------------------------------------------------
46 //------------------------------------------------------------------------------
47 {
48  if ( 0 != rtree ) {
49  // Fill the tree;
50  rtree->Fill();
51  // Reset the NTuple
52  nt->reset();
53  return StatusCode::SUCCESS;
54  }
55  MsgStream log(msgSvc(), "RRWNTupleCnv");
56  log << MSG::ERROR << "Attempt to write invalid N-tuple.";
57  if ( nt != 0 ) log << nt->title();
58  log << endmsg;
59  return StatusCode::FAILURE;
60 }
61 
62 //------------------------------------------------------------------------------
64  INTuple* /* nt */,
65  long /* ievt */)
66 //------------------------------------------------------------------------------
67 {
68  return StatusCode::FAILURE;
69 }
70 
71 //------------------------------------------------------------------------------
73  INTuple*& /* refpObject */)
74 //------------------------------------------------------------------------------
75 {
76  return StatusCode::FAILURE;
77 }

Generated at Thu Jul 18 2013 12:18:05 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004