CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
TofBuilder Class Reference

#include <TofBuilder.h>

+ Inheritance diagram for TofBuilder:

Public Member Functions

 TofBuilder ()
 
virtual ~TofBuilder ()
 
virtual StatusCode initialize (string &initFile)
 
virtual uint32_t getTEID (uint32_t reid)
 
virtual uint32_t getREID (uint32_t teid)
 
virtual void unPack (uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ)
 
virtual StatusCode pack (TofDigiCol *digiCol, WriteRawEvent *&re)
 
- Public Member Functions inherited from Builder

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)
 
- 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 9 of file TofBuilder.h.

Constructor & Destructor Documentation

◆ TofBuilder()

TofBuilder::TofBuilder ( )

Definition at line 7 of file TofBuilder.cxx.

8 :Builder()
9{
10 // set vector size (2^14) and initialize to -1
11 m_re2te = new uint32_t[16384]; // we have 2^14 different REID
12 memset((void*)m_re2te, 0xFF, 16384*sizeof(uint32_t));
13
15}
Builder()
Definition Builder.cxx:8
virtual StatusCode initialize(string &initFile)

◆ ~TofBuilder()

TofBuilder::~TofBuilder ( )
virtual

Definition at line 17 of file TofBuilder.cxx.

18{
19 delete m_re2te;
20}

Member Function Documentation

◆ getREID()

uint32_t TofBuilder::getREID ( uint32_t teid)
virtual

Implements Builder.

Definition at line 176 of file TofBuilder.cxx.

177{
178 TE2REMAP::iterator itr = m_te2reMap.find(teid);
179
180 if (itr == m_te2reMap.end()) {
181 cout << "wrong teid in tof" << teid << endl;
182 exit(8);
183 }
184
185 return itr->second;
186}

Referenced by pack().

◆ getTEID()

virtual uint32_t TofBuilder::getTEID ( uint32_t reid)
inlinevirtual

Implements Builder.

Definition at line 16 of file TofBuilder.h.

16{ return m_re2te[reid]; }

Referenced by TofConverter::convert().

◆ initialize()

StatusCode TofBuilder::initialize ( string & initFile)
virtual

Reimplemented from Builder.

Definition at line 89 of file TofBuilder.cxx.

90{
91 ifstream f;
92
93 uint32_t nRELayerPos, nRECellPos, nREEaWePos;
94 uint32_t nRELayerMask, nRECellMask, nREEaWeMask;
95
96 //-----------------------------------------------------------
97 // read initFile
98 f.open( initFile.c_str());
99
100 if( f.bad() ) {
101 cerr << "Error: could not open file " << initFile << endl;
102 return false;
103 }
104
105 if (!Builder::find( f, "##TofDigiConf", initFile)) {
106 cerr << "Error: could not find '##TofDigiConf' in file " << initFile << endl;
107 return StatusCode::FAILURE;
108 }
109
110 if( !Builder::expect( f, "#Index,mask", initFile) ||
111 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||
112 !Builder::expectInt( f, "data", initFile, m_dataIndex, m_dataMask) ||
113 !Builder::expectInt( f, "Overflow", initFile, m_overflowIndex, m_overflowMask) ||
114 !Builder::expectInt( f, "T/Q", initFile, m_TQIndex, m_TQMask) ||
115 !Builder::expectInt( f, "Cell", initFile, nRECellPos, nRECellMask) ||
116 !Builder::expectInt( f, "Layer", initFile, nRELayerPos, nRELayerMask) ||
117 !Builder::expectInt( f, "EaWe", initFile, nREEaWePos, nREEaWeMask) )
118 return false;
119
120
121 f.close();
122
123 //-----------------------------------------------------------
124 //Build re2te table
125 for(uint32_t barrel_ec_eawe = TofID::getBARREL_EC_MIN();
126 barrel_ec_eawe <= TofID::getBARREL_EC_MAX(); barrel_ec_eawe++)
127 {
128 uint32_t TELayerMax, TEphiMax, TEBaEaWe;
129 uint32_t eawe = 0, layer = 0, cell = 0;
130
131 if(barrel_ec_eawe == 1) {
132 //it is BARREL
133 TELayerMax = TofID::getLAYER_BARREL_MAX();
134 TEphiMax = TofID::getPHI_BARREL_MAX();
135 } else {
136 //it is ease and west ENDCAP
137 TELayerMax = TofID::getLAYER_ENDCAP_MAX();
138 //zoujh: for luminosity !!! the right value should be 47
139 TEphiMax = 48; //TofID::getPHI_ENDCAP_MAX();
140 }
141
142 for(TEBaEaWe = 0; TEBaEaWe < 2; TEBaEaWe++) {
143 if (barrel_ec_eawe != 1 && TEBaEaWe > 0) break;
144 eawe = TEBaEaWe + (barrel_ec_eawe/2);
145 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++) {
146 if (barrel_ec_eawe == 1) {
147 layer = TELayer + 1;
148 } else {
149 //if (barrel_ec_eawe == TofID::getBARREL_EC_MIN()) layer = TELayer + 0;
150 //else layer = TELayer + 3;
151 layer = 3;
152 }
153 if (layer <= 3) {
154 for (uint32_t TEphi = 0; TEphi <= TEphiMax; TEphi++) {
155 cell = TEphi + 1;
156 uint32_t reid = (((eawe<<nREEaWePos)&nREEaWeMask)|
157 ((layer<<nRELayerPos)&nRELayerMask)|
158 ((cell<<nRECellPos)&nRECellMask));
159 uint32_t teid = TofID::getIntID(barrel_ec_eawe, TELayer, TEphi, TEBaEaWe);
160 //std::cout << "reid " << reid << " eawe " << eawe << " layer " << layer << " cell " << cell
161 // << " teid " << hex << teid << dec << " barrel_ec_eawe " << barrel_ec_eawe << " TELayer "
162 // << TELayer << " TEphi " << TEphi << " TEBaEaWe " << TEBaEaWe << std::endl;
163 m_re2te[reid] = teid;
164 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
165 }
166 }
167 }
168 }
169 }
170
171 // return successful initialization
172 return StatusCode::SUCCESS;
173}
static bool find(ifstream &f, string msg, string fname)
Definition Builder.cxx:60
static bool expect(ifstream &f, string msg, string fname)
Definition Builder.cxx:28
static bool expectInt(ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2)
Definition Builder.cxx:44
static value_type getPHI_BARREL_MAX()
Definition TofID.cxx:237
static value_type getBARREL_EC_MIN()
Definition TofID.cxx:251
static value_type getBARREL_EC_MAX()
Definition TofID.cxx:246
static value_type getLAYER_ENDCAP_MAX()
Definition TofID.cxx:232
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
Definition TofID.cxx:200
static value_type getLAYER_BARREL_MAX()
Definition TofID.cxx:227

