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

Go to the documentation of this file.
00001 #include "GaudiKernel/Bootstrap.h"
00002 #include "GaudiKernel/ISvcLocator.h"
00003 #include "GaudiKernel/IJobOptionsSvc.h"
00004 #include "Identifier/MucID.h" 
00005 #include "RawDataCnv/EventManagement/MucBuilder.h"
00006 
00007 using namespace std;
00008 
00009 MucBuilder::MucBuilder()
00010   :Builder()
00011 {
00012   if (!m_fec2idFile.empty()) return;
00013   m_propMgr.declareProperty("Fec2IdMap", m_fec2idFile);
00014 
00015   // Get a pointer to the Job Options Service
00016   IJobOptionsSvc* jobSvc;
00017   Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
00018   jobSvc->setMyProperties("MucBuilder", &m_propMgr);
00019 
00020   m_re2te = new uint32_t[1024];
00021   strSqcVec = new uint32_t[1024];
00022   memset((void*)m_re2te, 0xFF, 1024*sizeof(uint32_t));
00023   memset((void*)strSqcVec, 0, 1024*sizeof(uint32_t));
00024 
00025   initialize (m_fec2idFile);
00026 }
00027 
00028 MucBuilder::~MucBuilder()
00029 {
00030    delete m_re2te;
00031    delete strSqcVec;
00032 }
00033 
00034 void MucBuilder::unPack(uint32_t reDigi, uint32_t& REId, uint32_t& FecData, uint32_t& StrSqc)
00035 {
00036   uint32_t fecAddr = (reDigi&0xFFFF0000) >> 16;
00037   uint32_t module = (fecAddr&0xF800) >> 5;
00038   REId = (fecAddr&0x07FF) | module;
00039   FecData = reDigi&0xFFFF;
00040   StrSqc = strSqcVec[REId];
00041   return;
00042 }
00043 
00044 StatusCode MucBuilder::pack(MucDigiCol* digiCol, WriteRawEvent*& re)
00045 {
00046   if (digiCol == 0 ) {
00047     cerr << "MdcBuilder::pack can't get digiCol" << endl;
00048     return StatusCode::FAILURE;
00049   }
00050 
00051   uint32_t size = 0, index;
00052   uint32_t teid, reid, channel;
00053 
00054   MucDigiCol::const_iterator pMucDigi = digiCol->begin();
00055   for (pMucDigi; pMucDigi!= digiCol->end(); pMucDigi++) {
00056     teid = (*pMucDigi)->getIntId();
00057     reid = getREID(teid&0xFFFFFFF0);
00058     channel = (strSqcVec[reid] == 0) ? (0x8000>>(teid&0xF)) : (0x1<<(teid&0xF));
00059     // set the value if the current reid has been in the buffer
00060     for (index = 0; index < size; index++) {
00061       if ((m_buf[index]>>16) == reid) {
00062         m_buf[index] |= channel;
00063         break;
00064       }
00065     }
00066     // otherwise, append the current reid and value to the buffer
00067     if (index == size) m_buf[size++] = ((reid << 16) | (channel));
00068   }
00069 
00070   append2event(re, 0xa40000, size);
00071 
00072   return StatusCode::SUCCESS;
00073 }
00074 
00075 // initialize re2te tables
00076 StatusCode  MucBuilder::initialize(string& fec2idFile)
00077 {
00078   ifstream fs(fec2idFile.c_str());
00079   if( fs.bad() ) {
00080      cerr << "Error: could not open file " << fec2idFile << endl;
00081      return false;
00082   }
00083 
00084   fs.ignore(256, '\n');
00085 
00086   int fec, part, seg, layer, firstStr, strSqc;
00087 
00088   for (int i = 0; i < 572; i++) {
00089     fs >> fec >> part >> seg >> layer >> firstStr >> strSqc;
00090     // reid ... teid
00091     uint32_t reid = fec;  // ?
00092     uint32_t teid = MucID::getIntID(part, seg, layer, firstStr);
00093     //if (strSqc < 0) teid |= 0x00F00000;  // local teid
00094 
00095     m_re2te[reid] = teid;
00096     strSqcVec[reid] = strSqc + 1;
00097     m_te2reMap.insert(TE2REMAP::value_type(teid, reid));
00098     //cout << "teid " << teid << "  reid " << reid << "  strSqc " << strSqcVec[reid] << endl;
00099   }
00100 
00101   return StatusCode::SUCCESS;
00102 }
00103 
00104 uint32_t MucBuilder::getREID(uint32_t teid)
00105 {
00106   TE2REMAP::iterator itr = m_te2reMap.find(teid);
00107  
00108   if (itr == m_te2reMap.end()) {
00109       cout << "wrong teid in muc " << teid << endl;
00110       exit(8);
00111   }
00112 
00113   return itr->second;
00114 }
00115 

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