Anonymous avatar Anonymous committed 7e5ad0f

Small update to RootConnection and RootSvc

Comments (0)

Files changed (4)

src/RootConnection.cxx

 ///////////////////////// -*- C++ -*- /////////////////////////////
 // RootConnection.cxx 
 // Implementation file for class RootConnection
-// Author Peter van Gemmeren <gemmeren@anl.gov>
+// Author: Peter van Gemmeren <gemmeren@anl.gov>
 // Author: S.Binet<binet@cern.ch>
 /////////////////////////////////////////////////////////////////// 
 
 // AthenaRootComps includes
 #include "RootConnection.h"
 
-// fwk
+// fwk includes
 #include "GaudiKernel/ServiceHandle.h"
 
-// ROOT
+// Reflex includes
+#include "Reflex/Type.h"
+
+// ROOT includes
 #include "TFile.h"
 #include "TTree.h"
 #include "TBranch.h"
 #include "TBranchElement.h"
 #include "TLeaf.h"
 
-// Reflex
-#include "Reflex/Type.h"
-
-// stl
-#include "CxxUtils/unordered_map.h" // move to stl when available.
-
 namespace {
   
   char typecode_from_typeid(const std::type_info &ti) 
 	 iend= m_descr.end();
        itr != iend;
        ++itr) {
-    delete itr->second;
+    delete itr->second; itr->second = 0;
   }
 }
 
 RootConnection::write(const void* data, unsigned long& len) 
 {
   if (m_file == 0 || m_tree == 0 || m_branch == 0) {
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
   BranchDescr* descr = m_descr[m_branch];
   descr->buffer = (void*)data;
     BranchDescr *brdescr = new BranchDescr;
     brdescr->typecode = ::typecode_from_typeid(rflx_type.TypeInfo());
     brdescr->buffer = ((void*)data);
-    if (brdescr->typecode != '\0') {
-      m_branch = m_tree->Branch(name.c_str(),
-				(void*)brdescr->buffer,
-				(name+"/"+brdescr->typecode).c_str(),
-				bufsize);
-    } else {
+    if (brdescr->typecode == '\0') {
       m_branch = m_tree->Bronch((name+"").c_str(), 
 				type.c_str(), 
 				(void*)&brdescr->buffer, 
 				bufsize, 
 				splitlevel);
+    } else {
+      m_branch = m_tree->Branch(name.c_str(),
+				(void*)brdescr->buffer,
+				(name+"/"+brdescr->typecode).c_str(),
+				bufsize);
     }
     if (m_branch != 0) {
       // let the Athena framework deal with deletion

src/RootConnection.h

 ///////////////////////// -*- C++ -*- /////////////////////////////
 // RootConnection.h 
 // Header file for class Athena::RootConnection
-// Author Peter van Gemmeren <gemmeren@anl.gov>
+// Author: Peter van Gemmeren <gemmeren@anl.gov>
 // Author: S.Binet<binet@cern.ch>
 /////////////////////////////////////////////////////////////////// 
 #ifndef ATHENAROOTCOMPS_ROOTCONNECTION_H
   typedef SG::unordered_map<TBranch*, BranchDescr*> BranchDescriptors_t;
   /// a map of branch descriptors for each branch we are asked to write out
   BranchDescriptors_t m_descr;
-  
 };
 
 } //> namespace Athena
 ///////////////////////// -*- C++ -*- /////////////////////////////
 // RootSvc.cxx 
 // Implementation file for class Athena::RootSvc
-// Author Peter van Gemmeren <gemmeren@anl.gov>
+// Author: Peter van Gemmeren <gemmeren@anl.gov>
 // Author: S.Binet<binet@cern.ch>
 /////////////////////////////////////////////////////////////////// 
 
   ATH_MSG_INFO("Initializing " << name() << " - package version " << PACKAGE_VERSION);
   if (!::AthService::initialize().isSuccess()) {
     ATH_MSG_FATAL("Cannot initialize ConversionSvc base class.");
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
   ATH_CHECK(m_dictsvc.retrieve());
   ATH_CHECK(m_iosvc.retrieve());
 
-  return(StatusCode::SUCCESS);
+  return StatusCode::SUCCESS;
 }
 
 StatusCode 
       ATH_MSG_WARNING("cannot close file = " << fd);
     }
   }
-  return(::AthService::finalize());
+  return ::AthService::finalize();
 }
 
 StatusCode
     *ppvInterface = dynamic_cast<IRootSvc*>(this);
   } else {
     // Interface is not directly available: try out a base class
-    return(::AthService::queryInterface(riid, ppvInterface));
+    return ::AthService::queryInterface(riid, ppvInterface);
   }
   addRef();
