/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Digi/DigiCnv.cxx

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

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