RawDataMcParticleCnv Class Reference

#include <RawDataMcParticleCnv.h>

Inheritance diagram for RawDataMcParticleCnv:

RawDataBaseCnv Converter< Ty1, Ty2 > List of all members.

Public Types

typedef Ty1 source
typedef Ty2 destination

Public Member Functions

StatusCode initialize ()
virtual long repSvcType () const
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *pObj)
 override the RawDataBaseCnv version
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&pAddr)
 Convert the transient object to the requested representation.
virtual StatusCode finalize ()
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &bank, long par=0)
 Store TDS path to link a particular converter to an object on the TDS.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the converted representation of a transient object.
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object.
destinationoperator (const source &) const

Static Public Member Functions

static const CLID & classID ()
static const unsigned char storageType ()

Protected Member Functions

 RawDataMcParticleCnv (ISvcLocator *svc)
virtual destinationconvert (const source &) const =0

Protected Attributes

IRawDataCnvSvcm_CnvSvc
 Pointer to event conversion service interface.
std::vector< IRawDataCnvSvc::Leafm_leaves
 Leaf objects giving the locations of the objects in the data store.

Private Member Functions

void addMother (McParticle *currentParticle, McParticleCol *particleCol)

Private Attributes

IRawDataInputSvcm_inputSvc
PackedRawDataCnvSvcm_RawDataAccess
 Define the interface to raw data cnv.
McParticleBuilder m_mcParticleBuilder
 MdcBuilder for packing or unpacking data.

Friends

class CnvFactory< RawDataMcParticleCnv >

Detailed Description

Definition at line 32 of file RawDataMcParticleCnv.h.


Member Typedef Documentation

template<class Ty1, class Ty2>
typedef Ty2 Converter< Ty1, Ty2 >::destination [inherited]

Definition at line 19 of file Converter.h.

template<class Ty1, class Ty2>
typedef Ty1 Converter< Ty1, Ty2 >::source [inherited]

Definition at line 18 of file Converter.h.


Constructor & Destructor Documentation

RawDataMcParticleCnv::RawDataMcParticleCnv ( ISvcLocator *  svc  )  [protected]

Definition at line 32 of file RawDataMcPaticleCnv.cxx.

00032                                                            : 
00033 RawDataBaseCnv(PACKEDRAWEVENT_StorageType, classID(), svc) 
00034 {
00035   //init();
00036 }


Member Function Documentation

void RawDataMcParticleCnv::addMother ( McParticle currentParticle,
McParticleCol particleCol 
) [private]

Referenced by createObj().

const CLID & RawDataMcParticleCnv::classID (  )  [static]

Reimplemented from RawDataBaseCnv.

Definition at line 40 of file RawDataMcPaticleCnv.cxx.

References CLID_McParticleCol.

Referenced by PackedRawDataCnvSvc::addConverters().

00041 {
00042   return CLID_McParticleCol;
00043 }

template<class Ty1, class Ty2>
virtual destination* Converter< Ty1, Ty2 >::convert ( const source  )  const [protected, pure virtual, inherited]

StatusCode RawDataMcParticleCnv::createObj ( IOpaqueAddress *  pAddr,
DataObject *&  pObj 
)

Definition at line 110 of file RawDataMcPaticleCnv.cxx.

References addMother(), IRawDataInputSvc::currentEvent(), RAWEVENT::getMcParBuf(), genRecEmupikp::i, m_inputSvc, m_mcParticleBuilder, EventModel::MC::McParticleCol, BufferHolder::nBuf(), and McParticleBuilder::unPack().

