| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RRWNTupleCnv.cpp

Go to the documentation of this file.
00001 // $Id: RRWNTupleCnv.cpp,v 1.6 2006/01/10 20:12:02 hmd Exp $
00002 #define ROOTHISTCNV_RRWNTUPLECNV_CPP
00003 
00004 #define ALLOW_ALL_TYPES
00005 
00006 // Compiler include files
00007 #include "GaudiKernel/CnvFactory.h"
00008 #include "GaudiKernel/MsgStream.h"
00009 #include "GaudiKernel/NTuple.h"
00010 
00011 #include "RRWNTupleCnv.h"
00012 #include "TTree.h"
00013 
00014 // Instantiation of a static factory class used by clients to create
00015 // instances of this service
00016 DECLARE_NAMESPACE_CONVERTER_FACTORY(RootHistCnv,RRWNTupleCnv)
00017 
00018 //------------------------------------------------------------------------------
00019 StatusCode RootHistCnv::RRWNTupleCnv::book(const std::string& desc, 
00020                                            INTuple* nt, 
00021                                            TTree*& rtree)
00022 //------------------------------------------------------------------------------
00023 {
00024   MsgStream log(msgSvc(), "RRWNTupleCnv");
00025   const INTuple::ItemContainer& itms = nt->items();
00026   // Book the tree
00027   rtree = new TTree(desc.c_str(),nt->title().c_str());
00028   // Add the branches
00029   for (size_t length = itms.size(), i = 0; i < length; i++ )    {
00030     const char* itm = itms[i]->name().c_str();
00031     std::string tag = itm;
00032     tag += rootVarType( itms[i]->type() );
00033     // add the branch
00034     log << MSG::INFO << "ID " << desc << ": added branch: " 
00035         << itm << " / " << tag << endreq;
00036     rtree->Branch(itm,const_cast<void*>(itms[i]->buffer()),tag.c_str());
00037   }
00038   log << MSG::INFO << "Booked TTree with ID:" << desc
00039       << " \"" << nt->title() << "\"" << endreq;
00040   return StatusCode::SUCCESS;
00041 }
00042 
00043 //------------------------------------------------------------------------------
00044 StatusCode RootHistCnv::RRWNTupleCnv::writeData(TTree* rtree, INTuple* nt)
00045 //------------------------------------------------------------------------------
00046 {
00047   if ( 0 != rtree )   {
00048     // Fill the tree;
00049     rtree->Fill();
00050     // Reset the NTuple
00051     nt->reset();
00052     return StatusCode::SUCCESS;
00053   }
00054   MsgStream log(msgSvc(), "RRWNTupleCnv");
00055   log << MSG::ERROR << "Attempt to write invalid N-tuple.";
00056   if ( nt != 0 ) log << nt->title();
00057   log << endmsg;
00058   return StatusCode::FAILURE;
00059 }
00060 
00061 //------------------------------------------------------------------------------
00062 StatusCode RootHistCnv::RRWNTupleCnv::readData(TTree* /* tree */, 
00063                                                INTuple* /* nt */, 
00064                                                long /* ievt */)
00065 //------------------------------------------------------------------------------
00066 {
00067   return StatusCode::FAILURE;
00068 }
00069 
00070 //------------------------------------------------------------------------------
00071 StatusCode RootHistCnv::RRWNTupleCnv::load(TTree* /* tree */,
00072                                            INTuple*& /* refpObject */)
00073 //------------------------------------------------------------------------------
00074 {
00075   return StatusCode::FAILURE;
00076 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:44 2011 for RootHistCnv by doxygen 1.4.7