Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Protected Member Functions | Protected Attributes

Gaudi::RootStatCnv Class Reference

Description: Base class converter for N-tuples and related classes. More...

#include <Root/RootStatCnv.h>

Inheritance diagram for Gaudi::RootStatCnv:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::RootStatCnv:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RootStatCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor.
virtual ~RootStatCnv ()
 Standard Destructor.

Protected Member Functions

MsgStream & log () const
 Helper to use mesage logger.
virtual StatusCode initialize ()
 Initialize converter object.
virtual StatusCode finalize ()
 Finalize converter object.
virtual const std::string containerName (IRegistry *pDir) const
 Retrieve the name of the container a given object is placed into.
virtual const std::string fileName (IRegistry *pReg) const
 Retrieve the name of the file a given object is placed into.
virtual const std::string topLevel (IRegistry *pReg) const
 Retrieve the full path of the file a given object is placed into.
StatusCode makeError (const std::string &msg, bool throw_exception=false) const
 Helper method to issue error messages.
StatusCode saveDescription (const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
 Save statistics object description.

Protected Attributes

IDataManagerSvc * m_dataMgr
 Reference to data manager service to manipulate the TES.
MsgStream * m_log
 Reference to logger object.

Detailed Description

Description: Base class converter for N-tuples and related classes.

Author:
M.Frank
Version:
1.0

Definition at line 31 of file RootStatCnv.h.


Constructor & Destructor Documentation

RootStatCnv::RootStatCnv ( long  typ,
const CLID &  clid,
ISvcLocator *  svc,
RootCnvSvc *  mgr 
)

Initializing Constructor.

Parameters:
typ[IN] Concrete storage type of the converter
clid[IN] Class identifier of the object
svc[IN] Pointer to service locator object
Returns:
Reference to RootBaseCnv object

Definition at line 25 of file RootStatCnv.cpp.

: RootConverter(typ, clid, svc, mgr), m_dataMgr(0), m_log(0)
{
}
virtual Gaudi::RootStatCnv::~RootStatCnv (  ) [inline, virtual]

Standard Destructor.

Definition at line 106 of file RootStatCnv.h.

{  }

Member Function Documentation

const string RootStatCnv::containerName ( IRegistry *  pDir ) const [protected, virtual]

Retrieve the name of the container a given object is placed into.

Parameters:
pReg[IN] Pointer to registry entry.
Returns:
Name of the container the object should be put to.

Reimplemented in Gaudi::RootDatabaseCnv.

Definition at line 58 of file RootStatCnv.cpp.

                                                             {
  const string& path = pReg->identifier();
  long loc = path.find('/',1);
  string local = "<local>";
  //local = "";
  if ( loc > 0 )  {
    loc = path.find('/',++loc);
    if ( loc > 0 )  {
      local += path.substr(loc,path.length()-loc);
    }
  }
  //for(size_t i=0; i<local.length();++i)
  //  if ( !isalnum(local[i])) local[i] = '_';
  return local;
}
const string RootStatCnv::fileName ( IRegistry *  pReg ) const [protected, virtual]

Retrieve the name of the file a given object is placed into.

Parameters:
pReg[IN] Pointer to registry entry.
Returns:
Name of the file the object should be put to.

Definition at line 75 of file RootStatCnv.cpp.

                                                        {
  string path = topLevel(pReg);
  DataObject* pObj = 0;
  dataProvider()->retrieveObject(path, pObj);
  if ( pObj )  {
    NTuple::File* fptr = dynamic_cast<NTuple::File*>(pObj);
    if ( fptr )  {
      return fptr->name();
    }
  }
  return "";
}
StatusCode RootStatCnv::finalize (  ) [protected, virtual]

Finalize converter object.

Reimplemented from Converter.

Definition at line 45 of file RootStatCnv.cpp.

                                 {
  if ( m_log ) {
    delete m_log;
    m_log = 0;
  }
  if ( m_dataMgr ) {
    m_dataMgr->release();
    m_dataMgr = 0;
  }
  return RootConverter::finalize();
}
StatusCode RootStatCnv::initialize (  ) [protected, virtual]

Initialize converter object.

Reimplemented from Converter.

Definition at line 31 of file RootStatCnv.cpp.

                                   {
  StatusCode sc = RootConverter::initialize();
  if ( sc.isSuccess() ) {
    sc = dataProvider()->queryInterface(IDataManagerSvc::interfaceID(),(void**)&m_dataMgr);
    if ( !sc.isSuccess() ) {
      return makeError("Failed to access IDataManagerSvc interface.");
    }
  }
  if ( m_log ) delete m_log;
  m_log = new MsgStream(msgSvc(),System::typeinfoName(typeid(*this)));
  return sc;
}
MsgStream& Gaudi::RootStatCnv::log (  ) const [inline, protected]

Helper to use mesage logger.

Definition at line 39 of file RootStatCnv.h.

{ return *m_log; }
StatusCode RootStatCnv::makeError ( const std::string &  msg,
bool  throw_exception = false 
) const [protected]

Helper method to issue error messages.

Parameters:
msg[IN] Text of the error message
throw_exc[IN]If true throw an exception of type std::runtime_error
Returns:
Status code indicating success or failure.

Definition at line 105 of file RootStatCnv.cpp.

                                                                             {
  if ( m_log )  {
    log() << MSG::ERROR << msg << endmsg;
  }
  else {
    MsgStream l(msgSvc(),"RootConverter");
    l << MSG::ERROR << msg << endmsg;    
  }
  if ( throw_exc ) {
  }
  return StatusCode::FAILURE;
}
StatusCode RootStatCnv::saveDescription ( const std::string &  path,
const std::string &  ident,
const std::string &  desc,
const std::string &  opt,
const CLID &  clid 
) [protected]

Save statistics object description.

Parameters:
path[IN] Path of file to save the description on.
ident[IN] Identifier of description to be saved.
desc[IN] Description
opt[IN] Optional description
guid[IN] Object giud of described object
openMode[IN] Mode of opening the file to save description
Returns:
Status code indicating success or failure.

Definition at line 120 of file RootStatCnv.cpp.

{
  RootDataConnection* con = 0;
  StatusCode status = m_dbMgr->connectDatabase(path, IDataConnection::UPDATE, &con);
  if ( status.isSuccess() )  {
    TClass* cl = gROOT->GetClass("Gaudi::RootNTupleDescriptor",kTRUE);
    if ( cl ) {
      RootNTupleDescriptor* ptr;
      auto_ptr<RootNTupleDescriptor> dsc(ptr=new RootNTupleDescriptor());
      TBranch* b = con->getBranch("##Descriptors","GaudiStatisticsDescription",cl,ptr);
      if ( b ) {
        dsc->description = desc;
        dsc->optional    = opt;
        dsc->container   = ident;
        dsc->clid        = clid;
        b->SetAddress(&ptr);
        int nb = b->Fill();
        if ( nb > 1 ) {
          log() << MSG::DEBUG << "Save description for " << ident << endmsg;
          return StatusCode::SUCCESS;
        }
      }
      return makeError("Failed to access ROOT branch GaudiStatisticsDescription");
    }
    return makeError("Failed to access TClass RootNTupleDescriptor");
  }
  return makeError("Failed to access Tuple file:"+path);
}
const string RootStatCnv::topLevel ( IRegistry *  pReg ) const [protected, virtual]

Retrieve the full path of the file a given object is placed into.

Parameters:
pReg[IN] Pointer to registry entry.
Returns:
Name of the file the object should be put to.

Definition at line 89 of file RootStatCnv.cpp.

                                                          {
  if ( pReg )    {
    string path = pReg->identifier();
    size_t idx = path.find('/', 1);
    if ( idx != string::npos )  {
      idx = path.find('/', idx+1);
      if ( idx != string::npos )  {
        path = path.substr(0, idx);
      }
      return path;
    }
  }
  return "";
}

Member Data Documentation

IDataManagerSvc* Gaudi::RootStatCnv::m_dataMgr [protected]

Reference to data manager service to manipulate the TES.

Definition at line 34 of file RootStatCnv.h.

MsgStream* Gaudi::RootStatCnv::m_log [protected]

Reference to logger object.

Definition at line 36 of file RootStatCnv.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:31 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004