/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootCnvSvc/RootCnvSvc-02-01-12/src/Trig/TrigCnv.cxx

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

Generated on Tue Nov 29 23:11:23 2016 for BOSS_7.0.2 by  doxygen 1.4.7