BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcBuilder Class Reference

#include <MdcBuilder.h>

+ Inheritance diagram for MdcBuilder:

Public Member Functions

 MdcBuilder ()
 
virtual ~MdcBuilder ()
 
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 (MdcDigiCol *digiCol, WriteRawEvent *&re)
 
 MdcBuilder ()
 
virtual ~MdcBuilder ()
 
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 (MdcDigiCol *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

◆ MdcBuilder() [1/2]

MdcBuilder::MdcBuilder ( )

Definition at line 7 of file MdcBuilder.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: MdcBuilder.cxx:99

◆ ~MdcBuilder() [1/2]

MdcBuilder::~MdcBuilder ( )
virtual

Definition at line 17 of file MdcBuilder.cxx.

18{
19 delete m_re2te;
20}

◆ MdcBuilder() [2/2]

MdcBuilder::MdcBuilder ( )

◆ ~MdcBuilder() [2/2]

virtual MdcBuilder::~MdcBuilder ( )
virtual

Member Function Documentation

◆ getREID() [1/2]

uint32_t MdcBuilder::getREID ( uint32_t  teid)
virtual

Implements Builder.

Definition at line 194 of file MdcBuilder.cxx.

195{
196 TE2REMAP::iterator itr = m_te2reMap.find(teid);
197
198 if (itr == m_te2reMap.end()) {
199 cout << "wrong teid in mdc " << teid << endl;
200 exit(8);
201 }
202
203 return itr->second;
204}

Referenced by pack().

◆ getREID() [2/2]

virtual uint32_t MdcBuilder::getREID ( uint32_t  teid)
virtual

Implements Builder.

◆ getTEID() [1/2]

virtual uint32_t MdcBuilder::getTEID ( uint32_t  reid)
inlinevirtual

Implements Builder.

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

16{ return m_re2te[reid]; }

Referenced by MdcConverter::convert().

◆ getTEID() [2/2]

virtual uint32_t MdcBuilder::getTEID ( uint32_t  reid)
inlinevirtual

Implements Builder.

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

16{ return m_re2te[reid]; }

◆ initialize() [1/2]

StatusCode MdcBuilder::initialize ( string &  initFile)
virtual

Reimplemented from Builder.

Definition at line 99 of file MdcBuilder.cxx.

100{
101 ifstream f;
102
103 uint32_t NRELAYERPOS, NREWIREPOS, NREEAWEPOS;
104 uint32_t NRELAYERMASK, NREWIREMASK, NREEAWEMASK;
105
106
107 //-----------------------------------------------------------
108 // read initFile
109 f.open( initFile.c_str());
110
111 if( f.bad() ) {
112 cerr << "Error: could not open file " << initFile << endl;
113 return false;
114 }
115
116 if (!Builder::find( f, "##MdcDigiConf", initFile)) {
117 cerr << "Error: could not find '##MdcDigiConf' in file " << initFile << endl;
118 return StatusCode::FAILURE;
119 }
120
121 if( !Builder::expect( f, "#Index,mask", initFile) ||
122 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||
123 !Builder::expectInt( f, "data", initFile, m_dataIndex, m_dataMask) ||
124 !Builder::expectInt( f, "Overflow", initFile, m_overflowIndex, m_overflowMask) ||
125 !Builder::expectInt( f, "T/Q", initFile, m_TQIndex, m_TQMask) ||
126 !Builder::expectInt( f, "Wire", initFile, NREWIREPOS, NREWIREMASK) ||
127 !Builder::expectInt( f, "Layer", initFile, NRELAYERPOS, NRELAYERMASK) )
128 return false;
129
130 f.close();
131 //-----------------------------------------------------------
132 //Build re2te table
133 uint32_t nRELayerPos, nREWirePos, nREEaWePos;
134 uint32_t nRELayerMask, nREWireMask, nREEaWeMask;
135
136
137 uint32_t TELayerMax = MdcID::getAXIAL_LAYER_MAX()+MdcID::getSTEREO_LAYER_MAX()+1;
138 uint32_t TEWireMax = MdcID::getAXIAL_WIRE_MAX();
139
140 int i = 0;
141
142 uint32_t layer, wire;
143
144 nRELayerPos = NRELAYERPOS;
145 nREWirePos = NREWIREPOS;
146 nRELayerMask = NRELAYERMASK;
147 nREWireMask = NREWIREMASK;
148
149 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++ )
150 {
151 layer = TELayer + 1;
152 // After Layer 32, there are changes in positions of Layers and wires
153 if(layer >= 0x20) {
154 layer = layer + i ;
155 i++;
156 nRELayerMask = nRELayerMask&0xFFFFFBFF;
157 nREWireMask = nREWireMask|0x00000400;
158 TEWireMax = MdcID::getAXIAL_WIRE_MAX();
159 }
160 else {
161 //When Layer is less than 32, the number of wire is less than 240 to prevent overflow;
162 TEWireMax = 240;
163 }
164
165 for(uint32_t TEWire = 0; TEWire <= TEWireMax; TEWire++ )
166 {
167 wire = TEWire + 1;
168 uint32_t reid = (((layer<<nRELayerPos)&nRELayerMask)|
169 ((wire<<nREWirePos)&nREWireMask))>>2;
170 //cout << "TELayer" << hex << TELayer;
171 //cout << " TEWire" << hex << TEWire;
172 //cout << " layer" << hex << layer;
173 //cout << " wire" << hex << wire;
174
175 uint32_t teid = MdcID::getIntID(TELayer, TEWire);
176
177 if( reid >= 16384 )
178 {
179 cerr << "Error: REID overflow !" << reid << endl;
180 exit(8);
181 }
182 //cout << " reid" << hex << reid;
183 //cout << " teid" << hex << teid << endl;
184 m_re2te[reid] = teid;
185 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ;
186 }
187 }
188
189 // return successful initialization
190 return StatusCode::SUCCESS;
191}
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 getAXIAL_LAYER_MAX()
Definition: MdcID.cxx:138
static value_type getAXIAL_WIRE_MAX()
Definition: MdcID.cxx:146
static value_type getIntID(unsigned int wireType, unsigned int layer, unsigned int wire)
Definition: MdcID.cxx:124
static value_type getSTEREO_LAYER_MAX()
Definition: MdcID.cxx:142
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")

