/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Mc/McCnv.cxx

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

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