#include <CalibFormats/SiPixelObjects/interface/PixelFEDConfig.h>
Public Member Functions | |
unsigned int | crateFromFEDNumber (unsigned int fednumber) const |
unsigned int | FEDNumberFromCrateAndVMEBaseAddress (unsigned int crate, unsigned int vmebaseaddress) const |
unsigned int | getCrate (unsigned int i) const |
unsigned int | getFEDNumber (unsigned int i) const |
unsigned int | getNFEDBoards () const |
unsigned int | getVMEBaseAddress (unsigned int i) const |
PixelFEDConfig (std::vector< std::vector< std::string > > &tableMat) | |
PixelFEDConfig (std::string filename) | |
unsigned int | VMEBaseAddressFromFEDNumber (unsigned int fednumber) const |
virtual void | writeASCII (std::string dir) const |
virtual void | writeXML (std::ofstream *out) const |
void | writeXML (pos::PixelConfigKey key, int version, std::string path) const |
virtual void | writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const |
virtual void | writeXMLTrailer (std::ofstream *out) const |
virtual | ~PixelFEDConfig () |
Private Attributes | |
std::vector< PixelFEDParameters > | fedconfig_ |
" "
This class specifies which FED boards are used and how they are addressed
Definition at line 27 of file PixelFEDConfig.h.
PixelFEDConfig::PixelFEDConfig | ( | std::string | filename | ) |
Definition at line 107 of file PixelFEDConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, dummy, lat::endl(), fedconfig_, in, pos::PixelFEDParameters::setFEDParameters(), and tmp.
00107 : 00108 PixelConfigBase(" "," "," "){ 00109 00110 std::ifstream in(filename.c_str()); 00111 00112 if (!in.good()){ 00113 std::cout << "Could not open:"<<filename.c_str()<<std::endl; 00114 assert(0); 00115 } 00116 else { 00117 std::cout << "Opened:"<<filename.c_str()<<std::endl; 00118 } 00119 00120 std::string dummy; 00121 00122 in >> dummy; 00123 in >> dummy; 00124 in >> dummy; 00125 in >> dummy; 00126 in >> dummy; 00127 in >> dummy; 00128 00129 do { 00130 00131 unsigned int fednumber; 00132 unsigned int crate; 00133 unsigned int vme_base_address; 00134 00135 in >> fednumber >> crate >> std::hex >> vme_base_address >> std::dec; 00136 00137 if (!in.eof() ){ 00138 // std::cout << std::dec << fednumber <<" "<< crate << " 0x" 00139 // << std::hex << vme_base_address<<std::dec<<std::endl; 00140 PixelFEDParameters tmp; 00141 00142 tmp.setFEDParameters(fednumber , crate , vme_base_address); 00143 00144 fedconfig_.push_back(tmp); 00145 } 00146 00147 } 00148 while (!in.eof()); 00149 in.close(); 00150 00151 }
PixelFEDConfig::PixelFEDConfig | ( | std::vector< std::vector< std::string > > & | tableMat | ) |
Definition at line 16 of file PixelFEDConfig.cc.
References c, TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedconfig_, getFEDNumber(), int, n, r, pos::PixelFEDParameters::setFEDParameters(), tmp, x, and y.
00016 : PixelConfigBase(" "," "," "){ 00017 std::vector< std::string > ins = tableMat[0]; 00018 std::map<std::string , int > colM; 00019 std::vector<std::string > colNames; 00020 colNames.push_back("PIXEL_FED" ); //0 00021 colNames.push_back("CRATE_NUMBER" ); //1 00022 colNames.push_back("VME_ADDRS_HEX"); //2 00023 00024 for(unsigned int c = 0 ; c < tableMat[0].size() ; c++) 00025 { 00026 for(unsigned int n=0; n<colNames.size(); n++) 00027 { 00028 if(tableMat[0][c] == colNames[n]) 00029 { 00030 colM[colNames[n]] = c; 00031 break; 00032 } 00033 } 00034 }//end for 00035 for(unsigned int n=0; n<colNames.size(); n++) 00036 { 00037 if(colM.find(colNames[n]) == colM.end()) 00038 { 00039 std::cerr << "[PixelFECConfig::PixelFECConfig()]\tCouldn't find in the database the column with name " << colNames[n] << std::endl; 00040 assert(0); 00041 } 00042 } 00043 00044 std::string fedname = ""; 00045 unsigned int fednum = 0; 00046 fedconfig_.clear(); 00047 bool flag = false; 00048 for(unsigned int r = 1 ; r < tableMat.size() ; r++){ //Goes to every row of the Matrix 00049 00050 fedname = tableMat[r][colM["PIXEL_FED"]]; //This is not going to work if you change in the database "PxlFed_#" in the FED column.Im removing "PlxFed_" and store the number 00051 //becuase the PixelFecConfig class ask for the fec number not the name. 00052 // 01234567 00053 // PxlFED_XX 00054 fedname.erase(0,7); 00055 fednum = (unsigned int)atoi(fedname.c_str()) ; 00056 00057 if(fedconfig_.empty()) 00058 { 00059 PixelFEDParameters tmp; 00060 unsigned int vme_base_address = 0 ; 00061 string hexVMEAddr = tableMat[r][colM["VME_ADDRS_HEX"]] ; 00062 sscanf(hexVMEAddr.c_str(), "%x", &vme_base_address) ; 00063 tmp.setFEDParameters( fednum, (unsigned int)atoi(tableMat[r][colM["CRATE_NUMBER"]].c_str()) , 00064 vme_base_address); 00065 fedconfig_.push_back(tmp); 00066 } 00067 else 00068 { 00069 for( unsigned int y = 0; y < fedconfig_.size() ; y++) 00070 { 00071 if (fedconfig_[y].getFEDNumber() == fednum) // This is to check if there are Pixel Feds already in the vector because 00072 { // in the view of the database that I'm reading there are many repeated entries (AS FAR AS THESE PARAMS ARE CONCERNED). 00073 flag = true; // This ensure that there are no objects in the fedconfig vector with repeated values. 00074 break; 00075 } 00076 else flag = false; 00077 } 00078 00079 if(flag == false) 00080 { 00081 PixelFEDParameters tmp; 00082 tmp.setFEDParameters( fednum, (unsigned int)atoi(tableMat[r][colM["CRATE_NUMBER"]].c_str()) , 00083 (unsigned int)atoi(tableMat[r][colM["VME_ADDRS_HEX"]].c_str())); 00084 fedconfig_.push_back(tmp); 00085 } 00086 }//end else 00087 }//end for r 00088 00089 std::cout<<std::endl; 00090 00091 for( unsigned int x = 0 ; x < fedconfig_.size() ; x++) 00092 { 00093 std::cout<<fedconfig_[x]<<std::endl; 00094 } 00095 00096 std::cout<<fedconfig_.size()<<std::endl; 00097 00098 }//end Constructor
PixelFEDConfig::~PixelFEDConfig | ( | ) | [virtual] |
Definition at line 215 of file PixelFEDConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedconfig_, getCrate(), getFEDNumber(), and i.
Referenced by pos::PixelCalibConfiguration::fedCardsAndChannels(), and pos::PixelCalibConfiguration::getFEDCrates().
00215 { 00216 00217 for(unsigned int i=0;i<fedconfig_.size();i++){ 00218 if (fedconfig_[i].getFEDNumber()==fednumber) return fedconfig_[i].getCrate(); 00219 } 00220 00221 std::cout << "Could not find FED number:"<<fednumber<<std::endl; 00222 00223 assert(0); 00224 00225 return 0; 00226 00227 }
unsigned int PixelFEDConfig::FEDNumberFromCrateAndVMEBaseAddress | ( | unsigned int | crate, | |
unsigned int | vmebaseaddress | |||
) | const |
Definition at line 244 of file PixelFEDConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedconfig_, getCrate(), getFEDNumber(), and i.
00244 { 00245 00246 for(unsigned int i=0;i<fedconfig_.size();i++){ 00247 if (fedconfig_[i].getCrate()==crate&& 00248 fedconfig_[i].getVMEBaseAddress()==vmebaseaddress) return fedconfig_[i].getFEDNumber(); 00249 } 00250 00251 std::cout << "Could not find FED crate and address:"<<crate<<", "<<vmebaseaddress<<std::endl; 00252 00253 assert(0); 00254 00255 return 0; 00256 00257 }
Definition at line 199 of file PixelFEDConfig.cc.
References fedconfig_.
Referenced by crateFromFEDNumber(), and FEDNumberFromCrateAndVMEBaseAddress().
00199 { 00200 00201 assert(i<fedconfig_.size()); 00202 return fedconfig_[i].getCrate(); 00203 00204 }
Definition at line 191 of file PixelFEDConfig.cc.
References fedconfig_.
Referenced by crateFromFEDNumber(), FEDNumberFromCrateAndVMEBaseAddress(), PixelFEDConfig(), and VMEBaseAddressFromFEDNumber().
00191 { 00192 00193 assert(i<fedconfig_.size()); 00194 return fedconfig_[i].getFEDNumber(); 00195 00196 }
unsigned int PixelFEDConfig::getNFEDBoards | ( | ) | const |
Definition at line 185 of file PixelFEDConfig.cc.
References fedconfig_.
00185 { 00186 00187 return fedconfig_.size(); 00188 00189 }
Definition at line 207 of file PixelFEDConfig.cc.
References fedconfig_.
Referenced by VMEBaseAddressFromFEDNumber().
00207 { 00208 00209 assert(i<fedconfig_.size()); 00210 return fedconfig_[i].getVMEBaseAddress(); 00211 00212 }
Definition at line 230 of file PixelFEDConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedconfig_, getFEDNumber(), getVMEBaseAddress(), and i.
00230 { 00231 00232 for(unsigned int i=0;i<fedconfig_.size();i++){ 00233 if (fedconfig_[i].getFEDNumber()==fednumber) return fedconfig_[i].getVMEBaseAddress(); 00234 } 00235 00236 std::cout << "Could not find FED number:"<<fednumber<<std::endl; 00237 00238 assert(0); 00239 00240 return 0; 00241 00242 }
void PixelFEDConfig::writeASCII | ( | std::string | dir | ) | const [virtual] |
Implements pos::PixelConfigBase.
Definition at line 164 of file PixelFEDConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedconfig_, EgammaValidation_cff::filename, i, and out.
00164 { 00165 00166 if (dir!="") dir+="/"; 00167 string filename=dir+"fedconfig.dat"; 00168 00169 ofstream out(filename.c_str()); 00170 if(!out.good()){ 00171 cout << "Could not open file:"<<filename<<endl; 00172 assert(0); 00173 } 00174 00175 out <<" #FED number crate vme base address" <<endl; 00176 for(unsigned int i=0;i<fedconfig_.size();i++){ 00177 out << fedconfig_[i].getFEDNumber()<<" " 00178 << fedconfig_[i].getCrate()<<" " 00179 << "0x"<<hex<<fedconfig_[i].getVMEBaseAddress()<<dec<<endl; 00180 } 00181 out.close(); 00182 }
virtual void pos::PixelFEDConfig::writeXML | ( | std::ofstream * | out | ) | const [inline, virtual] |
void pos::PixelFEDConfig::writeXML | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path | |||
) | const [inline, virtual] |
virtual void pos::PixelFEDConfig::writeXMLHeader | ( | pos::PixelConfigKey | key, | |
int | version, | |||
std::string | path, | |||
std::ofstream * | out | |||
) | const [inline, virtual] |
virtual void pos::PixelFEDConfig::writeXMLTrailer | ( | std::ofstream * | out | ) | const [inline, virtual] |
std::vector< PixelFEDParameters > pos::PixelFEDConfig::fedconfig_ [private] |
Definition at line 63 of file PixelFEDConfig.h.
Referenced by crateFromFEDNumber(), FEDNumberFromCrateAndVMEBaseAddress(), getCrate(), getFEDNumber(), getNFEDBoards(), getVMEBaseAddress(), PixelFEDConfig(), VMEBaseAddressFromFEDNumber(), and writeASCII().