21 PixelDetectorConfig::PixelDetectorConfig(std::vector<std::vector<std::string> > &tableMat)
23 std::string mthn =
"]\t[PixelDetectorConfig::PixelDetectorConfig()]\t\t ";
24 std::vector<std::string>
ins = tableMat[0];
25 std::map<std::string, int> colM;
26 std::vector<std::string> colNames;
38 colNames.push_back(
"CONFIG_KEY");
39 colNames.push_back(
"KEY_TYPE");
40 colNames.push_back(
"KEY_ALIAS");
41 colNames.push_back(
"VERSION");
42 colNames.push_back(
"KIND_OF_COND");
43 colNames.push_back(
"ROC_NAME");
44 colNames.push_back(
"ROC_STATUS");
46 for (
unsigned int c = 0;
c <
ins.size();
c++) {
47 for (
unsigned int n = 0;
n < colNames.size();
n++) {
48 if (tableMat[0][
c] == colNames[
n]) {
49 colM[colNames[
n]] =
c;
67 for (
unsigned int r = 1;
r < tableMat.size();
r++) {
74 if (
status.find(
"on") != string::npos) {
96 std::string mthn =
"[PixelDetectorConfig::PixelDetectorConfig()]\t\t ";
102 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " <<
filename << std::endl;
103 throw std::runtime_error(
"Failed to open file " +
filename);
109 std::cout << __LINE__ <<
"]\t" << mthn <<
"EOF before reading anything!" << std::endl;
110 throw std::runtime_error(
"File seems to be empty " +
filename);
121 std::cout << __LINE__ <<
"]\t" << mthn <<
"New format of detconfig" << std::endl;
131 istringstream instring(
line);
134 while (!instring.eof()) {
156 std::cout << mthn <<
"EOF after reading first module name" << std::endl;
158 std::cout << __LINE__ <<
"]\t" << mthn <<
"Old format of detconfig" << std::endl;
249 std::set<unsigned int>
feds;
251 std::vector<PixelModuleName>::const_iterator imodule =
modules_.begin();
253 for (; imodule !=
modules_.end(); ++imodule) {
255 for (std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin();
256 channelsOnThisModule_itr != channelsOnThisModule.end();
257 ++channelsOnThisModule_itr) {
259 unsigned int fednumber = channel_hdwaddress.
fednumber();
260 feds.insert(fednumber);
272 std::map<unsigned int, std::set<unsigned int> > fedsChannels;
274 std::vector<PixelModuleName>::const_iterator imodule =
modules_.begin();
276 for (; imodule !=
modules_.end(); ++imodule) {
278 for (std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin();
279 channelsOnThisModule_itr != channelsOnThisModule.end();
280 ++channelsOnThisModule_itr) {
282 unsigned int fednumber = channel_hdwaddress.
fednumber();
283 unsigned int fedchannel = channel_hdwaddress.
fedchannel();
284 fedsChannels[fednumber].insert(fedchannel);
292 for (std::vector<PixelModuleName>::const_iterator modules_itr =
modules_.begin(); modules_itr !=
modules_.end();
294 if (*modules_itr == moduleToFind)
303 s << __LINE__ <<
"]\t[PixelDetectorConfig::writeASCII()]\t\t ";
312 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file " <<
filename <<
" for write" << std::endl;
317 std::vector<PixelModuleName>::const_iterator imodule =
modules_.begin();
319 for (; imodule !=
modules_.end(); ++imodule) {
320 out << *imodule << std::endl;
323 out <<
"Rocs:" << endl;
324 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
325 for (; irocs !=
rocs_.end(); ++irocs) {
326 out << (irocs->first).rocname() <<
" " << (irocs->second).statusName() << endl;
337 std::ofstream *outstream,
338 std::ofstream *out1stream,
339 std::ofstream *out2stream)
const {
340 std::string mthn =
"]\t[PixelDetectorConfig::writeXMLHeader()]\t\t\t ";
343 cout << __LINE__ << mthn <<
"Writing to: " <<
fullPath.str() << endl;
345 outstream->open(
fullPath.str().c_str());
347 if (!outstream->good()) {
348 cout << __LINE__ << mthn <<
"FATAL: could not open file " <<
fullPath.str() << endl;
352 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
353 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
354 *outstream <<
"" << std::endl;
355 *outstream <<
" <!-- " << mthn <<
"-->" << std::endl;
356 *outstream <<
"" << std::endl;
357 *outstream <<
" <HEADER>" << std::endl;
358 *outstream <<
" <TYPE>" << std::endl;
359 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl;
360 *outstream <<
" <NAME>Pixel Detector Configuration</NAME>" << std::endl;
361 *outstream <<
" </TYPE>" << std::endl;
362 *outstream <<
" <RUN>" << std::endl;
363 *outstream <<
" <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl;
364 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
367 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << std::endl;
368 *outstream <<
" </RUN>" << std::endl;
369 *outstream <<
" </HEADER>" << std::endl;
370 *outstream <<
"" << std::endl;
371 *outstream <<
" <DATA_SET>" << std::endl;
372 *outstream <<
" " << std::endl;
373 *outstream <<
" <VERSION>" <<
version <<
"</VERSION>" << std::endl;
374 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << std::endl;
375 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << std::endl;
376 *outstream <<
" " << std::endl;
377 *outstream <<
" <PART>" << std::endl;
378 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
379 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
380 *outstream <<
" </PART>" << std::endl;
385 std::ofstream *out1stream,
386 std::ofstream *out2stream)
const {
388 s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXML()]\t\t\t ";
391 std::vector<PixelModuleName>::const_iterator imodule =
modules_.begin();
394 for (; imodule !=
modules_.end(); ++imodule) {
395 *outstream <<
" <DATA>" << std::endl;
397 *outstream <<
" <ROC_STATUS>on</ROC_STATUS>" << std::endl;
398 *outstream <<
" </DATA>" << std::endl;
399 *outstream <<
" " << std::endl;
402 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
403 for (; irocs !=
rocs_.end(); ++irocs) {
408 *outstream <<
" " << std::endl;
409 *outstream <<
" <DATA>" << std::endl;
410 *outstream <<
" <ROC_NAME>" << (irocs->first).rocname() <<
"</ROC_NAME>" << std::endl;
411 *outstream <<
" <ROC_STATUS>" << sts <<
"</ROC_STATUS>" << std::endl;
412 *outstream <<
" </DATA>" << std::endl;
419 std::ofstream *out1stream,
420 std::ofstream *out2stream)
const {
422 s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXMLTrailer()]\t\t\t ";
425 *outstream <<
" " << std::endl;
426 *outstream <<
" </DATA_SET>" << std::endl;
427 *outstream <<
"</ROOT> " << std::endl;
434 s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXML()]\t\t\t ";
440 cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " <<
fullPath.str() << std::endl;
444 out <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
445 out <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
446 out <<
" <HEADER>" << std::endl;
447 out <<
" <TYPE>" << std::endl;
448 out <<
" <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl;
449 out <<
" <NAME>Pixel Detector Configuration</NAME>" << std::endl;
450 out <<
" </TYPE>" << std::endl;
451 out <<
" <RUN>" << std::endl;
452 out <<
" <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl;
453 out <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
455 out <<
" <COMMENT_DESCRIPTION>Test of DetectorConfig xml</COMMENT_DESCRIPTION>" << std::endl;
456 out <<
" <LOCATION>CERN TAC</LOCATION>" << std::endl;
457 out <<
" <CREATED_BY_USER>Dario Menasce</CREATED_BY_USER>" << std::endl;
458 out <<
" </RUN>" << std::endl;
459 out <<
" </HEADER>" << std::endl;
460 out <<
"" << std::endl;
461 out <<
"" << std::endl;
464 std::vector<PixelModuleName>::const_iterator imodule =
modules_.begin();
467 for (; imodule !=
modules_.end(); ++imodule) {
468 out <<
" <DATA>" << std::endl;
470 out <<
" <ROC_STATUS>on</ROC_STATUS>" << std::endl;
471 out <<
" </DATA>" << std::endl;
472 out <<
" " << std::endl;
475 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
476 for (; irocs !=
rocs_.end(); ++irocs) {
481 out <<
" <DATA_SET>" << std::endl;
482 out <<
" <VERSION>" <<
version <<
"</VERSION>" << std::endl;
483 out <<
" <PART>" << std::endl;
484 out <<
" <NAME_LABEL>" << (irocs->first).rocname() <<
"</NAME_LABEL>" << std::endl;
485 out <<
" <KIND_OF_PART>ROC</KIND_OF_PART>" << std::endl;
486 out <<
" </PART>" << std::endl;
487 out <<
" <DATA>" << std::endl;
488 out <<
" <ROC_NAME>" << (irocs->first).rocname() <<
"</ROC_NAME>" << std::endl;
489 out <<
" <ROC_STATUS>" << sts <<
"</ROC_STATUS>" << std::endl;
490 out <<
" </DATA>" << std::endl;
491 out <<
" </DATA_SET>" << std::endl;
492 out <<
" " << std::endl;
495 out <<
" </DATA_SET>" << std::endl;
496 out <<
"</ROOT> " << std::endl;
505 s << __LINE__ <<
"]\t[PixelDetectorConfig::addROC()]\t\t\t\t ";
508 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC);
509 if (theROCIt ==
rocs_.end())
513 rocs_[theROC] = theStatus;
516 theROCIt->second.
reset();
525 s << __LINE__ <<
"]\t[PixelDetectorConfig::addROC()]\t\t\t\t ";
528 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC);
529 if (theROCIt ==
rocs_.end())
532 theStatus.
set(statusLabel);
534 rocs_[theROC] = theStatus;
537 theROCIt->second.
set(statusLabel);
545 std::string mthn =
"[PixelDetectorConfig::removeROC()]\t\t\t\t ";
547 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC);
548 if (theROCIt !=
rocs_.end())
550 theROCIt->second.set(
"noInit");
554 theStatus.
set(
"noInit");
555 rocs_[theROC] = theStatus;