/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Dst/DstCnv.cxx

Go to the documentation of this file.
00001 // File and Version Information:
00002 // Description:
00003 //      DstCnv is the concrete converter for the Rec branch
00004 //
00005 
00006 #ifndef DstCnv_CXX
00007 #define DstCnv_CXX 
00008 
00009 #include "GaudiKernel/MsgStream.h"
00010 #include "GaudiKernel/DataObject.h"
00011 #include "GaudiKernel/SmartDataPtr.h"
00012 #include "GaudiKernel/RegistryEntry.h"
00013 #include "GaudiKernel/IDataProviderSvc.h"
00014 #include "GaudiKernel/ISvcLocator.h"
00015 #include "GaudiKernel/PropertyMgr.h"
00016 
00017 #include "GaudiKernel/IOpaqueAddress.h"
00018 
00019 #include "EventModel/EventHeader.h"
00020 #include "DstEvent/DstEvent.h"
00021 #include "EventModel/EventModel.h"
00022 #include "RootCnvSvc/Dst/DstCnv.h"
00023 #include "RootCnvSvc/RootEvtSelector.h"
00024 #include "RootCnvSvc/RootAddress.h"
00025 #include "RootCnvSvc/Util.h"
00026 #include "McTruth/DecayMode.h"
00027 
00028 using namespace DataSvcHelpers;
00029 
00030 TDstEvent* DstCnv::m_objWrite = 0;
00031 
00032 DstCnv::DstCnv(ISvcLocator* svc)
00033 : RootEventBaseCnv(classID(), svc)
00034 {
00035   // Here we associate this converter with the path on the TDS.
00036   m_rootBranchname =""; 
00037   //declareObject(EventModel::Dst::Event, objType(), m_rootTreename, m_rootBranchname);
00038 }
00039 
00040 StatusCode DstCnv::TObjectToDataObject(DataObject*& refpObject) {
00041     // fills the TDS object from the persistent one
00042   StatusCode sc=StatusCode::SUCCESS;
00043     
00044   MsgStream log(msgSvc(), "DstCnv");
00045   log << MSG::DEBUG << "TObjectToDataObject" << endreq;
00046   /*
00047   SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
00048   if (!evt) {
00049     log << MSG::ERROR << "Failed to retrieve RecEvent" << endreq;
00050     return StatusCode::FAILURE;
00051   }
00052 
00053   */
00054   
00055  
00056   DstEvent * tdsev = new DstEvent();
00057   refpObject = tdsev;
00058 
00059 
00060   return sc;
00061 }
00062 
00063 StatusCode DstCnv::initialize()   {
00064   MsgStream log(msgSvc(), "DstCnv");
00065   log << MSG::DEBUG << "DstCnv::initialize"<< endreq;
00066  
00067   StatusCode status = RootEventBaseCnv::initialize();
00068 
00069   //pass dst converter to the conversion service
00070   m_cnvSvc->setDstCnv(this);
00071 
00072   return status;
00073 
00074 }
00075 
00076 StatusCode DstCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
00077   // transforms TDS event to Dst event in root format
00078   MsgStream log(msgSvc(), "DstCnv");
00079   log << MSG::DEBUG << "DstCnv::DataObjectToTObject" << endreq;
00080 
00081   // test if already done for this event
00082   //zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0)) return StatusCode::SUCCESS;
00083   if (m_common.m_dstEvt != NULL) return StatusCode::SUCCESS;
00084 
00085 /*
00086   SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
00087   
00088   if (!evtTds) {
00089     log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endreq;
00090     return StatusCode::FAILURE;
00091   }
00092   */
00093   DstEvent * devtTds=dynamic_cast<DstEvent *> (obj);
00094   if (!devtTds) {
00095     log << MSG::ERROR << "Could not downcast to TDS DstEvent" << endreq;
00096     return StatusCode::FAILURE;
00097   }
00098 
00099   m_objWrite = new TDstEvent();  //zoujh
00100   m_common.m_dstEvt = m_objWrite;  //zoujh
00101 
00102   // create branch if not yet done
00103     if (m_branchNrDst<0) {
00104       //zoujh: m_objWrite = new TDstEvent();
00105       StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TDstEvent",m_objWrite->ClassName(),&m_objWrite,m_branchNrDst);
00106       if (sc.isFailure()) {
00107         log << MSG::ERROR << "Could not create branch TDstEvent" << endreq;
00108         return sc;
00109       }
00110     }
00111 
00112 //  Int_t evtId = evtTds->eventNumber();
00113 //  Int_t runId = evtTds->runNumber();
00114 
00115 
00116   m_objWrite->initialize();
00117 
00118   return StatusCode::SUCCESS;
00119 }
00120 #endif
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 

Generated on Tue Nov 29 22:58:39 2016 for BOSS_7.0.2 by  doxygen 1.4.7