22 PixelDetectorConfig::PixelDetectorConfig(std::vector< std::vector < std::string> > &tableMat):
PixelConfigBase(
"",
"",
""){
24 std::string mthn =
"]\t[PixelDetectorConfig::PixelDetectorConfig()]\t\t " ;
25 std::vector< std::string >
ins = tableMat[0];
26 std::map<std::string , int > colM;
27 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(
"ROC_NAME" );
45 colNames.push_back(
"ROC_STATUS" );
47 for(
unsigned int c = 0 ;
c < ins.size() ;
c++){
48 for(
unsigned int n=0;
n<colNames.size();
n++){
49 if(tableMat[0][
c] == colNames[
n]){
50 colM[colNames[
n]] =
c;
68 for(
unsigned int r = 1 ;
r < tableMat.size() ;
r++)
76 if(status.find(
"on") != string::npos)
81 rocstatus.
set(status);
101 std::string mthn =
"[PixelDetectorConfig::PixelDetectorConfig()]\t\t " ;
103 if (filename[filename.size()-1]==
't'){
105 std::ifstream
in(filename.c_str());
108 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename << std::endl;
109 throw std::runtime_error(
"Failed to open file "+filename);
112 std::cout << __LINE__ <<
"]\t" << mthn <<
"Opened: " << filename << std::endl;
116 std::cout << __LINE__ <<
"]\t" << mthn <<
"EOF before reading anything!" << std::endl;
117 throw std::runtime_error(
"File seems to be empty "+filename);
128 if (module==
"Rocs:") {
129 std::cout << __LINE__ <<
"]\t" << mthn <<
"New format of detconfig"<<std::endl;
139 istringstream instring(line);
142 while (!instring.eof()) {
146 rocstatus.
set(status);
149 rocs_[roc]=rocstatus;
164 if (
in.eof())
std::cout << mthn <<
"EOF after reading first module name" << std::endl;
166 std::cout << __LINE__ <<
"]\t" << mthn <<
"Old format of detconfig"<<std::endl;
275 std::set <unsigned int> feds;
277 std::vector<PixelModuleName>::const_iterator imodule=
modules_.begin();
279 for (;imodule!=
modules_.end();++imodule) {
282 for ( std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin(); channelsOnThisModule_itr != channelsOnThisModule.end(); ++channelsOnThisModule_itr )
285 unsigned int fednumber=channel_hdwaddress.
fednumber();
286 feds.insert(fednumber);
300 std::map <unsigned int, std::set<unsigned int> > fedsChannels;
302 std::vector<PixelModuleName>::const_iterator imodule=
modules_.begin();
304 for (;imodule!=
modules_.end();++imodule) {
307 for ( std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin(); channelsOnThisModule_itr != channelsOnThisModule.end(); ++channelsOnThisModule_itr )
310 unsigned int fednumber=channel_hdwaddress.
fednumber();
311 unsigned int fedchannel=channel_hdwaddress.
fedchannel();
312 fedsChannels[fednumber].insert(fedchannel);
322 for ( std::vector<PixelModuleName>::const_iterator modules_itr =
modules_.begin(); modules_itr !=
modules_.end(); ++modules_itr )
324 if ( *modules_itr == moduleToFind )
return true;
332 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::writeASCII()]\t\t " ;
335 if (dir!=
"") dir+=
"/";
340 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file " << filename <<
" for write" << std::endl ;
347 std::vector<PixelModuleName>::const_iterator imodule=
modules_.begin();
349 for (;imodule!=
modules_.end();++imodule)
351 out << *imodule << std::endl;
356 out <<
"Rocs:" << endl ;
357 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
358 for(; irocs !=
rocs_.end() ; ++irocs)
360 out << (irocs->first).rocname() <<
" " << (irocs->second).statusName() << endl ;
372 std::ofstream *outstream,
373 std::ofstream *out1stream,
374 std::ofstream *out2stream)
const 376 std::string mthn =
"]\t[PixelDetectorConfig::writeXMLHeader()]\t\t\t " ;
377 std::stringstream fullPath ;
379 cout << __LINE__ << mthn <<
"Writing to: " << fullPath.str() << endl ;
381 outstream->open(fullPath.str().c_str()) ;
383 if( !outstream->good() )
385 cout << __LINE__ << mthn <<
"FATAL: could not open file " << fullPath.str() << endl ;
389 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
390 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
391 *outstream <<
"" << std::endl ;
392 *outstream <<
" <!-- " << mthn <<
"-->" << std::endl ;
393 *outstream <<
"" << std::endl ;
394 *outstream <<
" <HEADER>" << std::endl ;
395 *outstream <<
" <TYPE>" << std::endl ;
396 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl ;
397 *outstream <<
" <NAME>Pixel Detector Configuration</NAME>" << std::endl ;
398 *outstream <<
" </TYPE>" << std::endl ;
399 *outstream <<
" <RUN>" << std::endl ;
400 *outstream <<
" <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl ;
401 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
403 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << std::endl ;
404 *outstream <<
" </RUN>" << std::endl ;
405 *outstream <<
" </HEADER>" << std::endl ;
406 *outstream <<
"" << std::endl ;
407 *outstream <<
" <DATA_SET>" << std::endl ;
408 *outstream <<
" " << std::endl ;
409 *outstream <<
" <VERSION>" << version <<
"</VERSION>" << std::endl ;
410 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << std::endl ;
411 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << std::endl ;
412 *outstream <<
" " << std::endl ;
413 *outstream <<
" <PART>" << std::endl ;
414 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
415 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
416 *outstream <<
" </PART>" << std::endl ;
422 std::ofstream *out1stream,
423 std::ofstream *out2stream)
const 425 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXML()]\t\t\t " ;
429 std::vector<PixelModuleName>::const_iterator imodule=
modules_.begin();
432 for (;imodule!=
modules_.end();++imodule)
434 *outstream <<
" <DATA>" << std::endl ;
436 *outstream <<
" <ROC_STATUS>on</ROC_STATUS>" << std::endl ;
437 *outstream <<
" </DATA>" << std::endl ;
438 *outstream <<
" " << std::endl ;
443 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
444 for(; irocs !=
rocs_.end() ; ++irocs)
447 if( sts ==
"" ) {sts =
"on" ;}
448 *outstream <<
" " << std::endl ;
449 *outstream <<
" <DATA>" << std::endl ;
450 *outstream <<
" <ROC_NAME>" << (irocs->first).rocname() <<
"</ROC_NAME>" << std::endl ;
451 *outstream <<
" <ROC_STATUS>" << sts <<
"</ROC_STATUS>" << std::endl ;
452 *outstream <<
" </DATA>" << std::endl ;
459 std::ofstream *out1stream,
460 std::ofstream *out2stream)
const 462 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXMLTrailer()]\t\t\t " ;
465 *outstream <<
" " << std::endl ;
466 *outstream <<
" </DATA_SET>" << std::endl ;
467 *outstream <<
"</ROOT> " << std::endl ;
474 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::writeXML()]\t\t\t " ;
477 std::stringstream fullPath ;
479 fullPath << path <<
"/Pixel_DetectorConfig.xml" ;
480 cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << fullPath.str() << std::endl ;
482 std::ofstream
out(fullPath.str().c_str()) ;
484 out <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
485 out <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
486 out <<
" <HEADER>" << std::endl ;
487 out <<
" <TYPE>" << std::endl ;
488 out <<
" <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl ;
489 out <<
" <NAME>Pixel Detector Configuration</NAME>" << std::endl ;
490 out <<
" </TYPE>" << std::endl ;
491 out <<
" <RUN>" << std::endl ;
492 out <<
" <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl ;
493 out <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
495 out <<
" <COMMENT_DESCRIPTION>Test of DetectorConfig xml</COMMENT_DESCRIPTION>" << std::endl ;
496 out <<
" <LOCATION>CERN TAC</LOCATION>" << std::endl ;
497 out <<
" <CREATED_BY_USER>Dario Menasce</CREATED_BY_USER>" << std::endl ;
498 out <<
" </RUN>" << std::endl ;
499 out <<
" </HEADER>" << std::endl ;
500 out <<
"" << std::endl ;
501 out <<
"" << std::endl ;
505 std::vector<PixelModuleName>::const_iterator imodule=
modules_.begin();
508 for (;imodule!=
modules_.end();++imodule)
510 out <<
" <DATA>" << std::endl ;
512 out <<
" <ROC_STATUS>on</ROC_STATUS>" << std::endl ;
513 out <<
" </DATA>" << std::endl ;
514 out <<
" " << std::endl ;
519 std::map<PixelROCName, PixelROCStatus>::const_iterator irocs =
rocs_.begin();
520 for(; irocs !=
rocs_.end() ; ++irocs)
523 if( sts ==
"" ) {sts =
"on" ;}
524 out <<
" <DATA_SET>" << std::endl ;
525 out <<
" <VERSION>" << version <<
"</VERSION>" << std::endl ;
526 out <<
" <PART>" << std::endl ;
527 out <<
" <NAME_LABEL>" << (irocs->first).rocname() <<
"</NAME_LABEL>" << std::endl ;
528 out <<
" <KIND_OF_PART>ROC</KIND_OF_PART>" << std::endl ;
529 out <<
" </PART>" << std::endl ;
530 out <<
" <DATA>" << std::endl ;
531 out <<
" <ROC_NAME>" << (irocs->first).rocname() <<
"</ROC_NAME>" << std::endl ;
532 out <<
" <ROC_STATUS>" << sts <<
"</ROC_STATUS>" << std::endl ;
533 out <<
" </DATA>" << std::endl ;
534 out <<
" </DATA_SET>" << std::endl ;
535 out <<
" " << std::endl ;
538 out <<
" </DATA_SET>" << std::endl ;
539 out <<
"</ROOT> " << std::endl ;
547 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::addROC()]\t\t\t\t " ;
550 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC) ;
551 if( theROCIt ==
rocs_.end() )
555 rocs_[theROC] = theStatus ;
558 theROCIt->second.
reset() ;
566 std::stringstream
s ; s << __LINE__ <<
"]\t[PixelDetectorConfig::addROC()]\t\t\t\t " ;
569 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC) ;
570 if( theROCIt ==
rocs_.end() )
573 theStatus.
set(statusLabel) ;
575 rocs_[theROC] = theStatus ;
578 theROCIt->second.
set(statusLabel) ;
586 std::string mthn =
"[PixelDetectorConfig::removeROC()]\t\t\t\t " ;
588 std::map<PixelROCName, PixelROCStatus>::iterator theROCIt =
rocs_.find(theROC) ;
589 if( theROCIt !=
rocs_.end() )
591 theROCIt->second.set(
"noInit") ;
595 theStatus.
set(
"noInit") ;
596 rocs_[theROC] = theStatus ;
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
This class specifies which detector components are used in the configuration (and eventually should s...
This file contains the base class for "pixel configuration data" management.
std::set< unsigned int > getFEDs(PixelNameTranslation *translation) const
std::map< unsigned int, std::set< unsigned int > > getFEDsAndChannels(PixelNameTranslation *translation) const
unsigned int fednumber() const
unsigned int getNModules() const
bool get(ROCstatus stat) const
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, 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
std::string moduleName(Provenance const &provenance)
void writeASCII(std::string dir="") const override
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
PixelDetectorConfig(std::vector< std::vector< std::string > > &tableMat)
std::string getComment() const
unsigned int fedchannel() const
std::map< PixelROCName, PixelROCStatus > rocs_
PixelModuleName getModule(unsigned int i) const
Store mfec, mfecchannel etc.
std::string getAuthor() const
std::vector< PixelModuleName > modules_
void addROC(PixelROCName &, std::string statusLabel)
std::set< PixelChannel > getChannelsOnModule(const PixelModuleName &aModule) const
This is the documentation about PixelNameTranslation...
bool containsModule(const PixelModuleName &moduleToFind) const
void removeROC(PixelROCName &)