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