-  return(StatusCode::SUCCESS);
+  return StatusCode::SUCCESS;
 }
 
 /// Load the type (dictionary) from Root.
   if (m_wconn == 0) {
     ATH_MSG_ERROR("Cannot write without RootConnection for placement " 
                   << placement);
-    return(0);
+    return 0;
   }
   if (!m_wconn->setContainer(placement, 
 			     type.Name(Reflex::QUALIFIED | Reflex::SCOPED), 
 			     pObj).isSuccess()) {
     ATH_MSG_ERROR("Cannot set container " << placement);
-    return(0);
+    return 0;
   }
   unsigned long ientry = 0;
   if (!m_wconn->write(pObj, ientry).isSuccess()) {
     ATH_MSG_ERROR("Cannot write Object to placement " << placement);
-    return(0);
+    return 0;
   }
-  return(ientry);
+  return ientry;
 }
 
 /// Destruct a given object of type `Reflex::Type`.
 RootSvc::getClass(const std::type_info& type) const 
 {
   ATH_MSG_VERBOSE("RootSvc::getClass type = " << System::typeinfoName(type));
-  return(gROOT->GetClass(type));
+  return gROOT->GetClass(type);
 }
 
 void* 
 RootSvc::createObject(const TClass* classDesc) const 
 {
   ATH_MSG_VERBOSE("RootSvc::createObject type = " << classDesc->GetName());
-  return(classDesc->New());
+  return classDesc->New();
 }
 
 unsigned long 
   ATH_MSG_VERBOSE("RootSvc::writeObject placement = " << placement << ", pObj = " << pObj);
   if (m_wconn == 0) {
     ATH_MSG_ERROR("Cannot write without RootConnection for placement " << placement);
-    return(0);
+    return 0;
   }
   if (!m_wconn->setContainer(placement, 
 			     classDesc->GetName(), 
 			     pObj).isSuccess()) {
     ATH_MSG_ERROR("Cannot get container " << placement);
-    return(0);
+    return 0;
   }
   unsigned long ientry = 0;
   if (!m_wconn->write(pObj, ientry).isSuccess()) {
     ATH_MSG_ERROR("Cannot write Object to placement " << placement);
-    return(0);
+    return 0;
   }
-  return(ientry);
+  return ientry;
 }
 
 void 
 RootSvc::destructObject(TClass* classDesc, void* pObj) const 
 {
-  return(classDesc->Destructor(pObj));
+  return classDesc->Destructor(pObj);
 }
 
 /// open the file `fname` with open mode `mode`
     m_iosvc->close(fd);
     return -1;
   }
-  
   return fd;
 }
 
   ATH_MSG_VERBOSE("RootSvc::commitOutput");
   if (m_wconn == 0) {
     ATH_MSG_ERROR("Cannot commit without RootConnection.");
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
   if (!m_wconn->commit().isSuccess()) {
     ATH_MSG_ERROR("Cannot commit RootConnection.");
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
-  return(StatusCode::SUCCESS);
+  return StatusCode::SUCCESS;
 }
 
 /// Disconnect the file from the service.
   ConnMap_t::const_iterator entry = m_conns.find(fd);
   if (entry == m_conns.end()) {
     ATH_MSG_ERROR("Cannot get RootConnection for file " << file);
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
   if (!entry->second->disconnect().isSuccess()) {
     ATH_MSG_ERROR("Cannot disconnect to file " << file);
-    return(StatusCode::FAILURE);
+    return StatusCode::FAILURE;
   }
   return StatusCode::SUCCESS;
 }
 ///////////////////////// -*- C++ -*- /////////////////////////////
 // RootSvc.h 
 // Header file for class Athena::RootSvc
-// Author Peter van Gemmeren <gemmeren@anl.gov>
+// Author: Peter van Gemmeren <gemmeren@anl.gov>
 // Author: S.Binet<binet@cern.ch>
 /////////////////////////////////////////////////////////////////// 
 #ifndef ATHENAROOTCOMPS_ROOTSVC_H
  *  @author Peter van Gemmeren <gemmeren@anl.gov>
  **/
 
-// stl includes
+// STL includes
 #include <string>
 #include "CxxUtils/unordered_map.h" //> migrate to STL
 
 #include "AthenaRootKernel/IRootSvc.h"
 #include "AthenaRootKernel/IIoSvc.h"
 
-// reflex includes
+// Reflex includes
 #include "Reflex/Type.h"
 
+// fwd declares
 namespace Athena { class RootConnection; }
 class TClass;
 
 namespace Athena {
-
 /** @class RootSvc
  *  @brief This class provides the interface to the ROOT software.
  **/
 
 }//> namespace Athena
 
-#endif
+#endif /* !ATHENAROOTCOMPS_ROOTSVC_H */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.