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

Go to the documentation of this file.
00001 //====================================================================
00002 //      RawDataEmcDigiCnv.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/StatusCode.h"
00013 #include "GaudiKernel/Converter.h"
00014 #include "GaudiKernel/SmartDataPtr.h" 
00015 #include "GaudiKernel/MsgStream.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 "EmcRawEvent/EmcDigi.h"
00022 #include "RawDataCnv/EventManagement/RAWEVENT.h" 
00023 #include "RawDataCnv/EventManagement/RawEvent.h" 
00024 #include "RawDataCnv/RawDataInputSvc.h" 
00025 #include "RawDataCnv/PackedRawDataCnvSvc.h" 
00026 #include "RawDataCnv/Util/EmcConverter.h"
00027 #include "RawDataCnv/RawDataEmcDigiCnv.h"
00028 
00029 
00030 extern const CLID& CLID_EmcDigiCol;
00031 
00032 // Constructor.
00033 RawDataEmcDigiCnv::RawDataEmcDigiCnv(ISvcLocator* svc) : 
00034 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00035 {
00036 }
00037 RawDataEmcDigiCnv::~RawDataEmcDigiCnv(){
00038    EmcConverter::destroy();
00039 }
00040 
00041 // Return the identification number of this converter to the 
00042 // persistency service.
00043 const CLID& RawDataEmcDigiCnv::classID()
00044 {
00045    return CLID_EmcDigiCol;
00046 }
00047 
00048 StatusCode RawDataEmcDigiCnv::initialize()
00049 {
00050    std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00051    std::string RawDataInputSvc_Name("RawDataInputSvc");
00052    std::string RawDataEmcDigiCnv_Name("RawDataEmcDigiCnv");
00053    //std::string RawDataProviderSvc_Name("RawDataProviderSvc");
00054 
00055    // for Mutil-thread by tianhl
00056    //ConversionSvc*  pCnvSvc = 0;
00057    SmartIF<IService> pCnvSvc(conversionSvc());
00058    //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
00059       if  (isGaudiThreaded(pCnvSvc->name())){
00060          PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00061          RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00062          RawDataEmcDigiCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00063          //RawDataProviderSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00064       }
00065    //}
00066    // for Mutil-thread by tianhl
00067    MsgStream log(msgSvc(), RawDataEmcDigiCnv_Name.c_str());
00068 
00069    StatusCode sc = RawDataBaseCnv::initialize();
00070    if ( sc.isFailure() ) {
00071       return sc;
00072    }
00073 
00074    // Check RawDataCnvSvc
00075    IService* isvc = 0;
00076    StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00077    m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00078    if(m_RawDataAccess  == 0 ) {
00079       log<<MSG::ERROR<< "  RawDataCnv: Cant cast to  RawDataCnvSvc " <<endreq; 
00080       return StatusCode::FAILURE ;
00081    }
00082 
00083    IService* svc ;
00084    sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
00085    //if(sc != StatusCode::SUCCESS ) {
00086    //   log<<MSG::WARNING << " Cant get RawDataInputSvc " <<endreq;
00087    //   return sc ;
00088    //}
00089    m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
00090    if ( m_inputSvc == 0 ) {
00091       log<<MSG::WARNING<< " Cant cast to  RawDataInputSvc " <<endreq;
00092       return StatusCode::FAILURE ;
00093    }
00094 
00095    m_cnv = EmcConverter::instance( m_inputSvc->runMode() );
00096 
00097    return StatusCode::SUCCESS; 
00098 }
00099 
00100 
00101 StatusCode RawDataEmcDigiCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00102     // Purpose and Method:  This method does nothing other than announce it has
00103     //   been called.
00104 
00105     MsgStream log(msgSvc(), "RawDataEmcDigiCnv");
00106     log << MSG::DEBUG << "RawDataEmcDigiCnv::updateObj" << endreq;
00107     return Converter::updateObj(pAddr, pObj);
00108 }
00109 
00110 // Create a converted object in the Transient Data Store.
00111 StatusCode RawDataEmcDigiCnv::createObj(IOpaqueAddress*, DataObject*& pObj)
00112 {
00113    MsgStream log(msgSvc(), "RawDataEmcDigiCnv");
00114 
00115    // Purpose and Method:  This converter will create an empty EmcDigiCol on
00116    //   the TDS.
00117    EmcDigiCol *digiCol = new EmcDigiCol;
00118    pObj = digiCol;
00119 
00120    RAWEVENT *evt = m_inputSvc->currentEvent(); 
00121    if (evt == NULL) {
00122      cout << "RawDataEmcDigiCnv::createObj can't get event!" << endl; 
00123      return StatusCode::FAILURE;
00124    }
00125 
00126    const BufferHolder& emcBuf = evt->getEmcBuf();
00127 
00128    return m_cnv->convert(emcBuf, digiCol); 
00129 }
00130 
00131 StatusCode RawDataEmcDigiCnv::createRep(DataObject*, IOpaqueAddress*&)  
00132 {
00133   // convert PixelRaw in the container into ByteStream
00134   MsgStream log(msgSvc(), "RawDataEmcDigiCnv");
00135 
00136   WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00137   if (re == 0) {
00138     log << " get RawEvent failed !" << endreq;
00139     return StatusCode::FAILURE; 
00140   }
00141 
00142   SmartDataPtr<EmcDigiCol> digiCol(dataProvider(), EventModel::Digi::EmcDigiCol);
00143   if (digiCol == 0) {
00144     log << "no EmcDigiCol found" << endreq;
00145     return StatusCode::FAILURE;
00146   }
00147   /*
00148   else {
00149     log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq << endreq;
00150     int ndigi = 0;
00151     EmcDigiCol::const_iterator pEmcDigi = digiCol->begin();
00152     for (pEmcDigi; pEmcDigi!= digiCol->end(); pEmcDigi++) {
00153       log <<MSG::INFO << "Digi " << ndigi++ << " ";
00154       // output the digi proper:  " << digi " no longer works because
00155       // "digi" now returns an integer sort order
00156       (**pEmcDigi).fillStream(log.stream());
00157       log << endreq;
00158     }
00159   }
00160   */
00161 
00162   return m_cnv->convert(digiCol, re);
00163 }

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