BOSS 7.0.3
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)
 
 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)
 
virtual StatusCode initialize (string &initFile)
 
virtual uint32_t getTEID (uint32_t teid)=0
 
virtual uint32_t getREID (uint32_t reid)=0
 
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
 
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)
 
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)
 
 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

Constructor & Destructor Documentation

◆ TofBuilder() [1/2]

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)
Definition: TofBuilder.cxx:130

◆ ~TofBuilder() [1/2]

TofBuilder::~TofBuilder ( )
virtual

Definition at line 17 of file TofBuilder.cxx.

18{
19 delete m_re2te;
20}

◆ TofBuilder() [2/2]

TofBuilder::TofBuilder ( )

◆ ~TofBuilder() [2/2]

virtual TofBuilder::~TofBuilder ( )
virtual

Member Function Documentation

◆ getREID() [1/2]

uint32_t TofBuilder::getREID ( uint32_t  teid)
virtual

Implements Builder.

Definition at line 238 of file TofBuilder.cxx.

239{
240 TE2REMAP::iterator itr = m_te2reMap.find(teid);
241
242 if (itr == m_te2reMap.end()) {
243 cout << "wrong teid in tof" << teid << endl;
244 exit(8);
245 }
246
247 return itr->second;
248}

Referenced by pack().

◆ getREID() [2/2]

virtual uint32_t TofBuilder::getREID ( uint32_t  teid)
virtual

Implements Builder.

◆ getTEID() [1/2]

virtual uint32_t TofBuilder::getTEID ( uint32_t  reid)
inlinevirtual

Implements Builder.

Definition at line 16 of file Event/RawDataCnv/RawDataCnv-00-04-37/RawDataCnv/EventManagement/TofBuilder.h.

16{ return m_re2te[reid]; }

Referenced by TofConverter::convert().

◆ getTEID() [2/2]

virtual uint32_t TofBuilder::getTEID ( uint32_t  reid)
inlinevirtual

Implements Builder.

Definition at line 16 of file InstallArea/include/RawDataCnv/RawDataCnv/EventManagement/TofBuilder.h.

16{ return m_re2te[reid]; }

◆ initialize() [1/2]

StatusCode TofBuilder::initialize ( string &  initFile)
virtual

Reimplemented from Builder.

Definition at line 130 of file TofBuilder.cxx.

