Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:25

0001 //
0002 // Implementation of the detector configuration
0003 //
0004 //
0005 //
0006 //
0007 
0008 #include "CalibFormats/SiPixelObjects/interface/PixelDetectorConfig.h"
0009 #include "CalibFormats/SiPixelObjects/interface/PixelTimeFormatter.h"
0010 #include <fstream>
0011 #include <iostream>
0012 #include <sstream>
0013 #include <ios>
0014 #include <stdexcept>
0015 #include <cassert>
0016 #include <cstdio>
0017 
0018 using namespace std;
0019 using namespace pos;
0020 
0021 PixelDetectorConfig::PixelDetectorConfig(std::vector<std::vector<std::string> > &tableMat)
0022     : PixelConfigBase("", "", "") {
0023   std::string mthn = "]\t[PixelDetectorConfig::PixelDetectorConfig()]\t\t    ";
0024   std::vector<std::string> ins = tableMat[0];
0025   std::map<std::string, int> colM;
0026   std::vector<std::string> colNames;
0027   /*
0028     EXTENSION_TABLE_NAME: PIXEL_DETECTOR_CONFIG (VIEW: CONF_KEY_DET_CONFIG_V)
0029     
0030     CONFIG_KEY                    NOT NULL VARCHAR2(80)
0031     KEY_TYPE                      NOT NULL VARCHAR2(80)
0032     KEY_ALIAS                     NOT NULL VARCHAR2(80)
0033     VERSION                        VARCHAR2(40)
0034     KIND_OF_COND                  NOT NULL VARCHAR2(40)
0035     ROC_NAME                      NOT NULL VARCHAR2(200)
0036     ROC_STATUS                    NOT NULL VARCHAR2(200)
0037   */
0038   colNames.push_back("CONFIG_KEY");
0039   colNames.push_back("KEY_TYPE");
0040   colNames.push_back("KEY_ALIAS");
0041   colNames.push_back("VERSION");
0042   colNames.push_back("KIND_OF_COND");
0043   colNames.push_back("ROC_NAME");
0044   colNames.push_back("ROC_STATUS");
0045 
0046   for (unsigned int c = 0; c < ins.size(); c++) {
0047     for (unsigned int n = 0; n < colNames.size(); n++) {
0048       if (tableMat[0][c] == colNames[n]) {
0049         colM[colNames[n]] = c;
0050         break;
0051       }
0052     }
0053   }  //end for
0054 
0055   /*
0056   for(unsigned int n=0; n<colNames.size(); n++){
0057     if(colM.find(colNames[n]) == colM.end()){
0058       std::cerr << __LINE__ << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
0059       assert(0);
0060     }
0061   }
0062   */
0063 
0064   modules_.clear();
0065   rocs_.clear();
0066   std::string module = "";
0067   for (unsigned int r = 1; r < tableMat.size(); r++) {  //Goes to every row of the Matrix
0068     PixelROCName roc(tableMat[r][colM["ROC_NAME"]]);    // see DACSettings!!!!
0069     PixelROCStatus rocstatus;
0070     std::string status = tableMat[r][colM["ROC_STATUS"]];
0071     // The following is due to the fact that enabled ROCs are
0072     // labelled as ON in the DataBase, but have NO label in
0073     // configuration files!!!
0074     if (status.find("on") != string::npos) {
0075       status = "";
0076     }
0077     if (!status.empty()) {
0078       rocstatus.set(status);
0079     }
0080     rocs_[roc] = rocstatus;
0081     if (!rocstatus.get(PixelROCStatus::noInit)) {
0082       PixelModuleName module(tableMat[r][colM["ROC_NAME"]]);
0083       if (!containsModule(module)) {
0084         modules_.push_back(module);
0085       }
0086     }
0087   }  //end for r
0088 
0089   //   std::cout << __LINE__ << mthn << "Number of Modules in Detector Configuration Class: " << getNModules() << std::endl;
0090 
0091 }  //end constructor
0092 
0093 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0094 
0095 PixelDetectorConfig::PixelDetectorConfig(std::string filename) : PixelConfigBase("", "", "") {
0096   std::string mthn = "[PixelDetectorConfig::PixelDetectorConfig()]\t\t    ";
0097 
0098   if (filename[filename.size() - 1] == 't') {
0099     std::ifstream in(filename.c_str());
0100 
0101     if (!in.good()) {
0102       std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
0103       throw std::runtime_error("Failed to open file " + filename);
0104     } else {
0105       std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename << std::endl;
0106     }
0107 
0108     if (in.eof()) {
0109       std::cout << __LINE__ << "]\t" << mthn << "EOF before reading anything!" << std::endl;
0110       throw std::runtime_error("File seems to be empty " + filename);
0111     }
0112 
0113     modules_.clear();
0114     rocs_.clear();
0115 
0116     std::string module;
0117 
0118     in >> module;
0119 
0120     if (module == "Rocs:") {
0121       std::cout << __LINE__ << "]\t" << mthn << "New format of detconfig" << std::endl;
0122       //new format with list of ROCs.
0123       std::string rocname;
0124       in >> rocname;
0125       while (!in.eof()) {
0126         //cout << __LINE__ << "]\t" << mthn << "Read rocname:"<<rocname<<endl;
0127         PixelROCName roc(rocname);
0128         std::string line;
0129         getline(in, line);
0130         //cout << __LINE__ << "]\t" << mthn << "Read line:'"<<line<<"'"<<endl;
0131         istringstream instring(line);
0132         PixelROCStatus rocstatus;
0133         std::string status;
0134         while (!instring.eof()) {
0135           instring >> status;
0136           //        cout << __LINE__ << "]\t" << mthn << "Read status:"<<status<<endl;
0137           if (!status.empty()) {
0138             rocstatus.set(status);
0139           }
0140         }
0141         rocs_[roc] = rocstatus;
0142         if (!rocstatus.get(PixelROCStatus::noInit)) {
0143           PixelModuleName module(rocname);
0144           if (!containsModule(module)) {
0145             modules_.push_back(module);
0146           }
0147         }
0148         in >> rocname;
0149       }
0150       return;
0151     }
0152 
0153     //std::cout << __LINE__ << "]\t" << mthn << "Read module:"<<module<<std::endl;
0154 
0155     if (in.eof())
0156       std::cout << mthn << "EOF after reading first module name" << std::endl;
0157 
0158     std::cout << __LINE__ << "]\t" << mthn << "Old format of detconfig" << std::endl;
0159     while (!in.eof()) {
0160       //std::cout << __LINE__ << "]\t" << mthn << "Read module:"<<module<<std::endl;
0161 
0162       PixelModuleName moduleName(module);
0163 
0164       modules_.push_back(moduleName);
0165 
0166       in >> module;
0167 
0168       assert(modules_.size() < 10000);
0169     }
0170 
0171     in.close();
0172 
0173   } else {
0174     assert(0);
0175 
0176     /*
0177       std::ifstream in(filename.c_str(),std::ios::binary);
0178 
0179       if (!in.good()){
0180       std::cout << __LINE__ << "]\t" << mthn << "Could not open:"<<filename<<std::endl;
0181       assert(0);
0182       }
0183       else {
0184       std::cout << __LINE__ << "]\t" << mthn << "Opened:"<<filename<<std::endl;
0185       }
0186 
0187       char nchar;
0188 
0189       in.read(&nchar,1);
0190         
0191       std::string s1;
0192 
0193       //wrote these lines of code without ref. needs to be fixed
0194       for(int i=0;i< nchar; i++){
0195       char c;
0196       in >>c;
0197       s1.push_back(c);
0198       }
0199 
0200       //std::cout << __LINE__ << "]\t" << mthn << "READ ROC name:"<<s1<<std::endl;
0201 
0202       dacsettings_.clear();
0203 
0204 
0205       while (!in.eof()){
0206 
0207       //std::cout << __LINE__ << "]\t" << mthn << "read s1:"<<s1<<std::endl;
0208 
0209       PixelROCName rocid(s1);
0210 
0211       //std::cout << __LINE__ << "]\t" << mthn << "read rocid:"<<rocid<<std::endl;
0212             
0213       PixelROCDetectorConfig tmp;
0214       
0215       tmp.readBinary(in, rocid);
0216 
0217       dacsettings_.push_back(tmp);
0218 
0219 
0220       in.read(&nchar,1);
0221 
0222       s1.clear();
0223 
0224       if (in.eof()) continue;
0225 
0226       //wrote these lines of code without ref. needs to be fixed
0227       for(int i=0;i< nchar; i++){
0228       char c;
0229       in >>c;
0230       s1.push_back(c);
0231       }
0232 
0233 
0234       }
0235 
0236       in.close();
0237 
0238     */
0239   }
0240 
0241   //std::cout << __LINE__ << "]\t" << mthn << "Read dac settings for "<<dacsettings_.size()<<" ROCs"<<std::endl;
0242 }
0243 
0244 unsigned int PixelDetectorConfig::getNModules() const { return modules_.size(); }
0245 
0246 PixelModuleName PixelDetectorConfig::getModule(unsigned int i) const { return modules_[i]; }
0247 
0248 std::set<unsigned int> PixelDetectorConfig::getFEDs(PixelNameTranslation *translation) const {
0249   std::set<unsigned int> feds;
0250   assert(!modules_.empty());
0251   std::vector<PixelModuleName>::const_iterator imodule = modules_.begin();
0252 
0253   for (; imodule != modules_.end(); ++imodule) {
0254     std::set<PixelChannel> channelsOnThisModule = translation->getChannelsOnModule(*imodule);
0255     for (std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin();
0256          channelsOnThisModule_itr != channelsOnThisModule.end();
0257          ++channelsOnThisModule_itr) {
0258       const PixelHdwAddress &channel_hdwaddress = translation->getHdwAddress(*channelsOnThisModule_itr);
0259       unsigned int fednumber = channel_hdwaddress.fednumber();
0260       feds.insert(fednumber);
0261     }
0262   }
0263 
0264   return feds;
0265 }
0266 
0267 // Returns the FED numbers and channels within each FED that are used
0268 std::map<unsigned int, std::set<unsigned int> > PixelDetectorConfig::getFEDsAndChannels(
0269     PixelNameTranslation *translation) const {
0270   //      FED Number                channels
0271 
0272   std::map<unsigned int, std::set<unsigned int> > fedsChannels;
0273   assert(!modules_.empty());
0274   std::vector<PixelModuleName>::const_iterator imodule = modules_.begin();
0275 
0276   for (; imodule != modules_.end(); ++imodule) {
0277     std::set<PixelChannel> channelsOnThisModule = translation->getChannelsOnModule(*imodule);
0278     for (std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin();
0279          channelsOnThisModule_itr != channelsOnThisModule.end();
0280          ++channelsOnThisModule_itr) {
0281       const PixelHdwAddress &channel_hdwaddress = translation->getHdwAddress(*channelsOnThisModule_itr);
0282       unsigned int fednumber = channel_hdwaddress.fednumber();
0283       unsigned int fedchannel = channel_hdwaddress.fedchannel();
0284       fedsChannels[fednumber].insert(fedchannel);
0285     }
0286   }
0287 
0288   return fedsChannels;
0289 }
0290 
0291 bool PixelDetectorConfig::containsModule(const PixelModuleName &moduleToFind) const {
0292   for (std::vector<PixelModuleName>::const_iterator modules_itr = modules_.begin(); modules_itr != modules_.end();
0293        ++modules_itr) {
0294     if (*modules_itr == moduleToFind)
0295       return true;
0296   }
0297   return false;
0298 }
0299 
0300 // modified by MR on 11-01-2008 15:06:51
0301 void PixelDetectorConfig::writeASCII(std::string dir) const {
0302   std::stringstream s;
0303   s << __LINE__ << "]\t[PixelDetectorConfig::writeASCII()]\t\t    ";
0304   std::string mthn = s.str();
0305 
0306   if (!dir.empty())
0307     dir += "/";
0308   std::string filename = dir + "detectconfig.dat";
0309 
0310   std::ofstream out(filename.c_str(), std::ios_base::out);
0311   if (!out) {
0312     std::cout << __LINE__ << "]\t" << mthn << "Could not open file " << filename << " for write" << std::endl;
0313     exit(1);
0314   }
0315 
0316   if (rocs_.empty()) {
0317     std::vector<PixelModuleName>::const_iterator imodule = modules_.begin();
0318 
0319     for (; imodule != modules_.end(); ++imodule) {
0320       out << *imodule << std::endl;
0321     }
0322   } else {
0323     out << "Rocs:" << endl;
0324     std::map<PixelROCName, PixelROCStatus>::const_iterator irocs = rocs_.begin();
0325     for (; irocs != rocs_.end(); ++irocs) {
0326       out << (irocs->first).rocname() << " " << (irocs->second).statusName() << endl;
0327     }
0328   }
0329 
0330   out.close();
0331 }
0332 
0333 //=============================================================================================
0334 void PixelDetectorConfig::writeXMLHeader(pos::PixelConfigKey key,
0335                                          int version,
0336                                          std::string path,
0337                                          std::ofstream *outstream,
0338                                          std::ofstream *out1stream,
0339                                          std::ofstream *out2stream) const {
0340   std::string mthn = "]\t[PixelDetectorConfig::writeXMLHeader()]\t\t\t    ";
0341   std::stringstream fullPath;
0342   fullPath << path << "/Pixel_DetectorConfig_" << PixelTimeFormatter::getmSecTime() << ".xml";
0343   cout << __LINE__ << mthn << "Writing to: " << fullPath.str() << endl;
0344 
0345   outstream->open(fullPath.str().c_str());
0346 
0347   if (!outstream->good()) {
0348     cout << __LINE__ << mthn << "FATAL: could not open file " << fullPath.str() << endl;
0349     assert(0);
0350   }
0351 
0352   *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
0353   *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
0354   *outstream << "" << std::endl;
0355   *outstream << " <!-- " << mthn << "-->" << std::endl;
0356   *outstream << "" << std::endl;
0357   *outstream << " <HEADER>" << std::endl;
0358   *outstream << "  <TYPE>" << std::endl;
0359   *outstream << "   <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl;
0360   *outstream << "   <NAME>Pixel Detector Configuration</NAME>" << std::endl;
0361   *outstream << "  </TYPE>" << std::endl;
0362   *outstream << "  <RUN>" << std::endl;
0363   *outstream << "   <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl;
0364   *outstream << "   <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
0365   *outstream << "   <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>"
0366              << std::endl;
0367   *outstream << "   <LOCATION>CERN P5</LOCATION>" << std::endl;
0368   *outstream << "  </RUN>" << std::endl;
0369   *outstream << " </HEADER>" << std::endl;
0370   *outstream << "" << std::endl;
0371   *outstream << "  <DATA_SET>" << std::endl;
0372   *outstream << " " << std::endl;
0373   *outstream << "   <VERSION>" << version << "</VERSION>" << std::endl;
0374   *outstream << "   <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
0375   *outstream << "   <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
0376   *outstream << " " << std::endl;
0377   *outstream << "   <PART>" << std::endl;
0378   *outstream << "    <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
0379   *outstream << "    <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
0380   *outstream << "   </PART>" << std::endl;
0381 }
0382 
0383 //=============================================================================================
0384 void PixelDetectorConfig::writeXML(std::ofstream *outstream,
0385                                    std::ofstream *out1stream,
0386                                    std::ofstream *out2stream) const {
0387   std::stringstream s;
0388   s << __LINE__ << "]\t[PixelDetectorConfig::writeXML()]\t\t\t    ";
0389   std::string mthn = s.str();
0390   if (rocs_.empty()) {
0391     std::vector<PixelModuleName>::const_iterator imodule = modules_.begin();
0392 
0393     // This needs to be fixed: given a module name, actually loop over ROCs to write the XML data
0394     for (; imodule != modules_.end(); ++imodule) {
0395       *outstream << "  <DATA>" << std::endl;
0396       //---->          out << "   <ROC_NAME>" << (irocs->first).rocname() << "</ROC_NAME>"                         << std::endl ;
0397       *outstream << "   <ROC_STATUS>on</ROC_STATUS>" << std::endl;
0398       *outstream << "  </DATA>" << std::endl;
0399       *outstream << " " << std::endl;
0400     }
0401   } else {
0402     std::map<PixelROCName, PixelROCStatus>::const_iterator irocs = rocs_.begin();
0403     for (; irocs != rocs_.end(); ++irocs) {
0404       std::string sts = (irocs->second).statusName();
0405       if (sts.empty()) {
0406         sts = "on";
0407       }
0408       *outstream << " " << std::endl;
0409       *outstream << "   <DATA>" << std::endl;
0410       *outstream << "    <ROC_NAME>" << (irocs->first).rocname() << "</ROC_NAME>" << std::endl;
0411       *outstream << "    <ROC_STATUS>" << sts << "</ROC_STATUS>" << std::endl;
0412       *outstream << "   </DATA>" << std::endl;
0413     }
0414   }
0415 }
0416 
0417 //=============================================================================================
0418 void PixelDetectorConfig::writeXMLTrailer(std::ofstream *outstream,
0419                                           std::ofstream *out1stream,
0420                                           std::ofstream *out2stream) const {
0421   std::stringstream s;
0422   s << __LINE__ << "]\t[PixelDetectorConfig::writeXMLTrailer()]\t\t\t    ";
0423   std::string mthn = s.str();
0424 
0425   *outstream << " " << std::endl;
0426   *outstream << " </DATA_SET>" << std::endl;
0427   *outstream << "</ROOT> " << std::endl;
0428 
0429   outstream->close();
0430 }
0431 //=============================================================================================
0432 void PixelDetectorConfig::writeXML(pos::PixelConfigKey key, int version, std::string path) const {
0433   std::stringstream s;
0434   s << __LINE__ << "]\t[PixelDetectorConfig::writeXML()]\t\t\t    ";
0435   std::string mthn = s.str();
0436 
0437   std::stringstream fullPath;
0438 
0439   fullPath << path << "/Pixel_DetectorConfig.xml";
0440   cout << __LINE__ << "]\t" << mthn << "Writing to: " << fullPath.str() << std::endl;
0441 
0442   std::ofstream out(fullPath.str().c_str());
0443 
0444   out << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
0445   out << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
0446   out << " <HEADER>" << std::endl;
0447   out << "  <TYPE>" << std::endl;
0448   out << "   <EXTENSION_TABLE_NAME>PIXEL_DETECTOR_CONFIG</EXTENSION_TABLE_NAME>" << std::endl;
0449   out << "   <NAME>Pixel Detector Configuration</NAME>" << std::endl;
0450   out << "  </TYPE>" << std::endl;
0451   out << "  <RUN>" << std::endl;
0452   out << "   <RUN_TYPE>Pixel Detector Configuration test</RUN_TYPE>" << std::endl;
0453   out << "   <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
0454   out << "   <RUN_BEGIN_TIMESTAMP>" << pos::PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl;
0455   out << "   <COMMENT_DESCRIPTION>Test of DetectorConfig xml</COMMENT_DESCRIPTION>" << std::endl;
0456   out << "   <LOCATION>CERN TAC</LOCATION>" << std::endl;
0457   out << "   <CREATED_BY_USER>Dario Menasce</CREATED_BY_USER>" << std::endl;
0458   out << "  </RUN>" << std::endl;
0459   out << " </HEADER>" << std::endl;
0460   out << "" << std::endl;
0461   out << "" << std::endl;
0462 
0463   if (rocs_.empty()) {
0464     std::vector<PixelModuleName>::const_iterator imodule = modules_.begin();
0465 
0466     // This needs to be fixed: given a module name, actually loop over ROCs to write the XML data
0467     for (; imodule != modules_.end(); ++imodule) {
0468       out << "  <DATA>" << std::endl;
0469       //---->          out << "   <ROC_NAME>" << (irocs->first).rocname() << "</ROC_NAME>"                  << std::endl ;
0470       out << "   <ROC_STATUS>on</ROC_STATUS>" << std::endl;
0471       out << "  </DATA>" << std::endl;
0472       out << " " << std::endl;
0473     }
0474   } else {
0475     std::map<PixelROCName, PixelROCStatus>::const_iterator irocs = rocs_.begin();
0476     for (; irocs != rocs_.end(); ++irocs) {
0477       std::string sts = (irocs->second).statusName();
0478       if (sts.empty()) {
0479         sts = "on";
0480       }
0481       out << "  <DATA_SET>" << std::endl;
0482       out << "   <VERSION>" << version << "</VERSION>" << std::endl;
0483       out << "    <PART>" << std::endl;
0484       out << "     <NAME_LABEL>" << (irocs->first).rocname() << "</NAME_LABEL>" << std::endl;
0485       out << "     <KIND_OF_PART>ROC</KIND_OF_PART>" << std::endl;
0486       out << "    </PART>" << std::endl;
0487       out << "   <DATA>" << std::endl;
0488       out << "    <ROC_NAME>" << (irocs->first).rocname() << "</ROC_NAME>" << std::endl;
0489       out << "    <ROC_STATUS>" << sts << "</ROC_STATUS>" << std::endl;
0490       out << "   </DATA>" << std::endl;
0491       out << "  </DATA_SET>" << std::endl;
0492       out << " " << std::endl;
0493     }
0494   }
0495   out << " </DATA_SET>" << std::endl;
0496   out << "</ROOT> " << std::endl;
0497   out.close();
0498   assert(0);
0499 }
0500 
0501 //=============================================================================================
0502 void PixelDetectorConfig::addROC(PixelROCName &theROC)  // Added by Dario (March 3, 2008)
0503 {
0504   std::stringstream s;
0505   s << __LINE__ << "]\t[PixelDetectorConfig::addROC()]\t\t\t\t    ";
0506   std::string mthn = s.str();
0507 
0508   std::map<PixelROCName, PixelROCStatus>::iterator theROCIt = rocs_.find(theROC);
0509   if (theROCIt == rocs_.end())  // if theROC was not there, add it and turn it on
0510   {
0511     PixelROCStatus theStatus;
0512     theStatus.reset();
0513     rocs_[theROC] = theStatus;
0514     //  cout << __LINE__ << "]\t" << mthn << "Non existing ROC (" << theROC.rocname() << "): adding it"  << endl ;
0515   } else {
0516     theROCIt->second.reset();  // otherwise just turn it on by resetting it to zero
0517     //  cout << __LINE__ << "]\t" << mthn << "Already existing ROC (" << theROC.rocname() << "): switching it on"  << endl ;
0518   }
0519 }
0520 
0521 //=============================================================================================
0522 void PixelDetectorConfig::addROC(PixelROCName &theROC, string statusLabel)  // modified by MR on 14-05-2008 11:29:51
0523 {
0524   std::stringstream s;
0525   s << __LINE__ << "]\t[PixelDetectorConfig::addROC()]\t\t\t\t    ";
0526   std::string mthn = s.str();
0527 
0528   std::map<PixelROCName, PixelROCStatus>::iterator theROCIt = rocs_.find(theROC);
0529   if (theROCIt == rocs_.end())  // if theROC was not there, add it and turn it on
0530   {
0531     PixelROCStatus theStatus;
0532     theStatus.set(statusLabel);
0533     theStatus.reset();
0534     rocs_[theROC] = theStatus;
0535     //  cout << __LINE__ << "]\t" << mthn << "Non existing ROC (" << theROC.rocname() << "): adding it"  << endl ;
0536   } else {
0537     theROCIt->second.set(statusLabel);  // otherwise just turn it on by resetting it to zero
0538     //  cout << __LINE__ << "]\t" << mthn << "Already existing ROC (" << theROC.rocname() << "): switching it on"  << endl ;
0539   }
0540 }
0541 
0542 //=============================================================================================
0543 void PixelDetectorConfig::removeROC(PixelROCName &theROC)  // Added by Dario (March 3, 2008)
0544 {
0545   std::string mthn = "[PixelDetectorConfig::removeROC()]\t\t\t\t    ";
0546 
0547   std::map<PixelROCName, PixelROCStatus>::iterator theROCIt = rocs_.find(theROC);
0548   if (theROCIt != rocs_.end())  // if theROC was there remove it, otherwise ignore
0549   {
0550     theROCIt->second.set("noInit");
0551     //  cout << __LINE__ << "]\t" << mthn << "Already existing ROC (" << theROC.rocname() << "): switching it off"  << endl ;
0552   } else {
0553     PixelROCStatus theStatus;
0554     theStatus.set("noInit");
0555     rocs_[theROC] = theStatus;
0556     //  cout << __LINE__ << "]\t" << mthn << "ROC " << theROC.rocname() << " was not individually declared in the file: declare and switch off"  << endl ;
0557   }
0558 }
0559 
0560 //std::ostream& operator<<(std::ostream& s, const PixelDetectorConfig& dacs){
0561 //
0562 //  s << dacs.getDetectorConfig(0) <<std::endl;
0563 //
0564 //  return s;
0565 //
0566 //}