Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EmcBuilder Class Reference

#include <EmcBuilder.h>

Inheritance diagram for EmcBuilder:

Builder Builder List of all members.

Public Types

typedef std::map< uint32_t,
uint32_t > 
TE2REMAP
typedef std::map< uint32_t,
uint32_t > 
TE2REMAP

Public Member Functions

 EmcBuilder ()
 EmcBuilder ()
uint32_t getREID (uint32_t teid)
uint32_t getREID (uint32_t teid)
uint32_t getTEID (uint32_t reid)
uint32_t getTEID (uint32_t reid)
StatusCode initialize (string &initFile)
StatusCode initialize (string &initFile)
StatusCode pack (EmcDigiCol *digiCol, WriteRawEvent *&re)
StatusCode pack (EmcDigiCol *digiCol, WriteRawEvent *&re)
void unPack (uint32_t reDigi, uint32_t &REId, uint32_t &TETDC, uint32_t &TEADC, uint32_t &measure)
void unPack (uint32_t reDigi, uint32_t &REId, uint32_t &TETDC, uint32_t &TEADC, uint32_t &measure)
virtual ~EmcBuilder ()
virtual ~EmcBuilder ()

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_adcIndex
uint32_t m_adcMask
uint32_t m_idIndex
uint32_t m_idMask
uint32_t m_measureIndex
uint32_t m_measureMask
uint32_t m_overflowIndex
uint32_t m_overflowMask
PropertyMgr m_propMgr
uint32_t * m_re2te
uint32_t * m_re2te
uint32_t m_tdcIndex
uint32_t m_tdcMask
TE2REMAP m_te2reMap
uint32_t m_TQIndex
uint32_t m_TQMask

Member Typedef Documentation

typedef std::map<uint32_t, uint32_t> Builder::TE2REMAP [inherited]
 

typedef std::map<uint32_t, uint32_t> Builder::TE2REMAP [inherited]
 


Constructor & Destructor Documentation

EmcBuilder::EmcBuilder  ) 
 

00008   :Builder()
00009 {
00010   // set vector size (2^13) and initialize to -1
00011   m_re2te = new uint32_t[8192];  // we have 2^14 different REID
00012   memset((void*)m_re2te, 0xFF, 8192*sizeof(uint32_t));
00013 
00014   initialize (Builder::m_confFile);
00015 }

EmcBuilder::~EmcBuilder  )  [virtual]
 

00018 {
00019    delete m_re2te;
00020 }

EmcBuilder::EmcBuilder  ) 
 

virtual EmcBuilder::~EmcBuilder  )  [virtual]
 


Member Function Documentation

void Builder::append2event WriteRawEvent *&  re,
uint32_t  source_id,
uint32_t  size
[protected, inherited]
 

void Builder::append2event WriteRawEvent *&  re,
uint32_t  source_id,
uint32_t  size
[protected, inherited]
 

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 }

bool Builder::expect ifstream f,
string  msg,
string  fname
[static, inherited]
 

bool Builder::expect ifstream f,
string  msg,
string  fname
[static, inherited]
 

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]
 

bool Builder::expectInt ifstream f,
string  msg,
string  fname,
uint32_t &  val1,
uint32_t &  val2
[static, inherited]
 

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]
 

bool Builder::expectLong ifstream f,
string  msg,
string  fname,
uint64_t &  val
[static, inherited]
 

00053 {
00054   if ( !expect(f, msg, fname) || f.bad() )
00055     return false;
00056   f >> val;
00057   return true;
00058 }

bool Builder::find ifstream f,
string  msg,
string  fname
[static, inherited]
 

bool Builder::find ifstream f,
string  msg,
string  fname
[static, inherited]
 

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 EmcBuilder::getREID uint32_t  teid  )  [virtual]
 

Implements Builder.

uint32_t EmcBuilder::getREID uint32_t  teid  )  [virtual]
 

Implements Builder.

00183 {
00184   TE2REMAP::iterator itr = m_te2reMap.find(teid);
00185  
00186   if (itr == m_te2reMap.end()) {
00187       cout<<"wrong teid in emc "<<teid<<endl;
00188       exit(8);
00189   }
00190 
00191   return itr->second;
00192 }

uint32_t EmcBuilder::getTEID uint32_t  reid  )  [inline, virtual]
 

Implements Builder.

00016 { return m_re2te[reid]; }

uint32_t EmcBuilder::getTEID uint32_t  reid  )  [inline, virtual]
 

Implements Builder.

00016 { return m_re2te[reid]; }

StatusCode EmcBuilder::initialize string &  initFile  )  [virtual]
 

Reimplemented from Builder.

StatusCode EmcBuilder::initialize string &  initFile  )  [virtual]
 

Reimplemented from Builder.

00069 {
00070   ifstream f;
00071 
00072   uint32_t nREThetaPos, nREPhiPos, nREEaWePos;
00073   uint32_t nREThetaMask, nREPhiMask, nREEaWeMask;
00074   
00075   //-----------------------------------------------------------
00076   // read initFile
00077   f.open( initFile.c_str());
00078   
00079   if( f.bad() )
00080   {
00081      cerr << "Error: could not open file " << initFile << endl;
00082      return false;
00083   }
00084 
00085   if (!Builder::find( f, "##EmcDigiConf", initFile)) {
00086     cerr << "Error: could not find '##EmcDigiConf' in file " << initFile << endl;
00087     return StatusCode::FAILURE;
00088   }
00089 
00090   if( !Builder::expect( f, "#Index,mask", initFile) ||  
00091       !Builder::expectInt( f, "id", initFile, m_idIndex, m_idMask) ||   
00092       !Builder::expectInt( f, "tdc", initFile, m_tdcIndex, m_tdcMask) ||   
00093       !Builder::expectInt( f, "measure", initFile, m_measureIndex, m_measureMask) ||   
00094       !Builder::expectInt( f, "adc", initFile, m_adcIndex, m_adcMask) ||   
00095       !Builder::expectInt( f, "Phi", initFile, nREPhiPos, nREPhiMask) ||  
00096       !Builder::expectInt( f, "Theta", initFile, nREThetaPos, nREThetaMask) ||
00097       !Builder::expectInt( f, "EaWe", initFile, nREEaWePos, nREEaWeMask))
00098     return false; 
00099  
00100   
00101   f.close();
00102 
00103   //-----------------------------------------------------------
00104   //Build re2te table
00105   for(uint32_t  barrel_ec_eawe = EmcID::getBARREL_EC_MIN(); 
00106       barrel_ec_eawe <= EmcID::getBARREL_EC_MAX(); barrel_ec_eawe++)
00107   {
00108       uint32_t TEthetaMax, TEphiMax;
00109       uint32_t TEthetaMin, TEphiMin;
00110       uint32_t eawe, theta, phi;
00111       if(barrel_ec_eawe == EmcID::getBARREL())
00112       {
00113            //it is BARREL
00114            TEthetaMax = EmcID::getTHETA_BARREL_MAX();//43
00115            TEthetaMin = EmcID::getTHETA_BARREL_MIN();//0
00116       } else
00117       {
00118            //it is ease and west ENDCAP
00119            TEthetaMax = EmcID::getTHETA_ENDCAP_MAX();//5
00120            TEthetaMin = EmcID::getTHETA_ENDCAP_MIN();//0
00121            if (barrel_ec_eawe == EmcID::getBARREL_EC_MIN()) 
00122                eawe = 0;//east
00123            else
00124                eawe = 1;//west
00125       }
00126       for(uint32_t  TEtheta = TEthetaMin; TEtheta <= TEthetaMax; TEtheta++ )
00127       {
00128            if(barrel_ec_eawe == EmcID::getBARREL())
00129            {
00130                //it is BARREL
00131                if (TEtheta <= EmcID::getTHETA_BARREL_MAX()/2) 
00132                {
00133                   eawe = 0; //east
00134                   theta = EmcID::getTHETA_BARREL_MAX()/2 +1 - TEtheta; //0-21=>22-1
00135                }
00136                else {
00137                   eawe = 1; //west
00138                   theta = TEtheta - EmcID::getTHETA_BARREL_MAX()/2; //22-43=>1-22
00139                }
00140                TEphiMax = EmcID::getPHI_BARREL_MAX();//119
00141                TEphiMin = EmcID::getPHI_BARREL_MIN();//0
00142 
00143            } else
00144            {
00145                //it is ease and west ENDCAP
00146                theta = TEtheta + EmcID::getTHETA_BARREL_MAX()/2 + 2;
00147                TEphiMax = EmcID::getPHI_ENDCAP_MAX(TEtheta);//64,80,96
00148                TEphiMin = EmcID::getPHI_ENDCAP_MIN();
00149 
00150            }
00151 
00152            for(uint32_t TEphi = TEphiMin; TEphi <= TEphiMax; TEphi++ )
00153            {
00154              phi = TEphi + 1;
00155              //cout << "eawe" << hex << eawe <<endl;
00156              //cout << "__FILE__ theta " << theta << "phi " << phi << endl;
00157              uint32_t reid = ((eawe<<nREEaWePos)&nREEaWeMask)|
00158                ((theta<<nREThetaPos)&nREThetaMask)|
00159                ((phi<<nREPhiPos)&nREPhiMask);
00160              uint32_t teid = EmcID::getIntID(barrel_ec_eawe, TEtheta, TEphi);
00161              //cout << "barrel_ec_eawe" << barrel_ec_eawe <<endl;
00162              //cout << "TEtheta" << hex << TEtheta << endl;
00163              //cout << "TEphi" << hex << TEphi <<endl;
00164 
00165              if( reid >= 8192 )
00166              {
00167                cerr << "Error: REID overflow !" << reid << endl;
00168                exit(8);
00169              }
00170              //cout << "reid" << hex << reid << endl;
00171              //cout << "teid" << hex << teid << endl; 
00172              m_re2te[reid] = teid;
00173              m_te2reMap.insert(TE2REMAP::value_type(teid, reid)) ; 
00174            }
00175        }
00176     }
00177     // return successful initialization
00178     return StatusCode::SUCCESS;
00179 }