Referenced by MdcBuilder().

◆ initialize() [2/2]

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

Reimplemented from Builder.

◆ pack() [1/2]

StatusCode MdcBuilder::pack ( MdcDigiCol digiCol,
WriteRawEvent *&  re 
)
virtual

Definition at line 35 of file MdcBuilder.cxx.

36{
37 if (digiCol == 0 ) {
38 cerr << "MdcBuilder::pack can't get digiCol" << endl;
39 return StatusCode::FAILURE;
40 }
41
42 uint32_t size = 0;
43 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0;
44
45 MdcDigiCol::const_iterator pMdcDigi = digiCol->begin();
46 for (pMdcDigi; pMdcDigi!= digiCol->end(); pMdcDigi++) {
47 //zoujh+++++++++++, be consistent with DAQ raw data
48 Identifier id = (*pMdcDigi)->identify();
49 int layer = MdcID::layer(id), wire = MdcID::wire(id);
50 if ( layer == 20 && wire < 8 ) {
51 layer = 42;
52 }
53 else if ( layer == 42 && wire < 8 ) {
54 layer = 20;
55 }
56 else if ( layer == 40 ) {
57 if ( wire >= 200 && wire < 208 ) {
58 wire += 8;
59 }
60 else if ( wire >= 208 && wire < 216 ) {
61 wire -= 8;
62 }
63 }
64 //teid = (*pMdcDigi)->getIntId();
65 teid = MdcID::getIntID(layer, wire);
66 //zoujh-----------
67 reid = getREID(teid);
68 tetdc = (*pMdcDigi)->getTimeChannel();
69 teadc = (*pMdcDigi)->getChargeChannel();
70 // overflow
71 uint32_t overflow_tmp = (*pMdcDigi)->getOverflow();
72 // set tdc
73 if(tetdc!=0x7FFFFFFF){
74 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1);
75 redigi = (tetdc&m_dataMask)|
76 ((reid<<m_idIndex)&m_idMask)|
77 ((overflow<<m_overflowIndex)&m_overflowMask)|
78 ((0<<m_TQIndex)&m_TQMask);
79 m_buf[size++] = redigi;
80 }
81 // set adc
82 if(teadc!=0x7FFFFFFF){
83 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1);
84 redigi = (teadc&m_dataMask)|
85 ((reid<<m_idIndex)&m_idMask)|
86 ((overflow<<m_overflowIndex)&m_overflowMask)|
87 ((1<<m_TQIndex)&m_TQMask);
88 m_buf[size++] = redigi;
89 }
90 }
91
92 append2event(re, 0xa10000, size);
93
94 return StatusCode::SUCCESS;
95}
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: MdcBuilder.cxx:194
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54

Referenced by MdcConverter::convert().

◆ pack() [2/2]

virtual StatusCode MdcBuilder::pack ( MdcDigiCol digiCol,
WriteRawEvent *&  re 
)
virtual

◆ unPack() [1/2]

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

Definition at line 22 of file MdcBuilder.cxx.

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

Referenced by MdcConverter::convert().

◆ unPack() [2/2]

virtual void MdcBuilder::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: