/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RawDataCnv/RawDataCnv-00-04-35/src/EventManagement/HltBuilder.cxx

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 #include "Identifier/HltID.h"
00004 #include "RawDataCnv/EventManagement/HltBuilder.h"
00005 using namespace std;
00006 
00007 HltBuilder::HltBuilder()
00008   :Builder()
00009 {
00010   // set vector size (2^14) and initialize to -1
00011   m_re2te = new uint32_t[256];  // we have 2^8 different REID
00012   memset((void*)m_re2te, 0xFF, 256*sizeof(uint32_t));
00013 
00014   initialize (Builder::m_confFile);
00015 }
00016 
00017 HltBuilder::~HltBuilder()
00018 {
00019    delete m_re2te;
00020 }
00021 
00022 void HltBuilder::unPack(uint32_t reDigi, uint32_t n, 
00023                         uint32_t &REId, uint32_t &TEData1, uint32_t &TEData2)
00024 {
00025   if ( n == 0 ) {
00026     REId = 0;
00027     TEData1 = reDigi;
00028     TEData2 = 0;
00029   }
00030   else if ( n == 1 ) {
00031     REId = 1;
00032     TEData1 = (reDigi&m_algMask) >> m_algIndex;
00033     TEData2 = (reDigi&m_criMask) >> m_criIndex;
00034     //cout<<hex<<reDigi<<"=>"<<TEData1<<","<<TEData2<<endl
00035     //  <<m_algMask<<"  "<<m_algIndex<<"  "<<m_criMask
00036     //  <<"  "<<m_criIndex<<dec<<endl;
00037   }
00038   else {
00039     REId = n+1;
00040     TEData1 =reDigi;
00041     TEData2 =0;
00042   }
00043 
00044    return;
00045 }
00046 
00047 StatusCode HltBuilder::pack(HltRawCol* digiCol, WriteRawEvent*& re)
00048 {
00049   if (digiCol == 0 ) {
00050     cerr << "HltBuilder::pack can't get digiCol" << endl;
00051     return StatusCode::FAILURE;
00052   }
00053 
00054   uint32_t size = 0;
00055   uint32_t hltdigi = 0;
00056   Identifier id;
00057   uint32_t event_filter[4]={0,0,0,0};
00058 
00059   HltRawCol::const_iterator pHltDigi = digiCol->begin();
00060   for ( ; pHltDigi!= digiCol->end(); pHltDigi++) {
00061     id = (*pHltDigi)->identify();
00062     if(HltID::is_algorithm(id)){
00063       uint32_t alg= (*pHltDigi)->getIntChannel();
00064       uint32_t cri=0;
00065       //cout << " debug by fucd: alg=" << alg << endl;
00066       pHltDigi++;
00067       if(!HltID::is_criteria((*pHltDigi)->identify())) {
00068         pHltDigi--;
00069       }
00070       else {
00071         cri= (*pHltDigi)->getIntChannel();
00072       }
00073       hltdigi = ((alg<<m_algIndex)&m_algMask) | ((cri<<m_algIndex)&m_criMask);
00074       event_filter[1]                                    =hltdigi;
00075     }
00076     else if(HltID::is_criteria(id)){
00077       cerr<< "HltBuilder::pack():  HLT raw data error!" << endl;
00078       return StatusCode::FAILURE;
00079     }
00080     else{
00081       hltdigi = (*pHltDigi)->getIntChannel();
00082       if(HltID::is_eventtype(id))         event_filter[0]=hltdigi;
00083       else if(HltID::is_version(id))      event_filter[2]=hltdigi;
00084       else if(HltID::is_energy(id))  event_filter[3]=hltdigi;
00085       else                                m_buf[size++] = hltdigi;
00086     }
00087     //cout << " debug by fucd: digi="<< hex << hltdigi << dec <<endl;
00088   }
00089 
00090   re->event_filter_info(&event_filter[0]);
00091   append2event(re, 0x7c0000, size);
00092 
00093   return StatusCode::SUCCESS;
00094 }
00095 
00096 // initialize re2te tables
00097 
00098 StatusCode  HltBuilder::initialize(string& initFile)
00099 {
00100   ifstream f;
00101  
00102   //-----------------------------------------------------------
00103   // read initFile
00104   f.open( initFile.c_str());
00105   
00106   if( f.bad() )
00107   {
00108      cerr << "Error: could not open file " << initFile << endl;
00109      return false;
00110   }
00111 
00112   if (!Builder::find( f, "##HltRawConf", initFile)) {
00113     cerr << "Error: could not find '##HltRawConf' in file " << initFile << endl;
00114     return StatusCode::FAILURE;
00115   }
00116 
00117   if( !Builder::expect( f, "#Index,mask", initFile) ||  
00118       !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||   
00119       !Builder::expectInt( f, "alg", initFile, m_algIndex, m_algMask) ||
00120       !Builder::expectInt( f, "cri", initFile, m_criIndex, m_criMask) ||
00121       !Builder::expectInt( f, "var", initFile, m_varIndex, m_varMask))   
00122     return false; 
00123   f.close();
00124   
00125   cout<<"HltBuilder::   #Index      mask"<<endl
00126       <<"            "<<m_idIndex<<"   "<<m_idMask<<endl
00127       <<"            "<<m_algIndex<<"   "<<m_algMask<<endl
00128       <<"            "<<m_criIndex<<"   "<<m_criMask<<endl
00129       <<"            "<<m_varIndex<<"   "<<m_varMask<<endl;
00130 
00131   //-----------------------------------------------------------
00132   //Build re2te table
00133   for (uint32_t i = 0; i < 256; i++) {
00134      m_re2te[i] = (0x50000000 | i);  //m_re2te[i]=0x50000000+0x00000000+i;
00135      //if(i>4) m_re2te[i]+=0x00000000;
00136      m_te2reMap.insert(TE2REMAP::value_type(m_re2te[i], i)) ; 
00137   }
00138   // return successful initialization
00139   return StatusCode::SUCCESS;
00140 }
00141 
00142 
00143 uint32_t HltBuilder::getREID(uint32_t teid)
00144 {
00145  
00146   TE2REMAP::iterator itr = m_te2reMap.find(teid);
00147  
00148   uint32_t reid = 0;
00149   if(itr!= m_te2reMap.end())
00150      reid = (*itr).second;
00151   else
00152   {
00153       cout<<"wrong teid in emc "<<teid<<endl;
00154       exit(8);
00155   }
00156  
00157   return  reid;
00158  
00159 }
00160 

Generated on Tue Nov 29 22:58:32 2016 for BOSS_7.0.2 by  doxygen 1.4.7