22 std::map<std::string , int > colM;
23 std::vector<std::string > colNames;
39 colNames.push_back(
"CONFIG_KEY" );
40 colNames.push_back(
"KEY_TYPE" );
41 colNames.push_back(
"KEY_ALIAS" );
42 colNames.push_back(
"VERSION" );
43 colNames.push_back(
"KIND_OF_COND" );
44 colNames.push_back(
"PIXFEC_NAME" );
45 colNames.push_back(
"CRATE_NUMBER" );
46 colNames.push_back(
"SLOT_NUMBER" );
47 colNames.push_back(
"VME_ADDR" );
49 for(
unsigned int c = 0 ;
c < tableMat[0].size() ;
c++)
51 for(
unsigned int n=0;
n<colNames.size();
n++)
53 if(tableMat[0][
c] == colNames[
n]){
54 colM[colNames[
n]] =
c;
70 for(
unsigned int r = 1 ;
r < tableMat.size() ;
r++)
72 unsigned int fecnumber;
74 unsigned int vme_base_address;
80 fecnumber = atoi(tableMat[
r][colM[
"PIXFEC_NAME"]].c_str()) ;
81 crate = atoi(tableMat[
r][colM[
"CRATE_NUMBER"]].c_str()) ;
82 string hexVMEAddr = tableMat[
r][colM[
"VME_ADDR"]] ;
83 sscanf(hexVMEAddr.c_str(),
"%x", &vme_base_address) ;
86 tmp.setFECParameters(fecnumber , crate , vme_base_address);
99 std::string mthn =
"[[PixelFECConfig::PixelFECConfig()]\t\t\t " ;
101 std::ifstream
in(filename.c_str());
104 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename << std::endl;
105 throw std::runtime_error(
"Failed to open file "+filename);
108 std::cout << __LINE__ <<
"]\t" << mthn <<
" Opened: " << filename << std::endl;
122 unsigned int fecnumber;
124 unsigned int vme_base_address;
126 in >> fecnumber >> crate >> std::hex>> vme_base_address >>std::dec ;
187 std::string mthn =
"[PixelFECConfig::crateFromFECNumber()]\t\t\t " ;
192 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FEC number: " << fecnumber << std::endl;
202 std::string mthn =
"[PixelFECConfig::VMEBaseAddressFromFECNumber()]\t\t " ;
207 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FEC number: " << fecnumber << std::endl;
218 if (dir!=
"") dir+=
"/";
220 std::ofstream
out(filename.c_str());
222 std::vector< PixelFECParameters >::const_iterator
i=
fecconfig_.begin();
224 out <<
"#FEC number crate vme base address" << endl;
226 out << i->getFECNumber()<<
" "
227 << i->getCrate()<<
" "
228 <<
"0x"<<hex<<i->getVMEBaseAddress()<<dec<<endl;
237 std::ofstream *outstream,
238 std::ofstream *out1stream,
239 std::ofstream *out2stream)
const
241 std::string mthn =
"[PixelFECConfig::writeXMLHeader()]\t\t\t " ;
242 std::stringstream fullPath ;
244 cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << fullPath.str() << endl ;
246 outstream->open(fullPath.str().c_str()) ;
248 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << endl ;
249 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << endl ;
250 *outstream <<
" <HEADER>" << endl ;
251 *outstream <<
" <TYPE>" << endl ;
252 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_FEC_PARAMETERS</EXTENSION_TABLE_NAME>" << endl ;
253 *outstream <<
" <NAME>Pixel FEC Parameters</NAME>" << endl ;
254 *outstream <<
" </TYPE>" << endl ;
255 *outstream <<
" <RUN>" << endl ;
256 *outstream <<
" <RUN_TYPE>Pixel FEC Parameters</RUN_TYPE>" << endl ;
257 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << endl ;
259 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << endl ;
260 *outstream <<
" </RUN>" << endl ;
261 *outstream <<
" </HEADER>" << endl ;
262 *outstream <<
"" << endl ;
263 *outstream <<
" <DATA_SET>" << endl ;
264 *outstream <<
" <PART>" << endl ;
265 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << endl ;
266 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << endl ;
267 *outstream <<
" </PART>" << endl ;
268 *outstream <<
" <VERSION>" << version <<
"</VERSION>" << endl ;
269 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << endl ;
270 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << endl ;
275 std::ofstream *out1stream,
276 std::ofstream *out2stream)
const
278 std::string mthn =
"[PixelFECConfig::writeXML()]\t\t\t " ;
280 std::vector< PixelFECParameters >::const_iterator
i=
fecconfig_.begin();
283 *outstream <<
"" << endl ;
284 *outstream <<
" <DATA>" << endl ;
285 *outstream <<
" <PIXFEC_NAME>" << i->getFECNumber() <<
"</PIXFEC_NAME>" << endl ;
286 *outstream <<
" <CRATE_NUMBER>" << i->getCrate() <<
"</CRATE_NUMBER>" << endl ;
287 *outstream <<
" <VME_ADDR>0x" << hex << i->getVMEBaseAddress() << dec <<
"</VME_ADDR>" << endl ;
288 *outstream <<
" </DATA>" << endl ;
294 std::ofstream *out1stream,
295 std::ofstream *out2stream)
const
297 std::string mthn =
"[PixelFECConfig::writeXMLTrailer()]\t\t\t " ;
299 *outstream <<
"" << endl ;
300 *outstream <<
" </DATA_SET>" << endl ;
301 *outstream <<
"</ROOT> " << endl ;
virtual void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
This file contains the base class for "pixel configuration data" management.
unsigned int getFECNumber(unsigned int i) const
unsigned int getVMEBaseAddress(unsigned int i) const
unsigned int getCrate(unsigned int i) const
This class specifies which FEC boards are used and how they are addressed.
unsigned int crateFromFECNumber(unsigned int fecnumber) const
void writeASCII(std::string dir="") const
std::vector< PixelFECParameters > fecconfig_
std::string getComment() const
PixelFECConfig(std::string filename)
unsigned int VMEBaseAddressFromFECNumber(unsigned int fecnumber) const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const
std::string getAuthor() const
virtual void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
unsigned int getNFECBoards() const
std::vector< std::vector< double > > tmp
void setFECParameters(unsigned int fecnumber, unsigned int crate, unsigned int vmebaseaddress)