42{
43 if (mcParticleCol == 0 ) {
44 cerr << "McParticleBuilder::pack can't get mcParticleCol" << endl;
45 return StatusCode::FAILURE;
46 }
47
48 uint32_t nParticle = mcParticleCol->size();
49 uint32_t nVertex = 0;
50 vector<bool> vFlag(nParticle+1, false);
51 double* vPointer = (
double*)(
m_buf + nParticle*11 + 1);
52
53 uint32_t index = 0;
54 int tIndex, vIndex0, vIndex1;
55 int parId;
56 uint32_t statusFlag;
57
58 m_buf[index++] = (nParticle<<16);
59
60 McParticleCol::const_iterator itPar = mcParticleCol->begin();
61 for( ; itPar != mcParticleCol->end(); itPar++) {
62 tIndex = (*itPar)->trackIndex();
63 vIndex0 = (*itPar)->vertexIndex0();
64 vIndex1 = (*itPar)->vertexIndex1();
65 if (vIndex1 == -99) vIndex1 = 0xFF;
66 parId = (*itPar)->particleProperty();
67 statusFlag = (*itPar)->statusFlags();
68 const HepLorentzVector& p4vec = (*itPar)->initialFourMomentum();
69 m_buf[index++] = ((tIndex<<16) | (vIndex0<<8) | (vIndex1));
70 m_buf[index++] = (uint32_t)parId;
71 m_buf[index++] = statusFlag;
72 double* ptmp = (
double*)(
m_buf+index);
73 ptmp[0] = p4vec.x();
74 ptmp[1] = p4vec.y();
75 ptmp[2] = p4vec.z();
76 ptmp[3] = p4vec.t();
77 index += 8;
78
79 if ( !vFlag[vIndex0] ) {
80 const HepLorentzVector& initPos = (*itPar)->initialPosition();
81 vPointer[vIndex0*4 + 0] = initPos.px();
82 vPointer[vIndex0*4 + 1] = initPos.py();
83 vPointer[vIndex0*4 + 2] = initPos.pz();
84 vPointer[vIndex0*4 + 3] = initPos.e();
85 vFlag[vIndex0] = true;
86 nVertex++;
87 }
88
89 if ( (vIndex1 != 0xFF) && (!vFlag[vIndex1]) ) {
90 const HepLorentzVector& finalPos = (*itPar)->finalPosition();
91 vPointer[vIndex1*4 + 0] = finalPos.px();
92 vPointer[vIndex1*4 + 1] = finalPos.py();
93 vPointer[vIndex1*4 + 2] = finalPos.pz();
94 vPointer[vIndex1*4 + 3] = finalPos.e();
95 vFlag[vIndex1] = true;
96 nVertex++;
97 }
98 }
99
101
102 append2event(re, 0xf10000, (nParticle*11 + nVertex*8 + 1));
103
104 return StatusCode::SUCCESS;
105}
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size)