3#include "RawDataCnv/EventManagement/McParticleBuilder.h"
14 uint32_t trkIndex = (buf[0]>>16);
15 uint32_t vIndex0 = (buf[0]>>8) & 0xFF;
16 uint32_t vIndex1 = buf[0] & 0xFF;
18 double* ptmp = (
double*)(buf+3);
19 double* v0Pointer = vPointer + 4*vIndex0;
20 HepLorentzVector initMomentum(ptmp[0], ptmp[1], ptmp[2], ptmp[3]);
21 HepLorentzVector initPosition(v0Pointer[0], v0Pointer[1], v0Pointer[2], v0Pointer[3]);
23 mcPar->initialize(buf[1], buf[2], initMomentum, initPosition,
"");
24 mcPar->setTrackIndex(trkIndex);
25 mcPar->setVertexIndex0(vIndex0);
27 if (vIndex1 == 0xFF) {
28 mcPar->setVertexIndex1(-99);
31 mcPar->setVertexIndex1(vIndex1);
33 double* v1Pointer = vPointer + 4*vIndex1;
34 HepLorentzVector finalPosition(v1Pointer[0], v1Pointer[1], v1Pointer[2], v1Pointer[3]);
35 mcPar->finalize(finalPosition);
43 if (mcParticleCol == 0 ) {
44 cerr <<
"McParticleBuilder::pack can't get mcParticleCol" << endl;
45 return StatusCode::FAILURE;
48 uint32_t nParticle = mcParticleCol->size();
50 vector<bool> vFlag(nParticle+1,
false);
51 double* vPointer = (
double*)(
m_buf + nParticle*11 + 1);
54 int tIndex, vIndex0, vIndex1;
58 m_buf[index++] = (nParticle<<16);
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);
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;
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;
102 append2event(re, 0xf10000, (nParticle*11 + nVertex*8 + 1));
104 return StatusCode::SUCCESS;
114 f.open(initFile.c_str());
117 cerr <<
"Error: could not open file " << initFile << endl;
118 return StatusCode::FAILURE;
122 cerr <<
"Error: could not find '##McParticleConf' in file " << initFile << endl;
123 return StatusCode::FAILURE;
128 return StatusCode::SUCCESS;
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
static bool find(ifstream &f, string msg, string fname)
virtual uint32_t getREID(uint32_t reid)
virtual uint32_t getTEID(uint32_t teid)
virtual StatusCode initialize(string &initFile)
virtual void unPack(uint32_t *buf, double *vPointer, McParticle *mcPar)
virtual StatusCode pack(McParticleCol *mcParticleCol, WriteRawEvent *&re)
The Monte Carlo particle kinematics information.
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")