00111 {
00112   //MsgStream log(msgSvc(), "RawDataMcParticleCnv");
00113 
00114   //This converter will create an empty McParticleCol on the TDS
00115   McParticleCol *mcParticleCol = new McParticleCol;
00116   pObj = mcParticleCol;
00117    
00118   RAWEVENT *evt = m_inputSvc->currentEvent(); 
00119   if (evt == NULL) {
00120       //log << MSG::ERROR << "RawDataCnv has no event!" << endreq; 
00121       return StatusCode::FAILURE;
00122   }
00123 
00124   const BufferHolder& mcParBuf = evt->getMcParBuf();
00125   if (mcParBuf.nBuf() == 0) {
00126     //cerr << "no McParticle Data Buffer found!!!" << endl;
00127     return StatusCode::FAILURE;
00128   }
00129   uint32_t* buf = mcParBuf(0);
00130 
00131   uint32_t nParticle = (buf[0] >> 16);
00132   //uint32_t nVertex   = (buf[0] & 0xFFFF);
00133   double*  vPointer  = (double*)(buf + nParticle*11 + 1);
00134 
00135   for (uint32_t i = 0; i < nParticle; i++) {
00136     McParticle* mcPar = new McParticle;
00137     m_mcParticleBuilder.unPack((buf+1+i*11), vPointer, mcPar);
00138     mcParticleCol->push_back(mcPar);
00139   }
00140   
00141   // Get primary McParticles
00142   SmartRefVector<McParticle> primaryParticleCol;
00143   McParticleCol::iterator iter_particle = mcParticleCol->begin();
00144   for ( ; iter_particle != mcParticleCol->end(); iter_particle++) {
00145     if ((*iter_particle)->primaryParticle()) {
00146       McParticle* mcPart = (McParticle*)(*iter_particle);
00147       primaryParticleCol.push_back(mcPart);
00148     }
00149   }
00150 
00151   if (primaryParticleCol.empty()) {
00152     //log << MSG::WARNING << "createObj error: no primary particle found!" << endreq;
00153   }
00154 
00155   // Add mother particle recursively
00156   SmartRefVector<McParticle>::iterator iter_primary = primaryParticleCol.begin();
00157   //std::cout << "primaryParticleCol.size() = " << primaryParticleCol.size() << std::endl;
00158   for ( ; iter_primary != primaryParticleCol.end(); iter_primary++) {
00159 
00160     if (!(*iter_primary)->leafParticle())
00161       addMother((*iter_primary), mcParticleCol);
00162   }
00163 
00164   return StatusCode::SUCCESS; 
00165 }

StatusCode RawDataMcParticleCnv::createRep ( DataObject *  pObj,
IOpaqueAddress *&  pAddr 
) [virtual]

Convert the transient object to the requested representation.

Reimplemented from RawDataBaseCnv.

Definition at line 167 of file RawDataMcPaticleCnv.cxx.

References PackedRawDataCnvSvc::getRawEvent(), m_mcParticleBuilder, m_RawDataAccess, EventModel::MC::McParticleCol, and McParticleBuilder::pack().

00168 {
00169    // convert PixelRaw in the container into ByteStream
00170   //MsgStream log(messageService(), "RawDataMcParticleCnv");
00171   
00172   WriteRawEvent*& re = m_RawDataAccess->getRawEvent(); 
00173   if (re == 0) {
00174      //log << " get RawEvent failed !" << endreq;
00175      return StatusCode::FAILURE; 
00176   }
00177 
00178   SmartDataPtr<McParticleCol> mcParticleCol(dataProvider(), EventModel::MC::McParticleCol);
00179   if (mcParticleCol == 0) {
00180      //log << "no McParticleCol found" << endreq;
00181      return StatusCode::FAILURE;
00182   }
00183  
00184   return m_mcParticleBuilder.pack(mcParticleCol, re);
00185 }

void RawDataBaseCnv::declareObject ( const std::string fullPath,
const CLID &  clid,
const std::string bank,
long  par = 0 
) [inherited]

Store TDS path to link a particular converter to an object on the TDS.

Definition at line 81 of file RawDataBaseCnv.cxx.

00082                                                                       {
00083     // Purpose and Method:  Save the path on the TDS, in the m_leaves vector, 
00084     //   corresponding to the DataObject that the converter handles.
00085     // m_leaves.push_back(IRawDataCnvSvc::Leaf(path, cl, bank, par));
00086 }

StatusCode RawDataBaseCnv::fillRepRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual, inherited]

Resolve the references of the converted object.

Definition at line 29 of file RawDataBaseCnv.cxx.

00030                                                  {
00031     // Purpose and Method:  Resolve the references of the converted object.
00032     //     It is expected that derived classes will override this method.
00033     return StatusCode::SUCCESS;
00034 }

StatusCode RawDataBaseCnv::finalize (  )  [virtual, inherited]

Definition at line 73 of file RawDataBaseCnv.cxx.

References RawDataBaseCnv::m_CnvSvc.

00073                                       {
00074     if ( m_CnvSvc )     {
00075         m_CnvSvc->release();
00076         m_CnvSvc = 0;
00077     }
00078     return Converter::finalize();
00079 }

StatusCode RawDataMcParticleCnv::initialize (  ) 

Reimplemented from RawDataBaseCnv.

Definition at line 45 of file RawDataMcPaticleCnv.cxx.

References calibUtil::ERROR, RawDataBaseCnv::initialize(), m_inputSvc, m_RawDataAccess, deljobs::string, and Bes_Common::WARNING.

