BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
McParticleBuilder Class Reference

#include <McParticleBuilder.h>

+ Inheritance diagram for McParticleBuilder:

Public Member Functions

 McParticleBuilder ()
 
virtual ~McParticleBuilder ()
 
virtual StatusCode initialize (string &initFile)
 
virtual uint32_t getTEID (uint32_t teid)
 
virtual uint32_t getREID (uint32_t reid)
 
virtual void unPack (uint32_t *buf, double *vPointer, McParticle *mcPar)
 
virtual StatusCode pack (McParticleCol *mcParticleCol, WriteRawEvent *&re)
 
virtual StatusCode initialize (string &initFile)
 
virtual uint32_t getTEID (uint32_t teid)=0
 
virtual uint32_t getREID (uint32_t reid)=0
 

Additional Inherited Members

- Public Types inherited from Builder
typedef std::map< uint32_t, uint32_t > TE2REMAP
 
- Static Public Member Functions inherited from Builder
static bool expect (ifstream &f, string msg, string fname)
 
static bool expectInt (ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
 
static bool expectLong (ifstream &f, string msg, string fname, uint64_t &val)
 
static bool find (ifstream &f, string msg, string fname)
 
- Protected Member Functions inherited from Builder
 Builder ()
 
virtual ~Builder ()
 
void append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
 
- Protected Attributes inherited from Builder
PropertyMgr m_propMgr
 
uint32_t * m_buf
 
uint32_t m_status
 
- Static Protected Attributes inherited from Builder
static string m_confFile
 

Detailed Description

Definition at line 11 of file McParticleBuilder.h.

Constructor & Destructor Documentation

◆ McParticleBuilder()

McParticleBuilder::McParticleBuilder ( )

Definition at line 6 of file McParticleBuilder.cxx.

7 :Builder()
8{
9 //initialize(Builder::m_confFile);
10}
Builder()
Definition: Builder.cxx:8

◆ ~McParticleBuilder()

virtual McParticleBuilder::~McParticleBuilder ( )
inlinevirtual

Definition at line 16 of file McParticleBuilder.h.

16{};

Member Function Documentation

◆ getREID()

uint32_t McParticleBuilder::getREID ( uint32_t  reid)
virtual

Implements Builder.

Definition at line 138 of file McParticleBuilder.cxx.

139{
140 return 0;
141}

◆ getTEID()

uint32_t McParticleBuilder::getTEID ( uint32_t  teid)
virtual

Implements Builder.

Definition at line 132 of file McParticleBuilder.cxx.

133{
134 return 0;
135}

◆ initialize()

StatusCode McParticleBuilder::initialize ( string &  initFile)
virtual

Reimplemented from Builder.

Definition at line 109 of file McParticleBuilder.cxx.

110{
111 ifstream f;
112
113 //read init file
114 f.open(initFile.c_str());
115
116 if ( f.bad() ) {
117 cerr << "Error: could not open file " << initFile << endl;
118 return StatusCode::FAILURE;
119 }
120
121 if (!Builder::find( f, "##McParticleConf", initFile)) {
122 cerr << "Error: could not find '##McParticleConf' in file " << initFile << endl;
123 return StatusCode::FAILURE;
124 }
125
126 f.close();
127
128 return StatusCode::SUCCESS;
129}
static bool find(ifstream &f, string msg, string fname)
Definition: Builder.cxx:60
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
std::ifstream ifstream
Definition: bpkt_streams.h:44

◆ pack()

StatusCode McParticleBuilder::pack ( McParticleCol *  mcParticleCol,
WriteRawEvent *&  re 
)
virtual

Definition at line 41 of file McParticleBuilder.cxx.

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
100 m_buf[0] |= nVertex;
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, uint32_t shift=0)
Definition: Builder.cxx:76

Referenced by RawDataMcParticleCnv::createRep().

◆ unPack()

void McParticleBuilder::unPack ( uint32_t *  buf,
double *  vPointer,
McParticle mcPar 
)
virtual

Definition at line 12 of file McParticleBuilder.cxx.

13{
14 uint32_t trkIndex = (buf[0]>>16);
15 uint32_t vIndex0 = (buf[0]>>8) & 0xFF;
16 uint32_t vIndex1 = buf[0] & 0xFF;
17
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]);
22
23 mcPar->initialize(buf[1], buf[2], initMomentum, initPosition, "");
24 mcPar->setTrackIndex(trkIndex);
25 mcPar->setVertexIndex0(vIndex0);
26
27 if (vIndex1 == 0xFF) {
28 mcPar->setVertexIndex1(-99);
29 }
30 else {
31 mcPar->setVertexIndex1(vIndex1);
32
33 double* v1Pointer = vPointer + 4*vIndex1;
34 HepLorentzVector finalPosition(v1Pointer[0], v1Pointer[1], v1Pointer[2], v1Pointer[3]);
35 mcPar->finalize(finalPosition);
36 }
37
38 return;
39}
void setVertexIndex0(int index0)
methods for setting and getting vertex indexes
Definition: McParticle.h:119
void initialize(StdHepId id, unsigned int statusBits, const HepLorentzVector &initialMomentum, const HepLorentzVector &initialPosition, const std::string process="")
Set the initial attributes of the McParticle.
Definition: McParticle.cxx:50
void finalize(const HepLorentzVector &finalPosition)
Set the final attributes of the McParticle.
Definition: McParticle.cxx:85
void setVertexIndex1(int index1)
Definition: McParticle.h:123
void setTrackIndex(int trackIndex)
Definition: McParticle.h:128

Referenced by RawDataMcParticleCnv::createObj().


The documentation for this class was generated from the following files: