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

Go to the documentation of this file.
00001 //====================================================================
00002 //      RawDataMdcMcHitCnv.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 <assert.h>
00013 #include <vector>
00014 #include "GaudiKernel/MsgStream.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 "Identifier/Identifier.h"
00022 #include "Identifier/MdcID.h"
00023 #include "McTruth/MdcMcHit.h"
00024 #include "RawDataCnv/EventManagement/RAWEVENT.h" 
00025 #include "RawDataCnv/EventManagement/RawEvent.h" 
00026 #include "RawDataCnv/RawDataInputSvc.h" 
00027 #include "RawDataCnv/RawDataMdcMcHitCnv.h"
00028 
00029 using Event::MdcMcHit;
00030 using Event::MdcMcHitCol;
00031 
00032 
00033 extern const CLID& CLID_MdcMcHitCol;
00034 
00035 // Constructor.
00036 RawDataMdcMcHitCnv::RawDataMdcMcHitCnv(ISvcLocator* svc) : 
00037 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00038 {
00039   //init();
00040 }
00041 
00042 // Return the identification number of this converter to the 
00043 // persistency service.
00044 const CLID& RawDataMdcMcHitCnv::classID()
00045 {
00046   return CLID_MdcMcHitCol;
00047 }
00048 
00049 StatusCode RawDataMdcMcHitCnv::initialize()
00050 {
00051 
00052     std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00053     std::string RawDataInputSvc_Name("RawDataInputSvc");
00054     std::string RawDataMdcMcHitCnv_Name("RawDataMdcMcHitCnv");
00055     
00056     // for Mutil-thread by tianhl
00057     //ConversionSvc*  pCnvSvc = 0;
00058     //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
00059     SmartIF<IService> pCnvSvc(conversionSvc());  
00060     if  (isGaudiThreaded(pCnvSvc->name())){
00061         PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00062         RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00063         RawDataMdcMcHitCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00064       }
00065     //}
00066     
00067   MsgStream log(messageService(), RawDataMdcMcHitCnv_Name.c_str());
00068 
00069   StatusCode sc = RawDataBaseCnv::initialize();
00070   if (StatusCode::SUCCESS != sc) {
00071     log << MSG::ERROR << "RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
00072     return sc;
00073   }
00074 
00075   // Check RawDataCnvSvc
00076   IService* isvc = 0;
00077   sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00078   if (sc != StatusCode::SUCCESS) {
00079     log << MSG::ERROR << "Cant get PackedRawDataCnvSvc" << endreq;
00080   }
00081 
00082   m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00083   if (m_RawDataAccess  == 0 ) {
00084     log << MSG::ERROR << "RawDataMdcCnv: Cant cast to RawDataCnvSvc " << endreq; 
00085     return StatusCode::FAILURE;
00086   }
00087 
00088   IService* svc = 0;
00089   sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), svc);
00090   if (sc != StatusCode::SUCCESS ) {
00091     log << MSG::WARNING << "Cant get RawDataInputSvc " << endreq;
00092     return sc ;
00093   }
00094 
00095   m_inputSvc = dynamic_cast<RawDataInputSvc*> (svc);
00096   if (m_inputSvc == 0 ) {
00097     log << MSG::WARNING << "Cant cast to RawDataInputSvc " << endreq;
00098     return StatusCode::FAILURE ;
00099   }
00100 
00101   return StatusCode::SUCCESS; 
00102 }
00103 
00104 
00105 StatusCode RawDataMdcMcHitCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00106   // Purpose and Method:  This method does nothing other than announce it has
00107   //   been called.
00108 
00109   //MsgStream log(msgSvc(), "RawDataMdcMcHitCnv");
00110   //log << MSG::DEBUG << "RawDataMdcMcHitCnv::updateObj" << endreq;
00111   return Converter::updateObj(pAddr, pObj);
00112 }
00113 
00114 // Create a converted object in the Transient Data Store.
00115 StatusCode RawDataMdcMcHitCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
00116 {
00117   //MsgStream log(msgSvc(), "RawDataMdcMcHitCnv");
00118 
00119   //This converter will create an empty MdcMcHitCol on the TDS
00120   MdcMcHitCol *mdcMcHitCol = new MdcMcHitCol;
00121   pObj = mdcMcHitCol;
00122    
00123   RAWEVENT *evt = m_inputSvc->currentEvent(); 
00124   if (evt == NULL) {
00125       //log << MSG::ERROR << "RawDataCnv has no event!" << endreq; 
00126       return StatusCode::FAILURE;
00127   }
00128 
00129   assert((evt->getMdcTruth().size())%6 == 0);
00130 
00131   MdcTruth_t m_MdcTruth;
00132   MdcMcHit* mdcMcHit;
00133 
00134   std::vector<uint32_t>::const_iterator iter = evt->getMdcTruth().begin();
00135   std::vector<uint32_t>::const_iterator eiter = evt->getMdcTruth().end();
00136 
00137   for (int mdcMcHitId = 0; iter != eiter; mdcMcHitId++) {
00138     // retrieve the MdcTruth data
00139     m_mdcMcHitBuilder.unPack(iter, eiter, m_MdcTruth);
00140     //construct the identifier
00141     const Identifier ident =  MdcID::wire_id (m_MdcTruth.layerId, m_MdcTruth.cellId);
00143     mdcMcHit = new MdcMcHit(ident, m_MdcTruth.trackIndex,
00144                        m_MdcTruth.x/(m_mdcMcHitBuilder.m_xCoeff*1.0),
00145                        m_MdcTruth.y/(m_mdcMcHitBuilder.m_yCoeff*1.0),
00146                        m_MdcTruth.z/(m_mdcMcHitBuilder.m_zCoeff*1.0),
00147                        m_MdcTruth.driftD/(m_mdcMcHitBuilder.m_driftDCoeff*1.0),
00148                        m_MdcTruth.edep/(m_mdcMcHitBuilder.m_edepCoeff*1.0),
00149                        m_MdcTruth.posFlag );
00150     // And add the stuff to the container
00151     mdcMcHitCol->push_back(mdcMcHit);
00152   }
00153 
00154   return StatusCode::SUCCESS; 
00155 }
00156 
00157 StatusCode RawDataMdcMcHitCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)  
00158 {
00159    // convert PixelRaw in the container into ByteStream
00160   //MsgStream log(messageService(), "RawDataMdcMcHitCnv");
00161   
00162   WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00163   
00164   if (re == 0) {
00165      //log << " get RawEvent failed !" << endreq;
00166      return StatusCode::FAILURE; 
00167   }
00168 
00169   SmartDataPtr<MdcMcHitCol> mdcHitCol(dataProvider(), EventModel::MC::MdcMcHitCol);
00170 
00171   if (mdcHitCol == 0) {
00172      //log << "no MdcMcHitCol found" << endreq;
00173      return StatusCode::FAILURE;
00174   }
00175   /*else {
00176      log << MSG::INFO << endreq << "Detailed dump of 1st event: " << endreq;
00177      int nMcHit = 0;
00178      MdcMcHitCol::const_iterator pMdcMcHit = mdcHitCol->begin();
00179      for ( ; pMdcMcHit != mdcHitCol->end(); pMdcMcHit++) {
00180         log << MSG::INFO << "McHit " << nMcHit++ << " "
00181             << (*pMdcMcHit)->getTrackIndex() << "  "
00182             << (*pMdcMcHit)->identify() << "  "
00183             << (*pMdcMcHit)->getDepositEnergy() << "  "
00184             << (*pMdcMcHit)->getDriftDistance() << "  "
00185             << (*pMdcMcHit)->getPositionX() << "  "
00186             << (*pMdcMcHit)->getPositionY() << "  "
00187             << (*pMdcMcHit)->getPositionZ() << endreq;
00188      }
00189   }*/
00190   
00191   StatusCode sc = m_mdcMcHitBuilder.pack(mdcHitCol, re);
00192 
00193   return sc; 
00194 
00195 }
00196 

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