#include <MdcBuilder.h>
Inheritance diagram for MdcBuilder:
Public Types | |
typedef std::map< uint32_t, uint32_t > | TE2REMAP |
typedef std::map< uint32_t, uint32_t > | TE2REMAP |
Public Member Functions | |
virtual uint32_t | getREID (uint32_t teid) |
virtual uint32_t | getREID (uint32_t teid) |
virtual uint32_t | getTEID (uint32_t reid) |
virtual uint32_t | getTEID (uint32_t reid) |
virtual StatusCode | initialize (string &initFile) |
virtual StatusCode | initialize (string &initFile) |
MdcBuilder () | |
MdcBuilder () | |
virtual StatusCode | pack (MdcDigiCol *digiCol, WriteRawEvent *&re) |
virtual StatusCode | pack (MdcDigiCol *digiCol, WriteRawEvent *&re) |
virtual void | unPack (uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ) |
virtual void | unPack (uint32_t reDigi, uint32_t &REId, uint32_t &TEData, uint32_t &overFlow, uint32_t &TorQ) |
virtual | ~MdcBuilder () |
virtual | ~MdcBuilder () |
Static Public Member Functions | |
bool | expect (ifstream &f, string msg, string fname) |
bool | expect (ifstream &f, string msg, string fname) |
bool | expectInt (ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2) |
bool | expectInt (ifstream &f, string msg, string fname, uint32_t &val1, uint32_t &val2) |
bool | expectLong (ifstream &f, string msg, string fname, uint64_t &val) |
bool | expectLong (ifstream &f, string msg, string fname, uint64_t &val) |
bool | find (ifstream &f, string msg, string fname) |
bool | find (ifstream &f, string msg, string fname) |
Protected Member Functions | |
void | append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size) |
void | append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size) |
Protected Attributes | |
uint32_t * | m_buf |
uint32_t * | m_buf |
uint32_t | m_status |
Static Protected Attributes | |
string | m_confFile |
Private Attributes | |
uint32_t | m_dataIndex |
uint32_t | m_dataMask |
uint32_t | m_idIndex |
uint32_t | m_idMask |
uint32_t | m_overflowIndex |
uint32_t | m_overflowMask |
PropertyMgr | m_propMgr |
uint32_t * | m_re2te |
uint32_t * | m_re2te |
TE2REMAP | m_te2reMap |
uint32_t | m_TQIndex |
uint32_t | m_TQMask |
|
|
|
|
|
00008 :Builder() 00009 { 00010 // set vector size (2^14) and initialize to -1 00011 m_re2te = new uint32_t[16384]; // we have 2^14 different REID 00012 memset((void*)m_re2te, 0xFF, 16384*sizeof(uint32_t)); 00013 00014 initialize (Builder::m_confFile); 00015 }
|
|
00018 {
00019 delete m_re2te;
00020 }
|
|
|
|
|
|
|
|
00077 { 00078 uint32_t run_no = re->run_no(); 00079 uint32_t lvl1_id = re->lvl1_id(); 00080 uint32_t bc_id = 0; // ? 00081 // ROB 00082 eformat::write::ROBFragment* nrob = new eformat::write::ROBFragment( 00083 source_id, // source_id 00084 run_no, // run_no 00085 lvl1_id, // lvl1_id 00086 bc_id, // bc_id 00087 0, // lvl1_type 00088 0, // detev_type 00089 size, // ndata 00090 m_buf, // data 00091 0 // status_position 00092 ); 00093 if(m_status==0xFFFFFFFF){ 00094 nrob->status(0, NULL); 00095 nrob->rod_status(0, NULL); 00096 } 00097 else{ //fucd 00098 nrob->status(1, &m_status); 00099 nrob->rod_status(1, &m_status); 00100 } 00101 // ROS 00102 eformat::write::ROSFragment* nros = new eformat::write::ROSFragment( 00103 source_id, // source_id 00104 run_no, // run_no 00105 lvl1_id, // lvl1_id 00106 bc_id // bc_id 00107 ); 00108 if(m_status==0xFFFFFFFF) nros->status(0, NULL); 00109 else nros->status(1, &m_status); //fucd 00110 // SubDetector 00111 eformat::write::SubDetectorFragment* nsd = new eformat::write::SubDetectorFragment(source_id); 00112 if(m_status==0xFFFFFFFF) nsd->status(0, NULL); 00113 else nsd->status(1, &m_status); //fucd 00114 // append to FullEventFragment 00115 nros->append(nrob); 00116 nsd->append(nros); 00117 re->append(nsd); 00118 }
|
|
|
|
00029 { 00030 string str; 00031 if( f.bad() ) 00032 { 00033 cerr << "Error: file " << fname << " is bad" << endl; 00034 return false; 00035 } 00036 f >> str; 00037 if( str == msg ) 00038 return true; 00039 00040 cerr << "Error: expected `" << msg << "|" << str <<"` in " << fname << endl; 00041 return false; 00042 }
|
|
|
|
00045 { 00046 if( !expect( f, msg, fname ) || f.bad() ) 00047 return false; 00048 f >> val1 >> val2; 00049 return true; 00050 }
|
|
|
|
00053 { 00054 if ( !expect(f, msg, fname) || f.bad() ) 00055 return false; 00056 f >> val; 00057 return true; 00058 }
|
|
|
|
00061 { 00062 if ( f.bad() ) { 00063 cerr << "Error: file " << fname << " bad checked" << endl; 00064 return false; 00065 } 00066 00067 string str; 00068 while ( !f.eof() ) { 00069 f >> str; 00070 if ( str == msg ) return true; 00071 } 00072 00073 return false; 00074 }
|
|
Implements Builder. |
|
Implements Builder. 00176 { 00177 TE2REMAP::iterator itr = m_te2reMap.find(teid); 00178 00179 if (itr == m_te2reMap.end()) { 00180 cout << "wrong teid in mdc " << teid << endl; 00181 exit(8); 00182 } 00183 00184 return itr->second; 00185 }
|
|
Implements Builder. 00016 { return m_re2te[reid]; }
|
|
Implements Builder. 00016 { return m_re2te[reid]; }
|
|
Reimplemented from Builder. |
|
Reimplemented from Builder. 00081 { 00082 ifstream f; 00083 00084 uint32_t NRELAYERPOS, NREWIREPOS, NREEAWEPOS; 00085 uint32_t NRELAYERMASK, NREWIREMASK, NREEAWEMASK; 00086 00087 00088 //----------------------------------------------------------- 00089 // read initFile 00090 f.open( initFile.c_str()); 00091 00092 if( f.bad() ) { 00093 cerr << "Error: could not open file " << initFile << endl; 00094 return false; 00095 } 00096 00097 if (!Builder::find( f, "##MdcDigiConf", initFile)) { 00098 cerr << "Error: could not find '##MdcDigiConf' in file " << initFile << endl; 00099 return StatusCode::FAILURE; 00100 } 00101 00102 if( !Builder::expect( f, "#Index,mask", initFile) || 00103 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) || 00104 !Builder::expectInt( f, "data", initFile, m_dataIndex, m_dataMask) || 00105 !Builder::expectInt( f, "Overflow", initFile, m_overflowIndex, m_overflowMask) || 00106 !Builder::expectInt( f, "T/Q", initFile, m_TQIndex, m_TQMask) || 00107 !Builder::expectInt( f, "Wire", initFile, NREWIREPOS, NREWIREMASK) || 00108 !Builder::expectInt( f, "Layer", initFile, NRELAYERPOS, NRELAYERMASK) ) 00109 return false; 00110 00111 f.close(); 00112 //----------------------------------------------------------- 00113 //Build re2te table 00114 uint32_t nRELayerPos, nREWirePos, nREEaWePos; 00115 uint32_t nRELayerMask, nREWireMask, nREEaWeMask; 00116 00117 00118 uint32_t TELayerMax = MdcID::getAXIAL_LAYER_MAX()+MdcID::getSTEREO_LAYER_MAX()+1; 00119 uint32_t TEWireMax = MdcID::getAXIAL_WIRE_MAX(); 00120 00121 int i = 0; 00122 00123 uint32_t layer, wire; 00124 00125 nRELayerPos = NRELAYERPOS; 00126 nREWirePos = NREWIREPOS; 00127 nRELayerMask = NRELAYERMASK; 00128 nREWireMask = NREWIREMASK; 00129 00130 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++ ) 00131 { 00132 layer = TELayer + 1; 00133 // After Layer 32, there are changes in positions of Layers and wires 00134 if(layer >= 0x20) { 00135 layer = layer + i ; 00136 i++; 00137 nRELayerMask = nRELayerMask&0xFFFFFBFF; 00138 nREWireMask = nREWireMask|0x00000400; 00139 TEWireMax = MdcID::getAXIAL_WIRE_MAX(); 00140 } 00141 else { 00142 //When Layer is less than 32, the number of wire is less than 240 to prevent overflow; 00143 TEWireMax = 240; 00144 } 00145 00146 for(uint32_t TEWire = 0; TEWire <= TEWireMax; TEWire++ ) 00147 { 00148 wire = TEWire + 1; 00149 uint32_t reid = (((layer<<nRELayerPos)&nRELayerMask)| 00150 ((wire<<nREWirePos)&nREWireMask))>>2; 00151 //cout << "TELayer" << hex << TELayer; 00152 //cout << " TEWire" << hex << TEWire; 00153 //cout << " layer" << hex << layer; 00154 //cout << " wire" << hex << wire; 00155 00156 uint32_t teid = MdcID::getIntID(TELayer, TEWire); 00157 00158 if( reid >= 16384 ) 00159 { 00160 cerr << "Error: REID overflow !" << reid << endl; 00161 exit(8); 00162 } 00163 //cout << " reid" << hex << reid; 00164 //cout << " teid" << hex << teid << endl; 00165 m_re2te[reid] = teid; 00166 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ; 00167 } 00168 } 00169 00170 // return successful initialization 00171 return StatusCode::SUCCESS; 00172 }
|
|
|
|
00036 { 00037 if (digiCol == 0 ) { 00038 cerr << "MdcBuilder::pack can't get digiCol" << endl; 00039 return StatusCode::FAILURE; 00040 } 00041 00042 uint32_t size = 0; 00043 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0; 00044 00045 MdcDigiCol::const_iterator pMdcDigi = digiCol->begin(); 00046 for (pMdcDigi; pMdcDigi!= digiCol->end(); pMdcDigi++) { 00047 teid = (*pMdcDigi)->getIntId(); 00048 reid = getREID(teid); 00049 tetdc = (*pMdcDigi)->getTimeChannel(); 00050 teadc = (*pMdcDigi)->getChargeChannel(); 00051 // overflow 00052 uint32_t overflow_tmp = (*pMdcDigi)->getOverflow(); 00053 // set tdc 00054 if(tetdc!=0x7FFFFFFF){ 00055 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1); 00056 redigi = (tetdc&m_dataMask)| 00057 ((reid<<m_idIndex)&m_idMask)| 00058 ((overflow<<m_overflowIndex)&m_overflowMask)| 00059 ((0<<m_TQIndex)&m_TQMask); 00060 m_buf[size++] = redigi; 00061 } 00062 // set adc 00063 if(teadc!=0x7FFFFFFF){ 00064 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1); 00065 redigi = (teadc&m_dataMask)| 00066 ((reid<<m_idIndex)&m_idMask)| 00067 ((overflow<<m_overflowIndex)&m_overflowMask)| 00068 ((1<<m_TQIndex)&m_TQMask); 00069 m_buf[size++] = redigi; 00070 } 00071 } 00072 00073 append2event(re, 0xa10000, size); 00074 00075 return StatusCode::SUCCESS; 00076 }
|
|
|
|
00024 { 00025 REId = (reDigi&m_idMask)>>m_idIndex; 00026 //cout << "MdcBuilder::unPack reDigi: 0x" << hex << reDigi << " reid: 0x" << reid << dec << endl; 00027 TEData = reDigi&m_dataMask; 00028 overFlow = (reDigi&m_overflowMask)>>m_overflowIndex; 00029 TorQ = (reDigi&m_TQMask)>>m_TQIndex; 00030 //cout << "reid" << hex << reid << endl; 00031 //cout << "teid" << hex << TEId << endl; 00032 return; 00033 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reimplemented from Builder. |
|
|
|
|
|
|
|
|
|
|
|
|