19 std::map<std::string, int> colM;
20 std::vector<std::string> colNames;
36 colNames.push_back(
"CONFIG_KEY");
37 colNames.push_back(
"KEY_TYPE");
38 colNames.push_back(
"KEY_ALIAS");
39 colNames.push_back(
"VERSION");
40 colNames.push_back(
"KIND_OF_COND");
41 colNames.push_back(
"PIXFEC_NAME");
42 colNames.push_back(
"CRATE_NUMBER");
43 colNames.push_back(
"SLOT_NUMBER");
44 colNames.push_back(
"VME_ADDR");
46 for (
unsigned int c = 0;
c < tableMat[0].size();
c++) {
47 for (
unsigned int n = 0;
n < colNames.size();
n++) {
48 if (tableMat[0][
c] == colNames[
n]) {
49 colM[colNames[
n]] =
c;
65 for (
unsigned int r = 1;
r < tableMat.size();
r++)
67 unsigned int fecnumber;
69 unsigned int vme_base_address;
75 fecnumber = atoi(tableMat[
r][colM[
"PIXFEC_NAME"]].c_str());
76 crate = atoi(tableMat[
r][colM[
"CRATE_NUMBER"]].c_str());
77 string hexVMEAddr = tableMat[
r][colM[
"VME_ADDR"]];
78 sscanf(hexVMEAddr.c_str(),
"%x", &vme_base_address);
81 tmp.setFECParameters(fecnumber, crate, vme_base_address);
91 std::string mthn =
"[[PixelFECConfig::PixelFECConfig()]\t\t\t ";
93 std::ifstream
in(filename.c_str());
96 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename << std::endl;
97 throw std::runtime_error(
"Failed to open file " + filename);
99 std::cout << __LINE__ <<
"]\t" << mthn <<
" Opened: " << filename << std::endl;
112 unsigned int fecnumber;
114 unsigned int vme_base_address;
116 in >> fecnumber >> crate >> std::hex >> vme_base_address >>
std::dec;
160 std::string mthn =
"[PixelFECConfig::crateFromFECNumber()]\t\t\t ";
166 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FEC number: " << fecnumber << std::endl;
174 std::string mthn =
"[PixelFECConfig::VMEBaseAddressFromFECNumber()]\t\t ";
180 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FEC number: " << fecnumber << std::endl;
192 std::ofstream
out(filename.c_str());
194 std::vector<PixelFECParameters>::const_iterator
i =
fecconfig_.begin();
196 out <<
"#FEC number crate vme base address" << endl;
198 out << i->getFECNumber() <<
" " << i->getCrate() <<
" " 199 <<
"0x" << hex << i->getVMEBaseAddress() <<
dec << endl;
207 std::ofstream *outstream,
208 std::ofstream *out1stream,
209 std::ofstream *out2stream)
const {
210 std::string mthn =
"[PixelFECConfig::writeXMLHeader()]\t\t\t ";
213 cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << fullPath.str() << endl;
215 outstream->open(fullPath.str().c_str());
217 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << endl;
218 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << endl;
219 *outstream <<
" <HEADER>" << endl;
220 *outstream <<
" <TYPE>" << endl;
221 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_FEC_PARAMETERS</EXTENSION_TABLE_NAME>" << endl;
222 *outstream <<
" <NAME>Pixel FEC Parameters</NAME>" << endl;
223 *outstream <<
" </TYPE>" << endl;
224 *outstream <<
" <RUN>" << endl;
225 *outstream <<
" <RUN_TYPE>Pixel FEC Parameters</RUN_TYPE>" << endl;
226 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << endl;
228 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << endl;
229 *outstream <<
" </RUN>" << endl;
230 *outstream <<
" </HEADER>" << endl;
231 *outstream <<
"" << endl;
232 *outstream <<
" <DATA_SET>" << endl;
233 *outstream <<
" <PART>" << endl;
234 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << endl;
235 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << endl;
236 *outstream <<
" </PART>" << endl;
237 *outstream <<
" <VERSION>" << version <<
"</VERSION>" << endl;
238 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << endl;
239 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << endl;
244 std::string mthn =
"[PixelFECConfig::writeXML()]\t\t\t ";
246 std::vector<PixelFECParameters>::const_iterator
i =
fecconfig_.begin();
249 *outstream <<
"" << endl;
250 *outstream <<
" <DATA>" << endl;
251 *outstream <<
" <PIXFEC_NAME>" << i->getFECNumber() <<
"</PIXFEC_NAME>" << endl;
252 *outstream <<
" <CRATE_NUMBER>" << i->getCrate() <<
"</CRATE_NUMBER>" << endl;
253 *outstream <<
" <VME_ADDR>0x" << hex << i->getVMEBaseAddress() <<
dec <<
"</VME_ADDR>" << endl;
254 *outstream <<
" </DATA>" << endl;
260 std::ofstream *out1stream,
261 std::ofstream *out2stream)
const {
262 std::string mthn =
"[PixelFECConfig::writeXMLTrailer()]\t\t\t ";
264 *outstream <<
"" << endl;
265 *outstream <<
" </DATA_SET>" << endl;
266 *outstream <<
"</ROOT> " << endl;
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.
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
unsigned int crateFromFECNumber(unsigned int fecnumber) const
std::string getComment() const
PixelFECConfig(std::string filename)
unsigned int VMEBaseAddressFromFECNumber(unsigned int fecnumber) const
std::string getAuthor() const
void writeASCII(std::string dir="") const override
unsigned int getNFECBoards() const
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
std::vector< PixelFECParameters > fecconfig_
void setFECParameters(unsigned int fecnumber, unsigned int crate, unsigned int vmebaseaddress)