/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RawDataCnv/RawDataCnv-00-04-35/src/RawDataMdcDigiCnv.cxx

Go to the documentation of this file.
00001 //====================================================================
00002 //      RawDataMdcDigiCnv.cxx
00003 //====================================================================
00004 //
00005 // Description: A converter class to unpack Event Filter packed raw   
00006 //              event persistent data and place it in the Transient    
00007 //              Data Store of Athena.
00008 //
00009 //--------------------------------------------------------------------
00010 
00011 // Include files.
00012 #include "GaudiKernel/MsgStream.h"
00013 #include "GaudiKernel/PropertyMgr.h" 
00014 #include "GaudiKernel/IJobOptionsSvc.h" 
00015 #include "GaudiKernel/SmartDataPtr.h" 
00016 // for Mutil-thread by tianhl
00017 #include "GaudiKernel/ThreadGaudi.h"
00018 // for Mutil-thread by tianhl
00019 
00020 #include "EventModel/EventModel.h"
00021 #include "MdcRawEvent/MdcDigi.h"
00022 #include "RawDataCnv/EventManagement/RAWEVENT.h" 
00023 #include "RawDataCnv/EventManagement/RawEvent.h" 
00024 #include "RawDataCnv/RawDataInputSvc.h" 
00025 #include "RawDataCnv/RawDataMdcDigiCnv.h"
00026 
00027 // REMOVE THIS LINE AFTER "PACKEDRAWEVENT_StorageType" IS ADDED TO
00028 // THE FILE "GaudiKernel/ClassID.h"
00029 extern const CLID& CLID_MdcDigiCol;
00030 
00031 // Constructor.
00032 RawDataMdcDigiCnv::RawDataMdcDigiCnv(ISvcLocator* svc) : 
00033 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00034 {
00035    PropertyMgr m_propMgr;
00036    m_propMgr.declareProperty("ExWireFromRun", m_runFrom = 0 );  
00037    m_propMgr.declareProperty("ExWireToRun",   m_runTo = 999999);
00038 
00039    IJobOptionsSvc* jobSvc; 
00040    serviceLocator()->service("JobOptionsSvc", jobSvc);
00041    jobSvc->setMyProperties("RawDataMdcDigiCnv", &m_propMgr);
00042 }
00043 
00044 RawDataMdcDigiCnv::~RawDataMdcDigiCnv()
00045 {
00046    MdcConverter::destroy();
00047 }
00048 
00049 // Return the identification number of this converter to the 
00050 // persistency service.
00051 const CLID& RawDataMdcDigiCnv::classID()
00052 {
00053    return CLID_MdcDigiCol;
00054 }
00055 
00056 StatusCode RawDataMdcDigiCnv::initialize()
00057 {
00058    std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00059    std::string RawDataInputSvc_Name("RawDataInputSvc");
00060    std::string RawDataMdcDigiCnv_Name("RawDataMdcDigiCnv");
00061 
00062    // for Mutil-thread by tianhl
00063    //ConversionSvc*  pCnvSvc = 0;
00064    //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
00065    SmartIF<IService> pCnvSvc(conversionSvc());   
00066    if  (isGaudiThreaded(pCnvSvc->name())){
00067          PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00068          RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00069          RawDataMdcDigiCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00070       }
00071    //}
00072 
00073 
00074    StatusCode sc = RawDataBaseCnv::initialize();
00075    if ( sc.isFailure() ) {
00076       return sc;
00077    }
00078 
00079    MsgStream log(messageService(), RawDataMdcDigiCnv_Name.c_str());
00080 
00081    // Check RawDataCnvSvc
00082    IService* isvc = 0;
00083    StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00084    m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00085    if(m_RawDataAccess  == 0 ) {
00086       log<<MSG::ERROR<< "  RawDataMdcCnv: Cant cast to  RawDataCnvSvc " <<endreq; 
00087       return StatusCode::FAILURE ;
00088    }
00089 
00090    IService* svc ;
00091    sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
00092    //if ( sc.isFailure() ) {
00093    //   log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
00094    //   return sc ;
00095    //}
00096    m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
00097    if(m_inputSvc == 0 ) {
00098       log<<MSG::WARNING<< " Cant cast to  RawDataInputSvc " <<endreq;
00099       return StatusCode::FAILURE ;
00100    }
00101 
00102    m_cnv = MdcConverter::instance( m_inputSvc->runMode() );
00103 
00104    m_cnv->init(m_runFrom, m_runTo);
00105 
00106    return StatusCode::SUCCESS; 
00107 }
00108 
00109 
00110 StatusCode RawDataMdcDigiCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00111     // Purpose and Method:  This method does nothing other than announce it has
00112     //   been called.
00113 
00114     //MsgStream log(msgSvc(), "RawDataMdcDigiCnv");
00115     //log << MSG::DEBUG << "RawDataMdcDigiCnv::updateObj" << endreq;
00116     return Converter::updateObj(pAddr, pObj);
00117 }
00118 
00119 // Create a converted object in the Transient Data Store.
00120 StatusCode RawDataMdcDigiCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
00121 {
00122   //MsgStream log(msgSvc(), "RawDataMdcDigiCnv");
00123 
00124   // Purpose and Method:  This converter will create an empty MdcDigiCol on
00125   //   the TDS.
00126   MdcDigiCol *digiCol = new MdcDigiCol;
00127   pObj = digiCol;
00128 
00129   RAWEVENT* evt = m_inputSvc->currentEvent(); 
00130 
00131   if (evt == NULL) {
00132     //log << MSG::ERROR << "RawDataMdcDigiCnv::createObj has event!" << endreq; 
00133     return StatusCode::FAILURE;
00134   }
00135 
00136   int runId = evt->eventHeader().run_number();
00137   m_cnv->setRunId(runId);
00138 
00139   const BufferHolder& mdcBuf = evt->getMdcBuf();
00140 
00141   return m_cnv->convert(mdcBuf, digiCol);
00142 }
00143 
00144 StatusCode RawDataMdcDigiCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)  
00145 {
00146   // convert PixelRaw in the container into ByteStream
00147   MsgStream log(messageService(), "RawDataMdcDigiCnv");
00148 
00149   WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00150   if (re == 0) {
00151     log << " get RawEvent failed !" << endreq;
00152     return StatusCode::FAILURE; 
00153   }
00154 
00155   SmartDataPtr<MdcDigiCol> digiCol(dataProvider(), EventModel::Digi::MdcDigiCol);
00156   if (digiCol == 0) {
00157     log << "no MdcDigiCol found" << endreq;
00158     return StatusCode::FAILURE;
00159   }
00160   /*
00161   else {
00162     log << MSG::DEBUG << endreq << "Detailed dump of 1st event: " << endreq << endreq;
00163     int ndigi = 0;
00164     MdcDigiCol::const_iterator pMdcDigi = digiCol->begin();
00165     for (pMdcDigi; pMdcDigi!= digiCol->end(); pMdcDigi++) {
00166       log <<MSG::INFO << "Digi " << ndigi++ << " ";
00167       // output the digi proper:  " << digi " no longer works because
00168       // "digi" now returns an integer sort order
00169       (**pMdcDigi).fillStream(log.stream());
00170       log << endreq;
00171     }
00172   }
00173   */
00174 
00175   return m_cnv->convert(digiCol, re);
00176 }

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