00046 {
00047 
00048     std::string PackedRawDataCnvSvc_Name("PackedRawDataCnvSvc");
00049     std::string RawDataInputSvc_Name("RawDataInputSvc");
00050     std::string RawDataMcParticleCnv_Name("RawDataMcParticleCnv");
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         RawDataMcParticleCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
00060       }
00061     //}
00062     
00063   MsgStream log(messageService(), RawDataMcParticleCnv_Name.c_str());
00064 
00065   StatusCode sc = RawDataBaseCnv::initialize();
00066   if (StatusCode::SUCCESS != sc) {
00067     log << MSG::ERROR << "RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
00068     return sc;
00069   }
00070 
00071   // Check RawDataCnvSvc
00072   IService* isvc = 0;
00073   sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc, true);
00074   if (sc != StatusCode::SUCCESS) {
00075     log << MSG::ERROR << "Cant get PackedRawDataCnvSvc" << endreq;
00076   }
00077 
00078   m_RawDataAccess = dynamic_cast<PackedRawDataCnvSvc*> (isvc); 
00079   if (m_RawDataAccess  == 0 ) {
00080     log << MSG::ERROR << "RawDataMcParticleCnv: Cant cast to RawDataCnvSvc " << endreq; 
00081     return StatusCode::FAILURE;
00082   }
00083 
00084   sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), isvc);
00085   if (sc != StatusCode::SUCCESS ) {
00086     log << MSG::WARNING << "Cant get RawDataInputSvc " << endreq;
00087     return sc ;
00088   }
00089 
00090   m_inputSvc = dynamic_cast<RawDataInputSvc*> (isvc);
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 }

template<class Ty1, class Ty2>
destination* Converter< Ty1, Ty2 >::operator ( const source  )  const [inline, inherited]

virtual long RawDataMcParticleCnv::repSvcType (  )  const [inline, virtual]

Reimplemented from RawDataBaseCnv.

Definition at line 46 of file RawDataMcParticleCnv.h.

References PACKEDRAWEVENT_StorageType.

00046                                    {
00047       return PACKEDRAWEVENT_StorageType;
00048    }

static const unsigned char RawDataMcParticleCnv::storageType (  )  [inline, static]

Reimplemented from RawDataBaseCnv.

Definition at line 50 of file RawDataMcParticleCnv.h.

References PACKEDRAWEVENT_StorageType.

00050                                             {
00051       return PACKEDRAWEVENT_StorageType;
00052    }

StatusCode RawDataMcParticleCnv::updateObj ( IOpaqueAddress *  pAddr,
DataObject *  pObj 
) [virtual]

override the RawDataBaseCnv version

Definition at line 100 of file RawDataMcPaticleCnv.cxx.

00100                                                                                   {
00101   // Purpose and Method:  This method does nothing other than announce it has
00102   //   been called.
00103 
00104   //MsgStream log(msgSvc(), "RawDataMcParticleCnv");
00105   //log << MSG::DEBUG << "RawDataMcParticleCnv::updateObj" << endreq;
00106   return Converter::updateObj(pAddr, pObj);
00107 }

StatusCode RawDataBaseCnv::updateRep ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual, inherited]

Update the converted representation of a transient object.

Definition at line 36 of file RawDataBaseCnv.cxx.

00037                                               {
00038     // Purpose and Method:  Update the converted representation of a transient 
00039     //     object.  It is expected that derived classes will override this.
00040     return StatusCode::SUCCESS;
00041 }

StatusCode RawDataBaseCnv::updateRepRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual, inherited]

Update the references of an already converted object.

Definition at line 43 of file RawDataBaseCnv.cxx.

00044                                                 {
00045     // Purpose and Method:  Update the references of an already converted object.
00046     //   It is expected that derived classes will override this method.
00047     return StatusCode::SUCCESS;
00048 }


Friends And Related Function Documentation

friend class CnvFactory< RawDataMcParticleCnv > [friend]

Definition at line 36 of file RawDataMcParticleCnv.h.


Member Data Documentation

IRawDataCnvSvc* RawDataBaseCnv::m_CnvSvc [protected, inherited]

Pointer to event conversion service interface.

Definition at line 28 of file RawDataBaseCnv.h.

Referenced by RawDataBaseCnv::finalize().

IRawDataInputSvc* RawDataMcParticleCnv::m_inputSvc [private]

Definition at line 66 of file RawDataMcParticleCnv.h.

Referenced by createObj(), and initialize().

std::vector<IRawDataCnvSvc::Leaf> RawDataBaseCnv::m_leaves [protected, inherited]

Leaf objects giving the locations of the objects in the data store.

Definition at line 30 of file RawDataBaseCnv.h.

McParticleBuilder RawDataMcParticleCnv::m_mcParticleBuilder [private]

MdcBuilder for packing or unpacking data.

Definition at line 70 of file RawDataMcParticleCnv.h.

Referenced by createObj(), and createRep().

PackedRawDataCnvSvc* RawDataMcParticleCnv::m_RawDataAccess [private]

Define the interface to raw data cnv.

Definition at line 68 of file RawDataMcParticleCnv.h.

Referenced by createRep(), and initialize().


Generated on Tue Nov 29 23:20:45 2016 for BOSS_7.0.2 by  doxygen 1.4.7