11 uint32_t trkIndex = ( buf[0] >> 16 );
12 uint32_t vIndex0 = ( buf[0] >> 8 ) & 0xFF;
13 uint32_t vIndex1 = buf[0] & 0xFF;
15 double* ptmp = (
double*)( buf + 3 );
16 double* v0Pointer = vPointer + 4 * vIndex0;
17 HepLorentzVector initMomentum( ptmp[0], ptmp[1], ptmp[2], ptmp[3] );
18 HepLorentzVector initPosition( v0Pointer[0], v0Pointer[1], v0Pointer[2], v0Pointer[3] );
20 mcPar->
initialize( buf[1], buf[2], initMomentum, initPosition,
"" );
29 double* v1Pointer = vPointer + 4 * vIndex1;
30 HepLorentzVector finalPosition( v1Pointer[0], v1Pointer[1], v1Pointer[2], v1Pointer[3] );
38 if ( mcParticleCol == 0 )
40 cerr <<
"McParticleBuilder::pack can't get mcParticleCol" << endl;
41 return StatusCode::FAILURE;
44 uint32_t nParticle = mcParticleCol->size();
46 vector<bool> vFlag( nParticle + 1,
false );
47 double* vPointer = (
double*)(
m_buf + nParticle * 11 + 1 );
50 int tIndex, vIndex0, vIndex1;
54 m_buf[index++] = ( nParticle << 16 );
56 McParticleCol::const_iterator itPar = mcParticleCol->begin();
57 for ( ; itPar != mcParticleCol->end(); itPar++ )
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 );
76 if ( !vFlag[vIndex0] )
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;
87 if ( ( vIndex1 != 0xFF ) && ( !vFlag[vIndex1] ) )
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;
101 append2event( re, 0xf10000, ( nParticle * 11 + nVertex * 8 + 1 ) );
103 return StatusCode::SUCCESS;
void setVertexIndex0(int index0)
methods for setting and getting vertex indexes
void initialize(StdHepId id, unsigned int statusBits, const HepLorentzVector &initialMomentum, const HepLorentzVector &initialPosition, const std::string process="")
Set the initial attributes of the McParticle.
void finalize(const HepLorentzVector &finalPosition)
Set the final attributes of the McParticle.
void setVertexIndex1(int index1)
void setTrackIndex(int trackIndex)
virtual void unPack(uint32_t *buf, double *vPointer, McParticle *mcPar)
virtual uint32_t getREID(uint32_t reid)
virtual uint32_t getTEID(uint32_t teid)
virtual StatusCode initialize(string &initFile)
virtual StatusCode pack(McParticleCol *mcParticleCol, WriteRawEvent *&re)