/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Rec/RecTrackCnv.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 RecTrackCnv_CXX
00007 #define RecTrackCnv_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 "ReconEvent/ReconEvent.h"
00021 #include "EventModel/EventModel.h"
00022 #include "RootCnvSvc/Rec/RecTrackCnv.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 // Instantiation of a static factory class used by clients to create
00031 // instances of this service
00032 //static CnvFactory<RecTrackCnv> s_factory;
00033 //const ICnvFactory& RecTrackCnvFactory = s_factory;
00034 
00035 TRecTrackEvent* RecTrackCnv::m_objWrite = 0;
00036 
00037 RecTrackCnv::RecTrackCnv(ISvcLocator* svc)
00038 : RootEventBaseCnv(classID(), svc)
00039 {
00040 
00041   // Here we associate this converter with the path on the TDS.
00042   m_rootBranchname =""; 
00043   //declareObject(EventModel::Recon::Event, objType(), m_rootTreename, m_rootBranchname);   //Dst-->Recon liangyt -->Rec
00044   //m_objWrite=0; 
00045 }
00046 
00047 StatusCode RecTrackCnv::initialize()   {
00048   MsgStream log(msgSvc(), "RecTrackCnv");
00049   log << MSG::DEBUG << "RecTrackCnv::initialize"<< endreq;
00050  
00051   StatusCode status = RootEventBaseCnv::initialize();
00052 
00053   //pass dst converter to the conversion service
00054   m_cnvSvc->setRecTrackCnv(this);
00055 
00056   return status;
00057 
00058 }
00059 
00060 StatusCode RecTrackCnv::TObjectToDataObject(DataObject*& refpObject) {
00061     // fills the TDS object from the persistent one
00062   StatusCode sc=StatusCode::SUCCESS;
00063 
00064   MsgStream log(msgSvc(), "RecTrackCnv");
00065   log << MSG::DEBUG << "TObjectToDataObject" << endreq;
00066   /*
00067   SmartDataPtr<Event::EventHeader> evt(m_eds, EventModel::EventHeader);
00068   if (!evt) {
00069     log << MSG::ERROR << "Failed to retrieve RecEvent" << endreq;
00070     return StatusCode::FAILURE;
00071   }
00072 
00073   */
00074   
00075   ReconEvent * tdsev = new ReconEvent();
00076   refpObject = tdsev;
00077   //sc =m_eds ->registerObject(EventModel::EventHeader, evt);
00078 
00079 
00080   return sc;
00081 }
00082 
00083 StatusCode RecTrackCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
00084   // transforms TDS event to Dst event in root format
00085   MsgStream log(msgSvc(), "RecTrackCnv");
00086   log << MSG::DEBUG << "RecTrackCnv::DataObjectToTObject" << endreq;
00087 
00088   // test if already done for this event
00089   //zoujh: if (m_objWrite && (m_objWrite->getRunId()!=0 || m_objWrite->getEventId()!=0)) return StatusCode::SUCCESS;
00090 
00091   if (m_common.m_rectrackEvt != NULL) return StatusCode::SUCCESS;
00092 /*
00093   SmartDataPtr<Event::EventHeader> evtTds(m_eds, EventModel::EventHeader);
00094   
00095   if (!evtTds) {
00096     log << MSG::ERROR << "Failed to retrieve EventHeader in TDS" << endreq;
00097     return StatusCode::FAILURE;
00098   }
00099 */
00100   ReconEvent * devtTds=dynamic_cast<ReconEvent *> (obj);
00101   if (!devtTds) {
00102     log << MSG::ERROR << "Could not downcast to TDS Event" << endreq;
00103     return StatusCode::FAILURE;
00104   }
00105 
00106   m_objWrite = new TRecTrackEvent();  //zoujh
00107   m_common.m_rectrackEvt = m_objWrite;  //zoujh
00108 
00109   // create branch if not yet done
00110   if (m_branchNrRecon<0) {   
00111       //zoujh: m_objWrite = new TDstEvent();
00112       StatusCode sc = m_rootInterface->createBranch(rootaddr->getTreename(),"TRecEvent",m_objWrite->ClassName(),&m_objWrite,m_branchNrRecon);
00113 
00114 
00115       if (sc.isFailure()) {
00116         cout<<"Could not create branch TRecEvent"<<endl;
00117         log << MSG::ERROR << "Could not create branch TRecEvent" << endreq;
00118         return sc;
00119       }
00120     }
00121 
00122   //Int_t evtId = evtTds->eventNumber();
00123   //Int_t runId = evtTds->runNumber();
00124 
00125  
00126   m_objWrite->initialize();
00127 
00128   return StatusCode::SUCCESS;
00129 }
00130 #endif
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 

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