131{
132 ifstream f;
133
134 uint32_t nRELayerPos, nRECellPos, nREEaWePos;
135 uint32_t nRELayerMask, nRECellMask, nREEaWeMask;
136
137 //-----------------------------------------------------------
138 // read initFile
139 f.open( initFile.c_str());
140
141 if( f.bad() ) {
142 cerr << "Error: could not open file " << initFile << endl;
143 return false;
144 }
145
146 if (!Builder::find( f, "##TofDigiConf", initFile)) {
147 cerr << "Error: could not find '##TofDigiConf' in file " << initFile << endl;
148 return StatusCode::FAILURE;
149 }
150
151 if( !Builder::expect( f, "#Index,mask", initFile) ||
152 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||
153 !Builder::expectInt( f, "data", initFile, m_dataIndex, m_dataMask) ||
154 !Builder::expectInt( f, "Overflow", initFile, m_overflowIndex, m_overflowMask) ||
155 !Builder::expectInt( f, "T/Q", initFile, m_TQIndex, m_TQMask) ||
156 !Builder::expectInt( f, "Cell", initFile, nRECellPos, nRECellMask) ||
157 !Builder::expectInt( f, "Layer", initFile, nRELayerPos, nRELayerMask) ||
158 !Builder::expectInt( f, "EaWe", initFile, nREEaWePos, nREEaWeMask) )
159 return false;
160
161
162 f.close();
163
164 //-----------------------------------------------------------
165 //Build re2te table
166 for(uint32_t barrel_ec_eawe = TofID::getBARREL_EC_MIN();
167 barrel_ec_eawe <= TofID::getBARREL_EC_MAX(); barrel_ec_eawe++)
168 {
169 uint32_t TELayerMax, TEphiMax, TEBaEaWe;
170 uint32_t eawe = 0, layer = 0, cell = 0;
171
172 if(barrel_ec_eawe == 1) {
173 //it is BARREL
174 TELayerMax = TofID::getLAYER_BARREL_MAX();
175 TEphiMax = TofID::getPHI_BARREL_MAX();
176 } else {
177 //it is ease and west ENDCAP
178 TELayerMax = TofID::getLAYER_ENDCAP_MAX();
179 //zoujh: for luminosity !!! the right value should be 47
180 TEphiMax = 48; //TofID::getPHI_ENDCAP_MAX();
181 }
182
183 for(TEBaEaWe = 0; TEBaEaWe < 2; TEBaEaWe++) {
184 if (barrel_ec_eawe != 1 && TEBaEaWe > 0) break;
185 eawe = TEBaEaWe + (barrel_ec_eawe/2);
186 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++) {
187 if (barrel_ec_eawe == 1) {
188 layer = TELayer + 1;
189 } else {
190 //if (barrel_ec_eawe == TofID::getBARREL_EC_MIN()) layer = TELayer + 0;
191 //else layer = TELayer + 3;
192 layer = 3;
193 }
194 if (layer <= 3) {
195 for (uint32_t TEphi = 0; TEphi <= TEphiMax; TEphi++) {
196 cell = TEphi + 1;
197 uint32_t reid = (((eawe<<nREEaWePos)&nREEaWeMask)|
198 ((layer<<nRELayerPos)&nRELayerMask)|
199 ((cell<<nRECellPos)&nRECellMask));
200 uint32_t teid = TofID::getIntID(barrel_ec_eawe, TELayer, TEphi, TEBaEaWe);
201 //std::cout << "reid " << reid << " eawe " << eawe << " layer " << layer << " cell " << cell
202 // << " teid " << hex << teid << dec << " barrel_ec_eawe " << barrel_ec_eawe << " TELayer "
203 // << TELayer << " TEphi " << TEphi << " TEBaEaWe " << TEBaEaWe << std::endl;
204 m_re2te[reid] = teid;
205 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
206 }
207 }
208 }
209 }
210 }
211
212 //-----------------------------------------------------------
213 //Append the ETF te2re map
214 for ( uint32_t module = 0; module < 36; ++module )
215 {
216 for ( uint32_t strip = 0; strip < 12; ++strip )
217 {
218 //uint32_t ew = 0 or 1, sb = 0 or 1;
219 //uint32_t teid = TofID::getIntID(3/*barrel_ec, 3 means ETF*/, ew, module, strip, sb);
220 //uint32_t reid = teid & 0xFFF;
221 //m_te2reMap.insert(TE2REMAP::value_type(teid, reid));
222 uint32_t teid = TofID::getIntID(3, 0, module, strip, 0);
223 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
224 teid = TofID::getIntID(3, 0, module, strip, 1);
225 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
226 teid = TofID::getIntID(3, 1, module, strip, 0);
227 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
228 teid = TofID::getIntID(3, 1, module, strip, 1);
229 m_te2reMap.insert(TE2REMAP::value_type(teid, (teid&0xFFF)));
230 }
231 }
232
233 // return successful initialization
234 return StatusCode::SUCCESS;
235}
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 find(ifstream &f, string msg, string fname)
static value_type getPHI_BARREL_MAX()
Definition: TofID.cxx:217
static value_type getBARREL_EC_MIN()
Definition: TofID.cxx:231
static value_type getBARREL_EC_MAX()
Definition: TofID.cxx:226
static value_type getLAYER_ENDCAP_MAX()
Definition: TofID.cxx:212
static value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
Definition: TofID.cxx:178
static value_type getLAYER_BARREL_MAX()
Definition: TofID.cxx:207