Referenced by TofBuilder().

◆ pack()

StatusCode TofBuilder::pack ( TofDigiCol * digiCol,
WriteRawEvent *& re )
virtual

Definition at line 38 of file TofBuilder.cxx.

39{
40 if (digiCol == 0 ) {
41 cerr << "TofBuilder::pack can't get digiCol" << endl;
42 return StatusCode::FAILURE;
43 }
44
45 uint32_t size = 0;
46 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0;
47
48 TofDigiCol::const_iterator pTofDigi = digiCol->begin();
49 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) {
50 teid = (*pTofDigi)->getIntId();
51 if ( teid == 0xFFFFFFFF ) {
52 m_buf[size++] = (*pTofDigi)->getOverflow();
53 continue;
54 }
55 // check weither it's a valid teid (for a mistake in simulation)
56 if ((teid&0x4001) == 1) continue;
57 reid = getREID(teid);
58 tetdc = (*pTofDigi)->getTimeChannel();
59 teadc = (*pTofDigi)->getChargeChannel();
60 // overflow
61 uint32_t overflow_tmp = (*pTofDigi)->getOverflow();
62 // set tdc
63 if(tetdc!=0x7FFFFFFF){
64 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
65 redigi = (tetdc&m_dataMask)|
66 ((reid<<m_idIndex)&m_idMask)|
67 ((overflow<<m_overflowIndex)&m_overflowMask)|
68 ((0<<m_TQIndex)&m_TQMask);
69 m_buf[size++] = redigi;
70 }
71 // set adc
72 if(teadc!=0x7FFFFFFF){
73 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
74 redigi = (teadc&m_dataMask)|
75 ((reid<<m_idIndex)&m_idMask)|
76 ((overflow<<m_overflowIndex)&m_overflowMask)|
77 ((1<<m_TQIndex)&m_TQMask);
78 m_buf[size++] = redigi;
79 }
80 }
81
82 append2event(re, 0xa20000, size);
83
84 return StatusCode::SUCCESS;
85}
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size)
Definition Builder.cxx:76
virtual uint32_t getREID(uint32_t teid)

Referenced by TofConverter::convert().

◆ unPack()

void TofBuilder::unPack ( uint32_t reDigi,
uint32_t & REId,
uint32_t & TEData,
uint32_t & overFlow,
uint32_t & TorQ )
virtual

Definition at line 22 of file TofBuilder.cxx.

24{
25 REId = (reDigi&m_idMask)>>m_idIndex;
26 //cout << "TofBuilder::unPack reDigi: 0x" << hex << reDigi
27 // << " reid: 0x" << reid << dec << endl;
28
29 TEData = (reDigi&m_dataMask);
30 overFlow = (reDigi&m_overflowMask)>>m_overflowIndex;
31 TorQ = (reDigi&m_TQMask)>>m_TQIndex;
32 //if (TorQ) TEData &= 0x1FFF; // ADC 13 bits
33 //cout << "reid" << hex << reid << endl;
34 //cout << "teid" << hex << TEId << endl;
35 return;
36}

Referenced by TofConverter::convert().


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