19 std::string mthn =
"[PixelFEDConfig::PixelFEDConfig()]\t\t\t ";
21 std::vector<std::string>
ins = tableMat[0];
22 std::map<std::string, int> colM;
23 std::vector<std::string> colNames;
37 colNames.push_back(
"CONFIG_KEY");
38 colNames.push_back(
"KEY_TYPE");
39 colNames.push_back(
"KEY_ALIAS");
40 colNames.push_back(
"VERSION");
41 colNames.push_back(
"KIND_OF_COND");
42 colNames.push_back(
"PIXEL_FED");
43 colNames.push_back(
"CRATE_NUMBER");
44 colNames.push_back(
"VME_ADDR");
50 for (
unsigned int c = 0;
c < tableMat[0].size();
c++) {
51 for (
unsigned int n = 0;
n < colNames.size();
n++) {
52 if (tableMat[0][
c] == colNames[
n]) {
53 colM[colNames[
n]] =
c;
70 unsigned int fednum = 0;
73 for (
unsigned int r = 1;
r < tableMat.size();
r++) {
82 fednum = (
unsigned int)atoi(fedname.c_str());
86 unsigned int vme_base_address = 0;
87 vme_base_address = strtoul(tableMat[
r][colM[
"VME_ADDR"]].c_str(),
nullptr, 16);
90 tmp.setFEDParameters(fednum, (
unsigned int)atoi(tableMat[
r][colM[
"CRATE_NUMBER"]].c_str()), vme_base_address);
93 for (
unsigned int y = 0; y <
fedconfig_.size(); y++) {
105 tmp.setFEDParameters(fednum,
106 (
unsigned int)atoi(tableMat[
r][colM[
"CRATE_NUMBER"]].c_str()),
107 (
unsigned int)strtoul(tableMat[
r][colM[
"VME_ADDR"]].c_str(),
nullptr, 16));
127 std::string mthn =
"[PixelFEDConfig::PixelFEDConfig()]\t\t\t ";
131 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " <<
filename.c_str() << std::endl;
132 throw std::runtime_error(
"Failed to open file " +
filename);
134 std::cout << __LINE__ <<
"]\t" << mthn <<
"Opened: " <<
filename.c_str() << std::endl;
147 unsigned int fednumber;
149 unsigned int vme_base_address;
151 in >> fednumber >> crate >> std::hex >> vme_base_address >>
std::dec;
158 tmp.setFEDParameters(fednumber, crate, vme_base_address);
179 std::string mthn =
"[PixelFEDConfig::writeASCII()]\t\t\t\t ";
186 cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file: " <<
filename << endl;
190 out <<
" #FED number crate vme base address" << endl;
193 <<
"0x" << hex <<
fedconfig_[
i].getVMEBaseAddress() <<
dec << endl;
216 std::string mthn =
"[PixelFEDConfig::crateFromFEDNumber()]\t\t\t ";
222 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FED number: " << fednumber << std::endl;
230 std::string mthn =
"[PixelFEDConfig::VMEBaseAddressFromFEDNumber()]\t\t ";
236 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FED number: " << fednumber << std::endl;
244 unsigned int vmebaseaddress)
const {
245 std::string mthn =
"[PixelFEDConfig::FEDNumberFromCrateAndVMEBaseAddress()]\t ";
251 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not find FED crate and address: " << crate <<
", " << vmebaseaddress
263 std::ofstream *outstream,
264 std::ofstream *out1stream,
265 std::ofstream *out2stream)
const {
266 std::string mthn =
"[PixelFEDConfig::::writeXMLHeader()]\t\t\t ";
269 cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " <<
fullPath.str() << endl;
271 outstream->open(
fullPath.str().c_str());
272 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << endl;
273 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << endl;
274 *outstream <<
" <HEADER>" << endl;
275 *outstream <<
" <TYPE>" << endl;
276 *outstream <<
" <EXTENSION_TABLE_NAME>FED_CRATE_CONFIG</EXTENSION_TABLE_NAME>" << endl;
277 *outstream <<
" <NAME>Pixel FED Crate Configuration</NAME>" << endl;
278 *outstream <<
" </TYPE>" << endl;
279 *outstream <<
" <RUN>" << endl;
280 *outstream <<
" <RUN_NAME>Pixel FED Crate Configuration</RUN_NAME>" << endl;
282 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << endl;
283 *outstream <<
" </RUN>" << endl;
284 *outstream <<
" </HEADER>" << endl;
285 *outstream <<
" " << endl;
286 *outstream <<
" <DATA_SET>" << endl;
287 *outstream <<
" <PART>" << endl;
288 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << endl;
289 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << endl;
290 *outstream <<
" </PART>" << endl;
291 *outstream <<
" <VERSION>" <<
version <<
"</VERSION>" << endl;
292 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << endl;
293 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << endl;
294 *outstream <<
" " << endl;
299 std::string mthn =
"[PixelFEDConfig::writeXML()]\t\t\t ";
302 *outstream <<
" <DATA>" << endl;
303 *outstream <<
" <PIXEL_FED>" <<
fedconfig_[
i].getFEDNumber() <<
"</PIXEL_FED>" << endl;
304 *outstream <<
" <CRATE_NUMBER>" <<
fedconfig_[
i].getCrate() <<
"</CRATE_NUMBER>" << endl;
305 *outstream <<
" <VME_ADDR>" 306 <<
"0x" << hex <<
fedconfig_[
i].getVMEBaseAddress() <<
dec <<
"</VME_ADDR>" << endl;
307 *outstream <<
" </DATA>" << endl;
308 *outstream <<
"" << endl;
314 std::ofstream *out1stream,
315 std::ofstream *out2stream)
const {
316 std::string mthn =
"[PixelFEDConfig::writeXMLTrailer()]\t\t\t ";
318 *outstream <<
" </DATA_SET>" << endl;
319 *outstream <<
"</ROOT> " << endl;
unsigned int VMEBaseAddressFromFEDNumber(unsigned int fednumber) const
unsigned int FEDNumberFromCrateAndVMEBaseAddress(unsigned int crate, unsigned int vmebaseaddress) const
This file contains the base class for "pixel configuration data" management.
std::string getComment() const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
unsigned int getCrate(unsigned int i) const
unsigned int getNFEDBoards() const
void writeASCII(std::string dir) const override
unsigned int getVMEBaseAddress(unsigned int i) const
~PixelFEDConfig() override
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
unsigned int getFEDNumber(unsigned int i) const
PixelFEDConfig(std::string filename)
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
std::string getAuthor() const
std::vector< PixelFEDParameters > fedconfig_
unsigned int crateFromFEDNumber(unsigned int fednumber) const