12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/SmartDataPtr.h"
15#include "GaudiKernel/ThreadGaudi.h"
18#include "EventModel/EventModel.h"
19#include "McTruth/McParticle.h"
20#include "RawDataCnv/EventManagement/RAWEVENT.h"
21#include "RawDataCnv/EventManagement/RawEvent.h"
22#include "RawDataCnv/RawDataInputSvc.h"
23#include "RawDataCnv/RawDataMcParticleCnv.h"
48 std::string PackedRawDataCnvSvc_Name(
"PackedRawDataCnvSvc");
49 std::string RawDataInputSvc_Name(
"RawDataInputSvc");
50 std::string RawDataMcParticleCnv_Name(
"RawDataMcParticleCnv");
55 SmartIF<IService> pCnvSvc(conversionSvc());
56 if (isGaudiThreaded(pCnvSvc->name())){
57 PackedRawDataCnvSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
58 RawDataInputSvc_Name += getGaudiThreadIDfromName(pCnvSvc->name());
59 RawDataMcParticleCnv_Name += getGaudiThreadIDfromName(pCnvSvc->name());
63 MsgStream log(messageService(), RawDataMcParticleCnv_Name.c_str());
66 if (StatusCode::SUCCESS != sc) {
67 log << MSG::ERROR <<
"RawDataBaseCnv: Cant initialize PackedRawDataCnvSvc" << endreq;
73 sc = serviceLocator()->service(PackedRawDataCnvSvc_Name.c_str(), isvc,
true);
74 if (sc != StatusCode::SUCCESS) {
75 log << MSG::ERROR <<
"Cant get PackedRawDataCnvSvc" << endreq;
79 if (m_RawDataAccess == 0 ) {
80 log << MSG::ERROR <<
"RawDataMcParticleCnv: Cant cast to RawDataCnvSvc " << endreq;
81 return StatusCode::FAILURE;
84 sc = serviceLocator()->getService(RawDataInputSvc_Name.c_str(), isvc);
85 if (sc != StatusCode::SUCCESS ) {
86 log << MSG::WARNING <<
"Cant get RawDataInputSvc " << endreq;
91 if (m_inputSvc == 0 ) {
92 log << MSG::WARNING <<
"Cant cast to RawDataInputSvc " << endreq;
93 return StatusCode::FAILURE ;
96 return StatusCode::SUCCESS;
106 return Converter::updateObj(pAddr, pObj);
115 McParticleCol *mcParticleCol =
new McParticleCol;
116 pObj = mcParticleCol;
121 return StatusCode::FAILURE;
125 if (mcParBuf.
nBuf() == 0) {
127 return StatusCode::FAILURE;
129 uint32_t* buf = mcParBuf(0);
131 uint32_t nParticle = (buf[0] >> 16);
133 double* vPointer = (
double*)(buf + nParticle*11 + 1);
135 for (uint32_t i = 0; i < nParticle; i++) {
137 m_mcParticleBuilder.
unPack((buf+1+i*11), vPointer, mcPar);
138 mcParticleCol->push_back(mcPar);
142 SmartRefVector<McParticle> primaryParticleCol;
143 McParticleCol::iterator iter_particle = mcParticleCol->begin();
144 for ( ; iter_particle != mcParticleCol->end(); iter_particle++) {
145 if ((*iter_particle)->primaryParticle()) {
147 primaryParticleCol.push_back(mcPart);
151 if (primaryParticleCol.empty()) {
156 SmartRefVector<McParticle>::iterator iter_primary = primaryParticleCol.begin();
158 for ( ; iter_primary != primaryParticleCol.end(); iter_primary++) {
160 if (!(*iter_primary)->leafParticle())
161 addMother((*iter_primary), mcParticleCol);
164 return StatusCode::SUCCESS;
175 return StatusCode::FAILURE;
179 if (mcParticleCol == 0) {
181 return StatusCode::FAILURE;
184 return m_mcParticleBuilder.
pack(mcParticleCol, re);
187void RawDataMcParticleCnv::addMother(
McParticle* currentParticle, McParticleCol *particleCol)
193 McParticleCol::iterator
iter = particleCol->begin();
195 for ( ;
iter != particleCol->end();
iter++) {
196 if (currentParticle->
vertexIndex1() == (*iter)->vertexIndex0()) {
198 (*iter)->setMother(currentParticle);
200 addMother((*
iter), particleCol);
205 std::cout <<
"RawDataMcParticleCnv::addMother: inconsistency was found!" << std::endl;
const CLID & CLID_McParticleCol
unsigned const long PACKEDRAWEVENT_StorageType
const CLID & CLID_McParticleCol
bool leafParticle() const
Retrieve whether this is a leaf particle.
void addDaughter(const SmartRef< McParticle > d)
add a daugther particle to this particle
virtual void unPack(uint32_t *buf, double *vPointer, McParticle *mcPar)
virtual StatusCode pack(McParticleCol *mcParticleCol, WriteRawEvent *&re)
virtual WriteRawEvent *& getRawEvent()
const BufferHolder & getMcParBuf() const
static const CLID & classID()
virtual StatusCode updateObj(IOpaqueAddress *pAddr, DataObject *pObj)
override the RawDataBaseCnv version
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Convert the transient object to the requested representation.
RawDataMcParticleCnv(ISvcLocator *svc)
_EXTERN_ std::string McParticleCol
ObjectList< McParticle > McParticleCol