| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

# 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 #include "GaudiKernel/INTupleSvc.h"
    00011
    00012 #include "RRWNTupleCnv.h"
    00013 #include "TTree.h"
    00014
    00015 // Instantiation of a static factory class used by clients to create
    00016 // instances of this service
    00017 DECLARE_NAMESPACE_CONVERTER_FACTORY(RootHistCnv,RRWNTupleCnv)
    00018
    00019 //------------------------------------------------------------------------------
    00020 StatusCode RootHistCnv::RRWNTupleCnv::book(const std::string& desc,
    00021                                            INTuple* nt,
    00022                                            TTree*& rtree)
    00023 //------------------------------------------------------------------------------
    00024 {
    00025   MsgStream log(msgSvc(), "RRWNTupleCnv");
    00026   const INTuple::ItemContainer& itms = nt->items();
    00027   // Book the tree
    00028   rtree = new TTree(desc.c_str(),nt->title().c_str());
    00029   // Add the branches
    00030   for (size_t length = itms.size(), i = 0; i < length; i++ )    {
    00031     const char* itm = itms[i]->name().c_str();
    00032     std::string tag = itm;
    00033     tag += rootVarType( itms[i]->type() );
    00034     // add the branch
    00035     log << MSG::INFO << "ID " << desc << ": added branch: "
    00036         << itm << " / " << tag << endmsg;
    00037     rtree->Branch(itm,const_cast<void*>(itms[i]->buffer()),tag.c_str());
    00038   }
    00039   log << MSG::INFO << "Booked TTree with ID:" << desc
    00040       << " \"" << nt->title() << "\"" << endmsg;
    00041   return StatusCode::SUCCESS;
    00042 }
    00043
    00044 //------------------------------------------------------------------------------
    00045 StatusCode RootHistCnv::RRWNTupleCnv::writeData(TTree* rtree, INTuple* nt)
    00046 //------------------------------------------------------------------------------
    00047 {
    00048   if ( 0 != rtree )   {
    00049     // Fill the tree;
    00050     rtree->Fill();
    00051     // Reset the NTuple
    00052     nt->reset();
    00053     return StatusCode::SUCCESS;
    00054   }
    00055   MsgStream log(msgSvc(), "RRWNTupleCnv");
    00056   log << MSG::ERROR << "Attempt to write invalid N-tuple.";
    00057   if ( nt != 0 ) log << nt->title();
    00058   log << endmsg;
    00059   return StatusCode::FAILURE;
    00060 }
    00061
    00062 //------------------------------------------------------------------------------
    00063 StatusCode RootHistCnv::RRWNTupleCnv::readData(TTree* /* tree */,
    00064                                                INTuple* /* nt */,
    00065                                                long /* ievt */)
    00066 //------------------------------------------------------------------------------
    00067 {
    00068   return StatusCode::FAILURE;
    00069 }
    00070
    00071 //------------------------------------------------------------------------------
    00072 StatusCode RootHistCnv::RRWNTupleCnv::load(TTree* /* tree */,
    00073                                            INTuple*& /* refpObject */)
    00074 //------------------------------------------------------------------------------
    00075 {
    00076   return StatusCode::FAILURE;
    00077 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines