CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

pos::PixelFECConfig Class Reference

This class specifies which FEC boards are used and how they are addressed. More...

#include <PixelFECConfig.h>

Inheritance diagram for pos::PixelFECConfig:
pos::PixelConfigBase

List of all members.

Public Member Functions

unsigned int crateFromFECNumber (unsigned int fecnumber) const
unsigned int FECSlotFromFECNumber (unsigned int fecnumber)
unsigned int getCrate (unsigned int i) const
unsigned int getFECNumber (unsigned int i) const
unsigned int getFECSlot (unsigned int i)
unsigned int getNFECBoards () const
unsigned int getVMEBaseAddress (unsigned int i) const
 PixelFECConfig (std::vector< std::vector< std::string > > &tableMat)
 PixelFECConfig (std::string filename)
unsigned int VMEBaseAddressFromFECNumber (unsigned int fecnumber) const
void writeASCII (std::string dir="") const
void writeXML (pos::PixelConfigKey key, int version, std::string path) const
virtual void writeXML (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const

Private Member Functions

unsigned int FECSlotFromVMEBaseAddress (unsigned int VMEBaseAddress)

Private Attributes

std::vector< PixelFECParametersfecconfig_

Detailed Description

This class specifies which FEC boards are used and how they are addressed.

" "

Definition at line 24 of file PixelFECConfig.h.


Constructor & Destructor Documentation

PixelFECConfig::PixelFECConfig ( std::string  filename)

Definition at line 96 of file PixelFECConfig.cc.

References gather_cfg::cout, fecconfig_, recoMuon::in, pos::PixelFECParameters::setFECParameters(), and tmp.

                                                :
    PixelConfigBase(" "," "," "){

    std::string mthn = "[[PixelFECConfig::PixelFECConfig()]\t\t\t   " ;
    
    std::ifstream in(filename.c_str());

    if (!in.good()){
        std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
        throw std::runtime_error("Failed to open file "+filename);
    }
    else {
        std::cout << __LINE__ << "]\t" << mthn <<" Opened: "         << filename << std::endl;
    }

    std::string dummy;

    in >> dummy;
    in >> dummy;
    in >> dummy;
    in >> dummy;
    in >> dummy;
    in >> dummy;

    do {
        
        unsigned int fecnumber;
        unsigned int crate;
        unsigned int vme_base_address;

        in >> fecnumber >> crate >> std::hex>> vme_base_address >>std::dec ;

        if (!in.eof() ){
            //std::cout << __LINE__ << "]\t" << mthn << fecnumber <<" "<< crate << " "  
            //      << std::hex << vme_base_address<<std::dec<<std::endl;
            
            PixelFECParameters tmp;
            
            tmp.setFECParameters(fecnumber , crate , vme_base_address);
            
            fecconfig_.push_back(tmp);
        }

    }
    while (!in.eof());
    in.close();
}
PixelFECConfig::PixelFECConfig ( std::vector< std::vector< std::string > > &  tableMat)

EXTENSION_TABLE_NAME: (VIEW: )

CONFIG_KEY NOT NULL VARCHAR2(80) KEY_TYPE NOT NULL VARCHAR2(80) KEY_ALIAS NOT NULL VARCHAR2(80) VERSION VARCHAR2(40) KIND_OF_COND NOT NULL VARCHAR2(40) PIXFEC_NAME NOT NULL VARCHAR2(200) CRATE_NUMBER NOT NULL NUMBER(38) SLOT_NUMBER NUMBER(38) VME_ADDR NOT NULL VARCHAR2(200)

Definition at line 20 of file PixelFECConfig.cc.

References trackerHits::c, fecconfig_, n, csvReporter::r, and tmp.

                                                                          : PixelConfigBase(" "," "," "){

 std::map<std::string , int > colM;
 std::vector<std::string > colNames;
 colNames.push_back("CONFIG_KEY"   );       
 colNames.push_back("KEY_TYPE"     );       
 colNames.push_back("KEY_ALIAS"    );       
 colNames.push_back("VERSION"      );       
 colNames.push_back("KIND_OF_COND" ); 
 colNames.push_back("PIXFEC_NAME"  ); 
 colNames.push_back("CRATE_NUMBER" ); 
 colNames.push_back("SLOT_NUMBER"  ); 
 colNames.push_back("VME_ADDR"     );       

 for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
   {
     for(unsigned int n=0; n<colNames.size(); n++)
       {
         if(tableMat[0][c] == colNames[n]){
           colM[colNames[n]] = c;
           break;
         }
       }
   }//end for
 /*
 for(unsigned int n=0; n<colNames.size(); n++)
   {
     if(colM.find(colNames[n]) == colM.end()){
       std::cerr << "[PixelFECConfig::PixelFECConfig()]\tCouldn't find in the database the column with name " << colNames[n] << std::endl;
       assert(0);
     }
   }
 */

 fecconfig_.clear();
 for(unsigned int r = 1 ; r < tableMat.size() ; r++)    //Goes to every row of the Matrix
   {
     unsigned int fecnumber;
     unsigned int crate;
     unsigned int vme_base_address;
     
//      01234567890123
//      BPix_Pxl_FEC_1
//     string fullFECName = tableMat[r][colM["PIXEL_FEC"]] ;
//     fullFECName.replace(0,13,"") ;
     fecnumber = atoi(tableMat[r][colM["PIXFEC_NAME"]].c_str()) ;
     crate     = atoi(tableMat[r][colM["CRATE_NUMBER"]].c_str()) ;
     string hexVMEAddr = tableMat[r][colM["VME_ADDR"]] ;
     sscanf(hexVMEAddr.c_str(), "%x", &vme_base_address) ;
     PixelFECParameters tmp;
     
     tmp.setFECParameters(fecnumber , crate , vme_base_address);
     
     fecconfig_.push_back(tmp);
   }
 
}// end contructor

Member Function Documentation

unsigned int PixelFECConfig::crateFromFECNumber ( unsigned int  fecnumber) const

Definition at line 185 of file PixelFECConfig.cc.

References gather_cfg::cout, fecconfig_, getCrate(), getFECNumber(), and i.

Referenced by pos::PixelCalibConfiguration::getFECCrates().

                                                                           {

    std::string mthn = "[PixelFECConfig::crateFromFECNumber()]\t\t\t    " ;
    for(unsigned int i=0;i<fecconfig_.size();i++){
        if (fecconfig_[i].getFECNumber()==fecnumber) return fecconfig_[i].getCrate();
    }

    std::cout << __LINE__ << "]\t" << mthn << "Could not find FEC number: " << fecnumber << std::endl;

    assert(0);

    return 0;

}
unsigned int pos::PixelFECConfig::FECSlotFromFECNumber ( unsigned int  fecnumber) [inline]
unsigned int pos::PixelFECConfig::FECSlotFromVMEBaseAddress ( unsigned int  VMEBaseAddress) [inline, private]

Definition at line 64 of file PixelFECConfig.h.

Referenced by FECSlotFromFECNumber(), and getFECSlot().

{assert(VMEBaseAddress%0x8000000 == 0); return VMEBaseAddress/0x8000000;}
unsigned int PixelFECConfig::getCrate ( unsigned int  i) const

Definition at line 169 of file PixelFECConfig.cc.

References fecconfig_, and i.

Referenced by crateFromFECNumber().

                                                         {

    assert(i<fecconfig_.size());
    return fecconfig_[i].getCrate();

}
unsigned int PixelFECConfig::getFECNumber ( unsigned int  i) const

Definition at line 161 of file PixelFECConfig.cc.

References fecconfig_, and i.

Referenced by crateFromFECNumber(), and VMEBaseAddressFromFECNumber().

                                                             {

    assert(i<fecconfig_.size());
    return fecconfig_[i].getFECNumber();

}
unsigned int pos::PixelFECConfig::getFECSlot ( unsigned int  i) [inline]
unsigned int PixelFECConfig::getNFECBoards ( ) const

Definition at line 155 of file PixelFECConfig.cc.

References fecconfig_.

                                                {

    return fecconfig_.size();

}
unsigned int PixelFECConfig::getVMEBaseAddress ( unsigned int  i) const

Definition at line 177 of file PixelFECConfig.cc.

References fecconfig_, and i.

Referenced by getFECSlot(), and VMEBaseAddressFromFECNumber().

                                                                  {

    assert(i<fecconfig_.size());
    return fecconfig_[i].getVMEBaseAddress();

}
unsigned int PixelFECConfig::VMEBaseAddressFromFECNumber ( unsigned int  fecnumber) const

Definition at line 200 of file PixelFECConfig.cc.

References gather_cfg::cout, fecconfig_, getFECNumber(), getVMEBaseAddress(), and i.

Referenced by FECSlotFromFECNumber().

                                                                                    {

    std::string mthn = "[PixelFECConfig::VMEBaseAddressFromFECNumber()]\t\t    " ;
    for(unsigned int i=0;i<fecconfig_.size();i++){
        if (fecconfig_[i].getFECNumber()==fecnumber) return fecconfig_[i].getVMEBaseAddress();
    }

    std::cout << __LINE__ << "]\t" << mthn << "Could not find FEC number: " << fecnumber << std::endl;

    assert(0);

    return 0;

}
void PixelFECConfig::writeASCII ( std::string  dir = "") const [virtual]

Implements pos::PixelConfigBase.

Definition at line 216 of file PixelFECConfig.cc.

References fecconfig_, lut2db_cfg::filename, i, and dbtoconf::out.

                                                   {

  if (dir!="") dir+="/";
  std::string filename=dir+"fecconfig.dat";
  std::ofstream out(filename.c_str());

  std::vector< PixelFECParameters >::const_iterator i=fecconfig_.begin();

  out << "#FEC number     crate     vme base address" << endl;
  for(;i!=fecconfig_.end();++i){
    out << i->getFECNumber()<<"               "
        << i->getCrate()<<"         "
        << "0x"<<hex<<i->getVMEBaseAddress()<<dec<<endl;
  }

}
void pos::PixelFECConfig::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const [inline, virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 43 of file PixelFECConfig.h.

{;}
void PixelFECConfig::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 274 of file PixelFECConfig.cc.

References fecconfig_, and i.

{
  std::string mthn = "[PixelFECConfig::writeXML()]\t\t\t    " ;

  std::vector< PixelFECParameters >::const_iterator i=fecconfig_.begin();

  for(;i!=fecconfig_.end();++i){
   *outstream << ""                                                                                          << endl ;
   *outstream << "  <DATA>"                                                                                  << endl ;
   *outstream << "   <PIXFEC_NAME>"            << i->getFECNumber()             << "</PIXFEC_NAME>"          << endl ;
   *outstream << "   <CRATE_NUMBER>"           << i->getCrate()                 << "</CRATE_NUMBER>"         << endl ;
   *outstream << "   <VME_ADDR>0x" << hex << i->getVMEBaseAddress() << dec      << "</VME_ADDR>"             << endl ;
   *outstream << "  </DATA>"                                                                                 << endl ;
  }
}
void PixelFECConfig::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 234 of file PixelFECConfig.cc.

References gather_cfg::cout, pos::PixelConfigBase::getAuthor(), pos::PixelConfigBase::getComment(), pos::PixelTimeFormatter::getmSecTime(), and edm::service::getTime().

{
  std::string mthn = "[PixelFECConfig::writeXMLHeader()]\t\t\t    " ;
  std::stringstream fullPath ;
  fullPath << path << "/Pixel_PixelFecParameters_" << PixelTimeFormatter::getmSecTime() << ".xml" ;
  cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << endl ;
  
  outstream->open(fullPath.str().c_str()) ;
  
  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>"                                    << endl ;
  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>"                               << endl ;
  *outstream << " <HEADER>"                                                                                  << endl ;
  *outstream << "  <TYPE>"                                                                                   << endl ;
  *outstream << "   <EXTENSION_TABLE_NAME>PIXEL_FEC_PARAMETERS</EXTENSION_TABLE_NAME>"                       << endl ;
  *outstream << "   <NAME>Pixel FEC Parameters</NAME>"                                                       << endl ;
  *outstream << "  </TYPE>"                                                                                  << endl ;
  *outstream << "  <RUN>"                                                                                    << endl ;
  *outstream << "   <RUN_TYPE>Pixel FEC Parameters</RUN_TYPE>"                                               << endl ;
  *outstream << "   <RUN_NUMBER>1</RUN_NUMBER>"                                                              << endl ;
  *outstream << "   <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << endl ;
  *outstream << "   <LOCATION>CERN P5</LOCATION>"                                                            << endl ; 
  *outstream << "  </RUN>"                                                                                   << endl ;
  *outstream << " </HEADER>"                                                                                 << endl ;
  *outstream << ""                                                                                           << endl ;
  *outstream << " <DATA_SET>"                                                                                << endl ;
  *outstream << "  <PART>"                                                                                   << endl ;
  *outstream << "   <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>"                                                 << endl ;
  *outstream << "   <KIND_OF_PART>Detector ROOT</KIND_OF_PART>"                                              << endl ;
  *outstream << "  </PART>"                                                                                  << endl ;
  *outstream << "  <VERSION>"             << version      << "</VERSION>"                                    << endl ;
  *outstream << "  <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>"                        << endl ;
  *outstream << "  <CREATED_BY_USER>"     << getAuthor()  << "</CREATED_BY_USER>"                            << endl ;
}
void PixelFECConfig::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 293 of file PixelFECConfig.cc.

{
  std::string mthn = "[PixelFECConfig::writeXMLTrailer()]\t\t\t    " ;
  
  *outstream << ""                                                                                           << endl ;
  *outstream << " </DATA_SET>"                                                                               << endl ;
  *outstream << "</ROOT> "                                                                                   << endl ;

  outstream->close() ;
}

Member Data Documentation