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

Go to the documentation of this file.
00001 //====================================================================
00002 //      RawDataHltRawCnv.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/SmartDataPtr.h" 
00014 // for Mutil-thread by tianhl
00015 #include "GaudiKernel/ThreadGaudi.h"
00016 // for Mutil-thread by tianhl
00017 
00018 #include "EventModel/EventModel.h"
00019 #include "Identifier/HltID.h"
00020 #include "HltEvent/HltRaw.h"
00021 #include "RawDataCnv/EventManagement/RAWEVENT.h" 
00022 #include "RawDataCnv/EventManagement/RawEvent.h" 
00023 #include "RawDataCnv/RawDataAddress.h" 
00024 #include "RawDataCnv/RawDataInputSvc.h" 
00025 #include "RawDataCnv/RawDataHltRawCnv.h"
00026 
00027 
00028 extern const CLID& CLID_HltRawCol;
00029 
00030 // Constructor.
00031 RawDataHltRawCnv::RawDataHltRawCnv(ISvcLocator* svc) : 
00032 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00033 {
00034     //init();
00035 }
00036 RawDataHltRawCnv::~RawDataHltRawCnv(){
00037 }
00038 
00039 // Return the identification number of this converter to the 
00040 // persistency service.
00041 const CLID& RawDataHltRawCnv::classID()
00042 {
00043    return CLID_HltRawCol;
00044 }
00045 
00046 StatusCode RawDataHltRawCnv::initialize()
00047 {
00048     std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00049     std::string RawDataInputSvc_Name("RawDataInputSvc");
00050     std::string RawDataHltRawCnv_Name("RawDataHltRawCnv");
00051     
00052     // for Mutil-thread by tianhl
00053     //ConversionSvc*  pCnvSvc = 0;
00054     //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
00055     SmartIF<IService> pCnvSvc(conversionSvc());  
00056     if  (isGaudiThreaded(pCnvSvc->name())){
00057         PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00058         RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00059         RawDataHltRawCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00060       }
00061     //}
00062     
00063    MsgStream log(messageService(), RawDataHltRawCnv_Name.c_str());
00064    StatusCode sc = RawDataBaseCnv::initialize();
00065    if (StatusCode::SUCCESS != sc) {
00066      
00067      return sc;
00068    }
00069 
00070    // Check RawDataCnvSvc
00071    IService* isvc = 0;
00072    StatusCode status = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00073 
00074    m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00075     if(m_RawDataAccess  == 0 ) {
00076       log<<MSG::ERROR<< "  RawDataCnv: Cant cast to  RawDataCnvSvc " <<endreq; 
00077       return StatusCode::FAILURE ;
00078    }
00079    
00080    if(m_RawDataAccess)
00081         log << MSG::INFO << "RawDataCnvSvc retrieved "<< endreq;
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  
00090     m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
00091     if(m_inputSvc == 0 ) {
00092         log<<MSG::WARNING<< " Cant cast to  RawDataInputSvc " <<endreq;
00093         return StatusCode::FAILURE ;
00094     }
00095  
00096    return StatusCode::SUCCESS; 
00097 }
00098 
00099 
00100 StatusCode RawDataHltRawCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00101     // Purpose and Method:  This method does nothing other than announce it has
00102     //   been called.
00103 
00104     //MsgStream log(msgSvc(), "RawDataHltRawCnv");
00105     //log << MSG::DEBUG << "RawDataHltRawCnv::updateObj" << endreq;
00106     return Converter::updateObj(pAddr, pObj);
00107 }
00108 
00109 // Create a converted object in the Transient Data Store.
00110 StatusCode RawDataHltRawCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
00111 {
00112    //MsgStream log(msgSvc(), "RawDataHltRawCnv");
00113    RawDataAddress *pEFAddr;
00114    uint32_t TEData[2];
00115    
00116    // Purpose and Method:  This converter will create an empty HltRawCol on
00117    //   the TDS.
00118    HltRawCol *digiCol = new HltRawCol;
00119    pObj = digiCol;
00120 
00121    RAWEVENT *evt = m_inputSvc->currentEvent(); 
00122    if (evt == NULL) {
00123      cout << "RawDataHltRawCnv::createObj can't get event!" << endl; 
00124      return StatusCode::FAILURE;
00125    }
00126 
00127    int digiId = 0;
00128    const BufferHolder& hltBuf = evt->getHltBuf();
00129    uint32_t nbuf = hltBuf.nBuf();
00130    
00131    uint32_t REId = 0, TEId = 0;
00132    uint32_t nmdc=0,ntof=0,nemc=0,nmuc=0;
00133    for (uint32_t i = 0; i < nbuf; i++) {
00134      uint32_t* buf = hltBuf(i);
00135      uint32_t bufSize = hltBuf.bufSize(i);
00136      for (uint32_t j = 0; j < bufSize; j++, digiId++) {
00137 
00138         m_hltBuilder.unPack(buf[j], digiId, REId, TEData[0], TEData[1]);
00139         TEId = m_hltBuilder.getTEID(REId);
00140         if ( TEId == 0xFFFFFFFF ) continue;
00141 
00142 //       log << MSG::NIL << "HLT digit No: " << digiId << "="<<std::hex<<buf[j]
00143 //         <<"===>"<<TEId<<" : "<<TEData[0]<<","<<TEData[1]<<std::dec<<endreq;
00144        for (uint32_t k=0; k< 2;k++){
00145          // Create new track
00146          if(k==0||(k==1&&TEData[k])){
00147            if(k==1) TEId+=1;
00148            if(HltID::is_number(HltID::convert(TEId))) {
00149              nmdc=TEData[k]&0xFF;
00150              ntof=(TEData[k]>>8)&0xFF;
00151              nemc=(TEData[k]>>16)&0xFF;
00152              nmuc=(TEData[k]>>24)&0xFF;
00153              //log << MSG::INFO << "number=" << std::hex <<TEData[k] <<std::dec<< endreq;
00154            }
00155            HltRaw* hltRaw = new HltRaw(HltID::convert(TEId,nmdc,ntof,nemc,nmuc));
00156            hltRaw->setIntChannel(TEData[k]);
00157            //hltRaw->setFloatChannel(TEData[k]);
00158            hltRaw->setChargeChannel(TEData[k]);
00159 
00160            digiCol->push_back ( hltRaw );
00161          }
00162        }
00163      }
00164    }
00165    return StatusCode::SUCCESS; 
00166 }
00167 
00168 StatusCode RawDataHltRawCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)  
00169 {
00170     // convert PixelRaw in the container into ByteStream
00171     //MsgStream log(messageService(), "RawDataHltRawCnv");
00172 
00173     WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00174     if(re == 0) {
00175       //log << " get RawEvent failed !" << endreq;
00176       return StatusCode::FAILURE; 
00177     }
00178 
00179     SmartDataPtr<HltRawCol> digiCol(dataProvider(), EventModel::Hlt::HltRawCol);
00180     if (digiCol == 0) {
00181         //log << "no HltRawCol found" << endreq;
00182         return StatusCode::FAILURE;
00183     }
00184     /*
00185     else {
00186         log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq << endreq;
00187         int ndigi = 0;
00188         HltRawCol::const_iterator pHltRaw = digiCol->begin();
00189         for (pHltRaw; pHltRaw!= digiCol->end(); pHltRaw++) {
00190             log <<MSG::INFO << "Raw " << ndigi++ << " ";
00191             // output the digi proper:  " << digi " no longer works because
00192             // "digi" now returns an integer sort order
00193             (**pHltRaw).fillStream(log.stream());
00194             log << endreq;
00195         }
00196     }
00197     */
00198     return m_hltBuilder.pack(digiCol, re);
00199 }
00200 
00201 

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