#include <TofBuilder.h>
Inheritance diagram for TofBuilder:
Public Types | |
typedef std::map< uint32_t, uint32_t > | TE2REMAP |
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) |
Static Public Member Functions | |
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 | |
void | append2event (WriteRawEvent *&re, uint32_t source_id, uint32_t size) |
Protected Attributes | |
uint32_t * | m_buf |
uint32_t | m_status |
Static Protected Attributes | |
static string | m_confFile |
Private Attributes | |
uint32_t | m_idIndex |
uint32_t | m_dataIndex |
uint32_t | m_idMask |
uint32_t | m_dataMask |
uint32_t | m_overflowIndex |
uint32_t | m_overflowMask |
uint32_t | m_TQIndex |
uint32_t | m_TQMask |
uint32_t * | m_re2te |
TE2REMAP | m_te2reMap |
PropertyMgr | m_propMgr |
Definition at line 9 of file TofBuilder.h.
typedef std::map<uint32_t, uint32_t> Builder::TE2REMAP [inherited] |
TofBuilder::TofBuilder | ( | ) |
Definition at line 7 of file TofBuilder.cxx.
References initialize(), Builder::m_confFile, and m_re2te.
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 }
TofBuilder::~TofBuilder | ( | ) | [virtual] |
Definition at line 17 of file TofBuilder.cxx.
References m_re2te.
00018 { 00019 delete m_re2te; 00020 }
void Builder::append2event | ( | WriteRawEvent *& | re, | |
uint32_t | source_id, | |||
uint32_t | size | |||
) | [protected, inherited] |
Definition at line 76 of file Builder.cxx.
References eformat::write::FullEventFragment::append(), eformat::write::SubDetectorFragment::append(), eformat::write::ROSFragment::append(), eformat::write::FullEventFragment::lvl1_id(), Builder::m_buf, Builder::m_status, eformat::write::ROBFragment::rod_status(), eformat::write::FullEventFragment::run_no(), eformat::write::SubDetectorFragment::status(), eformat::write::ROSFragment::status(), and eformat::write::ROBFragment::status().
Referenced by pack(), MucBuilder::pack(), MdcBuilder::pack(), McParticleBuilder::pack(), HltBuilder::pack(), and EmcBuilder::pack().
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 }
Definition at line 28 of file Builder.cxx.
References deljobs::string.
Referenced by Builder::expectInt(), Builder::expectLong(), TofMcHitBuilder::initialize(), initialize(), MucMcHitBuilder::initialize(), MdcMcHitBuilder::initialize(), MdcBuilder::initialize(), HltBuilder::initialize(), EmcMcHitBuilder::initialize(), and EmcBuilder::initialize().
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 }
bool Builder::expectInt | ( | ifstream & | f, | |
string | msg, | |||
string | fname, | |||
uint32_t & | val1, | |||
uint32_t & | val2 | |||
) | [static, inherited] |
Definition at line 44 of file Builder.cxx.
References Builder::expect().
Referenced by TofMcHitBuilder::initialize(), initialize(), MucMcHitBuilder::initialize(), MdcMcHitBuilder::initialize(), MdcBuilder::initialize(), HltBuilder::initialize(), EmcMcHitBuilder::initialize(), and EmcBuilder::initialize().
00045 { 00046 if( !expect( f, msg, fname ) || f.bad() ) 00047 return false; 00048 f >> val1 >> val2; 00049 return true; 00050 }
bool Builder::expectLong | ( | ifstream & | f, | |
string | msg, | |||
string | fname, | |||
uint64_t & | val | |||
) | [static, inherited] |
Definition at line 52 of file Builder.cxx.
References Builder::expect().
Referenced by TofMcHitBuilder::initialize(), MucMcHitBuilder::initialize(), MdcMcHitBuilder::initialize(), and EmcMcHitBuilder::initialize().
00053 { 00054 if ( !expect(f, msg, fname) || f.bad() ) 00055 return false; 00056 f >> val; 00057 return true; 00058 }
Definition at line 60 of file Builder.cxx.
References deljobs::string.
Referenced by TofMcHitBuilder::initialize(), initialize(), MucMcHitBuilder::initialize(), MdcMcHitBuilder::initialize(), MdcBuilder::initialize(), McParticleBuilder::initialize(), HltBuilder::initialize(), EmcMcHitBuilder::initialize(), and EmcBuilder::initialize().
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 }
uint32_t TofBuilder::getREID | ( | uint32_t | teid | ) | [virtual] |
Implements Builder.
Definition at line 176 of file TofBuilder.cxx.
References m_te2reMap.
Referenced by pack().
00177 { 00178 TE2REMAP::iterator itr = m_te2reMap.find(teid); 00179 00180 if (itr == m_te2reMap.end()) { 00181 cout << "wrong teid in tof" << teid << endl; 00182 exit(8); 00183 } 00184 00185 return itr->second; 00186 }
virtual uint32_t TofBuilder::getTEID | ( | uint32_t | reid | ) | [inline, virtual] |
Implements Builder.
Definition at line 16 of file TofBuilder.h.
References m_re2te.
Referenced by TofConverter::convert().
00016 { return m_re2te[reid]; }
StatusCode TofBuilder::initialize | ( | string & | initFile | ) | [virtual] |
Reimplemented from Builder.
Definition at line 89 of file TofBuilder.cxx.
References Builder::expect(), Builder::expectInt(), Builder::find(), TofID::getBARREL_EC_MAX(), TofID::getBARREL_EC_MIN(), TofID::getIntID(), TofID::getLAYER_BARREL_MAX(), TofID::getLAYER_ENDCAP_MAX(), TofID::getPHI_BARREL_MAX(), m_dataIndex, m_dataMask, m_idIndex, m_idMask, m_overflowIndex, m_overflowMask, m_re2te, m_te2reMap, m_TQIndex, m_TQMask, and dchain::value_type().
Referenced by TofBuilder().
00090 { 00091 ifstream f; 00092 00093 uint32_t nRELayerPos, nRECellPos, nREEaWePos; 00094 uint32_t nRELayerMask, nRECellMask, nREEaWeMask; 00095 00096 //----------------------------------------------------------- 00097 // read initFile 00098 f.open( initFile.c_str()); 00099 00100 if( f.bad() ) { 00101 cerr << "Error: could not open file " << initFile << endl; 00102 return false; 00103 } 00104 00105 if (!Builder::find( f, "##TofDigiConf", initFile)) { 00106 cerr << "Error: could not find '##TofDigiConf' in file " << initFile << endl; 00107 return StatusCode::FAILURE; 00108 } 00109 00110 if( !Builder::expect( f, "#Index,mask", initFile) || 00111 !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) || 00112 !Builder::expectInt( f, "data", initFile, m_dataIndex, m_dataMask) || 00113 !Builder::expectInt( f, "Overflow", initFile, m_overflowIndex, m_overflowMask) || 00114 !Builder::expectInt( f, "T/Q", initFile, m_TQIndex, m_TQMask) || 00115 !Builder::expectInt( f, "Cell", initFile, nRECellPos, nRECellMask) || 00116 !Builder::expectInt( f, "Layer", initFile, nRELayerPos, nRELayerMask) || 00117 !Builder::expectInt( f, "EaWe", initFile, nREEaWePos, nREEaWeMask) ) 00118 return false; 00119 00120 00121 f.close(); 00122 00123 //----------------------------------------------------------- 00124 //Build re2te table 00125 for(uint32_t barrel_ec_eawe = TofID::getBARREL_EC_MIN(); 00126 barrel_ec_eawe <= TofID::getBARREL_EC_MAX(); barrel_ec_eawe++) 00127 { 00128 uint32_t TELayerMax, TEphiMax, TEBaEaWe; 00129 uint32_t eawe = 0, layer = 0, cell = 0; 00130 00131 if(barrel_ec_eawe == 1) { 00132 //it is BARREL 00133 TELayerMax = TofID::getLAYER_BARREL_MAX(); 00134 TEphiMax = TofID::getPHI_BARREL_MAX(); 00135 } else { 00136 //it is ease and west ENDCAP 00137 TELayerMax = TofID::getLAYER_ENDCAP_MAX(); 00138 //zoujh: for luminosity !!! the right value should be 47 00139 TEphiMax = 48; //TofID::getPHI_ENDCAP_MAX(); 00140 } 00141 00142 for(TEBaEaWe = 0; TEBaEaWe < 2; TEBaEaWe++) { 00143 if (barrel_ec_eawe != 1 && TEBaEaWe > 0) break; 00144 eawe = TEBaEaWe + (barrel_ec_eawe/2); 00145 for(uint32_t TELayer = 0; TELayer <= TELayerMax; TELayer++) { 00146 if (barrel_ec_eawe == 1) { 00147 layer = TELayer + 1; 00148 } else { 00149 //if (barrel_ec_eawe == TofID::getBARREL_EC_MIN()) layer = TELayer + 0; 00150 //else layer = TELayer + 3; 00151 layer = 3; 00152 } 00153 if (layer <= 3) { 00154 for (uint32_t TEphi = 0; TEphi <= TEphiMax; TEphi++) { 00155 cell = TEphi + 1; 00156 uint32_t reid = (((eawe<<nREEaWePos)&nREEaWeMask)| 00157 ((layer<<nRELayerPos)&nRELayerMask)| 00158 ((cell<<nRECellPos)&nRECellMask)); 00159 uint32_t teid = TofID::getIntID(barrel_ec_eawe, TELayer, TEphi, TEBaEaWe); 00160 //std::cout << "reid " << reid << " eawe " << eawe << " layer " << layer << " cell " << cell 00161 // << " teid " << hex << teid << dec << " barrel_ec_eawe " << barrel_ec_eawe << " TELayer " 00162 // << TELayer << " TEphi " << TEphi << " TEBaEaWe " << TEBaEaWe << std::endl; 00163 m_re2te[reid] = teid; 00164 m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ; 00165 } 00166 } 00167 } 00168 } 00169 } 00170 00171 // return successful initialization 00172 return StatusCode::SUCCESS; 00173 }
StatusCode TofBuilder::pack | ( | TofDigiCol * | digiCol, | |
WriteRawEvent *& | re | |||
) | [virtual] |
Definition at line 38 of file TofBuilder.cxx.
References Builder::append2event(), getREID(), Builder::m_buf, m_dataMask, m_idIndex, m_idMask, m_overflowIndex, m_overflowMask, m_TQIndex, m_TQMask, and delete_small_size::size.
Referenced by TofConverter::convert().
00039 { 00040 if (digiCol == 0 ) { 00041 cerr << "TofBuilder::pack can't get digiCol" << endl; 00042 return StatusCode::FAILURE; 00043 } 00044 00045 uint32_t size = 0; 00046 uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, overflow = 0; 00047 00048 TofDigiCol::const_iterator pTofDigi = digiCol->begin(); 00049 for (pTofDigi; pTofDigi!= digiCol->end(); pTofDigi++) { 00050 teid = (*pTofDigi)->getIntId(); 00051 if ( teid == 0xFFFFFFFF ) { 00052 m_buf[size++] = (*pTofDigi)->getOverflow(); 00053 continue; 00054 } 00055 // check weither it's a valid teid (for a mistake in simulation) 00056 if ((teid&0x4001) == 1) continue; 00057 reid = getREID(teid); 00058 tetdc = (*pTofDigi)->getTimeChannel(); 00059 teadc = (*pTofDigi)->getChargeChannel(); 00060 // overflow 00061 uint32_t overflow_tmp = (*pTofDigi)->getOverflow(); 00062 // set tdc 00063 if(tetdc!=0x7FFFFFFF){ 00064 overflow = ((tetdc > m_dataMask) ? 1 : 0) | (overflow_tmp&1); 00065 redigi = (tetdc&m_dataMask)| 00066 ((reid<<m_idIndex)&m_idMask)| 00067 ((overflow<<m_overflowIndex)&m_overflowMask)| 00068 ((0<<m_TQIndex)&m_TQMask); 00069 m_buf[size++] = redigi; 00070 } 00071 // set adc 00072 if(teadc!=0x7FFFFFFF){ 00073 overflow = ((teadc > m_dataMask) ? 1 : 0) | ((overflow_tmp>>1)&1); 00074 redigi = (teadc&m_dataMask)| 00075 ((reid<<m_idIndex)&m_idMask)| 00076 ((overflow<<m_overflowIndex)&m_overflowMask)| 00077 ((1<<m_TQIndex)&m_TQMask); 00078 m_buf[size++] = redigi; 00079 } 00080 } 00081 00082 append2event(re, 0xa20000, size); 00083 00084 return StatusCode::SUCCESS; 00085 }
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.
References m_dataMask, m_idIndex, m_idMask, m_overflowIndex, m_overflowMask, m_TQIndex, and m_TQMask.
Referenced by TofConverter::convert().
00024 { 00025 REId = (reDigi&m_idMask)>>m_idIndex; 00026 //cout << "TofBuilder::unPack reDigi: 0x" << hex << reDigi 00027 // << " reid: 0x" << reid << dec << endl; 00028 00029 TEData = (reDigi&m_dataMask); 00030 overFlow = (reDigi&m_overflowMask)>>m_overflowIndex; 00031 TorQ = (reDigi&m_TQMask)>>m_TQIndex; 00032 //if (TorQ) TEData &= 0x1FFF; // ADC 13 bits 00033 //cout << "reid" << hex << reid << endl; 00034 //cout << "teid" << hex << TEId << endl; 00035 return; 00036 }
uint32_t* Builder::m_buf [protected, inherited] |
Definition at line 46 of file Builder.h.
Referenced by Builder::append2event(), Builder::Builder(), pack(), MucBuilder::pack(), MdcBuilder::pack(), McParticleBuilder::pack(), HltBuilder::pack(), EmcBuilder::pack(), and Builder::~Builder().
string Builder::m_confFile [static, protected, inherited] |
Definition at line 47 of file Builder.h.
Referenced by Builder::Builder(), EmcBuilder::EmcBuilder(), EmcMcHitBuilder::EmcMcHitBuilder(), HltBuilder::HltBuilder(), MdcBuilder::MdcBuilder(), MdcMcHitBuilder::MdcMcHitBuilder(), MucMcHitBuilder::MucMcHitBuilder(), TofBuilder(), and TofMcHitBuilder::TofMcHitBuilder().
uint32_t TofBuilder::m_dataIndex [private] |
uint32_t TofBuilder::m_dataMask [private] |
uint32_t TofBuilder::m_idIndex [private] |
uint32_t TofBuilder::m_idMask [private] |
uint32_t TofBuilder::m_overflowIndex [private] |
uint32_t TofBuilder::m_overflowMask [private] |
PropertyMgr TofBuilder::m_propMgr [private] |
uint32_t* TofBuilder::m_re2te [private] |
Definition at line 33 of file TofBuilder.h.
Referenced by getTEID(), initialize(), TofBuilder(), and ~TofBuilder().
uint32_t Builder::m_status [protected, inherited] |
Definition at line 49 of file Builder.h.
Referenced by Builder::append2event(), and Builder::Builder().
TE2REMAP TofBuilder::m_te2reMap [private] |
uint32_t TofBuilder::m_TQIndex [private] |
uint32_t TofBuilder::m_TQMask [private] |