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

Go to the documentation of this file.
00001 //====================================================================
00002 //      RawDataMucMcHitCnv.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/MucID.h"
00023 #include "McTruth/MucMcHit.h"
00024 #include "RawDataCnv/EventManagement/RAWEVENT.h" 
00025 #include "RawDataCnv/EventManagement/RawEvent.h" 
00026 #include "RawDataCnv/RawDataInputSvc.h" 
00027 #include "RawDataCnv/RawDataMucMcHitCnv.h"
00028 
00029 
00030 using Event::MucMcHit;
00031 using Event::MucMcHitCol;
00032 
00033 // REMOVE THIS LINE AFTER "PACKEDRAWEVENT_StorageType" IS ADDED TO
00034 // THE FILE "GaudiKernel/ClassID.h"
00035 extern const CLID& CLID_MucMcHitCol;
00036 
00037 // Constructor.
00038 RawDataMucMcHitCnv::RawDataMucMcHitCnv(ISvcLocator* svc) : 
00039 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00040 {
00041   //init();
00042 }
00043 
00044 // Return the identification number of this converter to the 
00045 // persistency service.
00046 const CLID& RawDataMucMcHitCnv::classID()
00047 {
00048   return CLID_MucMcHitCol;
00049 }
00050 
00051 StatusCode RawDataMucMcHitCnv::initialize()
00052 {
00053     std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00054     std::string RawDataInputSvc_Name("RawDataInputSvc");
00055     std::string RawDataMucMcHitCnv_Name("RawDataMucMcHitCnv");
00056     
00057     // for Mutil-thread by tianhl
00058     //ConversionSvc*  pCnvSvc = 0;
00059     //if (pCnvSvc = dynamic_cast<ConversionSvc*>(conversionSvc())){
00060     SmartIF<IService> pCnvSvc(conversionSvc());  
00061     if  (isGaudiThreaded(pCnvSvc->name())){
00062         PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00063         RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00064         RawDataMucMcHitCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00065       }
00066     //}
00067     
00068 
00069   MsgStream log(messageService(), RawDataMucMcHitCnv_Name.c_str());
00070 
00071   StatusCode sc = RawDataBaseCnv::initialize();
00072   if (StatusCode::SUCCESS != sc) {
00073     log << MSG::ERROR << "RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
00074     return sc;
00075   }
00076 
00077   // Check RawDataCnvSvc
00078   IService* isvc = 0;
00079   sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00080   if (sc != StatusCode::SUCCESS) {
00081     log << MSG::ERROR << "Cant get PackedRawDataCnvSvc" << endreq;
00082   }
00083 
00084   m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00085   if (m_RawDataAccess  == 0 ) {
00086     log << MSG::ERROR << "RawDataMucCnv: Cant cast to RawDataCnvSvc " << endreq; 
00087     return StatusCode::FAILURE;
00088   }
00089 
00090   sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), isvc);
00091   if (sc != StatusCode::SUCCESS ) {
00092     log << MSG::WARNING << "Cant get RawDataInputSvc " << endreq;
00093     return sc ;
00094   }
00095 
00096   m_inputSvc = dynamic_cast<RawDataInputSvc*> (isvc);
00097   if (m_inputSvc == 0 ) {
00098     log << MSG::WARNING << "Cant cast to RawDataInputSvc " << endreq;
00099     return StatusCode::FAILURE ;
00100   }
00101 
00102   return StatusCode::SUCCESS; 
00103 }
00104 
00105 
00106 StatusCode RawDataMucMcHitCnv::updateObj(IOpaqueAddress* pAddr, DataObject* pObj) {
00107   // Purpose and Method:  This method does nothing other than announce it has
00108   //   been called.
00109 
00110   //MsgStream log(msgSvc(), "RawDataMucMcHitCnv");
00111   //log << MSG::DEBUG << "RawDataMucMcHitCnv::updateObj" << endreq;
00112   return Converter::updateObj(pAddr, pObj);
00113 }
00114 
00115 // Create a converted object in the Transient Data Store.
00116 StatusCode RawDataMucMcHitCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
00117 {
00118   //MsgStream log(msgSvc(), "RawDataMucMcHitCnv");
00119 
00120   //This converter will create an empty MucMcHitCol on the TDS
00121   MucMcHitCol *mucMcHitCol = new MucMcHitCol;
00122   pObj = mucMcHitCol;
00123    
00124   RAWEVENT *evt = m_inputSvc->currentEvent(); 
00125   if (evt == NULL) {
00126       //log << MSG::ERROR << "RawDataCnv has no event!" << endreq; 
00127       return StatusCode::FAILURE;
00128   }
00129   
00130   assert((evt->getMucTruth().size()%7) == 0);
00131 
00132   MucMcHit* mucMcHit;
00133   MucTruth_t m_MucTruth;
00134 
00135   std::vector<uint32_t>::const_iterator iter = evt->getMucTruth().begin();
00136   std::vector<uint32_t>::const_iterator eiter = evt->getMucTruth().end();
00137 
00138   for (int mucMcHitId = 0; iter != eiter; mucMcHitId++) {
00139     //retrieve the MucTruth data
00140     m_mucMcHitBuilder.unPack(iter, eiter, m_MucTruth);
00141     //construct the identifier
00142     const Identifier ident = MucID::channel_id
00143       (m_MucTruth.partId, m_MucTruth.segId, m_MucTruth.gapId, m_MucTruth.stripId);
00144     //construct the MucMcHit
00145     mucMcHit = new MucMcHit(ident, m_MucTruth.trackIndex%1000,
00146                        m_MucTruth.x/(m_mucMcHitBuilder.m_xCoeff*1.0),
00147                        m_MucTruth.y/(m_mucMcHitBuilder.m_yCoeff*1.0),
00148                        m_MucTruth.z/(m_mucMcHitBuilder.m_zCoeff*1.0),
00149                        m_MucTruth.px/(m_mucMcHitBuilder.m_pxCoeff*1.0),
00150                        m_MucTruth.py/(m_mucMcHitBuilder.m_pyCoeff*1.0),
00151                        m_MucTruth.pz/(m_mucMcHitBuilder.m_pzCoeff*1.0)  );
00152     // And add the stuff to the container
00153     mucMcHitCol->push_back(mucMcHit);
00154   }
00155 
00156   return StatusCode::SUCCESS; 
00157 
00158 }
00159 
00160 StatusCode RawDataMucMcHitCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)  
00161 {
00162    // convert PixelRaw in the container into ByteStream
00163   //MsgStream log(messageService(), "RawDataMucMcHitCnv");
00164   
00165   WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00166   
00167   if (re == 0) {
00168      //log << " get RawEvent failed !" << endreq;
00169      return StatusCode::FAILURE; 
00170   }
00171 
00172   SmartDataPtr<MucMcHitCol> mcHitCol(dataProvider(), EventModel::MC::MucMcHitCol);
00173 
00174   if (mcHitCol == 0) {
00175      //log << "no MucMcHitCol found" << endreq;
00176      return StatusCode::FAILURE;
00177   }
00178   
00179   StatusCode sc = m_mucMcHitBuilder.pack(mcHitCol, re);
00180 
00181   return sc; 
00182 
00183 }
00184 

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