StatusCode EmcBuilder::pack EmcDigiCol digiCol,
WriteRawEvent *&  re
 

StatusCode EmcBuilder::pack EmcDigiCol digiCol,
WriteRawEvent *&  re
 

00034 {
00035   if (digiCol == 0 ) {
00036     cerr << "EmcBuilder::pack can't get digiCol" << endl;
00037     return StatusCode::FAILURE;
00038   }
00039 
00040   uint32_t size = 0;
00041   uint32_t teid = 0, tetdc = 0, teadc = 0, reid = 0, redigi = 0, measure = 0;
00042 
00043   EmcDigiCol::const_iterator pEmcDigi = digiCol->begin();
00044   for (pEmcDigi; pEmcDigi!= digiCol->end(); pEmcDigi++) {
00045     teid  = (*pEmcDigi)->getIntId();
00046     reid  = getREID(teid);
00047     tetdc = (*pEmcDigi)->getTimeChannel();
00048     teadc = (*pEmcDigi)->getChargeChannel();
00049     measure = (*pEmcDigi)->getMeasure();
00050 
00051     // if negative energy, don't record 
00052     if(teadc&0x80000000) continue;
00053     // set ...
00054     redigi = ((reid<<m_idIndex)&m_idMask)|
00055              ((tetdc<<m_tdcIndex)&m_tdcMask)|
00056              ((teadc<<m_adcIndex)&m_adcMask)|
00057              ((measure<<m_measureIndex)&m_measureMask);
00058     m_buf[size++] = redigi;
00059   }
00060 
00061   append2event(re, 0xa30000, size);
00062 
00063   return StatusCode::SUCCESS;
00064 }

void EmcBuilder::unPack uint32_t  reDigi,
uint32_t &  REId,
uint32_t &  TETDC,
uint32_t &  TEADC,
uint32_t &  measure
 

void EmcBuilder::unPack uint32_t  reDigi,
uint32_t &  REId,
uint32_t &  TETDC,
uint32_t &  TEADC,
uint32_t &  measure
 

00024 {
00025    REId = (reDigi&m_idMask) >> m_idIndex; 
00026    TETDC = (reDigi&m_tdcMask) >> m_tdcIndex; 
00027    TEADC = (reDigi&m_adcMask) >> m_adcIndex;
00028    measure = (reDigi&m_measureMask) >> m_measureIndex; 
00029 
00030    return;
00031 }


Member Data Documentation

uint32_t EmcBuilder::m_adcIndex [private]
 

uint32_t EmcBuilder::m_adcMask [private]
 

uint32_t* Builder::m_buf [protected, inherited]
 

uint32_t* Builder::m_buf [protected, inherited]
 

string Builder::m_confFile [static, protected, inherited]
 

uint32_t EmcBuilder::m_idIndex [private]
 

uint32_t EmcBuilder::m_idMask [private]
 

uint32_t EmcBuilder::m_measureIndex [private]
 

uint32_t EmcBuilder::m_measureMask [private]
 

uint32_t EmcBuilder::m_overflowIndex [private]
 

uint32_t EmcBuilder::m_overflowMask [private]
 

PropertyMgr EmcBuilder::m_propMgr [private]
 

Reimplemented from Builder.

uint32_t* EmcBuilder::m_re2te [private]
 

uint32_t* EmcBuilder::m_re2te [private]
 

uint32_t Builder::m_status [protected, inherited]
 

uint32_t EmcBuilder::m_tdcIndex [private]
 

uint32_t EmcBuilder::m_tdcMask [private]
 

TE2REMAP EmcBuilder::m_te2reMap [private]
 

uint32_t EmcBuilder::m_TQIndex [private]
 

uint32_t EmcBuilder::m_TQMask [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:01:10 2011 for BOSS6.5.5 by  doxygen 1.3.9.1