BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucMcHitBuilder.cxx
Go to the documentation of this file.
1#include "RawDataCnv/EventManagement/MucMcHitBuilder.h"
2#include "Identifier/MucID.h"
3#include <fstream>
4#include <iostream>
5using namespace std;
6
8
9void MucMcHitBuilder::unPack( vector<uint32_t>::const_iterator& iter,
10 vector<uint32_t>::const_iterator& eiter, MucTruth_t& mt ) {
11 uint32_t helpVal = *( iter++ );
12 assert( iter != eiter );
13 mt.x = *( iter++ );
14 assert( iter != eiter );
15 mt.y = *( iter++ );
16 assert( iter != eiter );
17 mt.z = *( iter++ );
18 assert( iter != eiter );
19 mt.px = *( iter++ );
20 assert( iter != eiter );
21 mt.py = *( iter++ );
22 assert( iter != eiter );
23 mt.pz = *( iter++ );
24
25 mt.trackIndex = ( helpVal & m_trackIndexMask ) >> m_trackIndexIndex;
26 mt.partId = ( helpVal & m_partIdMask ) >> m_partIdIndex;
27 mt.segId = ( helpVal & m_segIdMask ) >> m_segIdIndex;
28 mt.gapId = ( helpVal & m_gapIdMask ) >> m_gapIdIndex;
29 mt.stripId = ( helpVal & m_stripIdMask ) >> m_stripIdIndex;
30
31 return;
32}
33
34StatusCode MucMcHitBuilder::pack( MucMcHitCol* mucMcHitCol, WriteRawEvent*& re ) {
35 /*
36
37 if (mucMcHitCol == NULL) {
38 cout << "MucMcHitBuilder::pack cant get MucMcHitCol" << endl;
39 return StatusCode::FAILURE;
40 }
41
42 vector<uint32_t> *mucReMcHitVec = new vector<uint32_t>;
43 MucTruth_t m_MucTruth;
44
45 MucMcHitCol::const_iterator pMucMcHit = mucMcHitCol->begin();
46 for ( ; pMucMcHit != mucMcHitCol->end(); pMucMcHit++) {
47 //make the MucTruth data
48 makeMucTruth(pMucMcHit, m_MucTruth);
49 //pack integers in mucTruth
50 uint32_t helpVal = (m_MucTruth.trackIndex<<m_trackIndexIndex) & m_trackIndexMask;
51 helpVal |= ((m_MucTruth.partId<<m_partIdIndex) & m_partIdMask);
52 helpVal |= ((m_MucTruth.segId<<m_segIdIndex) & m_segIdMask);
53 helpVal |= ((m_MucTruth.gapId<<m_gapIdIndex) & m_gapIdMask);
54 helpVal |= ((m_MucTruth.stripId<<m_stripIdIndex) & m_stripIdMask);
55 //fill the McHit vector
56 mucReMcHitVec->push_back(helpVal);
57 mucReMcHitVec->push_back(m_MucTruth.x);
58 mucReMcHitVec->push_back(m_MucTruth.y);
59 mucReMcHitVec->push_back(m_MucTruth.z);
60 mucReMcHitVec->push_back(m_MucTruth.px);
61 mucReMcHitVec->push_back(m_MucTruth.py);
62 mucReMcHitVec->push_back(m_MucTruth.pz);
63 }
64
65 OfflineEventFormat::SubDetectorHeader sh(OfflineEventFormat::MUCTRUTH);
66 SubRawEvent *sub = new SubRawEvent(sh, mucReMcHitVec);
67 re->append(sub);
68 */
69
70 return StatusCode::SUCCESS;
71}
72
73// initialize re2te tables
74
75StatusCode MucMcHitBuilder::initialize( string& initFile ) {
76 ifstream f;
77
78 // read init file
79 f.open( initFile.c_str() );
80
81 if ( f.bad() )
82 {
83 cerr << "Error: could not open file " << initFile << endl;
84 return StatusCode::FAILURE;
85 }
86
87 if ( !Builder::find( f, "##MucTruthConf", initFile ) )
88 {
89 cerr << "Error: could not find '##MucTruthConf' in file " << initFile << endl;
90 return StatusCode::FAILURE;
91 }
92
93 if ( !Builder::expect( f, "#MucTruthShift", initFile ) ||
94 !Builder::expectInt( f, "trackIndex", initFile, m_trackIndexIndex, m_trackIndexMask ) ||
95 !Builder::expectInt( f, "partId", initFile, m_partIdIndex, m_partIdMask ) ||
96 !Builder::expectInt( f, "segId", initFile, m_segIdIndex, m_segIdMask ) ||
97 !Builder::expectInt( f, "gapId", initFile, m_gapIdIndex, m_gapIdMask ) ||
98 !Builder::expectInt( f, "stripId", initFile, m_stripIdIndex, m_stripIdMask ) ||
99 !Builder::expect( f, "#MucTruthCoeff", initFile ) ||
100 !Builder::expectLong( f, "x", initFile, m_xCoeff ) ||
101 !Builder::expectLong( f, "y", initFile, m_yCoeff ) ||
102 !Builder::expectLong( f, "z", initFile, m_zCoeff ) ||
103 !Builder::expectLong( f, "px", initFile, m_pxCoeff ) ||
104 !Builder::expectLong( f, "py", initFile, m_pyCoeff ) ||
105 !Builder::expectLong( f, "pz", initFile, m_pzCoeff ) )
106 return StatusCode::FAILURE;
107
108 f.close();
109
110 return StatusCode::SUCCESS;
111}
112
113uint32_t MucMcHitBuilder::getTEID( uint32_t reid ) { return 0; }
114
115uint32_t MucMcHitBuilder::getREID( uint32_t teid ) { return 0; }
116
117void MucMcHitBuilder::makeMucTruth( MucMcHitCol::const_iterator& pMucMcHit, MucTruth_t& mt ) {
118 Identifier ident = ( *pMucMcHit )->identify();
119
120 mt.trackIndex = ( *pMucMcHit )->getTrackIndex() % 1000;
121 mt.partId = MucID::part( ident );
122 mt.segId = MucID::seg( ident );
123 mt.gapId = MucID::gap( ident );
124 mt.stripId = MucID::strip( ident );
125 mt.x = int( ( *pMucMcHit )->getPositionX() * m_xCoeff );
126 mt.y = int( ( *pMucMcHit )->getPositionY() * m_yCoeff );
127 mt.z = int( ( *pMucMcHit )->getPositionZ() * m_zCoeff );
128 mt.px = int( ( *pMucMcHit )->getPx() * m_pxCoeff );
129 mt.py = int( ( *pMucMcHit )->getPy() * m_pyCoeff );
130 mt.pz = int( ( *pMucMcHit )->getPz() * m_pzCoeff );
131
132 return;
133}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
eformat::write::FullEventFragment WriteRawEvent
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
static bool find(ifstream &f, string msg, string fname)
Definition Builder.cxx:52
static bool expect(ifstream &f, string msg, string fname)
Definition Builder.cxx:25
static bool expectLong(ifstream &f, string msg, string fname, uint64_t &val)
Definition Builder.cxx:46
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
Definition Builder.cxx:39
Builder()
Definition Builder.cxx:11
static int part(const Identifier &id)
Definition MucID.cxx:43
static int gap(const Identifier &id)
Definition MucID.cxx:63
static int seg(const Identifier &id)
Definition MucID.cxx:53
static int strip(const Identifier &id)
Definition MucID.cxx:73
virtual uint32_t getREID(uint32_t reid)
virtual StatusCode initialize(string &initFile)
virtual uint32_t getTEID(uint32_t teid)
virtual void unPack(vector< uint32_t >::const_iterator &, vector< uint32_t >::const_iterator &, MucTruth_t &)
virtual StatusCode pack(MucMcHitCol *mucMcHitCol, WriteRawEvent *&re)
ObjectVector< MucMcHit > MucMcHitCol