Referenced by TofBuilder().

◆ initialize() [2/2]

virtual StatusCode TofBuilder::initialize ( string &  initFile)
virtual

Reimplemented from Builder.

◆ pack() [1/2]

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 std::vector<TofDigi*> vEtfDigi;
48
49 // for TOF Digis
50 TofDigiCol::const_iterator pTofDigi = digiCol->begin();
51 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) {
52 if ( TofID::is_mrpc((*pTofDigi)->identify()) )
53 {
54 vEtfDigi.push_back(*pTofDigi);
55 continue;
56 }
57 teid = (*pTofDigi)->getIntId();
58 if ( teid == 0xFFFFFFFF ) {
59 m_buf[size++] = (*pTofDigi)->getOverflow();
60 continue;
61 }
62 // check weither it's a valid teid (for a mistake in simulation)
63 if ((teid&0x4001) == 1) continue;
64 reid = getREID(teid);
65 tetdc = (*pTofDigi)->getTimeChannel();
66 teadc = (*pTofDigi)->getChargeChannel();
67 // overflow
68 uint32_t overflow_tmp = (*pTofDigi)->getOverflow();
69 // set tdc
70 if(tetdc!=0x7FFFFFFF){
71 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
72 redigi = (tetdc&m_dataMask)|
73 ((reid<<m_idIndex)&m_idMask)|
74 ((overflow<<m_overflowIndex)&m_overflowMask)|
75 ((0<<m_TQIndex)&m_TQMask);
76 m_buf[size++] = redigi;
77 }
78 // set adc
79 if(teadc!=0x7FFFFFFF){
80 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
81 redigi = (teadc&m_dataMask)|
82 ((reid<<m_idIndex)&m_idMask)|
83 ((overflow<<m_overflowIndex)&m_overflowMask)|
84 ((1<<m_TQIndex)&m_TQMask);
85 m_buf[size++] = redigi;
86 }
87 }
88
89 append2event(re, 0xa20000, size);
90
91 // for ETF Digis
92 uint32_t shift = size;
93 for (std::vector<TofDigi*>::const_iterator pEtfDigi = vEtfDigi.begin();
94 pEtfDigi != vEtfDigi.end();
95 ++pEtfDigi )
96 {
97 teid = (*pEtfDigi)->getIntId();
98 if ( teid == 0xFFFFFFFF ) {
99 m_buf[size++] = (*pEtfDigi)->getOverflow();
100 continue;
101 }
102 reid = getREID(teid);
103 tetdc = (*pEtfDigi)->getTimeChannel();
104 teadc = (*pEtfDigi)->getChargeChannel();
105 // set tdc ( the L/T for ETF )
106 if ( tetdc != 0x7FFFFFFF )
107 {
108 redigi = (tetdc&0x7FFFF) |
109 // ((0<<19)&0x80000) |
110 ((reid<<20)&0xFFF00000);
111 m_buf[size++] = redigi;
112 }
113 // set adc ( the L/T for ETF )
114 if ( teadc != 0x7FFFFFFF )
115 {
116 redigi = (teadc&0x7FFFF) |
117 ((1<<19)&0x80000) |
118 ((reid<<20)&0xFFF00000);
119 m_buf[size++] = redigi;
120 }
121 }
122
123 if ( size != shift ) append2event(re, 0xa70000, size-shift, shift);
124
125 return StatusCode::SUCCESS;
126}
void append2event(WriteRawEvent *&re, uint32_t source_id, uint32_t size, uint32_t shift=0)
Definition: Builder.cxx:76
virtual uint32_t getREID(uint32_t teid)
Definition: TofBuilder.cxx:238
static bool is_mrpc(const Identifier &id)
Definition: TofID.cxx:113

Referenced by TofConverter::convert().

◆ pack() [2/2]

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

◆ unPack() [1/2]

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().

◆ unPack() [2/2]

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

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